diff --git a/CHANGELOG.md b/CHANGELOG.md index e1091e0..5d3575c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 241156f..a5c35aa 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/patch_api/__init__.py b/patch_api/__init__.py index 2e3672d..074ef0f 100644 --- a/patch_api/__init__.py +++ b/patch_api/__init__.py @@ -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 diff --git a/patch_api/api/projects_api.py b/patch_api/api/projects_api.py index 8427e62..d9849ec 100644 --- a/patch_api/api/projects_api.py +++ b/patch_api/api/projects_api.py @@ -79,6 +79,7 @@ def retrieve_project(self, id={}, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :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. @@ -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 @@ -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") @@ -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 = {} @@ -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. @@ -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 @@ -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") @@ -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 = {} diff --git a/patch_api/api_client.py b/patch_api/api_client.py index 652f783..6751106 100644 --- a/patch_api/api_client.py +++ b/patch_api/api_client.py @@ -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: diff --git a/patch_api/configuration.py b/patch_api/configuration.py index 9179e1f..fb0e066 100644 --- a/patch_api/configuration.py +++ b/patch_api/configuration.py @@ -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 ) ) diff --git a/patch_api/models/project.py b/patch_api/models/project.py index e772187..892a8c3 100644 --- a/patch_api/models/project.py +++ b/patch_api/models/project.py @@ -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 diff --git a/setup.py b/setup.py index cebcd9e..5352ee6 100644 --- a/setup.py +++ b/setup.py @@ -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 diff --git a/test/test_projects_api.py b/test/test_projects_api.py index e38f642..3ac0b51 100644 --- a/test/test_projects_api.py +++ b/test/test_projects_api.py @@ -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 @@ -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()