Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.22.0] - 2022-05-16

### Added

- Adds support for the `accept_language` option on `projects`, to add support for the `Accept-Language` header.

## [1.21.0] - 2022-05-03

### Added
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ patch.projects.retrieve_projects(country="CA")

# Retrieve a list of projects with at least 100 grams of available offsets
patch.projects.retrieve_projects(minimum_available_mass=100)

# Retrieve a project / all projects in a different language
# See http://docs.patch.test:3000/#/internationalization for more information and support
patch.projects.retrieve_projects(accept_language='fr')
project_id = 'pro_test_1234'
patch.projects.retrieve_project(id=project_id, accept_language='fr')
```

## Contributing
Expand Down
2 changes: 1 addition & 1 deletion patch_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from __future__ import absolute_import

__version__ = "1.21.0"
__version__ = "1.22.0"

# import ApiClient
from patch_api.api_client import ApiClient
Expand Down
22 changes: 20 additions & 2 deletions patch_api/api/projects_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def retrieve_project(self, id={}, **kwargs): # noqa: E501

:param async_req bool: execute request asynchronously

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the type last on this particular line? 😄

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. This is all auto-generated and not being a python expert i'm actually not quite sure what this does.

:param str id: (required)
:param str accept_language:
:param _preload_content: if False, the urllib3.HTTPResponse object will
be returned without reading/decoding response
data. Default is True.
Expand All @@ -104,6 +105,7 @@ def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501

:param async_req bool: execute request asynchronously
:param str id: (required)
:param str accept_language:
:param _return_http_data_only: response data without head status code
and headers
:param _preload_content: if False, the urllib3.HTTPResponse object will
Expand All @@ -120,7 +122,7 @@ def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501

local_var_params = locals()

all_params = ["id"] # noqa: E501
all_params = ["id", "accept_language"] # noqa: E501
all_params.append("async_req")
all_params.append("_return_http_data_only")
all_params.append("_preload_content")
Expand Down Expand Up @@ -193,6 +195,10 @@ def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501
query_params.append([key, kwargs.get(key)])

header_params = {}
if "accept_language" in local_var_params:
header_params["Accept-Language"] = local_var_params[
"accept_language"
] # noqa: E501

form_params = []
local_var_files = {}
Expand Down Expand Up @@ -240,6 +246,7 @@ def retrieve_projects(self, **kwargs): # noqa: E501
:param str country:
:param str type:
:param int minimum_available_mass:
:param str accept_language:
:param _preload_content: if False, the urllib3.HTTPResponse object will
be returned without reading/decoding response
data. Default is True.
Expand Down Expand Up @@ -268,6 +275,7 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501
:param str country:
:param str type:
:param int minimum_available_mass:
:param str accept_language:
:param _return_http_data_only: response data without head status code
and headers
:param _preload_content: if False, the urllib3.HTTPResponse object will
Expand All @@ -284,7 +292,13 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501

local_var_params = locals()

all_params = ["page", "country", "type", "minimum_available_mass"] # noqa: E501
all_params = [
"page",
"country",
"type",
"minimum_available_mass",
"accept_language",
] # noqa: E501
all_params.append("async_req")
all_params.append("_return_http_data_only")
all_params.append("_preload_content")
Expand Down Expand Up @@ -360,6 +374,10 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501
query_params.append([key, kwargs.get(key)])

header_params = {}
if "accept_language" in local_var_params:
header_params["Accept-Language"] = local_var_params[
"accept_language"
] # noqa: E501

form_params = []
local_var_files = {}
Expand Down
2 changes: 1 addition & 1 deletion patch_api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(
self.default_headers[header_name] = header_value
self.cookie = cookie
# Set default User-Agent.
self.user_agent = "patch-python/1.21.0"
self.user_agent = "patch-python/1.22.0"

def __del__(self):
if self._pool:
Expand Down
2 changes: 1 addition & 1 deletion patch_api/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def to_debug_report(self):
"OS: {env}\n"
"Python Version: {pyversion}\n"
"Version of the API: v1\n"
"SDK Package Version: 1.21.0".format(
"SDK Package Version: 1.22.0".format(
env=sys.platform, pyversion=sys.version
)
)
Expand Down
10 changes: 0 additions & 10 deletions patch_api/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,16 +317,6 @@ def mechanism(self, mechanism):
:param mechanism: The mechanism of this Project. # noqa: E501
:type: str
"""
allowed_values = ["removal", "avoidance"] # noqa: E501
if (
self.local_vars_configuration.client_side_validation
and mechanism not in allowed_values
): # noqa: E501
raise ValueError(
"Invalid value for `mechanism` ({0}), must be one of {1}".format( # noqa: E501
mechanism, allowed_values
)
)

self._mechanism = mechanism

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from setuptools import setup, find_packages # noqa: H301

NAME = "patch-api"
VERSION = "1.21.0"
VERSION = "1.22.0"
# To install the library, run the following
#
# python setup.py install
Expand Down
19 changes: 19 additions & 0 deletions test/test_projects_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ def test_retrieve_project(self):
self.assertTrue(isinstance(inventory[0].currency, str))
self.assertTrue(isinstance(inventory[0].unit, str))

def test_retrieve_project_language(self):
"""Test case for retrieve_project

Retrieves a project # noqa: E501
"""
project_id = "pro_test_2b67b11a030b66e0a6dd61a56b49079a"
project = self.api.retrieve_project(id=project_id, accept_language="fr").data
self.assertIn("Projet", project.name) # French

def test_retrieve_projects(self):
"""Test case for retrieve_projects

Expand Down Expand Up @@ -124,6 +133,16 @@ def test_retrieve_projects_with_more_than_100_grams_of_inventory(self):
for project in projects:
self.assertTrue(project.remaining_mass_g >= minimum_available_mass)

def test_retrieve_projects_language(self):
"""Test case for retrieve_projects with a type filter

Retrieves a list of projects # noqa: E501
"""
projects = self.api.retrieve_projects(accept_language="fr").data

for project in projects:
self.assertIn("Projet", project.name) # French


if __name__ == "__main__":
unittest.main()