From 6f1c0a1d96537bed2b8b29992aab980381bee8dc Mon Sep 17 00:00:00 2001 From: James Klein Date: Wed, 11 Aug 2021 16:25:34 -0600 Subject: [PATCH 01/11] update sdk post-addition of metadata query param --- patch_api/api/estimates_api.py | 836 ++++++++---------- patch_api/api/orders_api.py | 458 +++++----- patch_api/api/preferences_api.py | 374 ++++---- patch_api/api/projects_api.py | 204 ++--- patch_api/api_client.py | 422 ++++----- patch_api/configuration.py | 84 +- patch_api/exceptions.py | 12 +- patch_api/models/allocation.py | 60 +- .../models/bulk_create_success_response.py | 149 ++++ patch_api/models/error.py | 149 ++++ patch_api/models/error_response.py | 60 +- patch_api/models/estimate.py | 74 +- patch_api/models/estimate_list_response.py | 69 +- patch_api/models/estimate_response.py | 56 +- patch_api/models/meta_index_object.py | 34 +- patch_api/models/order.py | 178 ++-- patch_api/models/order_list_response.py | 69 +- patch_api/models/order_response.py | 56 +- patch_api/models/photo.py | 42 +- patch_api/models/preference.py | 61 +- patch_api/models/preference_list_response.py | 69 +- patch_api/models/preference_response.py | 56 +- patch_api/models/project.py | 167 ++-- patch_api/models/project_list_response.py | 69 +- patch_api/models/project_response.py | 56 +- patch_api/models/sdg.py | 77 +- patch_api/models/standard.py | 64 +- patch_api/rest.py | 297 +++---- setup.py | 8 +- 29 files changed, 1973 insertions(+), 2337 deletions(-) create mode 100644 patch_api/models/bulk_create_success_response.py create mode 100644 patch_api/models/error.py diff --git a/patch_api/api/estimates_api.py b/patch_api/api/estimates_api.py index 95d1af0..66c285f 100644 --- a/patch_api/api/estimates_api.py +++ b/patch_api/api/estimates_api.py @@ -18,7 +18,10 @@ # python 2 and python 3 compatibility library import six -from patch_api.exceptions import ApiTypeError, ApiValueError +from patch_api.exceptions import ( + ApiTypeError, + ApiValueError +) class EstimatesApi(object): @@ -29,28 +32,26 @@ class EstimatesApi(object): """ ALLOWED_QUERY_PARAMS = [ - "mass_g", - "total_price_cents_usd", - "project_id", - "page", - "distance_m", - "transportation_method", - "package_mass_g", - "create_order", - "model", - "make", - "year", - "transaction_value_btc_sats", - "timestamp", - "gas_used", + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year", + "transaction_value_btc_sats", + "timestamp", + "gas_used" ] def __init__(self, api_client=None): self.api_client = api_client - def create_bitcoin_estimate( - self, create_bitcoin_estimate_request={}, **kwargs - ): # noqa: E501 + def create_bitcoin_estimate(self, create_bitcoin_estimate_request={}, **kwargs): # noqa: E501 """Create a bitcoin estimate given a timestamp and transaction value # noqa: E501 Creates a bitcoin estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 @@ -72,14 +73,10 @@ def create_bitcoin_estimate( If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True - return self.create_bitcoin_estimate_with_http_info( - create_bitcoin_estimate_request, **kwargs - ) # noqa: E501 - - def create_bitcoin_estimate_with_http_info( - self, create_bitcoin_estimate_request, **kwargs - ): # noqa: E501 + kwargs['_return_http_data_only'] = True + return self.create_bitcoin_estimate_with_http_info(create_bitcoin_estimate_request, **kwargs) # noqa: E501 + + def create_bitcoin_estimate_with_http_info(self, create_bitcoin_estimate_request, **kwargs): # noqa: E501 """Create a bitcoin estimate given a timestamp and transaction value # noqa: E501 Creates a bitcoin estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 @@ -106,42 +103,38 @@ def create_bitcoin_estimate_with_http_info( local_var_params = locals() - all_params = ["create_bitcoin_estimate_request"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['create_bitcoin_estimate_request'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_bitcoin_estimate" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] # verify the required parameter 'create_bitcoin_estimate_request' is set - if ( - "create_bitcoin_estimate_request" not in local_var_params - or local_var_params["create_bitcoin_estimate_request"] is None - ): - raise ApiValueError( - "Missing the required parameter `create_bitcoin_estimate_request` when calling `create_bitcoin_estimate`" - ) # noqa: E501 + if ('create_bitcoin_estimate_request' not in local_var_params or + local_var_params['create_bitcoin_estimate_request'] is None): + raise ApiValueError("Missing the required parameter `create_bitcoin_estimate_request` when calling `create_bitcoin_estimate`") # noqa: E501 collection_formats = {} @@ -157,46 +150,36 @@ def create_bitcoin_estimate_with_http_info( local_var_files = {} body_params = None - if "create_bitcoin_estimate_request" in local_var_params: - body_params = local_var_params["create_bitcoin_estimate_request"] + if 'create_bitcoin_estimate_request' in local_var_params: + body_params = local_var_params['create_bitcoin_estimate_request'] # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params[ - "Content-Type" - ] = self.api_client.select_header_content_type( # noqa: E501 - ["application/json"] - ) # noqa: E501 + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/estimates/crypto/btc", - "POST", + '/v1/estimates/crypto/btc', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="EstimateResponse", # noqa: E501 + response_type='EstimateResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) - - def create_ethereum_estimate( - self, create_ethereum_estimate_request={}, **kwargs - ): # noqa: E501 + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) + + def create_ethereum_estimate(self, create_ethereum_estimate_request={}, **kwargs): # noqa: E501 """Create an ethereum estimate given a timestamp and gas used # noqa: E501 Creates an ethereum estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 @@ -218,14 +201,10 @@ def create_ethereum_estimate( If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True - return self.create_ethereum_estimate_with_http_info( - create_ethereum_estimate_request, **kwargs - ) # noqa: E501 - - def create_ethereum_estimate_with_http_info( - self, create_ethereum_estimate_request, **kwargs - ): # noqa: E501 + kwargs['_return_http_data_only'] = True + return self.create_ethereum_estimate_with_http_info(create_ethereum_estimate_request, **kwargs) # noqa: E501 + + def create_ethereum_estimate_with_http_info(self, create_ethereum_estimate_request, **kwargs): # noqa: E501 """Create an ethereum estimate given a timestamp and gas used # noqa: E501 Creates an ethereum estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 @@ -252,42 +231,38 @@ def create_ethereum_estimate_with_http_info( local_var_params = locals() - all_params = ["create_ethereum_estimate_request"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['create_ethereum_estimate_request'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_ethereum_estimate" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] # verify the required parameter 'create_ethereum_estimate_request' is set - if ( - "create_ethereum_estimate_request" not in local_var_params - or local_var_params["create_ethereum_estimate_request"] is None - ): - raise ApiValueError( - "Missing the required parameter `create_ethereum_estimate_request` when calling `create_ethereum_estimate`" - ) # noqa: E501 + if ('create_ethereum_estimate_request' not in local_var_params or + local_var_params['create_ethereum_estimate_request'] is None): + raise ApiValueError("Missing the required parameter `create_ethereum_estimate_request` when calling `create_ethereum_estimate`") # noqa: E501 collection_formats = {} @@ -303,46 +278,36 @@ def create_ethereum_estimate_with_http_info( local_var_files = {} body_params = None - if "create_ethereum_estimate_request" in local_var_params: - body_params = local_var_params["create_ethereum_estimate_request"] + if 'create_ethereum_estimate_request' in local_var_params: + body_params = local_var_params['create_ethereum_estimate_request'] # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params[ - "Content-Type" - ] = self.api_client.select_header_content_type( # noqa: E501 - ["application/json"] - ) # noqa: E501 + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/estimates/crypto/eth", - "POST", + '/v1/estimates/crypto/eth', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="EstimateResponse", # noqa: E501 + response_type='EstimateResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) - - def create_flight_estimate( - self, create_flight_estimate_request={}, **kwargs - ): # noqa: E501 + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) + + def create_flight_estimate(self, create_flight_estimate_request={}, **kwargs): # noqa: E501 """Create a flight estimate given the distance traveled in meters # noqa: E501 Creates a flight estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 @@ -364,14 +329,10 @@ def create_flight_estimate( If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True - return self.create_flight_estimate_with_http_info( - create_flight_estimate_request, **kwargs - ) # noqa: E501 - - def create_flight_estimate_with_http_info( - self, create_flight_estimate_request, **kwargs - ): # noqa: E501 + kwargs['_return_http_data_only'] = True + return self.create_flight_estimate_with_http_info(create_flight_estimate_request, **kwargs) # noqa: E501 + + def create_flight_estimate_with_http_info(self, create_flight_estimate_request, **kwargs): # noqa: E501 """Create a flight estimate given the distance traveled in meters # noqa: E501 Creates a flight estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 @@ -398,42 +359,38 @@ def create_flight_estimate_with_http_info( local_var_params = locals() - all_params = ["create_flight_estimate_request"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['create_flight_estimate_request'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_flight_estimate" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] # verify the required parameter 'create_flight_estimate_request' is set - if ( - "create_flight_estimate_request" not in local_var_params - or local_var_params["create_flight_estimate_request"] is None - ): - raise ApiValueError( - "Missing the required parameter `create_flight_estimate_request` when calling `create_flight_estimate`" - ) # noqa: E501 + if ('create_flight_estimate_request' not in local_var_params or + local_var_params['create_flight_estimate_request'] is None): + raise ApiValueError("Missing the required parameter `create_flight_estimate_request` when calling `create_flight_estimate`") # noqa: E501 collection_formats = {} @@ -449,46 +406,36 @@ def create_flight_estimate_with_http_info( local_var_files = {} body_params = None - if "create_flight_estimate_request" in local_var_params: - body_params = local_var_params["create_flight_estimate_request"] + if 'create_flight_estimate_request' in local_var_params: + body_params = local_var_params['create_flight_estimate_request'] # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params[ - "Content-Type" - ] = self.api_client.select_header_content_type( # noqa: E501 - ["application/json"] - ) # noqa: E501 + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/estimates/flight", - "POST", + '/v1/estimates/flight', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="EstimateResponse", # noqa: E501 + response_type='EstimateResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) - - def create_mass_estimate( - self, create_mass_estimate_request={}, **kwargs - ): # noqa: E501 + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) + + def create_mass_estimate(self, create_mass_estimate_request={}, **kwargs): # noqa: E501 """Create an estimate based on mass of CO2 # noqa: E501 Creates an estimate for the mass of CO2 to be compensated. An order in the `draft` state will also be created, linked to the estimate. # noqa: E501 @@ -510,14 +457,10 @@ def create_mass_estimate( If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True - return self.create_mass_estimate_with_http_info( - create_mass_estimate_request, **kwargs - ) # noqa: E501 - - def create_mass_estimate_with_http_info( - self, create_mass_estimate_request, **kwargs - ): # noqa: E501 + kwargs['_return_http_data_only'] = True + return self.create_mass_estimate_with_http_info(create_mass_estimate_request, **kwargs) # noqa: E501 + + def create_mass_estimate_with_http_info(self, create_mass_estimate_request, **kwargs): # noqa: E501 """Create an estimate based on mass of CO2 # noqa: E501 Creates an estimate for the mass of CO2 to be compensated. An order in the `draft` state will also be created, linked to the estimate. # noqa: E501 @@ -544,42 +487,38 @@ def create_mass_estimate_with_http_info( local_var_params = locals() - all_params = ["create_mass_estimate_request"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['create_mass_estimate_request'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_mass_estimate" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] # verify the required parameter 'create_mass_estimate_request' is set - if ( - "create_mass_estimate_request" not in local_var_params - or local_var_params["create_mass_estimate_request"] is None - ): - raise ApiValueError( - "Missing the required parameter `create_mass_estimate_request` when calling `create_mass_estimate`" - ) # noqa: E501 + if ('create_mass_estimate_request' not in local_var_params or + local_var_params['create_mass_estimate_request'] is None): + raise ApiValueError("Missing the required parameter `create_mass_estimate_request` when calling `create_mass_estimate`") # noqa: E501 collection_formats = {} @@ -595,46 +534,36 @@ def create_mass_estimate_with_http_info( local_var_files = {} body_params = None - if "create_mass_estimate_request" in local_var_params: - body_params = local_var_params["create_mass_estimate_request"] + if 'create_mass_estimate_request' in local_var_params: + body_params = local_var_params['create_mass_estimate_request'] # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params[ - "Content-Type" - ] = self.api_client.select_header_content_type( # noqa: E501 - ["application/json"] - ) # noqa: E501 + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/estimates/mass", - "POST", + '/v1/estimates/mass', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="EstimateResponse", # noqa: E501 + response_type='EstimateResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) - - def create_shipping_estimate( - self, create_shipping_estimate_request={}, **kwargs - ): # noqa: E501 + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) + + def create_shipping_estimate(self, create_shipping_estimate_request={}, **kwargs): # noqa: E501 """Create a shipping estimate given the distance traveled in meters, package weight, and transportation method. # noqa: E501 Creates a shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters. # noqa: E501 @@ -656,14 +585,10 @@ def create_shipping_estimate( If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True - return self.create_shipping_estimate_with_http_info( - create_shipping_estimate_request, **kwargs - ) # noqa: E501 - - def create_shipping_estimate_with_http_info( - self, create_shipping_estimate_request, **kwargs - ): # noqa: E501 + kwargs['_return_http_data_only'] = True + return self.create_shipping_estimate_with_http_info(create_shipping_estimate_request, **kwargs) # noqa: E501 + + def create_shipping_estimate_with_http_info(self, create_shipping_estimate_request, **kwargs): # noqa: E501 """Create a shipping estimate given the distance traveled in meters, package weight, and transportation method. # noqa: E501 Creates a shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters. # noqa: E501 @@ -690,42 +615,38 @@ def create_shipping_estimate_with_http_info( local_var_params = locals() - all_params = ["create_shipping_estimate_request"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['create_shipping_estimate_request'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_shipping_estimate" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] # verify the required parameter 'create_shipping_estimate_request' is set - if ( - "create_shipping_estimate_request" not in local_var_params - or local_var_params["create_shipping_estimate_request"] is None - ): - raise ApiValueError( - "Missing the required parameter `create_shipping_estimate_request` when calling `create_shipping_estimate`" - ) # noqa: E501 + if ('create_shipping_estimate_request' not in local_var_params or + local_var_params['create_shipping_estimate_request'] is None): + raise ApiValueError("Missing the required parameter `create_shipping_estimate_request` when calling `create_shipping_estimate`") # noqa: E501 collection_formats = {} @@ -741,46 +662,36 @@ def create_shipping_estimate_with_http_info( local_var_files = {} body_params = None - if "create_shipping_estimate_request" in local_var_params: - body_params = local_var_params["create_shipping_estimate_request"] + if 'create_shipping_estimate_request' in local_var_params: + body_params = local_var_params['create_shipping_estimate_request'] # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params[ - "Content-Type" - ] = self.api_client.select_header_content_type( # noqa: E501 - ["application/json"] - ) # noqa: E501 + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/estimates/shipping", - "POST", + '/v1/estimates/shipping', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="EstimateResponse", # noqa: E501 + response_type='EstimateResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) - - def create_vehicle_estimate( - self, create_vehicle_estimate_request={}, **kwargs - ): # noqa: E501 + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) + + def create_vehicle_estimate(self, create_vehicle_estimate_request={}, **kwargs): # noqa: E501 """Create a vehicle estimate given the distance traveled in meters and the type of vehicle # noqa: E501 Creates an estimate and calculates the amount of CO2 to be compensated depending on the distance and the vehicle. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 @@ -802,14 +713,10 @@ def create_vehicle_estimate( If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True - return self.create_vehicle_estimate_with_http_info( - create_vehicle_estimate_request, **kwargs - ) # noqa: E501 - - def create_vehicle_estimate_with_http_info( - self, create_vehicle_estimate_request, **kwargs - ): # noqa: E501 + kwargs['_return_http_data_only'] = True + return self.create_vehicle_estimate_with_http_info(create_vehicle_estimate_request, **kwargs) # noqa: E501 + + def create_vehicle_estimate_with_http_info(self, create_vehicle_estimate_request, **kwargs): # noqa: E501 """Create a vehicle estimate given the distance traveled in meters and the type of vehicle # noqa: E501 Creates an estimate and calculates the amount of CO2 to be compensated depending on the distance and the vehicle. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 @@ -836,42 +743,38 @@ def create_vehicle_estimate_with_http_info( local_var_params = locals() - all_params = ["create_vehicle_estimate_request"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['create_vehicle_estimate_request'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_vehicle_estimate" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] # verify the required parameter 'create_vehicle_estimate_request' is set - if ( - "create_vehicle_estimate_request" not in local_var_params - or local_var_params["create_vehicle_estimate_request"] is None - ): - raise ApiValueError( - "Missing the required parameter `create_vehicle_estimate_request` when calling `create_vehicle_estimate`" - ) # noqa: E501 + if ('create_vehicle_estimate_request' not in local_var_params or + local_var_params['create_vehicle_estimate_request'] is None): + raise ApiValueError("Missing the required parameter `create_vehicle_estimate_request` when calling `create_vehicle_estimate`") # noqa: E501 collection_formats = {} @@ -887,42 +790,34 @@ def create_vehicle_estimate_with_http_info( local_var_files = {} body_params = None - if "create_vehicle_estimate_request" in local_var_params: - body_params = local_var_params["create_vehicle_estimate_request"] + if 'create_vehicle_estimate_request' in local_var_params: + body_params = local_var_params['create_vehicle_estimate_request'] # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params[ - "Content-Type" - ] = self.api_client.select_header_content_type( # noqa: E501 - ["application/json"] - ) # noqa: E501 + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/estimates/vehicle", - "POST", + '/v1/estimates/vehicle', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="EstimateResponse", # noqa: E501 + response_type='EstimateResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) def retrieve_estimate(self, id={}, **kwargs): # noqa: E501 """Retrieves an estimate # noqa: E501 @@ -946,7 +841,7 @@ def retrieve_estimate(self, id={}, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True + kwargs['_return_http_data_only'] = True return self.retrieve_estimate_with_http_info(id, **kwargs) # noqa: E501 def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501 @@ -976,45 +871,44 @@ def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ["id"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['id'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method retrieve_estimate" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] # verify the required parameter 'id' is set - if "id" not in local_var_params or local_var_params["id"] is None: - raise ApiValueError( - "Missing the required parameter `id` when calling `retrieve_estimate`" - ) # noqa: E501 + if ('id' not in local_var_params or + local_var_params['id'] is None): + raise ApiValueError("Missing the required parameter `id` when calling `retrieve_estimate`") # noqa: E501 collection_formats = {} path_params = {} - if "id" in local_var_params: - path_params["id"] = local_var_params["id"] # noqa: E501 + if 'id' in local_var_params: + path_params['id'] = local_var_params['id'] # noqa: E501 query_params = [] for key in kwargs: @@ -1027,32 +921,27 @@ def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/estimates/{id}", - "GET", + '/v1/estimates/{id}', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="EstimateResponse", # noqa: E501 + response_type='EstimateResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) def retrieve_estimates(self, **kwargs): # noqa: E501 """Retrieves a list of estimates # noqa: E501 @@ -1076,7 +965,7 @@ def retrieve_estimates(self, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True + kwargs['_return_http_data_only'] = True return self.retrieve_estimates_with_http_info(**kwargs) # noqa: E501 def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501 @@ -1106,34 +995,34 @@ def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ["page"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['page'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method retrieve_estimates" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] collection_formats = {} @@ -1142,8 +1031,8 @@ def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501 query_params = [] for key in kwargs: query_params.append([key, kwargs.get(key)]) - if "page" in local_var_params: - query_params.append(("page", local_var_params["page"])) # noqa: E501 + if 'page' in local_var_params: + query_params.append(('page', local_var_params['page'])) # noqa: E501 header_params = {} @@ -1152,29 +1041,24 @@ def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/estimates", - "GET", + '/v1/estimates', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="EstimateListResponse", # noqa: E501 + response_type='EstimateListResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) diff --git a/patch_api/api/orders_api.py b/patch_api/api/orders_api.py index 2bf0532..6bd9662 100644 --- a/patch_api/api/orders_api.py +++ b/patch_api/api/orders_api.py @@ -18,7 +18,10 @@ # python 2 and python 3 compatibility library import six -from patch_api.exceptions import ApiTypeError, ApiValueError +from patch_api.exceptions import ( + ApiTypeError, + ApiValueError +) class OrdersApi(object): @@ -29,20 +32,20 @@ class OrdersApi(object): """ ALLOWED_QUERY_PARAMS = [ - "mass_g", - "total_price_cents_usd", - "project_id", - "page", - "distance_m", - "transportation_method", - "package_mass_g", - "create_order", - "model", - "make", - "year", - "transaction_value_btc_sats", - "timestamp", - "gas_used", + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year", + "transaction_value_btc_sats", + "timestamp", + "gas_used" ] def __init__(self, api_client=None): @@ -70,7 +73,7 @@ def cancel_order(self, id={}, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True + kwargs['_return_http_data_only'] = True return self.cancel_order_with_http_info(id, **kwargs) # noqa: E501 def cancel_order_with_http_info(self, id, **kwargs): # noqa: E501 @@ -100,45 +103,44 @@ def cancel_order_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ["id"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['id'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method cancel_order" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] # verify the required parameter 'id' is set - if "id" not in local_var_params or local_var_params["id"] is None: - raise ApiValueError( - "Missing the required parameter `id` when calling `cancel_order`" - ) # noqa: E501 + if ('id' not in local_var_params or + local_var_params['id'] is None): + raise ApiValueError("Missing the required parameter `id` when calling `cancel_order`") # noqa: E501 collection_formats = {} path_params = {} - if "id" in local_var_params: - path_params["id"] = local_var_params["id"] # noqa: E501 + if 'id' in local_var_params: + path_params['id'] = local_var_params['id'] # noqa: E501 query_params = [] for key in kwargs: @@ -151,32 +153,27 @@ def cancel_order_with_http_info(self, id, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/orders/{id}/cancel", - "PATCH", + '/v1/orders/{id}/cancel', 'PATCH', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="OrderResponse", # noqa: E501 + response_type='OrderResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) def create_order(self, create_order_request={}, **kwargs): # noqa: E501 """Creates an order # noqa: E501 @@ -200,10 +197,8 @@ def create_order(self, create_order_request={}, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True - return self.create_order_with_http_info( - create_order_request, **kwargs - ) # noqa: E501 + kwargs['_return_http_data_only'] = True + return self.create_order_with_http_info(create_order_request, **kwargs) # noqa: E501 def create_order_with_http_info(self, create_order_request, **kwargs): # noqa: E501 """Creates an order # noqa: E501 @@ -232,42 +227,38 @@ def create_order_with_http_info(self, create_order_request, **kwargs): # noqa: local_var_params = locals() - all_params = ["create_order_request"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['create_order_request'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_order" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] # verify the required parameter 'create_order_request' is set - if ( - "create_order_request" not in local_var_params - or local_var_params["create_order_request"] is None - ): - raise ApiValueError( - "Missing the required parameter `create_order_request` when calling `create_order`" - ) # noqa: E501 + if ('create_order_request' not in local_var_params or + local_var_params['create_order_request'] is None): + raise ApiValueError("Missing the required parameter `create_order_request` when calling `create_order`") # noqa: E501 collection_formats = {} @@ -283,42 +274,34 @@ def create_order_with_http_info(self, create_order_request, **kwargs): # noqa: local_var_files = {} body_params = None - if "create_order_request" in local_var_params: - body_params = local_var_params["create_order_request"] + if 'create_order_request' in local_var_params: + body_params = local_var_params['create_order_request'] # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params[ - "Content-Type" - ] = self.api_client.select_header_content_type( # noqa: E501 - ["application/json"] - ) # noqa: E501 + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/orders", - "POST", + '/v1/orders', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="OrderResponse", # noqa: E501 + response_type='OrderResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) def place_order(self, id={}, **kwargs): # noqa: E501 """Place an order # noqa: E501 @@ -342,7 +325,7 @@ def place_order(self, id={}, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True + kwargs['_return_http_data_only'] = True return self.place_order_with_http_info(id, **kwargs) # noqa: E501 def place_order_with_http_info(self, id, **kwargs): # noqa: E501 @@ -372,45 +355,44 @@ def place_order_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ["id"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['id'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method place_order" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] # verify the required parameter 'id' is set - if "id" not in local_var_params or local_var_params["id"] is None: - raise ApiValueError( - "Missing the required parameter `id` when calling `place_order`" - ) # noqa: E501 + if ('id' not in local_var_params or + local_var_params['id'] is None): + raise ApiValueError("Missing the required parameter `id` when calling `place_order`") # noqa: E501 collection_formats = {} path_params = {} - if "id" in local_var_params: - path_params["id"] = local_var_params["id"] # noqa: E501 + if 'id' in local_var_params: + path_params['id'] = local_var_params['id'] # noqa: E501 query_params = [] for key in kwargs: @@ -423,32 +405,27 @@ def place_order_with_http_info(self, id, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/orders/{id}/place", - "PATCH", + '/v1/orders/{id}/place', 'PATCH', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="OrderResponse", # noqa: E501 + response_type='OrderResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) def retrieve_order(self, id={}, **kwargs): # noqa: E501 """Retrieves an order # noqa: E501 @@ -472,7 +449,7 @@ def retrieve_order(self, id={}, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True + kwargs['_return_http_data_only'] = True return self.retrieve_order_with_http_info(id, **kwargs) # noqa: E501 def retrieve_order_with_http_info(self, id, **kwargs): # noqa: E501 @@ -502,45 +479,44 @@ def retrieve_order_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ["id"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['id'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method retrieve_order" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] # verify the required parameter 'id' is set - if "id" not in local_var_params or local_var_params["id"] is None: - raise ApiValueError( - "Missing the required parameter `id` when calling `retrieve_order`" - ) # noqa: E501 + if ('id' not in local_var_params or + local_var_params['id'] is None): + raise ApiValueError("Missing the required parameter `id` when calling `retrieve_order`") # noqa: E501 collection_formats = {} path_params = {} - if "id" in local_var_params: - path_params["id"] = local_var_params["id"] # noqa: E501 + if 'id' in local_var_params: + path_params['id'] = local_var_params['id'] # noqa: E501 query_params = [] for key in kwargs: @@ -553,32 +529,27 @@ def retrieve_order_with_http_info(self, id, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/orders/{id}", - "GET", + '/v1/orders/{id}', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="OrderResponse", # noqa: E501 + response_type='OrderResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) def retrieve_orders(self, **kwargs): # noqa: E501 """Retrieves a list of orders # noqa: E501 @@ -591,6 +562,8 @@ def retrieve_orders(self, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param int page: + :param str metadata_ext_id: + :param str metadata_disregarded: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -602,7 +575,7 @@ def retrieve_orders(self, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True + kwargs['_return_http_data_only'] = True return self.retrieve_orders_with_http_info(**kwargs) # noqa: E501 def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 @@ -616,6 +589,8 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param int page: + :param str metadata_ext_id: + :param str metadata_disregarded: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -632,34 +607,34 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ["page"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['page', 'metadata_ext_id', 'metadata_disregarded'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method retrieve_orders" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] collection_formats = {} @@ -668,8 +643,12 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 query_params = [] for key in kwargs: query_params.append([key, kwargs.get(key)]) - if "page" in local_var_params: - query_params.append(("page", local_var_params["page"])) # noqa: E501 + if 'page' in local_var_params: + query_params.append(('page', local_var_params['page'])) # noqa: E501 + if 'metadata_ext_id' in local_var_params: + query_params.append(('metadata[ext_id]', local_var_params['metadata_ext_id'])) # noqa: E501 + if 'metadata_disregarded' in local_var_params: + query_params.append(('metadata[disregarded]', local_var_params['metadata_disregarded'])) # noqa: E501 header_params = {} @@ -678,29 +657,24 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/orders", - "GET", + '/v1/orders', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="OrderListResponse", # noqa: E501 + response_type='OrderListResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) diff --git a/patch_api/api/preferences_api.py b/patch_api/api/preferences_api.py index d45e3fb..b992706 100644 --- a/patch_api/api/preferences_api.py +++ b/patch_api/api/preferences_api.py @@ -18,7 +18,10 @@ # python 2 and python 3 compatibility library import six -from patch_api.exceptions import ApiTypeError, ApiValueError +from patch_api.exceptions import ( + ApiTypeError, + ApiValueError +) class PreferencesApi(object): @@ -29,20 +32,20 @@ class PreferencesApi(object): """ ALLOWED_QUERY_PARAMS = [ - "mass_g", - "total_price_cents_usd", - "project_id", - "page", - "distance_m", - "transportation_method", - "package_mass_g", - "create_order", - "model", - "make", - "year", - "transaction_value_btc_sats", - "timestamp", - "gas_used", + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year", + "transaction_value_btc_sats", + "timestamp", + "gas_used" ] def __init__(self, api_client=None): @@ -70,14 +73,10 @@ def create_preference(self, create_preference_request={}, **kwargs): # noqa: E5 If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True - return self.create_preference_with_http_info( - create_preference_request, **kwargs - ) # noqa: E501 - - def create_preference_with_http_info( - self, create_preference_request, **kwargs - ): # noqa: E501 + kwargs['_return_http_data_only'] = True + return self.create_preference_with_http_info(create_preference_request, **kwargs) # noqa: E501 + + def create_preference_with_http_info(self, create_preference_request, **kwargs): # noqa: E501 """creates a project preference # noqa: E501 Creates a project preference for the given organization. If you have a `preference` in place, all of your orders will be directed to the project the preference points to. # noqa: E501 @@ -104,42 +103,38 @@ def create_preference_with_http_info( local_var_params = locals() - all_params = ["create_preference_request"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['create_preference_request'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_preference" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] # verify the required parameter 'create_preference_request' is set - if ( - "create_preference_request" not in local_var_params - or local_var_params["create_preference_request"] is None - ): - raise ApiValueError( - "Missing the required parameter `create_preference_request` when calling `create_preference`" - ) # noqa: E501 + if ('create_preference_request' not in local_var_params or + local_var_params['create_preference_request'] is None): + raise ApiValueError("Missing the required parameter `create_preference_request` when calling `create_preference`") # noqa: E501 collection_formats = {} @@ -155,42 +150,34 @@ def create_preference_with_http_info( local_var_files = {} body_params = None - if "create_preference_request" in local_var_params: - body_params = local_var_params["create_preference_request"] + if 'create_preference_request' in local_var_params: + body_params = local_var_params['create_preference_request'] # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # HTTP header `Content-Type` - header_params[ - "Content-Type" - ] = self.api_client.select_header_content_type( # noqa: E501 - ["application/json"] - ) # noqa: E501 + header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/preferences", - "POST", + '/v1/preferences', 'POST', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="PreferenceResponse", # noqa: E501 + response_type='PreferenceResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) def delete_preference(self, id={}, **kwargs): # noqa: E501 """Deletes an organization's preference for a project # noqa: E501 @@ -214,7 +201,7 @@ def delete_preference(self, id={}, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True + kwargs['_return_http_data_only'] = True return self.delete_preference_with_http_info(id, **kwargs) # noqa: E501 def delete_preference_with_http_info(self, id, **kwargs): # noqa: E501 @@ -244,45 +231,44 @@ def delete_preference_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ["id"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['id'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method delete_preference" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] # verify the required parameter 'id' is set - if "id" not in local_var_params or local_var_params["id"] is None: - raise ApiValueError( - "Missing the required parameter `id` when calling `delete_preference`" - ) # noqa: E501 + if ('id' not in local_var_params or + local_var_params['id'] is None): + raise ApiValueError("Missing the required parameter `id` when calling `delete_preference`") # noqa: E501 collection_formats = {} path_params = {} - if "id" in local_var_params: - path_params["id"] = local_var_params["id"] # noqa: E501 + if 'id' in local_var_params: + path_params['id'] = local_var_params['id'] # noqa: E501 query_params = [] for key in kwargs: @@ -295,32 +281,27 @@ def delete_preference_with_http_info(self, id, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/preferences/{id}", - "DELETE", + '/v1/preferences/{id}', 'DELETE', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="PreferenceResponse", # noqa: E501 + response_type='PreferenceResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) def retrieve_preference(self, id={}, **kwargs): # noqa: E501 """Retrieve the preference # noqa: E501 @@ -344,7 +325,7 @@ def retrieve_preference(self, id={}, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True + kwargs['_return_http_data_only'] = True return self.retrieve_preference_with_http_info(id, **kwargs) # noqa: E501 def retrieve_preference_with_http_info(self, id, **kwargs): # noqa: E501 @@ -374,45 +355,44 @@ def retrieve_preference_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ["id"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['id'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method retrieve_preference" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] # verify the required parameter 'id' is set - if "id" not in local_var_params or local_var_params["id"] is None: - raise ApiValueError( - "Missing the required parameter `id` when calling `retrieve_preference`" - ) # noqa: E501 + if ('id' not in local_var_params or + local_var_params['id'] is None): + raise ApiValueError("Missing the required parameter `id` when calling `retrieve_preference`") # noqa: E501 collection_formats = {} path_params = {} - if "id" in local_var_params: - path_params["id"] = local_var_params["id"] # noqa: E501 + if 'id' in local_var_params: + path_params['id'] = local_var_params['id'] # noqa: E501 query_params = [] for key in kwargs: @@ -425,32 +405,27 @@ def retrieve_preference_with_http_info(self, id, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/preferences/{id}", - "GET", + '/v1/preferences/{id}', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="PreferenceResponse", # noqa: E501 + response_type='PreferenceResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) def retrieve_preferences(self, **kwargs): # noqa: E501 """Retrieves a list of preferences # noqa: E501 @@ -474,7 +449,7 @@ def retrieve_preferences(self, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True + kwargs['_return_http_data_only'] = True return self.retrieve_preferences_with_http_info(**kwargs) # noqa: E501 def retrieve_preferences_with_http_info(self, **kwargs): # noqa: E501 @@ -504,34 +479,34 @@ def retrieve_preferences_with_http_info(self, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ["page"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['page'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method retrieve_preferences" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] collection_formats = {} @@ -540,8 +515,8 @@ def retrieve_preferences_with_http_info(self, **kwargs): # noqa: E501 query_params = [] for key in kwargs: query_params.append([key, kwargs.get(key)]) - if "page" in local_var_params: - query_params.append(("page", local_var_params["page"])) # noqa: E501 + if 'page' in local_var_params: + query_params.append(('page', local_var_params['page'])) # noqa: E501 header_params = {} @@ -550,29 +525,24 @@ def retrieve_preferences_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/preferences", - "GET", + '/v1/preferences', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="PreferenceListResponse", # noqa: E501 + response_type='PreferenceListResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) diff --git a/patch_api/api/projects_api.py b/patch_api/api/projects_api.py index 64fa2b4..baadb7f 100644 --- a/patch_api/api/projects_api.py +++ b/patch_api/api/projects_api.py @@ -18,7 +18,10 @@ # python 2 and python 3 compatibility library import six -from patch_api.exceptions import ApiTypeError, ApiValueError +from patch_api.exceptions import ( + ApiTypeError, + ApiValueError +) class ProjectsApi(object): @@ -29,20 +32,20 @@ class ProjectsApi(object): """ ALLOWED_QUERY_PARAMS = [ - "mass_g", - "total_price_cents_usd", - "project_id", - "page", - "distance_m", - "transportation_method", - "package_mass_g", - "create_order", - "model", - "make", - "year", - "transaction_value_btc_sats", - "timestamp", - "gas_used", + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year", + "transaction_value_btc_sats", + "timestamp", + "gas_used" ] def __init__(self, api_client=None): @@ -70,7 +73,7 @@ def retrieve_project(self, id={}, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True + kwargs['_return_http_data_only'] = True return self.retrieve_project_with_http_info(id, **kwargs) # noqa: E501 def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501 @@ -100,45 +103,44 @@ def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ["id"] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['id'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method retrieve_project" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] # verify the required parameter 'id' is set - if "id" not in local_var_params or local_var_params["id"] is None: - raise ApiValueError( - "Missing the required parameter `id` when calling `retrieve_project`" - ) # noqa: E501 + if ('id' not in local_var_params or + local_var_params['id'] is None): + raise ApiValueError("Missing the required parameter `id` when calling `retrieve_project`") # noqa: E501 collection_formats = {} path_params = {} - if "id" in local_var_params: - path_params["id"] = local_var_params["id"] # noqa: E501 + if 'id' in local_var_params: + path_params['id'] = local_var_params['id'] # noqa: E501 query_params = [] for key in kwargs: @@ -151,32 +153,27 @@ def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/projects/{id}", - "GET", + '/v1/projects/{id}', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="ProjectResponse", # noqa: E501 + response_type='ProjectResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) def retrieve_projects(self, **kwargs): # noqa: E501 """Retrieves a list of projects # noqa: E501 @@ -203,7 +200,7 @@ def retrieve_projects(self, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs["_return_http_data_only"] = True + kwargs['_return_http_data_only'] = True return self.retrieve_projects_with_http_info(**kwargs) # noqa: E501 def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501 @@ -236,34 +233,34 @@ 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.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("timestamp") - all_params.append("gas_used") - - for key, val in six.iteritems(local_var_params["kwargs"]): + all_params = ['page', 'country', 'type', 'minimum_available_mass'] # noqa: E501 + all_params.append('async_req') + all_params.append('_return_http_data_only') + all_params.append('_preload_content') + all_params.append('_request_timeout') + all_params.append('mass_g') + all_params.append('total_price_cents_usd') + all_params.append('project_id') + all_params.append('metadata') + all_params.append('distance_m') + all_params.append('transportation_method') + all_params.append('package_mass_g') + all_params.append('create_order') + all_params.append('make') + all_params.append('model') + all_params.append('year') + all_params.append('transaction_value_btc_sats') + all_params.append('timestamp') + all_params.append('gas_used') + + for key, val in six.iteritems(local_var_params['kwargs']): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method retrieve_projects" % key ) local_var_params[key] = val - del local_var_params["kwargs"] + del local_var_params['kwargs'] collection_formats = {} @@ -272,16 +269,14 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501 query_params = [] for key in kwargs: query_params.append([key, kwargs.get(key)]) - if "page" in local_var_params: - query_params.append(("page", local_var_params["page"])) # noqa: E501 - if "country" in local_var_params: - query_params.append(("country", local_var_params["country"])) # noqa: E501 - if "type" in local_var_params: - query_params.append(("type", local_var_params["type"])) # noqa: E501 - if "minimum_available_mass" in local_var_params: - query_params.append( - ("minimum_available_mass", local_var_params["minimum_available_mass"]) - ) # noqa: E501 + if 'page' in local_var_params: + query_params.append(('page', local_var_params['page'])) # noqa: E501 + if 'country' in local_var_params: + query_params.append(('country', local_var_params['country'])) # noqa: E501 + if 'type' in local_var_params: + query_params.append(('type', local_var_params['type'])) # noqa: E501 + if 'minimum_available_mass' in local_var_params: + query_params.append(('minimum_available_mass', local_var_params['minimum_available_mass'])) # noqa: E501 header_params = {} @@ -290,29 +285,24 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params["Accept"] = self.api_client.select_header_accept( - ["application/json"] - ) # noqa: E501 + header_params['Accept'] = self.api_client.select_header_accept( + ['application/json']) # noqa: E501 # Authentication setting - auth_settings = ["bearer_auth"] # noqa: E501 + auth_settings = ['bearer_auth'] # noqa: E501 return self.api_client.call_api( - "/v1/projects", - "GET", + '/v1/projects', 'GET', path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type="ProjectListResponse", # noqa: E501 + response_type='ProjectListResponse', # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get("async_req"), - _return_http_data_only=local_var_params.get( - "_return_http_data_only" - ), # noqa: E501 - _preload_content=local_var_params.get("_preload_content", True), - _request_timeout=local_var_params.get("_request_timeout"), - collection_formats=collection_formats, - ) + async_req=local_var_params.get('async_req'), + _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 + _preload_content=local_var_params.get('_preload_content', True), + _request_timeout=local_var_params.get('_request_timeout'), + collection_formats=collection_formats) diff --git a/patch_api/api_client.py b/patch_api/api_client.py index 5beb1c3..cf21c4b 100644 --- a/patch_api/api_client.py +++ b/patch_api/api_client.py @@ -58,28 +58,21 @@ class ApiClient(object): PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types NATIVE_TYPES_MAPPING = { - "int": int, - "long": int if six.PY3 else long, # noqa: F821 - "float": float, - "str": str, - "bool": bool, - "date": datetime.date, - "datetime": datetime.datetime, - "object": object, + 'int': int, + 'long': int if six.PY3 else long, # noqa: F821 + 'float': float, + 'str': str, + 'bool': bool, + 'date': datetime.date, + 'datetime': datetime.datetime, + 'object': object, } _pool = None - def __init__( - self, - api_key=None, - configuration=None, - header_name=None, - header_value=None, - cookie=None, - pool_threads=1, - ): + def __init__(self, api_key=None, configuration=None, header_name=None, header_value=None, + cookie=None, pool_threads=1): if api_key is None: - raise ValueError("ApiClient must be initialized with an api_key") + raise ValueError('ApiClient must be initialized with an api_key') if configuration is None: configuration = Configuration() self.configuration = configuration @@ -91,7 +84,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = "OpenAPI-Generator/1.8.0/python" + self.user_agent = 'OpenAPI-Generator/1.8.0/python' def __del__(self): if self._pool: @@ -101,17 +94,17 @@ def __del__(self): def __getattr__(self, method): resource = { - "projects": ProjectsApi, - "orders": OrdersApi, - "preferences": PreferencesApi, - "estimates": EstimatesApi, + 'projects': ProjectsApi, + 'orders': OrdersApi, + 'preferences': PreferencesApi, + 'estimates': EstimatesApi }[method] return resource(api_client=self) @property def pool(self): """Create thread pool on first request - avoids instantiating unused threadpool for blocking clients. + avoids instantiating unused threadpool for blocking clients. """ if self._pool is None: self._pool = ThreadPool(self.pool_threads) @@ -120,33 +113,21 @@ def pool(self): @property def user_agent(self): """User agent for this API client""" - return self.default_headers["User-Agent"] + return self.default_headers['User-Agent'] @user_agent.setter def user_agent(self, value): - self.default_headers["User-Agent"] = value + self.default_headers['User-Agent'] = value def set_default_header(self, header_name, header_value): self.default_headers[header_name] = header_value def __call_api( - self, - resource_path, - method, - path_params=None, - query_params=None, - header_params=None, - body=None, - post_params=None, - files=None, - response_type=None, - auth_settings=None, - _return_http_data_only=None, - collection_formats=None, - _preload_content=True, - _request_timeout=None, - _host=None, - ): + self, resource_path, method, path_params=None, + query_params=None, header_params=None, body=None, post_params=None, + files=None, response_type=None, auth_settings=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None, _host=None): config = self.configuration @@ -154,33 +135,36 @@ def __call_api( header_params = header_params or {} header_params.update(self.default_headers) if self.cookie: - header_params["Cookie"] = self.cookie + header_params['Cookie'] = self.cookie if header_params: header_params = self.sanitize_for_serialization(header_params) - header_params = dict( - self.parameters_to_tuples(header_params, collection_formats) - ) + header_params = dict(self.parameters_to_tuples(header_params, + collection_formats)) # path parameters if path_params: path_params = self.sanitize_for_serialization(path_params) - path_params = self.parameters_to_tuples(path_params, collection_formats) + path_params = self.parameters_to_tuples(path_params, + collection_formats) for k, v in path_params: # specified safe chars, encode everything resource_path = resource_path.replace( - "{%s}" % k, quote(str(v), safe=config.safe_chars_for_path_param) + '{%s}' % k, + quote(str(v), safe=config.safe_chars_for_path_param) ) # query parameters if query_params: query_params = self.sanitize_for_serialization(query_params) - query_params = self.parameters_to_tuples(query_params, collection_formats) + query_params = self.parameters_to_tuples(query_params, + collection_formats) # post parameters if post_params or files: post_params = post_params if post_params else [] post_params = self.sanitize_for_serialization(post_params) - post_params = self.parameters_to_tuples(post_params, collection_formats) + post_params = self.parameters_to_tuples(post_params, + collection_formats) post_params.extend(self.files_parameters(files)) # auth setting @@ -199,15 +183,10 @@ def __call_api( # perform request and return response response_data = self.request( - method, - url, - query_params=query_params, - headers=header_params, - post_params=post_params, - body=body, + method, url, query_params=query_params, headers=header_params, + post_params=post_params, body=body, _preload_content=_preload_content, - _request_timeout=_request_timeout, - ) + _request_timeout=_request_timeout) self.last_response = response_data @@ -220,9 +199,10 @@ def __call_api( return_data = None if _return_http_data_only: - return return_data + return (return_data) else: - return (return_data, response_data.status, response_data.getheaders()) + return (return_data, response_data.status, + response_data.getheaders()) def sanitize_for_serialization(self, obj): """Builds a JSON POST object. @@ -243,9 +223,11 @@ def sanitize_for_serialization(self, obj): elif isinstance(obj, self.PRIMITIVE_TYPES): return obj elif isinstance(obj, list): - return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj] + return [self.sanitize_for_serialization(sub_obj) + for sub_obj in obj] elif isinstance(obj, tuple): - return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj) + return tuple(self.sanitize_for_serialization(sub_obj) + for sub_obj in obj) elif isinstance(obj, (datetime.datetime, datetime.date)): return obj.isoformat() @@ -257,16 +239,12 @@ def sanitize_for_serialization(self, obj): # and attributes which value is not None. # Convert attribute name to json key in # model definition for request. - obj_dict = { - obj.attribute_map[attr]: getattr(obj, attr) - for attr, _ in six.iteritems(obj.openapi_types) - if getattr(obj, attr) is not None - } + obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) + for attr, _ in six.iteritems(obj.openapi_types) + if getattr(obj, attr) is not None} - return { - key: self.sanitize_for_serialization(val) - for key, val in six.iteritems(obj_dict) - } + return {key: self.sanitize_for_serialization(val) + for key, val in six.iteritems(obj_dict)} def deserialize(self, response, response_type): """Deserializes response into an object. @@ -302,15 +280,15 @@ def __deserialize(self, data, klass): return None if type(klass) == str: - if klass.startswith("list["): - sub_kls = re.match(r"list\[(.*)\]", klass).group(1) - return [self.__deserialize(sub_data, sub_kls) for sub_data in data] + if klass.startswith('list['): + sub_kls = re.match(r'list\[(.*)\]', klass).group(1) + return [self.__deserialize(sub_data, sub_kls) + for sub_data in data] - if klass.startswith("dict("): - sub_kls = re.match(r"dict\(([^,]*), (.*)\)", klass).group(2) - return { - k: self.__deserialize(v, sub_kls) for k, v in six.iteritems(data) - } + if klass.startswith('dict('): + sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2) + return {k: self.__deserialize(v, sub_kls) + for k, v in six.iteritems(data)} # convert str to class if klass in self.NATIVE_TYPES_MAPPING: @@ -329,25 +307,12 @@ def __deserialize(self, data, klass): else: return self.__deserialize_model(data, klass) - def call_api( - self, - resource_path, - method, - path_params=None, - query_params=None, - header_params=None, - body=None, - post_params=None, - files=None, - response_type=None, - auth_settings=None, - async_req=None, - _return_http_data_only=None, - collection_formats=None, - _preload_content=True, - _request_timeout=None, - _host=None, - ): + def call_api(self, resource_path, method, + path_params=None, query_params=None, header_params=None, + body=None, post_params=None, files=None, + response_type=None, auth_settings=None, async_req=None, + _return_http_data_only=None, collection_formats=None, + _preload_content=True, _request_timeout=None, _host=None): """Makes the HTTP request (synchronous) and returns deserialized data. To make an async_req request, set the async_req parameter. @@ -385,123 +350,80 @@ def call_api( then the method will return the response directly. """ if not async_req: - return self.__call_api( - resource_path, - method, - path_params, - query_params, - header_params, - body, - post_params, - files, - response_type, - auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, - _request_timeout, - _host, - ) + return self.__call_api(resource_path, method, + path_params, query_params, header_params, + body, post_params, files, + response_type, auth_settings, + _return_http_data_only, collection_formats, + _preload_content, _request_timeout, _host) else: - thread = self.pool.apply_async( - self.__call_api, - ( - resource_path, - method, - path_params, - query_params, - header_params, - body, - post_params, - files, - response_type, - auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, - _request_timeout, - _host, - ), - ) + thread = self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, query_params, + header_params, body, + post_params, files, + response_type, auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host)) return thread - def request( - self, - method, - url, - query_params=None, - headers=None, - post_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): + def request(self, method, url, query_params=None, headers=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): """Makes the HTTP request using RESTClient.""" if method == "GET": - return self.rest_client.GET( - url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers, - ) + return self.rest_client.GET(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) elif method == "HEAD": - return self.rest_client.HEAD( - url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers, - ) + return self.rest_client.HEAD(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) elif method == "OPTIONS": - return self.rest_client.OPTIONS( - url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) + return self.rest_client.OPTIONS(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) elif method == "POST": - return self.rest_client.POST( - url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) + return self.rest_client.POST(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) elif method == "PUT": - return self.rest_client.PUT( - url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) + return self.rest_client.PUT(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) elif method == "PATCH": - return self.rest_client.PATCH( - url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) + return self.rest_client.PATCH(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) elif method == "DELETE": - return self.rest_client.DELETE( - url, - query_params=query_params, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) + return self.rest_client.DELETE(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) else: raise ApiValueError( "http method must be `GET`, `HEAD`, `OPTIONS`," @@ -518,23 +440,22 @@ def parameters_to_tuples(self, params, collection_formats): new_params = [] if collection_formats is None: collection_formats = {} - for k, v in ( - six.iteritems(params) if isinstance(params, dict) else params - ): # noqa: E501 + for k, v in six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501 if k in collection_formats: collection_format = collection_formats[k] - if collection_format == "multi": + if collection_format == 'multi': new_params.extend((k, value) for value in v) else: - if collection_format == "ssv": - delimiter = " " - elif collection_format == "tsv": - delimiter = "\t" - elif collection_format == "pipes": - delimiter = "|" + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' else: # csv is the default - delimiter = "," - new_params.append((k, delimiter.join(str(value) for value in v))) + delimiter = ',' + new_params.append( + (k, delimiter.join(str(value) for value in v))) else: new_params.append((k, v)) return new_params @@ -553,14 +474,13 @@ def files_parameters(self, files=None): continue file_names = v if type(v) is list else [v] for n in file_names: - with open(n, "rb") as f: + with open(n, 'rb') as f: filename = os.path.basename(f.name) filedata = f.read() - mimetype = ( - mimetypes.guess_type(filename)[0] - or "application/octet-stream" - ) - params.append(tuple([k, tuple([filename, filedata, mimetype])])) + mimetype = (mimetypes.guess_type(filename)[0] or + 'application/octet-stream') + params.append( + tuple([k, tuple([filename, filedata, mimetype])])) return params @@ -575,10 +495,10 @@ def select_header_accept(self, accepts): accepts = [x.lower() for x in accepts] - if "application/json" in accepts: - return "application/json" + if 'application/json' in accepts: + return 'application/json' else: - return ", ".join(accepts) + return ', '.join(accepts) def select_header_content_type(self, content_types): """Returns `Content-Type` based on an array of content_types provided. @@ -587,12 +507,12 @@ def select_header_content_type(self, content_types): :return: Content-Type (e.g. application/json). """ if not content_types: - return "application/json" + return 'application/json' content_types = [x.lower() for x in content_types] - if "application/json" in content_types or "*/*" in content_types: - return "application/json" + if 'application/json' in content_types or '*/*' in content_types: + return 'application/json' else: return content_types[0] @@ -609,17 +529,17 @@ def update_params_for_auth(self, headers, querys, auth_settings): for auth in auth_settings: auth_setting = self.configuration.auth_settings().get(auth) if auth_setting: - if not auth_setting["value"]: + if not auth_setting['value']: continue - elif auth_setting["in"] == "cookie": - headers["Cookie"] = auth_setting["value"] - elif auth_setting["in"] == "header": - headers[auth_setting["key"]] = auth_setting["value"] - elif auth_setting["in"] == "query": - querys.append((auth_setting["key"], auth_setting["value"])) + elif auth_setting['in'] == 'cookie': + headers['Cookie'] = auth_setting['value'] + elif auth_setting['in'] == 'header': + headers[auth_setting['key']] = auth_setting['value'] + elif auth_setting['in'] == 'query': + querys.append((auth_setting['key'], auth_setting['value'])) else: raise ApiValueError( - "Authentication token must be in `query` or `header`" + 'Authentication token must be in `query` or `header`' ) def __deserialize_file(self, response): @@ -637,9 +557,8 @@ def __deserialize_file(self, response): content_disposition = response.getheader("Content-Disposition") if content_disposition: - filename = re.search( - r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition - ).group(1) + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).group(1) path = os.path.join(os.path.dirname(path), filename) with open(path, "wb") as f: @@ -677,13 +596,13 @@ def __deserialize_date(self, string): """ try: from dateutil.parser import parse - return parse(string).date() except ImportError: return string except ValueError: raise rest.ApiException( - status=0, reason="Failed to parse `{0}` as date object".format(string) + status=0, + reason="Failed to parse `{0}` as date object".format(string) ) def __deserialize_datatime(self, string): @@ -696,14 +615,16 @@ def __deserialize_datatime(self, string): """ try: from dateutil.parser import parse - return parse(string) except ImportError: return string except ValueError: raise rest.ApiException( status=0, - reason=("Failed to parse `{0}` as datetime object".format(string)), + reason=( + "Failed to parse `{0}` as datetime object" + .format(string) + ) ) def __deserialize_model(self, data, klass): @@ -714,23 +635,22 @@ def __deserialize_model(self, data, klass): :return: model object. """ - if not klass.openapi_types and not hasattr(klass, "get_real_child_model"): + if not klass.openapi_types and not hasattr(klass, + 'get_real_child_model'): return data kwargs = {} if klass.openapi_types is not None: for attr, attr_type in six.iteritems(klass.openapi_types): - if ( - data is not None - and klass.attribute_map[attr] in data - and isinstance(data, (list, dict)) - ): + if (data is not None and + klass.attribute_map[attr] in data and + isinstance(data, (list, dict))): value = data[klass.attribute_map[attr]] kwargs[attr] = self.__deserialize(value, attr_type) instance = klass(**kwargs) - if hasattr(instance, "get_real_child_model"): + if hasattr(instance, 'get_real_child_model'): klass_name = instance.get_real_child_model(data) if klass_name: instance = self.__deserialize(data, klass_name) diff --git a/patch_api/configuration.py b/patch_api/configuration.py index 80ed119..c4e4008 100644 --- a/patch_api/configuration.py +++ b/patch_api/configuration.py @@ -56,16 +56,13 @@ class Configuration(object): _default = None - def __init__( - self, - host="https://api.patch.io", - api_key=None, - api_key_prefix=None, - username=None, - password=None, - discard_unknown_keys=False, - ): - """Constructor""" + def __init__(self, host="https://api.patch.io", + api_key=None, api_key_prefix=None, + username=None, password=None, + discard_unknown_keys=False, + ): + """Constructor + """ self.host = host """Default Base url """ @@ -101,7 +98,7 @@ def __init__( """ self.logger["package_logger"] = logging.getLogger("patch_api") self.logger["urllib3_logger"] = logging.getLogger("urllib3") - self.logger_format = "%(asctime)s %(levelname)s %(message)s" + self.logger_format = '%(asctime)s %(levelname)s %(message)s' """Log format """ self.logger_stream_handler = None @@ -149,7 +146,7 @@ def __init__( self.proxy_headers = None """Proxy headers """ - self.safe_chars_for_path_param = "" + self.safe_chars_for_path_param = '' """Safe chars for path_param """ self.retries = None @@ -163,7 +160,7 @@ def __deepcopy__(self, memo): result = cls.__new__(cls) memo[id(self)] = result for k, v in self.__dict__.items(): - if k not in ("logger", "logger_file_handler"): + if k not in ('logger', 'logger_file_handler'): setattr(result, k, copy.deepcopy(v, memo)) # shallow copy of loggers result.logger = copy.copy(self.logger) @@ -312,9 +309,9 @@ def get_basic_auth_token(self): password = "" if self.password is not None: password = self.password - return urllib3.util.make_headers(basic_auth=username + ":" + password).get( - "authorization" - ) + return urllib3.util.make_headers( + basic_auth=username + ':' + password + ).get('authorization') def auth_settings(self): """Gets Auth Settings dict for api client. @@ -323,11 +320,11 @@ def auth_settings(self): """ auth = {} if self.access_token is not None: - auth["bearer_auth"] = { - "type": "bearer", - "in": "header", - "key": "Authorization", - "value": "Bearer " + self.access_token, + auth['bearer_auth'] = { + 'type': 'bearer', + 'in': 'header', + 'key': 'Authorization', + 'value': 'Bearer ' + self.access_token } return auth @@ -336,13 +333,12 @@ def to_debug_report(self): :return: The report for debugging. """ - return ( - "Python SDK Debug Report:\n" - "OS: {env}\n" - "Python Version: {pyversion}\n" - "Version of the API: v1\n" - "SDK Package Version: 1.8.0".format(env=sys.platform, pyversion=sys.version) - ) + return "Python SDK Debug Report:\n"\ + "OS: {env}\n"\ + "Python Version: {pyversion}\n"\ + "Version of the API: v1\n"\ + "SDK Package Version: 1.8.0".\ + format(env=sys.platform, pyversion=sys.version) def get_host_settings(self): """Gets an array of host settings @@ -351,14 +347,14 @@ def get_host_settings(self): """ return [ { - "url": "https://{defaultHost}", - "description": "No description provided", - "variables": { - "defaultHost": { - "description": "No description provided", - "default_value": "api.patch.io", + 'url': "https://{defaultHost}", + 'description': "No description provided", + 'variables': { + 'defaultHost': { + 'description': "No description provided", + 'default_value': "api.patch.io", + } } - }, } ] @@ -376,22 +372,22 @@ def get_host_from_settings(self, index, variables=None): except IndexError: raise ValueError( "Invalid index {0} when selecting the host settings. " - "Must be less than {1}".format(index, len(servers)) - ) + "Must be less than {1}".format(index, len(servers))) - url = server["url"] + url = server['url'] # go through variables and replace placeholders - for variable_name, variable in server["variables"].items(): - used_value = variables.get(variable_name, variable["default_value"]) + for variable_name, variable in server['variables'].items(): + used_value = variables.get( + variable_name, variable['default_value']) - if "enum_values" in variable and used_value not in variable["enum_values"]: + if 'enum_values' in variable \ + and used_value not in variable['enum_values']: raise ValueError( "The variable `{0}` in the host URL has invalid value " "{1}. Must be {2}.".format( - variable_name, variables[variable_name], variable["enum_values"] - ) - ) + variable_name, variables[variable_name], + variable['enum_values'])) url = url.replace("{" + variable_name + "}", used_value) diff --git a/patch_api/exceptions.py b/patch_api/exceptions.py index 64b8229..e2bd822 100644 --- a/patch_api/exceptions.py +++ b/patch_api/exceptions.py @@ -19,8 +19,9 @@ class OpenApiException(Exception): class ApiTypeError(OpenApiException, TypeError): - def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None): - """Raises an exception for TypeErrors + def __init__(self, msg, path_to_item=None, valid_classes=None, + key_type=None): + """ Raises an exception for TypeErrors Args: msg (str): the exception message @@ -82,6 +83,7 @@ def __init__(self, msg, path_to_item=None): class ApiException(OpenApiException): + def __init__(self, status=None, reason=None, http_resp=None): if http_resp: self.status = http_resp.status @@ -96,9 +98,11 @@ def __init__(self, status=None, reason=None, http_resp=None): def __str__(self): """Custom error messages for exception""" - error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason) + error_message = "({0})\n"\ + "Reason: {1}\n".format(self.status, self.reason) if self.headers: - error_message += "HTTP response headers: {0}\n".format(self.headers) + error_message += "HTTP response headers: {0}\n".format( + self.headers) if self.body: error_message += "HTTP response body: {0}\n".format(self.body) diff --git a/patch_api/models/allocation.py b/patch_api/models/allocation.py index b6629ae..e37d829 100644 --- a/patch_api/models/allocation.py +++ b/patch_api/models/allocation.py @@ -33,13 +33,19 @@ class Allocation(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = {"id": "str", "production": "bool", "mass_g": "int"} - - attribute_map = {"id": "id", "production": "production", "mass_g": "mass_g"} - - def __init__( - self, id=None, production=None, mass_g=None, local_vars_configuration=None - ): # noqa: E501 + openapi_types = { + 'id': 'str', + 'production': 'bool', + 'mass_g': 'int' + } + + attribute_map = { + 'id': 'id', + 'production': 'production', + 'mass_g': 'mass_g' + } + + def __init__(self, id=None, production=None, mass_g=None, local_vars_configuration=None): # noqa: E501 """Allocation - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -74,9 +80,7 @@ def id(self, id): :param id: The id of this Allocation. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and id is None - ): # noqa: E501 + if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -101,12 +105,8 @@ def production(self, production): :param production: The production of this Allocation. # noqa: E501 :type: bool """ - if ( - self.local_vars_configuration.client_side_validation and production is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `production`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and production is None: # noqa: E501 + raise ValueError("Invalid value for `production`, must not be `None`") # noqa: E501 self._production = production @@ -130,12 +130,8 @@ def mass_g(self, mass_g): :param mass_g: The mass_g of this Allocation. # noqa: E501 :type: int """ - if ( - self.local_vars_configuration.client_side_validation and mass_g is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `mass_g`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and mass_g is None: # noqa: E501 + raise ValueError("Invalid value for `mass_g`, must not be `None`") # noqa: E501 self._mass_g = mass_g @@ -146,20 +142,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/bulk_create_success_response.py b/patch_api/models/bulk_create_success_response.py new file mode 100644 index 0000000..3a35217 --- /dev/null +++ b/patch_api/models/bulk_create_success_response.py @@ -0,0 +1,149 @@ +# coding: utf-8 + +""" + Patch API V1 + + The core API used to integrate with Patch's service # noqa: E501 + + The version of the OpenAPI document: v1 + Contact: developers@usepatch.com + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from patch_api.configuration import Configuration + + +class BulkCreateSuccessResponse(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'success': 'bool', + 'error': 'Error' + } + + attribute_map = { + 'success': 'success', + 'error': 'error' + } + + def __init__(self, success=None, error=None, local_vars_configuration=None): # noqa: E501 + """BulkCreateSuccessResponse - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._success = None + self._error = None + self.discriminator = None + + self.success = success + self.error = error + + @property + def success(self): + """Gets the success of this BulkCreateSuccessResponse. # noqa: E501 + + + :return: The success of this BulkCreateSuccessResponse. # noqa: E501 + :rtype: bool + """ + return self._success + + @success.setter + def success(self, success): + """Sets the success of this BulkCreateSuccessResponse. + + + :param success: The success of this BulkCreateSuccessResponse. # noqa: E501 + :type: bool + """ + if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 + raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 + + self._success = success + + @property + def error(self): + """Gets the error of this BulkCreateSuccessResponse. # noqa: E501 + + + :return: The error of this BulkCreateSuccessResponse. # noqa: E501 + :rtype: Error + """ + return self._error + + @error.setter + def error(self, error): + """Sets the error of this BulkCreateSuccessResponse. + + + :param error: The error of this BulkCreateSuccessResponse. # noqa: E501 + :type: Error + """ + if self.local_vars_configuration.client_side_validation and error is None: # noqa: E501 + raise ValueError("Invalid value for `error`, must not be `None`") # noqa: E501 + + self._error = error + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, BulkCreateSuccessResponse): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, BulkCreateSuccessResponse): + return True + + return self.to_dict() != other.to_dict() diff --git a/patch_api/models/error.py b/patch_api/models/error.py new file mode 100644 index 0000000..a07c81d --- /dev/null +++ b/patch_api/models/error.py @@ -0,0 +1,149 @@ +# coding: utf-8 + +""" + Patch API V1 + + The core API used to integrate with Patch's service # noqa: E501 + + The version of the OpenAPI document: v1 + Contact: developers@usepatch.com + Generated by: https://openapi-generator.tech +""" + + +import pprint +import re # noqa: F401 + +import six + +from patch_api.configuration import Configuration + + +class Error(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + Attributes: + openapi_types (dict): The key is attribute name + and the value is attribute type. + attribute_map (dict): The key is attribute name + and the value is json key in definition. + """ + openapi_types = { + 'code': 'int', + 'message': 'str' + } + + attribute_map = { + 'code': 'code', + 'message': 'message' + } + + def __init__(self, code=None, message=None, local_vars_configuration=None): # noqa: E501 + """Error - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration() + self.local_vars_configuration = local_vars_configuration + + self._code = None + self._message = None + self.discriminator = None + + self.code = code + self.message = message + + @property + def code(self): + """Gets the code of this Error. # noqa: E501 + + + :return: The code of this Error. # noqa: E501 + :rtype: int + """ + return self._code + + @code.setter + def code(self, code): + """Sets the code of this Error. + + + :param code: The code of this Error. # noqa: E501 + :type: int + """ + if self.local_vars_configuration.client_side_validation and code is None: # noqa: E501 + raise ValueError("Invalid value for `code`, must not be `None`") # noqa: E501 + + self._code = code + + @property + def message(self): + """Gets the message of this Error. # noqa: E501 + + + :return: The message of this Error. # noqa: E501 + :rtype: str + """ + return self._message + + @message.setter + def message(self, message): + """Sets the message of this Error. + + + :param message: The message of this Error. # noqa: E501 + :type: str + """ + if self.local_vars_configuration.client_side_validation and message is None: # noqa: E501 + raise ValueError("Invalid value for `message`, must not be `None`") # noqa: E501 + + self._message = message + + def to_dict(self): + """Returns the model properties as a dict""" + result = {} + + for attr, _ in six.iteritems(self.openapi_types): + value = getattr(self, attr) + if isinstance(value, list): + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) + elif hasattr(value, "to_dict"): + result[attr] = value.to_dict() + elif isinstance(value, dict): + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) + else: + result[attr] = value + + return result + + def to_str(self): + """Returns the string representation of the model""" + return pprint.pformat(self.to_dict()) + + def __repr__(self): + """For `print` and `pprint`""" + return self.to_str() + + def __eq__(self, other): + """Returns true if both objects are equal""" + if not isinstance(other, Error): + return False + + return self.to_dict() == other.to_dict() + + def __ne__(self, other): + """Returns true if both objects are not equal""" + if not isinstance(other, Error): + return True + + return self.to_dict() != other.to_dict() diff --git a/patch_api/models/error_response.py b/patch_api/models/error_response.py index 8303054..c872700 100644 --- a/patch_api/models/error_response.py +++ b/patch_api/models/error_response.py @@ -33,13 +33,19 @@ class ErrorResponse(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = {"success": "bool", "error": "object", "data": "object"} - - attribute_map = {"success": "success", "error": "error", "data": "data"} - - def __init__( - self, success=None, error=None, data=None, local_vars_configuration=None - ): # noqa: E501 + openapi_types = { + 'success': 'bool', + 'error': 'Error', + 'data': 'object' + } + + attribute_map = { + 'success': 'success', + 'error': 'error', + 'data': 'data' + } + + def __init__(self, success=None, error=None, data=None, local_vars_configuration=None): # noqa: E501 """ErrorResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -72,12 +78,8 @@ def success(self, success): :param success: The success of this ErrorResponse. # noqa: E501 :type: bool """ - if ( - self.local_vars_configuration.client_side_validation and success is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `success`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 + raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 self._success = success @@ -87,7 +89,7 @@ def error(self): :return: The error of this ErrorResponse. # noqa: E501 - :rtype: object + :rtype: Error """ return self._error @@ -97,14 +99,10 @@ def error(self, error): :param error: The error of this ErrorResponse. # noqa: E501 - :type: object + :type: Error """ - if ( - self.local_vars_configuration.client_side_validation and error is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `error`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and error is None: # noqa: E501 + raise ValueError("Invalid value for `error`, must not be `None`") # noqa: E501 self._error = error @@ -136,20 +134,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/estimate.py b/patch_api/models/estimate.py index e767292..1ef336d 100644 --- a/patch_api/models/estimate.py +++ b/patch_api/models/estimate.py @@ -34,30 +34,22 @@ class Estimate(object): and the value is json key in definition. """ openapi_types = { - "id": "str", - "production": "bool", - "type": "str", - "mass_g": "int", - "order": "Order", + 'id': 'str', + 'production': 'bool', + 'type': 'str', + 'mass_g': 'int', + 'order': 'Order' } attribute_map = { - "id": "id", - "production": "production", - "type": "type", - "mass_g": "mass_g", - "order": "order", + 'id': 'id', + 'production': 'production', + 'type': 'type', + 'mass_g': 'mass_g', + 'order': 'order' } - def __init__( - self, - id=None, - production=None, - type=None, - mass_g=None, - order=None, - local_vars_configuration=None, - ): # noqa: E501 + def __init__(self, id=None, production=None, type=None, mass_g=None, order=None, local_vars_configuration=None): # noqa: E501 """Estimate - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -97,9 +89,7 @@ def id(self, id): :param id: The id of this Estimate. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and id is None - ): # noqa: E501 + if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -124,12 +114,8 @@ def production(self, production): :param production: The production of this Estimate. # noqa: E501 :type: bool """ - if ( - self.local_vars_configuration.client_side_validation and production is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `production`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and production is None: # noqa: E501 + raise ValueError("Invalid value for `production`, must not be `None`") # noqa: E501 self._production = production @@ -137,7 +123,7 @@ def production(self, production): def type(self): """Gets the type of this Estimate. # noqa: E501 - The type of estimate. Available types are mass, flight, shipping, and vehicle. # noqa: E501 + The type of estimate. Available types are mass, flight, shipping, vehicle, and crypto. # noqa: E501 :return: The type of this Estimate. # noqa: E501 :rtype: str @@ -148,17 +134,13 @@ def type(self): def type(self, type): """Sets the type of this Estimate. - The type of estimate. Available types are mass, flight, shipping, and vehicle. # noqa: E501 + The type of estimate. Available types are mass, flight, shipping, vehicle, and crypto. # noqa: E501 :param type: The type of this Estimate. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and type is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `type`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and type is None: # noqa: E501 + raise ValueError("Invalid value for `type`, must not be `None`") # noqa: E501 self._type = type @@ -215,20 +197,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/estimate_list_response.py b/patch_api/models/estimate_list_response.py index ccb0a68..1b42b43 100644 --- a/patch_api/models/estimate_list_response.py +++ b/patch_api/models/estimate_list_response.py @@ -34,27 +34,20 @@ class EstimateListResponse(object): and the value is json key in definition. """ openapi_types = { - "success": "bool", - "error": "object", - "data": "list[Estimate]", - "meta": "MetaIndexObject", + 'success': 'bool', + 'error': 'object', + 'data': 'list[Estimate]', + 'meta': 'MetaIndexObject' } attribute_map = { - "success": "success", - "error": "error", - "data": "data", - "meta": "meta", + 'success': 'success', + 'error': 'error', + 'data': 'data', + 'meta': 'meta' } - def __init__( - self, - success=None, - error=None, - data=None, - meta=None, - local_vars_configuration=None, - ): # noqa: E501 + def __init__(self, success=None, error=None, data=None, meta=None, local_vars_configuration=None): # noqa: E501 """EstimateListResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -89,12 +82,8 @@ def success(self, success): :param success: The success of this EstimateListResponse. # noqa: E501 :type: bool """ - if ( - self.local_vars_configuration.client_side_validation and success is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `success`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 + raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 self._success = success @@ -137,12 +126,8 @@ def data(self, data): :param data: The data of this EstimateListResponse. # noqa: E501 :type: list[Estimate] """ - if ( - self.local_vars_configuration.client_side_validation and data is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `data`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and data is None: # noqa: E501 + raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 self._data = data @@ -164,12 +149,8 @@ def meta(self, meta): :param meta: The meta of this EstimateListResponse. # noqa: E501 :type: MetaIndexObject """ - if ( - self.local_vars_configuration.client_side_validation and meta is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `meta`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and meta is None: # noqa: E501 + raise ValueError("Invalid value for `meta`, must not be `None`") # noqa: E501 self._meta = meta @@ -180,20 +161,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/estimate_response.py b/patch_api/models/estimate_response.py index f15ac7c..bee841e 100644 --- a/patch_api/models/estimate_response.py +++ b/patch_api/models/estimate_response.py @@ -33,13 +33,19 @@ class EstimateResponse(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = {"success": "bool", "error": "object", "data": "Estimate"} - - attribute_map = {"success": "success", "error": "error", "data": "data"} - - def __init__( - self, success=None, error=None, data=None, local_vars_configuration=None - ): # noqa: E501 + openapi_types = { + 'success': 'bool', + 'error': 'object', + 'data': 'Estimate' + } + + attribute_map = { + 'success': 'success', + 'error': 'error', + 'data': 'data' + } + + def __init__(self, success=None, error=None, data=None, local_vars_configuration=None): # noqa: E501 """EstimateResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -72,12 +78,8 @@ def success(self, success): :param success: The success of this EstimateResponse. # noqa: E501 :type: bool """ - if ( - self.local_vars_configuration.client_side_validation and success is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `success`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 + raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 self._success = success @@ -120,12 +122,8 @@ def data(self, data): :param data: The data of this EstimateResponse. # noqa: E501 :type: Estimate """ - if ( - self.local_vars_configuration.client_side_validation and data is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `data`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and data is None: # noqa: E501 + raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 self._data = data @@ -136,20 +134,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/meta_index_object.py b/patch_api/models/meta_index_object.py index cbc5313..5de83d5 100644 --- a/patch_api/models/meta_index_object.py +++ b/patch_api/models/meta_index_object.py @@ -33,13 +33,17 @@ class MetaIndexObject(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = {"prev_page": "int", "next_page": "int"} + openapi_types = { + 'prev_page': 'int', + 'next_page': 'int' + } - attribute_map = {"prev_page": "prev_page", "next_page": "next_page"} + attribute_map = { + 'prev_page': 'prev_page', + 'next_page': 'next_page' + } - def __init__( - self, prev_page=None, next_page=None, local_vars_configuration=None - ): # noqa: E501 + def __init__(self, prev_page=None, next_page=None, local_vars_configuration=None): # noqa: E501 """MetaIndexObject - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -101,20 +105,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/order.py b/patch_api/models/order.py index 130d2d6..35b1999 100644 --- a/patch_api/models/order.py +++ b/patch_api/models/order.py @@ -34,45 +34,32 @@ class Order(object): and the value is json key in definition. """ openapi_types = { - "id": "str", - "mass_g": "int", - "production": "bool", - "state": "str", - "allocation_state": "str", - "price_cents_usd": "int", - "patch_fee_cents_usd": "int", - "allocations": "list[Allocation]", - "registry_url": "str", - "metadata": "object", + 'id': 'str', + 'mass_g': 'int', + 'production': 'bool', + 'state': 'str', + 'allocation_state': 'str', + 'price_cents_usd': 'int', + 'patch_fee_cents_usd': 'int', + 'allocations': 'list[Allocation]', + 'registry_url': 'str', + 'metadata': 'object' } attribute_map = { - "id": "id", - "mass_g": "mass_g", - "production": "production", - "state": "state", - "allocation_state": "allocation_state", - "price_cents_usd": "price_cents_usd", - "patch_fee_cents_usd": "patch_fee_cents_usd", - "allocations": "allocations", - "registry_url": "registry_url", - "metadata": "metadata", + 'id': 'id', + 'mass_g': 'mass_g', + 'production': 'production', + 'state': 'state', + 'allocation_state': 'allocation_state', + 'price_cents_usd': 'price_cents_usd', + 'patch_fee_cents_usd': 'patch_fee_cents_usd', + 'allocations': 'allocations', + 'registry_url': 'registry_url', + 'metadata': 'metadata' } - def __init__( - self, - id=None, - mass_g=None, - production=None, - state=None, - allocation_state=None, - price_cents_usd=None, - patch_fee_cents_usd=None, - allocations=None, - registry_url=None, - metadata=None, - local_vars_configuration=None, - ): # noqa: E501 + def __init__(self, id=None, mass_g=None, production=None, state=None, allocation_state=None, price_cents_usd=None, patch_fee_cents_usd=None, allocations=None, registry_url=None, metadata=None, local_vars_configuration=None): # noqa: E501 """Order - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -122,9 +109,7 @@ def id(self, id): :param id: The id of this Order. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and id is None - ): # noqa: E501 + if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -149,28 +134,14 @@ def mass_g(self, mass_g): :param mass_g: The mass_g of this Order. # noqa: E501 :type: int """ - if ( - self.local_vars_configuration.client_side_validation and mass_g is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `mass_g`, must not be `None`" - ) # noqa: E501 - if ( - self.local_vars_configuration.client_side_validation - and mass_g is not None - and mass_g > 2000000000 - ): # noqa: E501 - raise ValueError( - "Invalid value for `mass_g`, must be a value less than or equal to `2000000000`" - ) # noqa: E501 - if ( - self.local_vars_configuration.client_side_validation - and mass_g is not None - and mass_g < 0 - ): # noqa: E501 - raise ValueError( - "Invalid value for `mass_g`, must be a value greater than or equal to `0`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and mass_g is None: # noqa: E501 + raise ValueError("Invalid value for `mass_g`, must not be `None`") # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + mass_g is not None and mass_g > 2000000000): # noqa: E501 + raise ValueError("Invalid value for `mass_g`, must be a value less than or equal to `2000000000`") # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + mass_g is not None and mass_g < 0): # noqa: E501 + raise ValueError("Invalid value for `mass_g`, must be a value greater than or equal to `0`") # noqa: E501 self._mass_g = mass_g @@ -194,12 +165,8 @@ def production(self, production): :param production: The production of this Order. # noqa: E501 :type: bool """ - if ( - self.local_vars_configuration.client_side_validation and production is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `production`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and production is None: # noqa: E501 + raise ValueError("Invalid value for `production`, must not be `None`") # noqa: E501 self._production = production @@ -223,27 +190,13 @@ def state(self, state): :param state: The state of this Order. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and state is None - ): # noqa: E501 + if self.local_vars_configuration.client_side_validation and state is None: # noqa: E501 + raise ValueError("Invalid value for `state`, must not be `None`") # noqa: E501 + allowed_values = ["draft", "placed", "processing", "complete", "cancelled"] # noqa: E501 + if self.local_vars_configuration.client_side_validation and state not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `state`, must not be `None`" - ) # noqa: E501 - allowed_values = [ - "draft", - "placed", - "processing", - "complete", - "cancelled", - ] # noqa: E501 - if ( - self.local_vars_configuration.client_side_validation - and state not in allowed_values - ): # noqa: E501 - raise ValueError( - "Invalid value for `state` ({0}), must be one of {1}".format( # noqa: E501 - state, allowed_values - ) + "Invalid value for `state` ({0}), must be one of {1}" # noqa: E501 + .format(state, allowed_values) ) self._state = state @@ -268,22 +221,13 @@ def allocation_state(self, allocation_state): :param allocation_state: The allocation_state of this Order. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation - and allocation_state is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `allocation_state`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and allocation_state is None: # noqa: E501 + raise ValueError("Invalid value for `allocation_state`, must not be `None`") # noqa: E501 allowed_values = ["pending", "partially_allocated", "allocated"] # noqa: E501 - if ( - self.local_vars_configuration.client_side_validation - and allocation_state not in allowed_values - ): # noqa: E501 + if self.local_vars_configuration.client_side_validation and allocation_state not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `allocation_state` ({0}), must be one of {1}".format( # noqa: E501 - allocation_state, allowed_values - ) + "Invalid value for `allocation_state` ({0}), must be one of {1}" # noqa: E501 + .format(allocation_state, allowed_values) ) self._allocation_state = allocation_state @@ -354,12 +298,8 @@ def allocations(self, allocations): :param allocations: The allocations of this Order. # noqa: E501 :type: list[Allocation] """ - if ( - self.local_vars_configuration.client_side_validation and allocations is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `allocations`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and allocations is None: # noqa: E501 + raise ValueError("Invalid value for `allocations`, must not be `None`") # noqa: E501 self._allocations = allocations @@ -406,12 +346,8 @@ def metadata(self, metadata): :param metadata: The metadata of this Order. # noqa: E501 :type: object """ - if ( - self.local_vars_configuration.client_side_validation and metadata is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `metadata`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and metadata is None: # noqa: E501 + raise ValueError("Invalid value for `metadata`, must not be `None`") # noqa: E501 self._metadata = metadata @@ -422,20 +358,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/order_list_response.py b/patch_api/models/order_list_response.py index a558841..d9c6b4c 100644 --- a/patch_api/models/order_list_response.py +++ b/patch_api/models/order_list_response.py @@ -34,27 +34,20 @@ class OrderListResponse(object): and the value is json key in definition. """ openapi_types = { - "success": "bool", - "error": "object", - "data": "list[Order]", - "meta": "MetaIndexObject", + 'success': 'bool', + 'error': 'object', + 'data': 'list[Order]', + 'meta': 'MetaIndexObject' } attribute_map = { - "success": "success", - "error": "error", - "data": "data", - "meta": "meta", + 'success': 'success', + 'error': 'error', + 'data': 'data', + 'meta': 'meta' } - def __init__( - self, - success=None, - error=None, - data=None, - meta=None, - local_vars_configuration=None, - ): # noqa: E501 + def __init__(self, success=None, error=None, data=None, meta=None, local_vars_configuration=None): # noqa: E501 """OrderListResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -89,12 +82,8 @@ def success(self, success): :param success: The success of this OrderListResponse. # noqa: E501 :type: bool """ - if ( - self.local_vars_configuration.client_side_validation and success is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `success`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 + raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 self._success = success @@ -137,12 +126,8 @@ def data(self, data): :param data: The data of this OrderListResponse. # noqa: E501 :type: list[Order] """ - if ( - self.local_vars_configuration.client_side_validation and data is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `data`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and data is None: # noqa: E501 + raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 self._data = data @@ -164,12 +149,8 @@ def meta(self, meta): :param meta: The meta of this OrderListResponse. # noqa: E501 :type: MetaIndexObject """ - if ( - self.local_vars_configuration.client_side_validation and meta is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `meta`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and meta is None: # noqa: E501 + raise ValueError("Invalid value for `meta`, must not be `None`") # noqa: E501 self._meta = meta @@ -180,20 +161,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/order_response.py b/patch_api/models/order_response.py index 971e9a1..ffc9f94 100644 --- a/patch_api/models/order_response.py +++ b/patch_api/models/order_response.py @@ -33,13 +33,19 @@ class OrderResponse(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = {"success": "bool", "error": "object", "data": "Order"} - - attribute_map = {"success": "success", "error": "error", "data": "data"} - - def __init__( - self, success=None, error=None, data=None, local_vars_configuration=None - ): # noqa: E501 + openapi_types = { + 'success': 'bool', + 'error': 'object', + 'data': 'Order' + } + + attribute_map = { + 'success': 'success', + 'error': 'error', + 'data': 'data' + } + + def __init__(self, success=None, error=None, data=None, local_vars_configuration=None): # noqa: E501 """OrderResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -72,12 +78,8 @@ def success(self, success): :param success: The success of this OrderResponse. # noqa: E501 :type: bool """ - if ( - self.local_vars_configuration.client_side_validation and success is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `success`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 + raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 self._success = success @@ -120,12 +122,8 @@ def data(self, data): :param data: The data of this OrderResponse. # noqa: E501 :type: Order """ - if ( - self.local_vars_configuration.client_side_validation and data is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `data`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and data is None: # noqa: E501 + raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 self._data = data @@ -136,20 +134,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/photo.py b/patch_api/models/photo.py index 65be8bc..7716e55 100644 --- a/patch_api/models/photo.py +++ b/patch_api/models/photo.py @@ -33,9 +33,15 @@ class Photo(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = {"url": "str", "id": "str"} + openapi_types = { + 'url': 'str', + 'id': 'str' + } - attribute_map = {"url": "url", "id": "id"} + attribute_map = { + 'url': 'url', + 'id': 'id' + } def __init__(self, url=None, id=None, local_vars_configuration=None): # noqa: E501 """Photo - a model defined in OpenAPI""" # noqa: E501 @@ -68,12 +74,8 @@ def url(self, url): :param url: The url of this Photo. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and url is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `url`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and url is None: # noqa: E501 + raise ValueError("Invalid value for `url`, must not be `None`") # noqa: E501 self._url = url @@ -95,9 +97,7 @@ def id(self, id): :param id: The id of this Photo. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and id is None - ): # noqa: E501 + if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -109,20 +109,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/preference.py b/patch_api/models/preference.py index ad87aa0..ff30fc6 100644 --- a/patch_api/models/preference.py +++ b/patch_api/models/preference.py @@ -33,21 +33,19 @@ class Preference(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = {"id": "str", "allocation_percentage": "int", "project": "Project"} + openapi_types = { + 'id': 'str', + 'allocation_percentage': 'int', + 'project': 'Project' + } attribute_map = { - "id": "id", - "allocation_percentage": "allocation_percentage", - "project": "project", + 'id': 'id', + 'allocation_percentage': 'allocation_percentage', + 'project': 'project' } - def __init__( - self, - id=None, - allocation_percentage=None, - project=None, - local_vars_configuration=None, - ): # noqa: E501 + def __init__(self, id=None, allocation_percentage=None, project=None, local_vars_configuration=None): # noqa: E501 """Preference - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -82,9 +80,7 @@ def id(self, id): :param id: The id of this Preference. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and id is None - ): # noqa: E501 + if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -109,13 +105,8 @@ def allocation_percentage(self, allocation_percentage): :param allocation_percentage: The allocation_percentage of this Preference. # noqa: E501 :type: int """ - if ( - self.local_vars_configuration.client_side_validation - and allocation_percentage is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `allocation_percentage`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and allocation_percentage is None: # noqa: E501 + raise ValueError("Invalid value for `allocation_percentage`, must not be `None`") # noqa: E501 self._allocation_percentage = allocation_percentage @@ -139,12 +130,8 @@ def project(self, project): :param project: The project of this Preference. # noqa: E501 :type: Project """ - if ( - self.local_vars_configuration.client_side_validation and project is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `project`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and project is None: # noqa: E501 + raise ValueError("Invalid value for `project`, must not be `None`") # noqa: E501 self._project = project @@ -155,20 +142,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/preference_list_response.py b/patch_api/models/preference_list_response.py index 0e06bef..7ed2d12 100644 --- a/patch_api/models/preference_list_response.py +++ b/patch_api/models/preference_list_response.py @@ -34,27 +34,20 @@ class PreferenceListResponse(object): and the value is json key in definition. """ openapi_types = { - "success": "bool", - "error": "object", - "data": "list[Preference]", - "meta": "MetaIndexObject", + 'success': 'bool', + 'error': 'object', + 'data': 'list[Preference]', + 'meta': 'MetaIndexObject' } attribute_map = { - "success": "success", - "error": "error", - "data": "data", - "meta": "meta", + 'success': 'success', + 'error': 'error', + 'data': 'data', + 'meta': 'meta' } - def __init__( - self, - success=None, - error=None, - data=None, - meta=None, - local_vars_configuration=None, - ): # noqa: E501 + def __init__(self, success=None, error=None, data=None, meta=None, local_vars_configuration=None): # noqa: E501 """PreferenceListResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -89,12 +82,8 @@ def success(self, success): :param success: The success of this PreferenceListResponse. # noqa: E501 :type: bool """ - if ( - self.local_vars_configuration.client_side_validation and success is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `success`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 + raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 self._success = success @@ -137,12 +126,8 @@ def data(self, data): :param data: The data of this PreferenceListResponse. # noqa: E501 :type: list[Preference] """ - if ( - self.local_vars_configuration.client_side_validation and data is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `data`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and data is None: # noqa: E501 + raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 self._data = data @@ -164,12 +149,8 @@ def meta(self, meta): :param meta: The meta of this PreferenceListResponse. # noqa: E501 :type: MetaIndexObject """ - if ( - self.local_vars_configuration.client_side_validation and meta is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `meta`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and meta is None: # noqa: E501 + raise ValueError("Invalid value for `meta`, must not be `None`") # noqa: E501 self._meta = meta @@ -180,20 +161,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/preference_response.py b/patch_api/models/preference_response.py index 73d5fc4..4fa0965 100644 --- a/patch_api/models/preference_response.py +++ b/patch_api/models/preference_response.py @@ -33,13 +33,19 @@ class PreferenceResponse(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = {"success": "bool", "error": "object", "data": "Preference"} - - attribute_map = {"success": "success", "error": "error", "data": "data"} - - def __init__( - self, success=None, error=None, data=None, local_vars_configuration=None - ): # noqa: E501 + openapi_types = { + 'success': 'bool', + 'error': 'object', + 'data': 'Preference' + } + + attribute_map = { + 'success': 'success', + 'error': 'error', + 'data': 'data' + } + + def __init__(self, success=None, error=None, data=None, local_vars_configuration=None): # noqa: E501 """PreferenceResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -72,12 +78,8 @@ def success(self, success): :param success: The success of this PreferenceResponse. # noqa: E501 :type: bool """ - if ( - self.local_vars_configuration.client_side_validation and success is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `success`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 + raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 self._success = success @@ -120,12 +122,8 @@ def data(self, data): :param data: The data of this PreferenceResponse. # noqa: E501 :type: Preference """ - if ( - self.local_vars_configuration.client_side_validation and data is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `data`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and data is None: # noqa: E501 + raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 self._data = data @@ -136,20 +134,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/project.py b/patch_api/models/project.py index c1a9ffa..9c6dcb4 100644 --- a/patch_api/models/project.py +++ b/patch_api/models/project.py @@ -34,51 +34,36 @@ class Project(object): and the value is json key in definition. """ openapi_types = { - "id": "str", - "production": "bool", - "name": "str", - "description": "str", - "type": "str", - "country": "str", - "developer": "str", - "photos": "list[Photo]", - "average_price_per_tonne_cents_usd": "int", - "remaining_mass_g": "int", - "standard": "Standard", - "sdgs": "list[Sdg]", + 'id': 'str', + 'production': 'bool', + 'name': 'str', + 'description': 'str', + 'type': 'str', + 'country': 'str', + 'developer': 'str', + 'photos': 'list[Photo]', + 'average_price_per_tonne_cents_usd': 'int', + 'remaining_mass_g': 'int', + 'standard': 'Standard', + 'sdgs': 'list[Sdg]' } attribute_map = { - "id": "id", - "production": "production", - "name": "name", - "description": "description", - "type": "type", - "country": "country", - "developer": "developer", - "photos": "photos", - "average_price_per_tonne_cents_usd": "average_price_per_tonne_cents_usd", - "remaining_mass_g": "remaining_mass_g", - "standard": "standard", - "sdgs": "sdgs", + 'id': 'id', + 'production': 'production', + 'name': 'name', + 'description': 'description', + 'type': 'type', + 'country': 'country', + 'developer': 'developer', + 'photos': 'photos', + 'average_price_per_tonne_cents_usd': 'average_price_per_tonne_cents_usd', + 'remaining_mass_g': 'remaining_mass_g', + 'standard': 'standard', + 'sdgs': 'sdgs' } - def __init__( - self, - id=None, - production=None, - name=None, - description=None, - type=None, - country=None, - developer=None, - photos=None, - average_price_per_tonne_cents_usd=None, - remaining_mass_g=None, - standard=None, - sdgs=None, - local_vars_configuration=None, - ): # noqa: E501 + def __init__(self, id=None, production=None, name=None, description=None, type=None, country=None, developer=None, photos=None, average_price_per_tonne_cents_usd=None, remaining_mass_g=None, standard=None, sdgs=None, local_vars_configuration=None): # noqa: E501 """Project - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -132,9 +117,7 @@ def id(self, id): :param id: The id of this Project. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and id is None - ): # noqa: E501 + if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -159,12 +142,8 @@ def production(self, production): :param production: The production of this Project. # noqa: E501 :type: bool """ - if ( - self.local_vars_configuration.client_side_validation and production is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `production`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and production is None: # noqa: E501 + raise ValueError("Invalid value for `production`, must not be `None`") # noqa: E501 self._production = production @@ -188,12 +167,8 @@ def name(self, name): :param name: The name of this Project. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and name is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `name`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and name is None: # noqa: E501 + raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 self._name = name @@ -217,12 +192,8 @@ def description(self, description): :param description: The description of this Project. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and description is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `description`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and description is None: # noqa: E501 + raise ValueError("Invalid value for `description`, must not be `None`") # noqa: E501 self._description = description @@ -246,23 +217,11 @@ def type(self, type): :param type: The type of this Project. # noqa: E501 :type: str """ - allowed_values = [ - "biomass", - "dac", - "forestry", - "mineralization", - "ocean", - "renewables", - "soil", - ] # noqa: E501 - if ( - self.local_vars_configuration.client_side_validation - and type not in allowed_values - ): # noqa: E501 + allowed_values = ["biomass", "dac", "forestry", "mineralization", "ocean", "renewables", "soil"] # noqa: E501 + if self.local_vars_configuration.client_side_validation and type not in allowed_values: # noqa: E501 raise ValueError( - "Invalid value for `type` ({0}), must be one of {1}".format( # noqa: E501 - type, allowed_values - ) + "Invalid value for `type` ({0}), must be one of {1}" # noqa: E501 + .format(type, allowed_values) ) self._type = type @@ -287,12 +246,8 @@ def country(self, country): :param country: The country of this Project. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and country is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `country`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and country is None: # noqa: E501 + raise ValueError("Invalid value for `country`, must not be `None`") # noqa: E501 self._country = country @@ -316,12 +271,8 @@ def developer(self, developer): :param developer: The developer of this Project. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and developer is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `developer`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and developer is None: # noqa: E501 + raise ValueError("Invalid value for `developer`, must not be `None`") # noqa: E501 self._developer = developer @@ -368,13 +319,8 @@ def average_price_per_tonne_cents_usd(self, average_price_per_tonne_cents_usd): :param average_price_per_tonne_cents_usd: The average_price_per_tonne_cents_usd of this Project. # noqa: E501 :type: int """ - if ( - self.local_vars_configuration.client_side_validation - and average_price_per_tonne_cents_usd is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `average_price_per_tonne_cents_usd`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and average_price_per_tonne_cents_usd is None: # noqa: E501 + raise ValueError("Invalid value for `average_price_per_tonne_cents_usd`, must not be `None`") # noqa: E501 self._average_price_per_tonne_cents_usd = average_price_per_tonne_cents_usd @@ -398,13 +344,8 @@ def remaining_mass_g(self, remaining_mass_g): :param remaining_mass_g: The remaining_mass_g of this Project. # noqa: E501 :type: int """ - if ( - self.local_vars_configuration.client_side_validation - and remaining_mass_g is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `remaining_mass_g`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and remaining_mass_g is None: # noqa: E501 + raise ValueError("Invalid value for `remaining_mass_g`, must not be `None`") # noqa: E501 self._remaining_mass_g = remaining_mass_g @@ -461,20 +402,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/project_list_response.py b/patch_api/models/project_list_response.py index 466d482..7b627cd 100644 --- a/patch_api/models/project_list_response.py +++ b/patch_api/models/project_list_response.py @@ -34,27 +34,20 @@ class ProjectListResponse(object): and the value is json key in definition. """ openapi_types = { - "success": "bool", - "error": "object", - "data": "list[Project]", - "meta": "MetaIndexObject", + 'success': 'bool', + 'error': 'object', + 'data': 'list[Project]', + 'meta': 'MetaIndexObject' } attribute_map = { - "success": "success", - "error": "error", - "data": "data", - "meta": "meta", + 'success': 'success', + 'error': 'error', + 'data': 'data', + 'meta': 'meta' } - def __init__( - self, - success=None, - error=None, - data=None, - meta=None, - local_vars_configuration=None, - ): # noqa: E501 + def __init__(self, success=None, error=None, data=None, meta=None, local_vars_configuration=None): # noqa: E501 """ProjectListResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -89,12 +82,8 @@ def success(self, success): :param success: The success of this ProjectListResponse. # noqa: E501 :type: bool """ - if ( - self.local_vars_configuration.client_side_validation and success is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `success`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 + raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 self._success = success @@ -137,12 +126,8 @@ def data(self, data): :param data: The data of this ProjectListResponse. # noqa: E501 :type: list[Project] """ - if ( - self.local_vars_configuration.client_side_validation and data is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `data`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and data is None: # noqa: E501 + raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 self._data = data @@ -164,12 +149,8 @@ def meta(self, meta): :param meta: The meta of this ProjectListResponse. # noqa: E501 :type: MetaIndexObject """ - if ( - self.local_vars_configuration.client_side_validation and meta is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `meta`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and meta is None: # noqa: E501 + raise ValueError("Invalid value for `meta`, must not be `None`") # noqa: E501 self._meta = meta @@ -180,20 +161,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/project_response.py b/patch_api/models/project_response.py index 3de074c..25a1b93 100644 --- a/patch_api/models/project_response.py +++ b/patch_api/models/project_response.py @@ -33,13 +33,19 @@ class ProjectResponse(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = {"success": "bool", "error": "object", "data": "Project"} - - attribute_map = {"success": "success", "error": "error", "data": "data"} - - def __init__( - self, success=None, error=None, data=None, local_vars_configuration=None - ): # noqa: E501 + openapi_types = { + 'success': 'bool', + 'error': 'object', + 'data': 'Project' + } + + attribute_map = { + 'success': 'success', + 'error': 'error', + 'data': 'data' + } + + def __init__(self, success=None, error=None, data=None, local_vars_configuration=None): # noqa: E501 """ProjectResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -72,12 +78,8 @@ def success(self, success): :param success: The success of this ProjectResponse. # noqa: E501 :type: bool """ - if ( - self.local_vars_configuration.client_side_validation and success is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `success`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 + raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 self._success = success @@ -120,12 +122,8 @@ def data(self, data): :param data: The data of this ProjectResponse. # noqa: E501 :type: Project """ - if ( - self.local_vars_configuration.client_side_validation and data is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `data`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and data is None: # noqa: E501 + raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 self._data = data @@ -136,20 +134,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/sdg.py b/patch_api/models/sdg.py index 9c3e143..0faebdd 100644 --- a/patch_api/models/sdg.py +++ b/patch_api/models/sdg.py @@ -34,27 +34,20 @@ class Sdg(object): and the value is json key in definition. """ openapi_types = { - "title": "str", - "number": "int", - "description": "str", - "url": "str", + 'title': 'str', + 'number': 'int', + 'description': 'str', + 'url': 'str' } attribute_map = { - "title": "title", - "number": "number", - "description": "description", - "url": "url", + 'title': 'title', + 'number': 'number', + 'description': 'description', + 'url': 'url' } - def __init__( - self, - title=None, - number=None, - description=None, - url=None, - local_vars_configuration=None, - ): # noqa: E501 + def __init__(self, title=None, number=None, description=None, url=None, local_vars_configuration=None): # noqa: E501 """Sdg - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -91,12 +84,8 @@ def title(self, title): :param title: The title of this Sdg. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and title is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `title`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and title is None: # noqa: E501 + raise ValueError("Invalid value for `title`, must not be `None`") # noqa: E501 self._title = title @@ -120,12 +109,8 @@ def number(self, number): :param number: The number of this Sdg. # noqa: E501 :type: int """ - if ( - self.local_vars_configuration.client_side_validation and number is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `number`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and number is None: # noqa: E501 + raise ValueError("Invalid value for `number`, must not be `None`") # noqa: E501 self._number = number @@ -149,12 +134,8 @@ def description(self, description): :param description: The description of this Sdg. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and description is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `description`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and description is None: # noqa: E501 + raise ValueError("Invalid value for `description`, must not be `None`") # noqa: E501 self._description = description @@ -178,12 +159,8 @@ def url(self, url): :param url: The url of this Sdg. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and url is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `url`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and url is None: # noqa: E501 + raise ValueError("Invalid value for `url`, must not be `None`") # noqa: E501 self._url = url @@ -194,20 +171,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/models/standard.py b/patch_api/models/standard.py index 40f18a1..42c874d 100644 --- a/patch_api/models/standard.py +++ b/patch_api/models/standard.py @@ -33,13 +33,19 @@ class Standard(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = {"type": "str", "acronym": "str", "description": "str"} - - attribute_map = {"type": "type", "acronym": "acronym", "description": "description"} - - def __init__( - self, type=None, acronym=None, description=None, local_vars_configuration=None - ): # noqa: E501 + openapi_types = { + 'type': 'str', + 'acronym': 'str', + 'description': 'str' + } + + attribute_map = { + 'type': 'type', + 'acronym': 'acronym', + 'description': 'description' + } + + def __init__(self, type=None, acronym=None, description=None, local_vars_configuration=None): # noqa: E501 """Standard - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -74,12 +80,8 @@ def type(self, type): :param type: The type of this Standard. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and type is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `type`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and type is None: # noqa: E501 + raise ValueError("Invalid value for `type`, must not be `None`") # noqa: E501 self._type = type @@ -103,12 +105,8 @@ def acronym(self, acronym): :param acronym: The acronym of this Standard. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and acronym is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `acronym`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and acronym is None: # noqa: E501 + raise ValueError("Invalid value for `acronym`, must not be `None`") # noqa: E501 self._acronym = acronym @@ -132,12 +130,8 @@ def description(self, description): :param description: The description of this Standard. # noqa: E501 :type: str """ - if ( - self.local_vars_configuration.client_side_validation and description is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `description`, must not be `None`" - ) # noqa: E501 + if self.local_vars_configuration.client_side_validation and description is None: # noqa: E501 + raise ValueError("Invalid value for `description`, must not be `None`") # noqa: E501 self._description = description @@ -148,20 +142,18 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) + result[attr] = list(map( + lambda x: x.to_dict() if hasattr(x, "to_dict") else x, + value + )) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") else item, + value.items() + )) else: result[attr] = value diff --git a/patch_api/rest.py b/patch_api/rest.py index f67e65f..f415203 100644 --- a/patch_api/rest.py +++ b/patch_api/rest.py @@ -20,7 +20,6 @@ import ssl import certifi - # python 2 and python 3 compatibility library import six from six.moves.urllib.parse import urlencode @@ -33,6 +32,7 @@ class RESTResponse(io.IOBase): + def __init__(self, resp): self.urllib3_response = resp self.status = resp.status @@ -49,6 +49,7 @@ def getheader(self, name, default=None): class RESTClientObject(object): + def __init__(self, api_key, configuration, pools_size=4, maxsize=None): # urllib3.PoolManager will pass all kw parameters to connectionpool # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 @@ -73,12 +74,10 @@ def __init__(self, api_key, configuration, pools_size=4, maxsize=None): addition_pool_args = {} if configuration.assert_hostname is not None: - addition_pool_args[ - "assert_hostname" - ] = configuration.assert_hostname # noqa: E501 + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 if configuration.retries is not None: - addition_pool_args["retries"] = configuration.retries + addition_pool_args['retries'] = configuration.retries if maxsize is None: if configuration.connection_pool_maxsize is not None: @@ -110,17 +109,9 @@ def __init__(self, api_key, configuration, pools_size=4, maxsize=None): **addition_pool_args ) - def request( - self, - method, - url, - query_params=None, - headers=None, - body=None, - post_params=None, - _preload_content=True, - _request_timeout=None, - ): + def request(self, method, url, query_params=None, headers=None, + body=None, post_params=None, _preload_content=True, + _request_timeout=None): """Perform requests. :param method: http request method @@ -140,7 +131,8 @@ def request( (connection, read) timeouts. """ method = method.upper() - assert method in ["GET", "HEAD", "DELETE", "POST", "PUT", "PATCH", "OPTIONS"] + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] if post_params and body: raise ApiValueError( @@ -152,77 +144,65 @@ def request( timeout = None if _request_timeout: - if isinstance( - _request_timeout, (int,) if six.PY3 else (int, long) - ): # noqa: E501,F821 + if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821 timeout = urllib3.Timeout(total=_request_timeout) - elif isinstance(_request_timeout, tuple) and len(_request_timeout) == 2: + elif (isinstance(_request_timeout, tuple) and + len(_request_timeout) == 2): timeout = urllib3.Timeout( - connect=_request_timeout[0], read=_request_timeout[1] - ) + connect=_request_timeout[0], read=_request_timeout[1]) - if "Content-Type" not in headers: - headers["Content-Type"] = "application/json" + if 'Content-Type' not in headers: + headers['Content-Type'] = 'application/json' - if "Authorization" not in headers: - headers["Authorization"] = "Bearer " + self.api_key + if 'Authorization' not in headers: + headers['Authorization'] = 'Bearer ' + self.api_key try: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` - if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]: + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: if query_params: - url += "?" + urlencode(query_params) - if re.search("json", headers["Content-Type"], re.IGNORECASE): + url += '?' + urlencode(query_params) + if re.search('json', headers['Content-Type'], re.IGNORECASE): request_body = None if body is not None: request_body = json.dumps(body) r = self.pool_manager.request( - method, - url, + method, url, body=request_body, preload_content=_preload_content, timeout=timeout, - headers=headers, - ) - elif ( - headers["Content-Type"] == "application/x-www-form-urlencoded" - ): # noqa: E501 + headers=headers) + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 r = self.pool_manager.request( - method, - url, + method, url, fields=post_params, encode_multipart=False, preload_content=_preload_content, timeout=timeout, - headers=headers, - ) - elif headers["Content-Type"] == "multipart/form-data": + headers=headers) + elif headers['Content-Type'] == 'multipart/form-data': # must del headers['Content-Type'], or the correct # Content-Type which generated by urllib3 will be # overwritten. - del headers["Content-Type"] + del headers['Content-Type'] r = self.pool_manager.request( - method, - url, + method, url, fields=post_params, encode_multipart=True, preload_content=_preload_content, timeout=timeout, - headers=headers, - ) + headers=headers) # Pass a `string` parameter directly in the body to support # other content types than Json when `body` argument is # provided in serialized form elif isinstance(body, str) or isinstance(body, bytes): request_body = body r = self.pool_manager.request( - method, - url, + method, url, body=request_body, preload_content=_preload_content, timeout=timeout, - headers=headers, - ) + headers=headers) else: # Cannot generate the request from given parameters msg = """Cannot prepare a request message for provided @@ -231,14 +211,11 @@ def request( raise ApiException(status=0, reason=msg) # For `GET`, `HEAD` else: - r = self.pool_manager.request( - method, - url, - fields=query_params, - preload_content=_preload_content, - timeout=timeout, - headers=headers, - ) + r = self.pool_manager.request(method, url, + fields=query_params, + preload_content=_preload_content, + timeout=timeout, + headers=headers) except urllib3.exceptions.SSLError as e: msg = "{0}\n{1}".format(type(e).__name__, str(e)) raise ApiException(status=0, reason=msg) @@ -249,7 +226,7 @@ def request( # In the python 3, the response.data is bytes. # we need to decode it to string. if six.PY3: - r.data = r.data.decode("utf8") + r.data = r.data.decode('utf8') # log response body logger.debug("response body: %s", r.data) @@ -259,139 +236,67 @@ def request( return r - def GET( - self, - url, - headers=None, - query_params=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "GET", - url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params, - ) - - def HEAD( - self, - url, - headers=None, - query_params=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "HEAD", - url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params, - ) - - def OPTIONS( - self, - url, - headers=None, - query_params=None, - post_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "OPTIONS", - url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) - - def DELETE( - self, - url, - headers=None, - query_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "DELETE", - url, - headers=headers, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) - - def POST( - self, - url, - headers=None, - query_params=None, - post_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "POST", - url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) - - def PUT( - self, - url, - headers=None, - query_params=None, - post_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "PUT", - url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) - - def PATCH( - self, - url, - headers=None, - query_params=None, - post_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "PATCH", - url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) + def GET(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def HEAD(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def OPTIONS(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def DELETE(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + return self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def POST(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def PUT(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def PATCH(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) diff --git a/setup.py b/setup.py index 2944ae0..6e99589 100644 --- a/setup.py +++ b/setup.py @@ -21,9 +21,9 @@ # http://pypi.python.org/pypi/setuptools REQUIRES = [ - "urllib3 >= 1.25.3", - "python-dateutil", - "certifi", + "urllib3 >= 1.25.3", + "python-dateutil", + "certifi", ] setup( @@ -40,5 +40,5 @@ include_package_data=True, long_description="""\ The core API used to integrate with Patch's service # noqa: E501 - """, + """ ) From 8cf4dfdb92222ffc849fc0ce6f8386ca4d39985a Mon Sep 17 00:00:00 2001 From: James Klein Date: Fri, 13 Aug 2021 18:47:11 -0600 Subject: [PATCH 02/11] update from latest swagger json --- patch_api/api/orders_api.py | 6 +- patch_api/models/error.py | 149 ----------------------------- patch_api/models/error_response.py | 6 +- test/test_orders_api.py | 1 + 4 files changed, 9 insertions(+), 153 deletions(-) delete mode 100644 patch_api/models/error.py diff --git a/patch_api/api/orders_api.py b/patch_api/api/orders_api.py index 6bd9662..f70b88c 100644 --- a/patch_api/api/orders_api.py +++ b/patch_api/api/orders_api.py @@ -562,6 +562,7 @@ def retrieve_orders(self, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param int page: + :param str metadata: :param str metadata_ext_id: :param str metadata_disregarded: :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -589,6 +590,7 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param int page: + :param str metadata: :param str metadata_ext_id: :param str metadata_disregarded: :param _return_http_data_only: response data without head status code @@ -607,7 +609,7 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ['page', 'metadata_ext_id', 'metadata_disregarded'] # noqa: E501 + all_params = ['page', 'metadata', 'metadata_ext_id', 'metadata_disregarded'] # noqa: E501 all_params.append('async_req') all_params.append('_return_http_data_only') all_params.append('_preload_content') @@ -645,6 +647,8 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 query_params.append([key, kwargs.get(key)]) if 'page' in local_var_params: query_params.append(('page', local_var_params['page'])) # noqa: E501 + if 'metadata' in local_var_params: + query_params.append(('metadata', local_var_params['metadata'])) # noqa: E501 if 'metadata_ext_id' in local_var_params: query_params.append(('metadata[ext_id]', local_var_params['metadata_ext_id'])) # noqa: E501 if 'metadata_disregarded' in local_var_params: diff --git a/patch_api/models/error.py b/patch_api/models/error.py deleted file mode 100644 index a07c81d..0000000 --- a/patch_api/models/error.py +++ /dev/null @@ -1,149 +0,0 @@ -# coding: utf-8 - -""" - Patch API V1 - - The core API used to integrate with Patch's service # noqa: E501 - - The version of the OpenAPI document: v1 - Contact: developers@usepatch.com - Generated by: https://openapi-generator.tech -""" - - -import pprint -import re # noqa: F401 - -import six - -from patch_api.configuration import Configuration - - -class Error(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - """ - Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - openapi_types = { - 'code': 'int', - 'message': 'str' - } - - attribute_map = { - 'code': 'code', - 'message': 'message' - } - - def __init__(self, code=None, message=None, local_vars_configuration=None): # noqa: E501 - """Error - a model defined in OpenAPI""" # noqa: E501 - if local_vars_configuration is None: - local_vars_configuration = Configuration() - self.local_vars_configuration = local_vars_configuration - - self._code = None - self._message = None - self.discriminator = None - - self.code = code - self.message = message - - @property - def code(self): - """Gets the code of this Error. # noqa: E501 - - - :return: The code of this Error. # noqa: E501 - :rtype: int - """ - return self._code - - @code.setter - def code(self, code): - """Sets the code of this Error. - - - :param code: The code of this Error. # noqa: E501 - :type: int - """ - if self.local_vars_configuration.client_side_validation and code is None: # noqa: E501 - raise ValueError("Invalid value for `code`, must not be `None`") # noqa: E501 - - self._code = code - - @property - def message(self): - """Gets the message of this Error. # noqa: E501 - - - :return: The message of this Error. # noqa: E501 - :rtype: str - """ - return self._message - - @message.setter - def message(self, message): - """Sets the message of this Error. - - - :param message: The message of this Error. # noqa: E501 - :type: str - """ - if self.local_vars_configuration.client_side_validation and message is None: # noqa: E501 - raise ValueError("Invalid value for `message`, must not be `None`") # noqa: E501 - - self._message = message - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.openapi_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) - else: - result[attr] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, Error): - return False - - return self.to_dict() == other.to_dict() - - def __ne__(self, other): - """Returns true if both objects are not equal""" - if not isinstance(other, Error): - return True - - return self.to_dict() != other.to_dict() diff --git a/patch_api/models/error_response.py b/patch_api/models/error_response.py index c872700..efb6ee8 100644 --- a/patch_api/models/error_response.py +++ b/patch_api/models/error_response.py @@ -35,7 +35,7 @@ class ErrorResponse(object): """ openapi_types = { 'success': 'bool', - 'error': 'Error', + 'error': 'object', 'data': 'object' } @@ -89,7 +89,7 @@ def error(self): :return: The error of this ErrorResponse. # noqa: E501 - :rtype: Error + :rtype: object """ return self._error @@ -99,7 +99,7 @@ def error(self, error): :param error: The error of this ErrorResponse. # noqa: E501 - :type: Error + :type: object """ if self.local_vars_configuration.client_side_validation and error is None: # noqa: E501 raise ValueError("Invalid value for `error`, must not be `None`") # noqa: E501 diff --git a/test/test_orders_api.py b/test/test_orders_api.py index ba1b37c..87dcd5d 100644 --- a/test/test_orders_api.py +++ b/test/test_orders_api.py @@ -68,6 +68,7 @@ def test_retrieve_orders(self): orders = self.api.retrieve_orders().data self.assertTrue(isinstance(orders, list)) + import pdb; pdb.set_trace() if len(orders) > 1: retrieved_order = orders[0] From bd9c101f40ef789cd878428b4d9b445b822bec6b Mon Sep 17 00:00:00 2001 From: James Klein Date: Mon, 16 Aug 2021 22:43:39 -0600 Subject: [PATCH 03/11] create working, index still failing --- patch_api/api/orders_api.py | 4 ++ patch_api/api_client.py | 1 + patch_api/configuration.py | 2 +- patch_api/rest.py | 58 ++++++++++++++++++- test/test_orders_api.py | 107 ++++++++++++++++++++---------------- 5 files changed, 121 insertions(+), 51 deletions(-) diff --git a/patch_api/api/orders_api.py b/patch_api/api/orders_api.py index f70b88c..21d7770 100644 --- a/patch_api/api/orders_api.py +++ b/patch_api/api/orders_api.py @@ -17,6 +17,7 @@ # python 2 and python 3 compatibility library import six +from collections import OrderedDict from patch_api.exceptions import ( ApiTypeError, @@ -644,6 +645,7 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 query_params = [] for key in kwargs: + # this adds the params twice. once from kwargs and once from the named metadata query_params.append([key, kwargs.get(key)]) if 'page' in local_var_params: query_params.append(('page', local_var_params['page'])) # noqa: E501 @@ -653,6 +655,8 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 query_params.append(('metadata[ext_id]', local_var_params['metadata_ext_id'])) # noqa: E501 if 'metadata_disregarded' in local_var_params: query_params.append(('metadata[disregarded]', local_var_params['metadata_disregarded'])) # noqa: E501 + # import pdb; pdb.set_trace() + header_params = {} diff --git a/patch_api/api_client.py b/patch_api/api_client.py index cf21c4b..7302d59 100644 --- a/patch_api/api_client.py +++ b/patch_api/api_client.py @@ -655,3 +655,4 @@ def __deserialize_model(self, data, klass): if klass_name: instance = self.__deserialize(data, klass_name) return instance + diff --git a/patch_api/configuration.py b/patch_api/configuration.py index c4e4008..5d1e81e 100644 --- a/patch_api/configuration.py +++ b/patch_api/configuration.py @@ -56,7 +56,7 @@ class Configuration(object): _default = None - def __init__(self, host="https://api.patch.io", + def __init__(self, host="http://api.patch.test:3000", api_key=None, api_key_prefix=None, username=None, password=None, discard_unknown_keys=False, diff --git a/patch_api/rest.py b/patch_api/rest.py index f415203..c171ccd 100644 --- a/patch_api/rest.py +++ b/patch_api/rest.py @@ -27,9 +27,9 @@ from patch_api.exceptions import ApiException, ApiValueError - logger = logging.getLogger(__name__) +import urllib.parse class RESTResponse(io.IOBase): @@ -109,6 +109,42 @@ def __init__(self, api_key, configuration, pools_size=4, maxsize=None): **addition_pool_args ) + + + + + @staticmethod + def recursive_urlencode(d): + """URL-encode a multidimensional dictionary. + + >>> data = {'a': 'b&c', 'd': {'e': {'f&g': 'h*i'}}, 'j': 'k'} + >>> recursive_urlencode(data) + u'a=b%26c&j=k&d[e][f%26g]=h%2Ai' + """ + def recursion(d, base=[]): + pairs = [] + + for key, value in d.items(): + new_base = base + [key] + if hasattr(value, 'values'): + pairs += recursion(value, new_base) + else: + new_pair = None + if len(new_base) > 1: + first = urllib.parse.quote(new_base.pop(0)) + rest = map(lambda x: urllib.parse.quote(x), new_base) + new_pair = "%s[%s]=%s" % (first, ']['.join(rest), urllib.parse.quote(str(value))) + else: + new_pair = "%s=%s" % (urllib.parse.quote(str(key)), urllib.parse.quote(str(value))) + pairs.append(new_pair) + return pairs + + return '&'.join(recursion(d)) + + + + + def request(self, method, url, query_params=None, headers=None, body=None, post_params=None, _preload_content=True, _request_timeout=None): @@ -161,7 +197,25 @@ def request(self, method, url, query_params=None, headers=None, # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: if query_params: - url += '?' + urlencode(query_params) + final_query_params = '' + for key, value in query_params: + if isinstance(value, dict): + nested_param = {} + nested_param[key] = value + final_query_params += self.recursive_urlencode(nested_param) + query_params.remove((key, value)) + + final_query_params += '&' + urlencode(query_params) + url += '?' + final_query_params + # declare empty string + # for each query param, + # if dict + # add to string recursive_urlencode + # else + # add to string urlencode + # add to url + # url += '?' + urlencode(query_params) + # url += '?' + self.recursive_urlencode(query_params) if re.search('json', headers['Content-Type'], re.IGNORECASE): request_body = None if body is not None: diff --git a/test/test_orders_api.py b/test/test_orders_api.py index 87dcd5d..13e7d5a 100644 --- a/test/test_orders_api.py +++ b/test/test_orders_api.py @@ -29,54 +29,65 @@ def setUp(self): def tearDown(self): self.api = None - def test_interactions_with_an_order(self): - """Test case for create_order""" - - """Create an order - """ - order = self.api.create_order(mass_g=100) - - self.assertTrue(order) - - self.assertEqual(order.data.mass_g, 100) - - """Create an order on price - """ - order = self.api.create_order(total_price_cents_usd=100) - - self.assertTrue(order) - self.assertEqual( - order.data.price_cents_usd + order.data.patch_fee_cents_usd, 100 - ) - - def test_retrieve_order(self): - """Test case for retrieve_order""" - - """Retrieve an order - """ - order = self.api.create_order(mass_g=100) - retrieved_order = self.api.retrieve_order(id=order.data.id) - - self.assertTrue(retrieved_order) - self.assertEqual(retrieved_order.data.mass_g, 100) - - def test_retrieve_orders(self): - """Test case for retrieve_orders - - Retrieves a list of orders # noqa: E501 - """ - orders = self.api.retrieve_orders().data - self.assertTrue(isinstance(orders, list)) - - import pdb; pdb.set_trace() - if len(orders) > 1: - retrieved_order = orders[0] - - self.assertTrue(retrieved_order.id) - self.assertEqual(retrieved_order.production, False) - self.assertEqual(retrieved_order.state, "placed") - self.assertEqual(retrieved_order.metadata, {}) - self.assertTrue(isinstance(retrieved_order.allocations, list)) + # def test_interactions_with_an_order(self): + # """Test case for create_order""" + # + # """Create an order + # """ + # order = self.api.create_order(mass_g=100) + # + # self.assertTrue(order) + # + # self.assertEqual(order.data.mass_g, 100) + # + # """Create an order on price + # """ + # order = self.api.create_order(total_price_cents_usd=100) + # + # self.assertTrue(order) + # self.assertEqual( + # order.data.price_cents_usd + order.data.patch_fee_cents_usd, 100 + # ) + # + # def test_retrieve_order(self): + # """Test case for retrieve_order""" + # + # """Retrieve an order + # """ + # order = self.api.create_order(mass_g=100) + # retrieved_order = self.api.retrieve_order(id=order.data.id) + # + # self.assertTrue(retrieved_order) + # self.assertEqual(retrieved_order.data.mass_g, 100) + # + # def test_retrieve_orders(self): + # """Test case for retrieve_orders + # + # Retrieves a list of orders # noqa: E501 + # """ + # orders = self.api.retrieve_orders().data + # self.assertTrue(isinstance(orders, list)) + # + # if len(orders) > 1: + # retrieved_order = orders[0] + # + # self.assertTrue(retrieved_order.id) + # self.assertEqual(retrieved_order.production, False) + # self.assertEqual(retrieved_order.state, "placed") + # self.assertEqual(retrieved_order.metadata, {}) + # self.assertTrue(isinstance(retrieved_order.allocations, list)) + + def test_create_and_retrieve_order_via_metadata(self): + """Test case for create_order and retrieve_orders with metadata""" + # mass_g = 100 + # metadata = { 'user': 'john doe' } + # order = self.api.create_order(mass_g=mass_g, metadata=metadata) + # + # self.assertTrue(order) + # self.assertEqual(order.data.metadata, { 'user': 'john doe' }) + + retrieved_order = self.api.retrieve_orders(metadata={ 'user': 'john' }).data[0] + self.assertTrue(retrieved_order.data.metadata, { 'user': 'john doe' }) if __name__ == "__main__": From 2d2b24c341ad10f1fdf10bd7522bcb39bf27ea8c Mon Sep 17 00:00:00 2001 From: James Klein Date: Tue, 17 Aug 2021 10:03:02 -0600 Subject: [PATCH 04/11] query params working for create and index --- patch_api/api/orders_api.py | 13 ++-- patch_api/rest.py | 43 +++++--------- test/test_orders_api.py | 115 ++++++++++++++++++------------------ 3 files changed, 84 insertions(+), 87 deletions(-) diff --git a/patch_api/api/orders_api.py b/patch_api/api/orders_api.py index 21d7770..d82add4 100644 --- a/patch_api/api/orders_api.py +++ b/patch_api/api/orders_api.py @@ -644,9 +644,6 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 path_params = {} query_params = [] - for key in kwargs: - # this adds the params twice. once from kwargs and once from the named metadata - query_params.append([key, kwargs.get(key)]) if 'page' in local_var_params: query_params.append(('page', local_var_params['page'])) # noqa: E501 if 'metadata' in local_var_params: @@ -655,7 +652,15 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 query_params.append(('metadata[ext_id]', local_var_params['metadata_ext_id'])) # noqa: E501 if 'metadata_disregarded' in local_var_params: query_params.append(('metadata[disregarded]', local_var_params['metadata_disregarded'])) # noqa: E501 - # import pdb; pdb.set_trace() + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + + for key in kwargs: + if not key in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} diff --git a/patch_api/rest.py b/patch_api/rest.py index c171ccd..3e7c44b 100644 --- a/patch_api/rest.py +++ b/patch_api/rest.py @@ -109,12 +109,7 @@ def __init__(self, api_key, configuration, pools_size=4, maxsize=None): **addition_pool_args ) - - - - - @staticmethod - def recursive_urlencode(d): + def recursive_urlencode(self, d): """URL-encode a multidimensional dictionary. >>> data = {'a': 'b&c', 'd': {'e': {'f&g': 'h*i'}}, 'j': 'k'} @@ -141,9 +136,22 @@ def recursion(d, base=[]): return '&'.join(recursion(d)) + def encoded_query_params(self, query_params): + if not query_params: + return '' + final_query_params = '' + for key, value in query_params: + if isinstance(value, dict): + nested_param = {} + nested_param[key] = value + final_query_params += self.recursive_urlencode(nested_param) + query_params.remove((key, value)) + if query_params: + final_query_params += '&' + urlencode(query_params) + return '?' + final_query_params def request(self, method, url, query_params=None, headers=None, body=None, post_params=None, _preload_content=True, @@ -196,26 +204,7 @@ def request(self, method, url, query_params=None, headers=None, try: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: - if query_params: - final_query_params = '' - for key, value in query_params: - if isinstance(value, dict): - nested_param = {} - nested_param[key] = value - final_query_params += self.recursive_urlencode(nested_param) - query_params.remove((key, value)) - - final_query_params += '&' + urlencode(query_params) - url += '?' + final_query_params - # declare empty string - # for each query param, - # if dict - # add to string recursive_urlencode - # else - # add to string urlencode - # add to url - # url += '?' + urlencode(query_params) - # url += '?' + self.recursive_urlencode(query_params) + url += self.encoded_query_params(query_params) if re.search('json', headers['Content-Type'], re.IGNORECASE): request_body = None if body is not None: @@ -265,8 +254,8 @@ def request(self, method, url, query_params=None, headers=None, raise ApiException(status=0, reason=msg) # For `GET`, `HEAD` else: + url += self.encoded_query_params(query_params) r = self.pool_manager.request(method, url, - fields=query_params, preload_content=_preload_content, timeout=timeout, headers=headers) diff --git a/test/test_orders_api.py b/test/test_orders_api.py index 13e7d5a..541c6b8 100644 --- a/test/test_orders_api.py +++ b/test/test_orders_api.py @@ -29,65 +29,68 @@ def setUp(self): def tearDown(self): self.api = None - # def test_interactions_with_an_order(self): - # """Test case for create_order""" - # - # """Create an order - # """ - # order = self.api.create_order(mass_g=100) - # - # self.assertTrue(order) - # - # self.assertEqual(order.data.mass_g, 100) - # - # """Create an order on price - # """ - # order = self.api.create_order(total_price_cents_usd=100) - # - # self.assertTrue(order) - # self.assertEqual( - # order.data.price_cents_usd + order.data.patch_fee_cents_usd, 100 - # ) - # - # def test_retrieve_order(self): - # """Test case for retrieve_order""" - # - # """Retrieve an order - # """ - # order = self.api.create_order(mass_g=100) - # retrieved_order = self.api.retrieve_order(id=order.data.id) - # - # self.assertTrue(retrieved_order) - # self.assertEqual(retrieved_order.data.mass_g, 100) - # - # def test_retrieve_orders(self): - # """Test case for retrieve_orders - # - # Retrieves a list of orders # noqa: E501 - # """ - # orders = self.api.retrieve_orders().data - # self.assertTrue(isinstance(orders, list)) - # - # if len(orders) > 1: - # retrieved_order = orders[0] - # - # self.assertTrue(retrieved_order.id) - # self.assertEqual(retrieved_order.production, False) - # self.assertEqual(retrieved_order.state, "placed") - # self.assertEqual(retrieved_order.metadata, {}) - # self.assertTrue(isinstance(retrieved_order.allocations, list)) + def test_interactions_with_an_order(self): + """Test case for create_order""" + + """Create an order + """ + order = self.api.create_order(mass_g=100) + + self.assertTrue(order) + + self.assertEqual(order.data.mass_g, 100) + + """Create an order on price + """ + order = self.api.create_order(total_price_cents_usd=100) + + self.assertTrue(order) + self.assertEqual( + order.data.price_cents_usd + order.data.patch_fee_cents_usd, 100 + ) + + def test_retrieve_order(self): + """Test case for retrieve_order""" + + """Retrieve an order + """ + order = self.api.create_order(mass_g=100) + retrieved_order = self.api.retrieve_order(id=order.data.id) + + self.assertTrue(retrieved_order) + self.assertEqual(retrieved_order.data.mass_g, 100) + + def test_retrieve_orders(self): + """Test case for retrieve_orders + + Retrieves a list of orders # noqa: E501 + """ + orders = self.api.retrieve_orders().data + self.assertTrue(isinstance(orders, list)) + + if len(orders) > 1: + retrieved_order = orders[0] + + self.assertTrue(retrieved_order.id) + self.assertEqual(retrieved_order.production, False) + self.assertEqual(retrieved_order.state, "placed") + self.assertEqual(retrieved_order.metadata, {}) + self.assertTrue(isinstance(retrieved_order.allocations, list)) def test_create_and_retrieve_order_via_metadata(self): """Test case for create_order and retrieve_orders with metadata""" - # mass_g = 100 - # metadata = { 'user': 'john doe' } - # order = self.api.create_order(mass_g=mass_g, metadata=metadata) - # - # self.assertTrue(order) - # self.assertEqual(order.data.metadata, { 'user': 'john doe' }) - - retrieved_order = self.api.retrieve_orders(metadata={ 'user': 'john' }).data[0] - self.assertTrue(retrieved_order.data.metadata, { 'user': 'john doe' }) + mass_g = 100 + metadata = { 'external_id': 'abc-123' } + order = self.api.create_order(mass_g=mass_g, metadata=metadata) + + self.assertTrue(order) + self.assertEqual(order.data.mass_g, 100) + self.assertEqual(order.data.metadata, { 'external_id': 'abc-123' }) + + retrieved_orders = self.api.retrieve_orders(metadata={ 'external_id': 'abc-' }).data + self.assertGreater(len(retrieved_orders), 0) + for retrieved_order in retrieved_orders: + self.assertTrue('external_id' in retrieved_order.metadata) if __name__ == "__main__": From eb8fb5ed7a84bf381c2823e121c3af7e6f832e99 Mon Sep 17 00:00:00 2001 From: James Klein Date: Tue, 17 Aug 2021 10:32:03 -0600 Subject: [PATCH 05/11] regenerated sdk --- patch_api/api/estimates_api.py | 908 +++++++++++------- patch_api/api/orders_api.py | 513 +++++----- patch_api/api/preferences_api.py | 410 ++++---- patch_api/api/projects_api.py | 222 +++-- patch_api/api_client.py | 423 ++++---- patch_api/configuration.py | 84 +- patch_api/exceptions.py | 12 +- patch_api/models/allocation.py | 60 +- .../models/bulk_create_success_response.py | 50 +- patch_api/models/error_response.py | 56 +- patch_api/models/estimate.py | 70 +- patch_api/models/estimate_list_response.py | 69 +- patch_api/models/estimate_response.py | 56 +- patch_api/models/meta_index_object.py | 34 +- patch_api/models/order.py | 178 ++-- patch_api/models/order_list_response.py | 69 +- patch_api/models/order_response.py | 56 +- patch_api/models/photo.py | 42 +- patch_api/models/preference.py | 61 +- patch_api/models/preference_list_response.py | 69 +- patch_api/models/preference_response.py | 56 +- patch_api/models/project.py | 167 +++- patch_api/models/project_list_response.py | 69 +- patch_api/models/project_response.py | 56 +- patch_api/models/sdg.py | 77 +- patch_api/models/standard.py | 64 +- patch_api/rest.py | 324 ++++--- setup.py | 8 +- test/test_orders_api.py | 10 +- 29 files changed, 2547 insertions(+), 1726 deletions(-) diff --git a/patch_api/api/estimates_api.py b/patch_api/api/estimates_api.py index 66c285f..fc5d274 100644 --- a/patch_api/api/estimates_api.py +++ b/patch_api/api/estimates_api.py @@ -18,10 +18,7 @@ # python 2 and python 3 compatibility library import six -from patch_api.exceptions import ( - ApiTypeError, - ApiValueError -) +from patch_api.exceptions import ApiTypeError, ApiValueError class EstimatesApi(object): @@ -32,26 +29,28 @@ class EstimatesApi(object): """ ALLOWED_QUERY_PARAMS = [ - "mass_g", - "total_price_cents_usd", - "project_id", - "page", - "distance_m", - "transportation_method", - "package_mass_g", - "create_order", - "model", - "make", - "year", - "transaction_value_btc_sats", - "timestamp", - "gas_used" + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year", + "transaction_value_btc_sats", + "timestamp", + "gas_used", ] def __init__(self, api_client=None): self.api_client = api_client - def create_bitcoin_estimate(self, create_bitcoin_estimate_request={}, **kwargs): # noqa: E501 + def create_bitcoin_estimate( + self, create_bitcoin_estimate_request={}, **kwargs + ): # noqa: E501 """Create a bitcoin estimate given a timestamp and transaction value # noqa: E501 Creates a bitcoin estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 @@ -73,10 +72,14 @@ def create_bitcoin_estimate(self, create_bitcoin_estimate_request={}, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True - return self.create_bitcoin_estimate_with_http_info(create_bitcoin_estimate_request, **kwargs) # noqa: E501 - - def create_bitcoin_estimate_with_http_info(self, create_bitcoin_estimate_request, **kwargs): # noqa: E501 + kwargs["_return_http_data_only"] = True + return self.create_bitcoin_estimate_with_http_info( + create_bitcoin_estimate_request, **kwargs + ) # noqa: E501 + + def create_bitcoin_estimate_with_http_info( + self, create_bitcoin_estimate_request, **kwargs + ): # noqa: E501 """Create a bitcoin estimate given a timestamp and transaction value # noqa: E501 Creates a bitcoin estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 @@ -103,46 +106,57 @@ def create_bitcoin_estimate_with_http_info(self, create_bitcoin_estimate_request local_var_params = locals() - all_params = ['create_bitcoin_estimate_request'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["create_bitcoin_estimate_request"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_bitcoin_estimate" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] # verify the required parameter 'create_bitcoin_estimate_request' is set - if ('create_bitcoin_estimate_request' not in local_var_params or - local_var_params['create_bitcoin_estimate_request'] is None): - raise ApiValueError("Missing the required parameter `create_bitcoin_estimate_request` when calling `create_bitcoin_estimate`") # noqa: E501 + if ( + "create_bitcoin_estimate_request" not in local_var_params + or local_var_params["create_bitcoin_estimate_request"] is None + ): + raise ApiValueError( + "Missing the required parameter `create_bitcoin_estimate_request` when calling `create_bitcoin_estimate`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -150,36 +164,46 @@ def create_bitcoin_estimate_with_http_info(self, create_bitcoin_estimate_request local_var_files = {} body_params = None - if 'create_bitcoin_estimate_request' in local_var_params: - body_params = local_var_params['create_bitcoin_estimate_request'] + if "create_bitcoin_estimate_request" in local_var_params: + body_params = local_var_params["create_bitcoin_estimate_request"] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params[ + "Content-Type" + ] = self.api_client.select_header_content_type( # noqa: E501 + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/estimates/crypto/btc', 'POST', + "/v1/estimates/crypto/btc", + "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='EstimateResponse', # noqa: E501 + response_type="EstimateResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def create_ethereum_estimate(self, create_ethereum_estimate_request={}, **kwargs): # noqa: E501 + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) + + def create_ethereum_estimate( + self, create_ethereum_estimate_request={}, **kwargs + ): # noqa: E501 """Create an ethereum estimate given a timestamp and gas used # noqa: E501 Creates an ethereum estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 @@ -201,10 +225,14 @@ def create_ethereum_estimate(self, create_ethereum_estimate_request={}, **kwargs If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True - return self.create_ethereum_estimate_with_http_info(create_ethereum_estimate_request, **kwargs) # noqa: E501 - - def create_ethereum_estimate_with_http_info(self, create_ethereum_estimate_request, **kwargs): # noqa: E501 + kwargs["_return_http_data_only"] = True + return self.create_ethereum_estimate_with_http_info( + create_ethereum_estimate_request, **kwargs + ) # noqa: E501 + + def create_ethereum_estimate_with_http_info( + self, create_ethereum_estimate_request, **kwargs + ): # noqa: E501 """Create an ethereum estimate given a timestamp and gas used # noqa: E501 Creates an ethereum estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 @@ -231,46 +259,57 @@ def create_ethereum_estimate_with_http_info(self, create_ethereum_estimate_reque local_var_params = locals() - all_params = ['create_ethereum_estimate_request'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["create_ethereum_estimate_request"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_ethereum_estimate" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] # verify the required parameter 'create_ethereum_estimate_request' is set - if ('create_ethereum_estimate_request' not in local_var_params or - local_var_params['create_ethereum_estimate_request'] is None): - raise ApiValueError("Missing the required parameter `create_ethereum_estimate_request` when calling `create_ethereum_estimate`") # noqa: E501 + if ( + "create_ethereum_estimate_request" not in local_var_params + or local_var_params["create_ethereum_estimate_request"] is None + ): + raise ApiValueError( + "Missing the required parameter `create_ethereum_estimate_request` when calling `create_ethereum_estimate`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -278,36 +317,46 @@ def create_ethereum_estimate_with_http_info(self, create_ethereum_estimate_reque local_var_files = {} body_params = None - if 'create_ethereum_estimate_request' in local_var_params: - body_params = local_var_params['create_ethereum_estimate_request'] + if "create_ethereum_estimate_request" in local_var_params: + body_params = local_var_params["create_ethereum_estimate_request"] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params[ + "Content-Type" + ] = self.api_client.select_header_content_type( # noqa: E501 + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/estimates/crypto/eth', 'POST', + "/v1/estimates/crypto/eth", + "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='EstimateResponse', # noqa: E501 + response_type="EstimateResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def create_flight_estimate(self, create_flight_estimate_request={}, **kwargs): # noqa: E501 + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) + + def create_flight_estimate( + self, create_flight_estimate_request={}, **kwargs + ): # noqa: E501 """Create a flight estimate given the distance traveled in meters # noqa: E501 Creates a flight estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 @@ -329,10 +378,14 @@ def create_flight_estimate(self, create_flight_estimate_request={}, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True - return self.create_flight_estimate_with_http_info(create_flight_estimate_request, **kwargs) # noqa: E501 - - def create_flight_estimate_with_http_info(self, create_flight_estimate_request, **kwargs): # noqa: E501 + kwargs["_return_http_data_only"] = True + return self.create_flight_estimate_with_http_info( + create_flight_estimate_request, **kwargs + ) # noqa: E501 + + def create_flight_estimate_with_http_info( + self, create_flight_estimate_request, **kwargs + ): # noqa: E501 """Create a flight estimate given the distance traveled in meters # noqa: E501 Creates a flight estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 @@ -359,46 +412,57 @@ def create_flight_estimate_with_http_info(self, create_flight_estimate_request, local_var_params = locals() - all_params = ['create_flight_estimate_request'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["create_flight_estimate_request"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_flight_estimate" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] # verify the required parameter 'create_flight_estimate_request' is set - if ('create_flight_estimate_request' not in local_var_params or - local_var_params['create_flight_estimate_request'] is None): - raise ApiValueError("Missing the required parameter `create_flight_estimate_request` when calling `create_flight_estimate`") # noqa: E501 + if ( + "create_flight_estimate_request" not in local_var_params + or local_var_params["create_flight_estimate_request"] is None + ): + raise ApiValueError( + "Missing the required parameter `create_flight_estimate_request` when calling `create_flight_estimate`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -406,36 +470,46 @@ def create_flight_estimate_with_http_info(self, create_flight_estimate_request, local_var_files = {} body_params = None - if 'create_flight_estimate_request' in local_var_params: - body_params = local_var_params['create_flight_estimate_request'] + if "create_flight_estimate_request" in local_var_params: + body_params = local_var_params["create_flight_estimate_request"] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params[ + "Content-Type" + ] = self.api_client.select_header_content_type( # noqa: E501 + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/estimates/flight', 'POST', + "/v1/estimates/flight", + "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='EstimateResponse', # noqa: E501 + response_type="EstimateResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def create_mass_estimate(self, create_mass_estimate_request={}, **kwargs): # noqa: E501 + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) + + def create_mass_estimate( + self, create_mass_estimate_request={}, **kwargs + ): # noqa: E501 """Create an estimate based on mass of CO2 # noqa: E501 Creates an estimate for the mass of CO2 to be compensated. An order in the `draft` state will also be created, linked to the estimate. # noqa: E501 @@ -457,10 +531,14 @@ def create_mass_estimate(self, create_mass_estimate_request={}, **kwargs): # no If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True - return self.create_mass_estimate_with_http_info(create_mass_estimate_request, **kwargs) # noqa: E501 - - def create_mass_estimate_with_http_info(self, create_mass_estimate_request, **kwargs): # noqa: E501 + kwargs["_return_http_data_only"] = True + return self.create_mass_estimate_with_http_info( + create_mass_estimate_request, **kwargs + ) # noqa: E501 + + def create_mass_estimate_with_http_info( + self, create_mass_estimate_request, **kwargs + ): # noqa: E501 """Create an estimate based on mass of CO2 # noqa: E501 Creates an estimate for the mass of CO2 to be compensated. An order in the `draft` state will also be created, linked to the estimate. # noqa: E501 @@ -487,46 +565,57 @@ def create_mass_estimate_with_http_info(self, create_mass_estimate_request, **kw local_var_params = locals() - all_params = ['create_mass_estimate_request'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["create_mass_estimate_request"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_mass_estimate" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] # verify the required parameter 'create_mass_estimate_request' is set - if ('create_mass_estimate_request' not in local_var_params or - local_var_params['create_mass_estimate_request'] is None): - raise ApiValueError("Missing the required parameter `create_mass_estimate_request` when calling `create_mass_estimate`") # noqa: E501 + if ( + "create_mass_estimate_request" not in local_var_params + or local_var_params["create_mass_estimate_request"] is None + ): + raise ApiValueError( + "Missing the required parameter `create_mass_estimate_request` when calling `create_mass_estimate`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -534,36 +623,46 @@ def create_mass_estimate_with_http_info(self, create_mass_estimate_request, **kw local_var_files = {} body_params = None - if 'create_mass_estimate_request' in local_var_params: - body_params = local_var_params['create_mass_estimate_request'] + if "create_mass_estimate_request" in local_var_params: + body_params = local_var_params["create_mass_estimate_request"] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params[ + "Content-Type" + ] = self.api_client.select_header_content_type( # noqa: E501 + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/estimates/mass', 'POST', + "/v1/estimates/mass", + "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='EstimateResponse', # noqa: E501 + response_type="EstimateResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def create_shipping_estimate(self, create_shipping_estimate_request={}, **kwargs): # noqa: E501 + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) + + def create_shipping_estimate( + self, create_shipping_estimate_request={}, **kwargs + ): # noqa: E501 """Create a shipping estimate given the distance traveled in meters, package weight, and transportation method. # noqa: E501 Creates a shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters. # noqa: E501 @@ -585,10 +684,14 @@ def create_shipping_estimate(self, create_shipping_estimate_request={}, **kwargs If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True - return self.create_shipping_estimate_with_http_info(create_shipping_estimate_request, **kwargs) # noqa: E501 - - def create_shipping_estimate_with_http_info(self, create_shipping_estimate_request, **kwargs): # noqa: E501 + kwargs["_return_http_data_only"] = True + return self.create_shipping_estimate_with_http_info( + create_shipping_estimate_request, **kwargs + ) # noqa: E501 + + def create_shipping_estimate_with_http_info( + self, create_shipping_estimate_request, **kwargs + ): # noqa: E501 """Create a shipping estimate given the distance traveled in meters, package weight, and transportation method. # noqa: E501 Creates a shipping estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters. # noqa: E501 @@ -615,46 +718,57 @@ def create_shipping_estimate_with_http_info(self, create_shipping_estimate_reque local_var_params = locals() - all_params = ['create_shipping_estimate_request'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["create_shipping_estimate_request"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_shipping_estimate" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] # verify the required parameter 'create_shipping_estimate_request' is set - if ('create_shipping_estimate_request' not in local_var_params or - local_var_params['create_shipping_estimate_request'] is None): - raise ApiValueError("Missing the required parameter `create_shipping_estimate_request` when calling `create_shipping_estimate`") # noqa: E501 + if ( + "create_shipping_estimate_request" not in local_var_params + or local_var_params["create_shipping_estimate_request"] is None + ): + raise ApiValueError( + "Missing the required parameter `create_shipping_estimate_request` when calling `create_shipping_estimate`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -662,36 +776,46 @@ def create_shipping_estimate_with_http_info(self, create_shipping_estimate_reque local_var_files = {} body_params = None - if 'create_shipping_estimate_request' in local_var_params: - body_params = local_var_params['create_shipping_estimate_request'] + if "create_shipping_estimate_request" in local_var_params: + body_params = local_var_params["create_shipping_estimate_request"] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params[ + "Content-Type" + ] = self.api_client.select_header_content_type( # noqa: E501 + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/estimates/shipping', 'POST', + "/v1/estimates/shipping", + "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='EstimateResponse', # noqa: E501 + response_type="EstimateResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) - - def create_vehicle_estimate(self, create_vehicle_estimate_request={}, **kwargs): # noqa: E501 + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) + + def create_vehicle_estimate( + self, create_vehicle_estimate_request={}, **kwargs + ): # noqa: E501 """Create a vehicle estimate given the distance traveled in meters and the type of vehicle # noqa: E501 Creates an estimate and calculates the amount of CO2 to be compensated depending on the distance and the vehicle. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 @@ -713,10 +837,14 @@ def create_vehicle_estimate(self, create_vehicle_estimate_request={}, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True - return self.create_vehicle_estimate_with_http_info(create_vehicle_estimate_request, **kwargs) # noqa: E501 - - def create_vehicle_estimate_with_http_info(self, create_vehicle_estimate_request, **kwargs): # noqa: E501 + kwargs["_return_http_data_only"] = True + return self.create_vehicle_estimate_with_http_info( + create_vehicle_estimate_request, **kwargs + ) # noqa: E501 + + def create_vehicle_estimate_with_http_info( + self, create_vehicle_estimate_request, **kwargs + ): # noqa: E501 """Create a vehicle estimate given the distance traveled in meters and the type of vehicle # noqa: E501 Creates an estimate and calculates the amount of CO2 to be compensated depending on the distance and the vehicle. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 @@ -743,46 +871,57 @@ def create_vehicle_estimate_with_http_info(self, create_vehicle_estimate_request local_var_params = locals() - all_params = ['create_vehicle_estimate_request'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["create_vehicle_estimate_request"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_vehicle_estimate" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] # verify the required parameter 'create_vehicle_estimate_request' is set - if ('create_vehicle_estimate_request' not in local_var_params or - local_var_params['create_vehicle_estimate_request'] is None): - raise ApiValueError("Missing the required parameter `create_vehicle_estimate_request` when calling `create_vehicle_estimate`") # noqa: E501 + if ( + "create_vehicle_estimate_request" not in local_var_params + or local_var_params["create_vehicle_estimate_request"] is None + ): + raise ApiValueError( + "Missing the required parameter `create_vehicle_estimate_request` when calling `create_vehicle_estimate`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -790,34 +929,42 @@ def create_vehicle_estimate_with_http_info(self, create_vehicle_estimate_request local_var_files = {} body_params = None - if 'create_vehicle_estimate_request' in local_var_params: - body_params = local_var_params['create_vehicle_estimate_request'] + if "create_vehicle_estimate_request" in local_var_params: + body_params = local_var_params["create_vehicle_estimate_request"] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params[ + "Content-Type" + ] = self.api_client.select_header_content_type( # noqa: E501 + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/estimates/vehicle', 'POST', + "/v1/estimates/vehicle", + "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='EstimateResponse', # noqa: E501 + response_type="EstimateResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) def retrieve_estimate(self, id={}, **kwargs): # noqa: E501 """Retrieves an estimate # noqa: E501 @@ -841,7 +988,7 @@ def retrieve_estimate(self, id={}, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True + kwargs["_return_http_data_only"] = True return self.retrieve_estimate_with_http_info(id, **kwargs) # noqa: E501 def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501 @@ -871,48 +1018,56 @@ def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ['id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["id"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method retrieve_estimate" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] # verify the required parameter 'id' is set - if ('id' not in local_var_params or - local_var_params['id'] is None): - raise ApiValueError("Missing the required parameter `id` when calling `retrieve_estimate`") # noqa: E501 + if "id" not in local_var_params or local_var_params["id"] is None: + raise ApiValueError( + "Missing the required parameter `id` when calling `retrieve_estimate`" + ) # noqa: E501 collection_formats = {} path_params = {} - if 'id' in local_var_params: - path_params['id'] = local_var_params['id'] # noqa: E501 + if "id" in local_var_params: + path_params["id"] = local_var_params["id"] # noqa: E501 query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -921,27 +1076,32 @@ def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/estimates/{id}', 'GET', + "/v1/estimates/{id}", + "GET", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='EstimateResponse', # noqa: E501 + response_type="EstimateResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) def retrieve_estimates(self, **kwargs): # noqa: E501 """Retrieves a list of estimates # noqa: E501 @@ -965,7 +1125,7 @@ def retrieve_estimates(self, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True + kwargs["_return_http_data_only"] = True return self.retrieve_estimates_with_http_info(**kwargs) # noqa: E501 def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501 @@ -995,44 +1155,51 @@ def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ['page'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["page"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method retrieve_estimates" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] collection_formats = {} path_params = {} query_params = [] + if "page" in local_var_params: + query_params.append(("page", local_var_params["page"])) # noqa: E501 + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) - if 'page' in local_var_params: - query_params.append(('page', local_var_params['page'])) # noqa: E501 + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -1041,24 +1208,29 @@ def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/estimates', 'GET', + "/v1/estimates", + "GET", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='EstimateListResponse', # noqa: E501 + response_type="EstimateListResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) diff --git a/patch_api/api/orders_api.py b/patch_api/api/orders_api.py index d82add4..ecba096 100644 --- a/patch_api/api/orders_api.py +++ b/patch_api/api/orders_api.py @@ -17,12 +17,8 @@ # python 2 and python 3 compatibility library import six -from collections import OrderedDict -from patch_api.exceptions import ( - ApiTypeError, - ApiValueError -) +from patch_api.exceptions import ApiTypeError, ApiValueError class OrdersApi(object): @@ -33,20 +29,20 @@ class OrdersApi(object): """ ALLOWED_QUERY_PARAMS = [ - "mass_g", - "total_price_cents_usd", - "project_id", - "page", - "distance_m", - "transportation_method", - "package_mass_g", - "create_order", - "model", - "make", - "year", - "transaction_value_btc_sats", - "timestamp", - "gas_used" + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year", + "transaction_value_btc_sats", + "timestamp", + "gas_used", ] def __init__(self, api_client=None): @@ -74,7 +70,7 @@ def cancel_order(self, id={}, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True + kwargs["_return_http_data_only"] = True return self.cancel_order_with_http_info(id, **kwargs) # noqa: E501 def cancel_order_with_http_info(self, id, **kwargs): # noqa: E501 @@ -104,48 +100,56 @@ def cancel_order_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ['id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["id"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method cancel_order" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] # verify the required parameter 'id' is set - if ('id' not in local_var_params or - local_var_params['id'] is None): - raise ApiValueError("Missing the required parameter `id` when calling `cancel_order`") # noqa: E501 + if "id" not in local_var_params or local_var_params["id"] is None: + raise ApiValueError( + "Missing the required parameter `id` when calling `cancel_order`" + ) # noqa: E501 collection_formats = {} path_params = {} - if 'id' in local_var_params: - path_params['id'] = local_var_params['id'] # noqa: E501 + if "id" in local_var_params: + path_params["id"] = local_var_params["id"] # noqa: E501 query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -154,27 +158,32 @@ def cancel_order_with_http_info(self, id, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/orders/{id}/cancel', 'PATCH', + "/v1/orders/{id}/cancel", + "PATCH", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='OrderResponse', # noqa: E501 + response_type="OrderResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) def create_order(self, create_order_request={}, **kwargs): # noqa: E501 """Creates an order # noqa: E501 @@ -198,8 +207,10 @@ def create_order(self, create_order_request={}, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True - return self.create_order_with_http_info(create_order_request, **kwargs) # noqa: E501 + kwargs["_return_http_data_only"] = True + return self.create_order_with_http_info( + create_order_request, **kwargs + ) # noqa: E501 def create_order_with_http_info(self, create_order_request, **kwargs): # noqa: E501 """Creates an order # noqa: E501 @@ -228,46 +239,57 @@ def create_order_with_http_info(self, create_order_request, **kwargs): # noqa: local_var_params = locals() - all_params = ['create_order_request'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["create_order_request"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_order" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] # verify the required parameter 'create_order_request' is set - if ('create_order_request' not in local_var_params or - local_var_params['create_order_request'] is None): - raise ApiValueError("Missing the required parameter `create_order_request` when calling `create_order`") # noqa: E501 + if ( + "create_order_request" not in local_var_params + or local_var_params["create_order_request"] is None + ): + raise ApiValueError( + "Missing the required parameter `create_order_request` when calling `create_order`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -275,34 +297,42 @@ def create_order_with_http_info(self, create_order_request, **kwargs): # noqa: local_var_files = {} body_params = None - if 'create_order_request' in local_var_params: - body_params = local_var_params['create_order_request'] + if "create_order_request" in local_var_params: + body_params = local_var_params["create_order_request"] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params[ + "Content-Type" + ] = self.api_client.select_header_content_type( # noqa: E501 + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/orders', 'POST', + "/v1/orders", + "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='OrderResponse', # noqa: E501 + response_type="OrderResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) def place_order(self, id={}, **kwargs): # noqa: E501 """Place an order # noqa: E501 @@ -326,7 +356,7 @@ def place_order(self, id={}, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True + kwargs["_return_http_data_only"] = True return self.place_order_with_http_info(id, **kwargs) # noqa: E501 def place_order_with_http_info(self, id, **kwargs): # noqa: E501 @@ -356,48 +386,56 @@ def place_order_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ['id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["id"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method place_order" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] # verify the required parameter 'id' is set - if ('id' not in local_var_params or - local_var_params['id'] is None): - raise ApiValueError("Missing the required parameter `id` when calling `place_order`") # noqa: E501 + if "id" not in local_var_params or local_var_params["id"] is None: + raise ApiValueError( + "Missing the required parameter `id` when calling `place_order`" + ) # noqa: E501 collection_formats = {} path_params = {} - if 'id' in local_var_params: - path_params['id'] = local_var_params['id'] # noqa: E501 + if "id" in local_var_params: + path_params["id"] = local_var_params["id"] # noqa: E501 query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -406,27 +444,32 @@ def place_order_with_http_info(self, id, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/orders/{id}/place', 'PATCH', + "/v1/orders/{id}/place", + "PATCH", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='OrderResponse', # noqa: E501 + response_type="OrderResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) def retrieve_order(self, id={}, **kwargs): # noqa: E501 """Retrieves an order # noqa: E501 @@ -450,7 +493,7 @@ def retrieve_order(self, id={}, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True + kwargs["_return_http_data_only"] = True return self.retrieve_order_with_http_info(id, **kwargs) # noqa: E501 def retrieve_order_with_http_info(self, id, **kwargs): # noqa: E501 @@ -480,48 +523,56 @@ def retrieve_order_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ['id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["id"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method retrieve_order" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] # verify the required parameter 'id' is set - if ('id' not in local_var_params or - local_var_params['id'] is None): - raise ApiValueError("Missing the required parameter `id` when calling `retrieve_order`") # noqa: E501 + if "id" not in local_var_params or local_var_params["id"] is None: + raise ApiValueError( + "Missing the required parameter `id` when calling `retrieve_order`" + ) # noqa: E501 collection_formats = {} path_params = {} - if 'id' in local_var_params: - path_params['id'] = local_var_params['id'] # noqa: E501 + if "id" in local_var_params: + path_params["id"] = local_var_params["id"] # noqa: E501 query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -530,27 +581,32 @@ def retrieve_order_with_http_info(self, id, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/orders/{id}', 'GET', + "/v1/orders/{id}", + "GET", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='OrderResponse', # noqa: E501 + response_type="OrderResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) def retrieve_orders(self, **kwargs): # noqa: E501 """Retrieves a list of orders # noqa: E501 @@ -577,7 +633,7 @@ def retrieve_orders(self, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True + kwargs["_return_http_data_only"] = True return self.retrieve_orders_with_http_info(**kwargs) # noqa: E501 def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 @@ -610,48 +666,59 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ['page', 'metadata', 'metadata_ext_id', 'metadata_disregarded'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = [ + "page", + "metadata", + "metadata_ext_id", + "metadata_disregarded", + ] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method retrieve_orders" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] collection_formats = {} path_params = {} query_params = [] - if 'page' in local_var_params: - query_params.append(('page', local_var_params['page'])) # noqa: E501 - if 'metadata' in local_var_params: - query_params.append(('metadata', local_var_params['metadata'])) # noqa: E501 - if 'metadata_ext_id' in local_var_params: - query_params.append(('metadata[ext_id]', local_var_params['metadata_ext_id'])) # noqa: E501 - if 'metadata_disregarded' in local_var_params: - query_params.append(('metadata[disregarded]', local_var_params['metadata_disregarded'])) # noqa: E501 + if "page" in local_var_params: + query_params.append(("page", local_var_params["page"])) # noqa: E501 + if "metadata" in local_var_params: + query_params.append( + ("metadata", local_var_params["metadata"]) + ) # noqa: E501 + if "metadata_ext_id" in local_var_params: + query_params.append( + ("metadata[ext_id]", local_var_params["metadata_ext_id"]) + ) # noqa: E501 + if "metadata_disregarded" in local_var_params: + query_params.append( + ("metadata[disregarded]", local_var_params["metadata_disregarded"]) + ) # noqa: E501 # do not add duplicate keys to query_params list existing_keys = [] @@ -659,10 +726,9 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 existing_keys.append(param[0]) for key in kwargs: - if not key in existing_keys: + if key not in existing_keys: query_params.append([key, kwargs.get(key)]) - header_params = {} form_params = [] @@ -670,24 +736,29 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/orders', 'GET', + "/v1/orders", + "GET", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='OrderListResponse', # noqa: E501 + response_type="OrderListResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) diff --git a/patch_api/api/preferences_api.py b/patch_api/api/preferences_api.py index b992706..8160bdc 100644 --- a/patch_api/api/preferences_api.py +++ b/patch_api/api/preferences_api.py @@ -18,10 +18,7 @@ # python 2 and python 3 compatibility library import six -from patch_api.exceptions import ( - ApiTypeError, - ApiValueError -) +from patch_api.exceptions import ApiTypeError, ApiValueError class PreferencesApi(object): @@ -32,20 +29,20 @@ class PreferencesApi(object): """ ALLOWED_QUERY_PARAMS = [ - "mass_g", - "total_price_cents_usd", - "project_id", - "page", - "distance_m", - "transportation_method", - "package_mass_g", - "create_order", - "model", - "make", - "year", - "transaction_value_btc_sats", - "timestamp", - "gas_used" + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year", + "transaction_value_btc_sats", + "timestamp", + "gas_used", ] def __init__(self, api_client=None): @@ -73,10 +70,14 @@ def create_preference(self, create_preference_request={}, **kwargs): # noqa: E5 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True - return self.create_preference_with_http_info(create_preference_request, **kwargs) # noqa: E501 - - def create_preference_with_http_info(self, create_preference_request, **kwargs): # noqa: E501 + kwargs["_return_http_data_only"] = True + return self.create_preference_with_http_info( + create_preference_request, **kwargs + ) # noqa: E501 + + def create_preference_with_http_info( + self, create_preference_request, **kwargs + ): # noqa: E501 """creates a project preference # noqa: E501 Creates a project preference for the given organization. If you have a `preference` in place, all of your orders will be directed to the project the preference points to. # noqa: E501 @@ -103,46 +104,57 @@ def create_preference_with_http_info(self, create_preference_request, **kwargs): local_var_params = locals() - all_params = ['create_preference_request'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["create_preference_request"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method create_preference" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] # verify the required parameter 'create_preference_request' is set - if ('create_preference_request' not in local_var_params or - local_var_params['create_preference_request'] is None): - raise ApiValueError("Missing the required parameter `create_preference_request` when calling `create_preference`") # noqa: E501 + if ( + "create_preference_request" not in local_var_params + or local_var_params["create_preference_request"] is None + ): + raise ApiValueError( + "Missing the required parameter `create_preference_request` when calling `create_preference`" + ) # noqa: E501 collection_formats = {} path_params = {} query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -150,34 +162,42 @@ def create_preference_with_http_info(self, create_preference_request, **kwargs): local_var_files = {} body_params = None - if 'create_preference_request' in local_var_params: - body_params = local_var_params['create_preference_request'] + if "create_preference_request" in local_var_params: + body_params = local_var_params["create_preference_request"] # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # HTTP header `Content-Type` - header_params['Content-Type'] = self.api_client.select_header_content_type( # noqa: E501 - ['application/json']) # noqa: E501 + header_params[ + "Content-Type" + ] = self.api_client.select_header_content_type( # noqa: E501 + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/preferences', 'POST', + "/v1/preferences", + "POST", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='PreferenceResponse', # noqa: E501 + response_type="PreferenceResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) def delete_preference(self, id={}, **kwargs): # noqa: E501 """Deletes an organization's preference for a project # noqa: E501 @@ -201,7 +221,7 @@ def delete_preference(self, id={}, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True + kwargs["_return_http_data_only"] = True return self.delete_preference_with_http_info(id, **kwargs) # noqa: E501 def delete_preference_with_http_info(self, id, **kwargs): # noqa: E501 @@ -231,48 +251,56 @@ def delete_preference_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ['id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["id"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method delete_preference" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] # verify the required parameter 'id' is set - if ('id' not in local_var_params or - local_var_params['id'] is None): - raise ApiValueError("Missing the required parameter `id` when calling `delete_preference`") # noqa: E501 + if "id" not in local_var_params or local_var_params["id"] is None: + raise ApiValueError( + "Missing the required parameter `id` when calling `delete_preference`" + ) # noqa: E501 collection_formats = {} path_params = {} - if 'id' in local_var_params: - path_params['id'] = local_var_params['id'] # noqa: E501 + if "id" in local_var_params: + path_params["id"] = local_var_params["id"] # noqa: E501 query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -281,27 +309,32 @@ def delete_preference_with_http_info(self, id, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/preferences/{id}', 'DELETE', + "/v1/preferences/{id}", + "DELETE", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='PreferenceResponse', # noqa: E501 + response_type="PreferenceResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) def retrieve_preference(self, id={}, **kwargs): # noqa: E501 """Retrieve the preference # noqa: E501 @@ -325,7 +358,7 @@ def retrieve_preference(self, id={}, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True + kwargs["_return_http_data_only"] = True return self.retrieve_preference_with_http_info(id, **kwargs) # noqa: E501 def retrieve_preference_with_http_info(self, id, **kwargs): # noqa: E501 @@ -355,48 +388,56 @@ def retrieve_preference_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ['id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["id"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method retrieve_preference" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] # verify the required parameter 'id' is set - if ('id' not in local_var_params or - local_var_params['id'] is None): - raise ApiValueError("Missing the required parameter `id` when calling `retrieve_preference`") # noqa: E501 + if "id" not in local_var_params or local_var_params["id"] is None: + raise ApiValueError( + "Missing the required parameter `id` when calling `retrieve_preference`" + ) # noqa: E501 collection_formats = {} path_params = {} - if 'id' in local_var_params: - path_params['id'] = local_var_params['id'] # noqa: E501 + if "id" in local_var_params: + path_params["id"] = local_var_params["id"] # noqa: E501 query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -405,27 +446,32 @@ def retrieve_preference_with_http_info(self, id, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/preferences/{id}', 'GET', + "/v1/preferences/{id}", + "GET", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='PreferenceResponse', # noqa: E501 + response_type="PreferenceResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) def retrieve_preferences(self, **kwargs): # noqa: E501 """Retrieves a list of preferences # noqa: E501 @@ -449,7 +495,7 @@ def retrieve_preferences(self, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True + kwargs["_return_http_data_only"] = True return self.retrieve_preferences_with_http_info(**kwargs) # noqa: E501 def retrieve_preferences_with_http_info(self, **kwargs): # noqa: E501 @@ -479,44 +525,51 @@ def retrieve_preferences_with_http_info(self, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ['page'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["page"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method retrieve_preferences" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] collection_formats = {} path_params = {} query_params = [] + if "page" in local_var_params: + query_params.append(("page", local_var_params["page"])) # noqa: E501 + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) - if 'page' in local_var_params: - query_params.append(('page', local_var_params['page'])) # noqa: E501 + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -525,24 +578,29 @@ def retrieve_preferences_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/preferences', 'GET', + "/v1/preferences", + "GET", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='PreferenceListResponse', # noqa: E501 + response_type="PreferenceListResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) diff --git a/patch_api/api/projects_api.py b/patch_api/api/projects_api.py index baadb7f..438ac43 100644 --- a/patch_api/api/projects_api.py +++ b/patch_api/api/projects_api.py @@ -18,10 +18,7 @@ # python 2 and python 3 compatibility library import six -from patch_api.exceptions import ( - ApiTypeError, - ApiValueError -) +from patch_api.exceptions import ApiTypeError, ApiValueError class ProjectsApi(object): @@ -32,20 +29,20 @@ class ProjectsApi(object): """ ALLOWED_QUERY_PARAMS = [ - "mass_g", - "total_price_cents_usd", - "project_id", - "page", - "distance_m", - "transportation_method", - "package_mass_g", - "create_order", - "model", - "make", - "year", - "transaction_value_btc_sats", - "timestamp", - "gas_used" + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year", + "transaction_value_btc_sats", + "timestamp", + "gas_used", ] def __init__(self, api_client=None): @@ -73,7 +70,7 @@ def retrieve_project(self, id={}, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True + kwargs["_return_http_data_only"] = True return self.retrieve_project_with_http_info(id, **kwargs) # noqa: E501 def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501 @@ -103,48 +100,56 @@ def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501 local_var_params = locals() - all_params = ['id'] # noqa: E501 - all_params.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["id"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method retrieve_project" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] # verify the required parameter 'id' is set - if ('id' not in local_var_params or - local_var_params['id'] is None): - raise ApiValueError("Missing the required parameter `id` when calling `retrieve_project`") # noqa: E501 + if "id" not in local_var_params or local_var_params["id"] is None: + raise ApiValueError( + "Missing the required parameter `id` when calling `retrieve_project`" + ) # noqa: E501 collection_formats = {} path_params = {} - if 'id' in local_var_params: - path_params['id'] = local_var_params['id'] # noqa: E501 + if "id" in local_var_params: + path_params["id"] = local_var_params["id"] # noqa: E501 query_params = [] + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -153,27 +158,32 @@ def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/projects/{id}', 'GET', + "/v1/projects/{id}", + "GET", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='ProjectResponse', # noqa: E501 + response_type="ProjectResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) def retrieve_projects(self, **kwargs): # noqa: E501 """Retrieves a list of projects # noqa: E501 @@ -200,7 +210,7 @@ def retrieve_projects(self, **kwargs): # noqa: E501 If the method is called asynchronously, returns the request thread. """ - kwargs['_return_http_data_only'] = True + kwargs["_return_http_data_only"] = True return self.retrieve_projects_with_http_info(**kwargs) # noqa: E501 def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501 @@ -233,50 +243,59 @@ 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.append('async_req') - all_params.append('_return_http_data_only') - all_params.append('_preload_content') - all_params.append('_request_timeout') - all_params.append('mass_g') - all_params.append('total_price_cents_usd') - all_params.append('project_id') - all_params.append('metadata') - all_params.append('distance_m') - all_params.append('transportation_method') - all_params.append('package_mass_g') - all_params.append('create_order') - all_params.append('make') - all_params.append('model') - all_params.append('year') - all_params.append('transaction_value_btc_sats') - all_params.append('timestamp') - all_params.append('gas_used') - - for key, val in six.iteritems(local_var_params['kwargs']): + all_params = ["page", "country", "type", "minimum_available_mass"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: raise ApiTypeError( "Got an unexpected keyword argument '%s'" " to method retrieve_projects" % key ) local_var_params[key] = val - del local_var_params['kwargs'] + del local_var_params["kwargs"] collection_formats = {} path_params = {} query_params = [] + if "page" in local_var_params: + query_params.append(("page", local_var_params["page"])) # noqa: E501 + if "country" in local_var_params: + query_params.append(("country", local_var_params["country"])) # noqa: E501 + if "type" in local_var_params: + query_params.append(("type", local_var_params["type"])) # noqa: E501 + if "minimum_available_mass" in local_var_params: + query_params.append( + ("minimum_available_mass", local_var_params["minimum_available_mass"]) + ) # noqa: E501 + + # do not add duplicate keys to query_params list + existing_keys = [] + for param in query_params: + existing_keys.append(param[0]) + for key in kwargs: - query_params.append([key, kwargs.get(key)]) - if 'page' in local_var_params: - query_params.append(('page', local_var_params['page'])) # noqa: E501 - if 'country' in local_var_params: - query_params.append(('country', local_var_params['country'])) # noqa: E501 - if 'type' in local_var_params: - query_params.append(('type', local_var_params['type'])) # noqa: E501 - if 'minimum_available_mass' in local_var_params: - query_params.append(('minimum_available_mass', local_var_params['minimum_available_mass'])) # noqa: E501 + if key not in existing_keys: + query_params.append([key, kwargs.get(key)]) header_params = {} @@ -285,24 +304,29 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501 body_params = None # HTTP header `Accept` - header_params['Accept'] = self.api_client.select_header_accept( - ['application/json']) # noqa: E501 + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 # Authentication setting - auth_settings = ['bearer_auth'] # noqa: E501 + auth_settings = ["bearer_auth"] # noqa: E501 return self.api_client.call_api( - '/v1/projects', 'GET', + "/v1/projects", + "GET", path_params, query_params, header_params, body=body_params, post_params=form_params, files=local_var_files, - response_type='ProjectListResponse', # noqa: E501 + response_type="ProjectListResponse", # noqa: E501 auth_settings=auth_settings, - async_req=local_var_params.get('async_req'), - _return_http_data_only=local_var_params.get('_return_http_data_only'), # noqa: E501 - _preload_content=local_var_params.get('_preload_content', True), - _request_timeout=local_var_params.get('_request_timeout'), - collection_formats=collection_formats) + async_req=local_var_params.get("async_req"), + _return_http_data_only=local_var_params.get( + "_return_http_data_only" + ), # noqa: E501 + _preload_content=local_var_params.get("_preload_content", True), + _request_timeout=local_var_params.get("_request_timeout"), + collection_formats=collection_formats, + ) diff --git a/patch_api/api_client.py b/patch_api/api_client.py index 7302d59..5beb1c3 100644 --- a/patch_api/api_client.py +++ b/patch_api/api_client.py @@ -58,21 +58,28 @@ class ApiClient(object): PRIMITIVE_TYPES = (float, bool, bytes, six.text_type) + six.integer_types NATIVE_TYPES_MAPPING = { - 'int': int, - 'long': int if six.PY3 else long, # noqa: F821 - 'float': float, - 'str': str, - 'bool': bool, - 'date': datetime.date, - 'datetime': datetime.datetime, - 'object': object, + "int": int, + "long": int if six.PY3 else long, # noqa: F821 + "float": float, + "str": str, + "bool": bool, + "date": datetime.date, + "datetime": datetime.datetime, + "object": object, } _pool = None - def __init__(self, api_key=None, configuration=None, header_name=None, header_value=None, - cookie=None, pool_threads=1): + def __init__( + self, + api_key=None, + configuration=None, + header_name=None, + header_value=None, + cookie=None, + pool_threads=1, + ): if api_key is None: - raise ValueError('ApiClient must be initialized with an api_key') + raise ValueError("ApiClient must be initialized with an api_key") if configuration is None: configuration = Configuration() self.configuration = configuration @@ -84,7 +91,7 @@ def __init__(self, api_key=None, configuration=None, header_name=None, header_va self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = 'OpenAPI-Generator/1.8.0/python' + self.user_agent = "OpenAPI-Generator/1.8.0/python" def __del__(self): if self._pool: @@ -94,17 +101,17 @@ def __del__(self): def __getattr__(self, method): resource = { - 'projects': ProjectsApi, - 'orders': OrdersApi, - 'preferences': PreferencesApi, - 'estimates': EstimatesApi + "projects": ProjectsApi, + "orders": OrdersApi, + "preferences": PreferencesApi, + "estimates": EstimatesApi, }[method] return resource(api_client=self) @property def pool(self): """Create thread pool on first request - avoids instantiating unused threadpool for blocking clients. + avoids instantiating unused threadpool for blocking clients. """ if self._pool is None: self._pool = ThreadPool(self.pool_threads) @@ -113,21 +120,33 @@ def pool(self): @property def user_agent(self): """User agent for this API client""" - return self.default_headers['User-Agent'] + return self.default_headers["User-Agent"] @user_agent.setter def user_agent(self, value): - self.default_headers['User-Agent'] = value + self.default_headers["User-Agent"] = value def set_default_header(self, header_name, header_value): self.default_headers[header_name] = header_value def __call_api( - self, resource_path, method, path_params=None, - query_params=None, header_params=None, body=None, post_params=None, - files=None, response_type=None, auth_settings=None, - _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None, _host=None): + self, + resource_path, + method, + path_params=None, + query_params=None, + header_params=None, + body=None, + post_params=None, + files=None, + response_type=None, + auth_settings=None, + _return_http_data_only=None, + collection_formats=None, + _preload_content=True, + _request_timeout=None, + _host=None, + ): config = self.configuration @@ -135,36 +154,33 @@ def __call_api( header_params = header_params or {} header_params.update(self.default_headers) if self.cookie: - header_params['Cookie'] = self.cookie + header_params["Cookie"] = self.cookie if header_params: header_params = self.sanitize_for_serialization(header_params) - header_params = dict(self.parameters_to_tuples(header_params, - collection_formats)) + header_params = dict( + self.parameters_to_tuples(header_params, collection_formats) + ) # path parameters if path_params: path_params = self.sanitize_for_serialization(path_params) - path_params = self.parameters_to_tuples(path_params, - collection_formats) + path_params = self.parameters_to_tuples(path_params, collection_formats) for k, v in path_params: # specified safe chars, encode everything resource_path = resource_path.replace( - '{%s}' % k, - quote(str(v), safe=config.safe_chars_for_path_param) + "{%s}" % k, quote(str(v), safe=config.safe_chars_for_path_param) ) # query parameters if query_params: query_params = self.sanitize_for_serialization(query_params) - query_params = self.parameters_to_tuples(query_params, - collection_formats) + query_params = self.parameters_to_tuples(query_params, collection_formats) # post parameters if post_params or files: post_params = post_params if post_params else [] post_params = self.sanitize_for_serialization(post_params) - post_params = self.parameters_to_tuples(post_params, - collection_formats) + post_params = self.parameters_to_tuples(post_params, collection_formats) post_params.extend(self.files_parameters(files)) # auth setting @@ -183,10 +199,15 @@ def __call_api( # perform request and return response response_data = self.request( - method, url, query_params=query_params, headers=header_params, - post_params=post_params, body=body, + method, + url, + query_params=query_params, + headers=header_params, + post_params=post_params, + body=body, _preload_content=_preload_content, - _request_timeout=_request_timeout) + _request_timeout=_request_timeout, + ) self.last_response = response_data @@ -199,10 +220,9 @@ def __call_api( return_data = None if _return_http_data_only: - return (return_data) + return return_data else: - return (return_data, response_data.status, - response_data.getheaders()) + return (return_data, response_data.status, response_data.getheaders()) def sanitize_for_serialization(self, obj): """Builds a JSON POST object. @@ -223,11 +243,9 @@ def sanitize_for_serialization(self, obj): elif isinstance(obj, self.PRIMITIVE_TYPES): return obj elif isinstance(obj, list): - return [self.sanitize_for_serialization(sub_obj) - for sub_obj in obj] + return [self.sanitize_for_serialization(sub_obj) for sub_obj in obj] elif isinstance(obj, tuple): - return tuple(self.sanitize_for_serialization(sub_obj) - for sub_obj in obj) + return tuple(self.sanitize_for_serialization(sub_obj) for sub_obj in obj) elif isinstance(obj, (datetime.datetime, datetime.date)): return obj.isoformat() @@ -239,12 +257,16 @@ def sanitize_for_serialization(self, obj): # and attributes which value is not None. # Convert attribute name to json key in # model definition for request. - obj_dict = {obj.attribute_map[attr]: getattr(obj, attr) - for attr, _ in six.iteritems(obj.openapi_types) - if getattr(obj, attr) is not None} + obj_dict = { + obj.attribute_map[attr]: getattr(obj, attr) + for attr, _ in six.iteritems(obj.openapi_types) + if getattr(obj, attr) is not None + } - return {key: self.sanitize_for_serialization(val) - for key, val in six.iteritems(obj_dict)} + return { + key: self.sanitize_for_serialization(val) + for key, val in six.iteritems(obj_dict) + } def deserialize(self, response, response_type): """Deserializes response into an object. @@ -280,15 +302,15 @@ def __deserialize(self, data, klass): return None if type(klass) == str: - if klass.startswith('list['): - sub_kls = re.match(r'list\[(.*)\]', klass).group(1) - return [self.__deserialize(sub_data, sub_kls) - for sub_data in data] + if klass.startswith("list["): + sub_kls = re.match(r"list\[(.*)\]", klass).group(1) + return [self.__deserialize(sub_data, sub_kls) for sub_data in data] - if klass.startswith('dict('): - sub_kls = re.match(r'dict\(([^,]*), (.*)\)', klass).group(2) - return {k: self.__deserialize(v, sub_kls) - for k, v in six.iteritems(data)} + if klass.startswith("dict("): + sub_kls = re.match(r"dict\(([^,]*), (.*)\)", klass).group(2) + return { + k: self.__deserialize(v, sub_kls) for k, v in six.iteritems(data) + } # convert str to class if klass in self.NATIVE_TYPES_MAPPING: @@ -307,12 +329,25 @@ def __deserialize(self, data, klass): else: return self.__deserialize_model(data, klass) - def call_api(self, resource_path, method, - path_params=None, query_params=None, header_params=None, - body=None, post_params=None, files=None, - response_type=None, auth_settings=None, async_req=None, - _return_http_data_only=None, collection_formats=None, - _preload_content=True, _request_timeout=None, _host=None): + def call_api( + self, + resource_path, + method, + path_params=None, + query_params=None, + header_params=None, + body=None, + post_params=None, + files=None, + response_type=None, + auth_settings=None, + async_req=None, + _return_http_data_only=None, + collection_formats=None, + _preload_content=True, + _request_timeout=None, + _host=None, + ): """Makes the HTTP request (synchronous) and returns deserialized data. To make an async_req request, set the async_req parameter. @@ -350,80 +385,123 @@ def call_api(self, resource_path, method, then the method will return the response directly. """ if not async_req: - return self.__call_api(resource_path, method, - path_params, query_params, header_params, - body, post_params, files, - response_type, auth_settings, - _return_http_data_only, collection_formats, - _preload_content, _request_timeout, _host) + return self.__call_api( + resource_path, + method, + path_params, + query_params, + header_params, + body, + post_params, + files, + response_type, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, + ) else: - thread = self.pool.apply_async(self.__call_api, (resource_path, - method, path_params, query_params, - header_params, body, - post_params, files, - response_type, auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, - _request_timeout, - _host)) + thread = self.pool.apply_async( + self.__call_api, + ( + resource_path, + method, + path_params, + query_params, + header_params, + body, + post_params, + files, + response_type, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, + ), + ) return thread - def request(self, method, url, query_params=None, headers=None, - post_params=None, body=None, _preload_content=True, - _request_timeout=None): + def request( + self, + method, + url, + query_params=None, + headers=None, + post_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): """Makes the HTTP request using RESTClient.""" if method == "GET": - return self.rest_client.GET(url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers) + return self.rest_client.GET( + url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers, + ) elif method == "HEAD": - return self.rest_client.HEAD(url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers) + return self.rest_client.HEAD( + url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers, + ) elif method == "OPTIONS": - return self.rest_client.OPTIONS(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + return self.rest_client.OPTIONS( + url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) elif method == "POST": - return self.rest_client.POST(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + return self.rest_client.POST( + url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) elif method == "PUT": - return self.rest_client.PUT(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + return self.rest_client.PUT( + url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) elif method == "PATCH": - return self.rest_client.PATCH(url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + return self.rest_client.PATCH( + url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) elif method == "DELETE": - return self.rest_client.DELETE(url, - query_params=query_params, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + return self.rest_client.DELETE( + url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) else: raise ApiValueError( "http method must be `GET`, `HEAD`, `OPTIONS`," @@ -440,22 +518,23 @@ def parameters_to_tuples(self, params, collection_formats): new_params = [] if collection_formats is None: collection_formats = {} - for k, v in six.iteritems(params) if isinstance(params, dict) else params: # noqa: E501 + for k, v in ( + six.iteritems(params) if isinstance(params, dict) else params + ): # noqa: E501 if k in collection_formats: collection_format = collection_formats[k] - if collection_format == 'multi': + if collection_format == "multi": new_params.extend((k, value) for value in v) else: - if collection_format == 'ssv': - delimiter = ' ' - elif collection_format == 'tsv': - delimiter = '\t' - elif collection_format == 'pipes': - delimiter = '|' + if collection_format == "ssv": + delimiter = " " + elif collection_format == "tsv": + delimiter = "\t" + elif collection_format == "pipes": + delimiter = "|" else: # csv is the default - delimiter = ',' - new_params.append( - (k, delimiter.join(str(value) for value in v))) + delimiter = "," + new_params.append((k, delimiter.join(str(value) for value in v))) else: new_params.append((k, v)) return new_params @@ -474,13 +553,14 @@ def files_parameters(self, files=None): continue file_names = v if type(v) is list else [v] for n in file_names: - with open(n, 'rb') as f: + with open(n, "rb") as f: filename = os.path.basename(f.name) filedata = f.read() - mimetype = (mimetypes.guess_type(filename)[0] or - 'application/octet-stream') - params.append( - tuple([k, tuple([filename, filedata, mimetype])])) + mimetype = ( + mimetypes.guess_type(filename)[0] + or "application/octet-stream" + ) + params.append(tuple([k, tuple([filename, filedata, mimetype])])) return params @@ -495,10 +575,10 @@ def select_header_accept(self, accepts): accepts = [x.lower() for x in accepts] - if 'application/json' in accepts: - return 'application/json' + if "application/json" in accepts: + return "application/json" else: - return ', '.join(accepts) + return ", ".join(accepts) def select_header_content_type(self, content_types): """Returns `Content-Type` based on an array of content_types provided. @@ -507,12 +587,12 @@ def select_header_content_type(self, content_types): :return: Content-Type (e.g. application/json). """ if not content_types: - return 'application/json' + return "application/json" content_types = [x.lower() for x in content_types] - if 'application/json' in content_types or '*/*' in content_types: - return 'application/json' + if "application/json" in content_types or "*/*" in content_types: + return "application/json" else: return content_types[0] @@ -529,17 +609,17 @@ def update_params_for_auth(self, headers, querys, auth_settings): for auth in auth_settings: auth_setting = self.configuration.auth_settings().get(auth) if auth_setting: - if not auth_setting['value']: + if not auth_setting["value"]: continue - elif auth_setting['in'] == 'cookie': - headers['Cookie'] = auth_setting['value'] - elif auth_setting['in'] == 'header': - headers[auth_setting['key']] = auth_setting['value'] - elif auth_setting['in'] == 'query': - querys.append((auth_setting['key'], auth_setting['value'])) + elif auth_setting["in"] == "cookie": + headers["Cookie"] = auth_setting["value"] + elif auth_setting["in"] == "header": + headers[auth_setting["key"]] = auth_setting["value"] + elif auth_setting["in"] == "query": + querys.append((auth_setting["key"], auth_setting["value"])) else: raise ApiValueError( - 'Authentication token must be in `query` or `header`' + "Authentication token must be in `query` or `header`" ) def __deserialize_file(self, response): @@ -557,8 +637,9 @@ def __deserialize_file(self, response): content_disposition = response.getheader("Content-Disposition") if content_disposition: - filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', - content_disposition).group(1) + filename = re.search( + r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition + ).group(1) path = os.path.join(os.path.dirname(path), filename) with open(path, "wb") as f: @@ -596,13 +677,13 @@ def __deserialize_date(self, string): """ try: from dateutil.parser import parse + return parse(string).date() except ImportError: return string except ValueError: raise rest.ApiException( - status=0, - reason="Failed to parse `{0}` as date object".format(string) + status=0, reason="Failed to parse `{0}` as date object".format(string) ) def __deserialize_datatime(self, string): @@ -615,16 +696,14 @@ def __deserialize_datatime(self, string): """ try: from dateutil.parser import parse + return parse(string) except ImportError: return string except ValueError: raise rest.ApiException( status=0, - reason=( - "Failed to parse `{0}` as datetime object" - .format(string) - ) + reason=("Failed to parse `{0}` as datetime object".format(string)), ) def __deserialize_model(self, data, klass): @@ -635,24 +714,24 @@ def __deserialize_model(self, data, klass): :return: model object. """ - if not klass.openapi_types and not hasattr(klass, - 'get_real_child_model'): + if not klass.openapi_types and not hasattr(klass, "get_real_child_model"): return data kwargs = {} if klass.openapi_types is not None: for attr, attr_type in six.iteritems(klass.openapi_types): - if (data is not None and - klass.attribute_map[attr] in data and - isinstance(data, (list, dict))): + if ( + data is not None + and klass.attribute_map[attr] in data + and isinstance(data, (list, dict)) + ): value = data[klass.attribute_map[attr]] kwargs[attr] = self.__deserialize(value, attr_type) instance = klass(**kwargs) - if hasattr(instance, 'get_real_child_model'): + if hasattr(instance, "get_real_child_model"): klass_name = instance.get_real_child_model(data) if klass_name: instance = self.__deserialize(data, klass_name) return instance - diff --git a/patch_api/configuration.py b/patch_api/configuration.py index 5d1e81e..80ed119 100644 --- a/patch_api/configuration.py +++ b/patch_api/configuration.py @@ -56,13 +56,16 @@ class Configuration(object): _default = None - def __init__(self, host="http://api.patch.test:3000", - api_key=None, api_key_prefix=None, - username=None, password=None, - discard_unknown_keys=False, - ): - """Constructor - """ + def __init__( + self, + host="https://api.patch.io", + api_key=None, + api_key_prefix=None, + username=None, + password=None, + discard_unknown_keys=False, + ): + """Constructor""" self.host = host """Default Base url """ @@ -98,7 +101,7 @@ def __init__(self, host="http://api.patch.test:3000", """ self.logger["package_logger"] = logging.getLogger("patch_api") self.logger["urllib3_logger"] = logging.getLogger("urllib3") - self.logger_format = '%(asctime)s %(levelname)s %(message)s' + self.logger_format = "%(asctime)s %(levelname)s %(message)s" """Log format """ self.logger_stream_handler = None @@ -146,7 +149,7 @@ def __init__(self, host="http://api.patch.test:3000", self.proxy_headers = None """Proxy headers """ - self.safe_chars_for_path_param = '' + self.safe_chars_for_path_param = "" """Safe chars for path_param """ self.retries = None @@ -160,7 +163,7 @@ def __deepcopy__(self, memo): result = cls.__new__(cls) memo[id(self)] = result for k, v in self.__dict__.items(): - if k not in ('logger', 'logger_file_handler'): + if k not in ("logger", "logger_file_handler"): setattr(result, k, copy.deepcopy(v, memo)) # shallow copy of loggers result.logger = copy.copy(self.logger) @@ -309,9 +312,9 @@ def get_basic_auth_token(self): password = "" if self.password is not None: password = self.password - return urllib3.util.make_headers( - basic_auth=username + ':' + password - ).get('authorization') + return urllib3.util.make_headers(basic_auth=username + ":" + password).get( + "authorization" + ) def auth_settings(self): """Gets Auth Settings dict for api client. @@ -320,11 +323,11 @@ def auth_settings(self): """ auth = {} if self.access_token is not None: - auth['bearer_auth'] = { - 'type': 'bearer', - 'in': 'header', - 'key': 'Authorization', - 'value': 'Bearer ' + self.access_token + auth["bearer_auth"] = { + "type": "bearer", + "in": "header", + "key": "Authorization", + "value": "Bearer " + self.access_token, } return auth @@ -333,12 +336,13 @@ def to_debug_report(self): :return: The report for debugging. """ - return "Python SDK Debug Report:\n"\ - "OS: {env}\n"\ - "Python Version: {pyversion}\n"\ - "Version of the API: v1\n"\ - "SDK Package Version: 1.8.0".\ - format(env=sys.platform, pyversion=sys.version) + return ( + "Python SDK Debug Report:\n" + "OS: {env}\n" + "Python Version: {pyversion}\n" + "Version of the API: v1\n" + "SDK Package Version: 1.8.0".format(env=sys.platform, pyversion=sys.version) + ) def get_host_settings(self): """Gets an array of host settings @@ -347,14 +351,14 @@ def get_host_settings(self): """ return [ { - 'url': "https://{defaultHost}", - 'description': "No description provided", - 'variables': { - 'defaultHost': { - 'description': "No description provided", - 'default_value': "api.patch.io", - } + "url": "https://{defaultHost}", + "description": "No description provided", + "variables": { + "defaultHost": { + "description": "No description provided", + "default_value": "api.patch.io", } + }, } ] @@ -372,22 +376,22 @@ def get_host_from_settings(self, index, variables=None): except IndexError: raise ValueError( "Invalid index {0} when selecting the host settings. " - "Must be less than {1}".format(index, len(servers))) + "Must be less than {1}".format(index, len(servers)) + ) - url = server['url'] + url = server["url"] # go through variables and replace placeholders - for variable_name, variable in server['variables'].items(): - used_value = variables.get( - variable_name, variable['default_value']) + for variable_name, variable in server["variables"].items(): + used_value = variables.get(variable_name, variable["default_value"]) - if 'enum_values' in variable \ - and used_value not in variable['enum_values']: + if "enum_values" in variable and used_value not in variable["enum_values"]: raise ValueError( "The variable `{0}` in the host URL has invalid value " "{1}. Must be {2}.".format( - variable_name, variables[variable_name], - variable['enum_values'])) + variable_name, variables[variable_name], variable["enum_values"] + ) + ) url = url.replace("{" + variable_name + "}", used_value) diff --git a/patch_api/exceptions.py b/patch_api/exceptions.py index e2bd822..64b8229 100644 --- a/patch_api/exceptions.py +++ b/patch_api/exceptions.py @@ -19,9 +19,8 @@ class OpenApiException(Exception): class ApiTypeError(OpenApiException, TypeError): - def __init__(self, msg, path_to_item=None, valid_classes=None, - key_type=None): - """ Raises an exception for TypeErrors + def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None): + """Raises an exception for TypeErrors Args: msg (str): the exception message @@ -83,7 +82,6 @@ def __init__(self, msg, path_to_item=None): class ApiException(OpenApiException): - def __init__(self, status=None, reason=None, http_resp=None): if http_resp: self.status = http_resp.status @@ -98,11 +96,9 @@ def __init__(self, status=None, reason=None, http_resp=None): def __str__(self): """Custom error messages for exception""" - error_message = "({0})\n"\ - "Reason: {1}\n".format(self.status, self.reason) + error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason) if self.headers: - error_message += "HTTP response headers: {0}\n".format( - self.headers) + error_message += "HTTP response headers: {0}\n".format(self.headers) if self.body: error_message += "HTTP response body: {0}\n".format(self.body) diff --git a/patch_api/models/allocation.py b/patch_api/models/allocation.py index e37d829..b6629ae 100644 --- a/patch_api/models/allocation.py +++ b/patch_api/models/allocation.py @@ -33,19 +33,13 @@ class Allocation(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'id': 'str', - 'production': 'bool', - 'mass_g': 'int' - } - - attribute_map = { - 'id': 'id', - 'production': 'production', - 'mass_g': 'mass_g' - } - - def __init__(self, id=None, production=None, mass_g=None, local_vars_configuration=None): # noqa: E501 + openapi_types = {"id": "str", "production": "bool", "mass_g": "int"} + + attribute_map = {"id": "id", "production": "production", "mass_g": "mass_g"} + + def __init__( + self, id=None, production=None, mass_g=None, local_vars_configuration=None + ): # noqa: E501 """Allocation - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -80,7 +74,9 @@ def id(self, id): :param id: The id of this Allocation. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and id is None + ): # noqa: E501 raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -105,8 +101,12 @@ def production(self, production): :param production: The production of this Allocation. # noqa: E501 :type: bool """ - if self.local_vars_configuration.client_side_validation and production is None: # noqa: E501 - raise ValueError("Invalid value for `production`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and production is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `production`, must not be `None`" + ) # noqa: E501 self._production = production @@ -130,8 +130,12 @@ def mass_g(self, mass_g): :param mass_g: The mass_g of this Allocation. # noqa: E501 :type: int """ - if self.local_vars_configuration.client_side_validation and mass_g is None: # noqa: E501 - raise ValueError("Invalid value for `mass_g`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and mass_g is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `mass_g`, must not be `None`" + ) # noqa: E501 self._mass_g = mass_g @@ -142,18 +146,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/bulk_create_success_response.py b/patch_api/models/bulk_create_success_response.py index 3a35217..3e3a222 100644 --- a/patch_api/models/bulk_create_success_response.py +++ b/patch_api/models/bulk_create_success_response.py @@ -33,17 +33,13 @@ class BulkCreateSuccessResponse(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'success': 'bool', - 'error': 'Error' - } + openapi_types = {"success": "bool", "error": "Error"} - attribute_map = { - 'success': 'success', - 'error': 'error' - } + attribute_map = {"success": "success", "error": "error"} - def __init__(self, success=None, error=None, local_vars_configuration=None): # noqa: E501 + def __init__( + self, success=None, error=None, local_vars_configuration=None + ): # noqa: E501 """BulkCreateSuccessResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -74,8 +70,12 @@ def success(self, success): :param success: The success of this BulkCreateSuccessResponse. # noqa: E501 :type: bool """ - if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 - raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and success is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `success`, must not be `None`" + ) # noqa: E501 self._success = success @@ -97,8 +97,12 @@ def error(self, error): :param error: The error of this BulkCreateSuccessResponse. # noqa: E501 :type: Error """ - if self.local_vars_configuration.client_side_validation and error is None: # noqa: E501 - raise ValueError("Invalid value for `error`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and error is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `error`, must not be `None`" + ) # noqa: E501 self._error = error @@ -109,18 +113,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/error_response.py b/patch_api/models/error_response.py index efb6ee8..8303054 100644 --- a/patch_api/models/error_response.py +++ b/patch_api/models/error_response.py @@ -33,19 +33,13 @@ class ErrorResponse(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'success': 'bool', - 'error': 'object', - 'data': 'object' - } - - attribute_map = { - 'success': 'success', - 'error': 'error', - 'data': 'data' - } - - def __init__(self, success=None, error=None, data=None, local_vars_configuration=None): # noqa: E501 + openapi_types = {"success": "bool", "error": "object", "data": "object"} + + attribute_map = {"success": "success", "error": "error", "data": "data"} + + def __init__( + self, success=None, error=None, data=None, local_vars_configuration=None + ): # noqa: E501 """ErrorResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -78,8 +72,12 @@ def success(self, success): :param success: The success of this ErrorResponse. # noqa: E501 :type: bool """ - if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 - raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and success is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `success`, must not be `None`" + ) # noqa: E501 self._success = success @@ -101,8 +99,12 @@ def error(self, error): :param error: The error of this ErrorResponse. # noqa: E501 :type: object """ - if self.local_vars_configuration.client_side_validation and error is None: # noqa: E501 - raise ValueError("Invalid value for `error`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and error is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `error`, must not be `None`" + ) # noqa: E501 self._error = error @@ -134,18 +136,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/estimate.py b/patch_api/models/estimate.py index 1ef336d..3792db3 100644 --- a/patch_api/models/estimate.py +++ b/patch_api/models/estimate.py @@ -34,22 +34,30 @@ class Estimate(object): and the value is json key in definition. """ openapi_types = { - 'id': 'str', - 'production': 'bool', - 'type': 'str', - 'mass_g': 'int', - 'order': 'Order' + "id": "str", + "production": "bool", + "type": "str", + "mass_g": "int", + "order": "Order", } attribute_map = { - 'id': 'id', - 'production': 'production', - 'type': 'type', - 'mass_g': 'mass_g', - 'order': 'order' + "id": "id", + "production": "production", + "type": "type", + "mass_g": "mass_g", + "order": "order", } - def __init__(self, id=None, production=None, type=None, mass_g=None, order=None, local_vars_configuration=None): # noqa: E501 + def __init__( + self, + id=None, + production=None, + type=None, + mass_g=None, + order=None, + local_vars_configuration=None, + ): # noqa: E501 """Estimate - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -89,7 +97,9 @@ def id(self, id): :param id: The id of this Estimate. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and id is None + ): # noqa: E501 raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -114,8 +124,12 @@ def production(self, production): :param production: The production of this Estimate. # noqa: E501 :type: bool """ - if self.local_vars_configuration.client_side_validation and production is None: # noqa: E501 - raise ValueError("Invalid value for `production`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and production is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `production`, must not be `None`" + ) # noqa: E501 self._production = production @@ -139,8 +153,12 @@ def type(self, type): :param type: The type of this Estimate. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and type is None: # noqa: E501 - raise ValueError("Invalid value for `type`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and type is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `type`, must not be `None`" + ) # noqa: E501 self._type = type @@ -197,18 +215,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/estimate_list_response.py b/patch_api/models/estimate_list_response.py index 1b42b43..ccb0a68 100644 --- a/patch_api/models/estimate_list_response.py +++ b/patch_api/models/estimate_list_response.py @@ -34,20 +34,27 @@ class EstimateListResponse(object): and the value is json key in definition. """ openapi_types = { - 'success': 'bool', - 'error': 'object', - 'data': 'list[Estimate]', - 'meta': 'MetaIndexObject' + "success": "bool", + "error": "object", + "data": "list[Estimate]", + "meta": "MetaIndexObject", } attribute_map = { - 'success': 'success', - 'error': 'error', - 'data': 'data', - 'meta': 'meta' + "success": "success", + "error": "error", + "data": "data", + "meta": "meta", } - def __init__(self, success=None, error=None, data=None, meta=None, local_vars_configuration=None): # noqa: E501 + def __init__( + self, + success=None, + error=None, + data=None, + meta=None, + local_vars_configuration=None, + ): # noqa: E501 """EstimateListResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -82,8 +89,12 @@ def success(self, success): :param success: The success of this EstimateListResponse. # noqa: E501 :type: bool """ - if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 - raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and success is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `success`, must not be `None`" + ) # noqa: E501 self._success = success @@ -126,8 +137,12 @@ def data(self, data): :param data: The data of this EstimateListResponse. # noqa: E501 :type: list[Estimate] """ - if self.local_vars_configuration.client_side_validation and data is None: # noqa: E501 - raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and data is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `data`, must not be `None`" + ) # noqa: E501 self._data = data @@ -149,8 +164,12 @@ def meta(self, meta): :param meta: The meta of this EstimateListResponse. # noqa: E501 :type: MetaIndexObject """ - if self.local_vars_configuration.client_side_validation and meta is None: # noqa: E501 - raise ValueError("Invalid value for `meta`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and meta is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `meta`, must not be `None`" + ) # noqa: E501 self._meta = meta @@ -161,18 +180,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/estimate_response.py b/patch_api/models/estimate_response.py index bee841e..f15ac7c 100644 --- a/patch_api/models/estimate_response.py +++ b/patch_api/models/estimate_response.py @@ -33,19 +33,13 @@ class EstimateResponse(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'success': 'bool', - 'error': 'object', - 'data': 'Estimate' - } - - attribute_map = { - 'success': 'success', - 'error': 'error', - 'data': 'data' - } - - def __init__(self, success=None, error=None, data=None, local_vars_configuration=None): # noqa: E501 + openapi_types = {"success": "bool", "error": "object", "data": "Estimate"} + + attribute_map = {"success": "success", "error": "error", "data": "data"} + + def __init__( + self, success=None, error=None, data=None, local_vars_configuration=None + ): # noqa: E501 """EstimateResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -78,8 +72,12 @@ def success(self, success): :param success: The success of this EstimateResponse. # noqa: E501 :type: bool """ - if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 - raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and success is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `success`, must not be `None`" + ) # noqa: E501 self._success = success @@ -122,8 +120,12 @@ def data(self, data): :param data: The data of this EstimateResponse. # noqa: E501 :type: Estimate """ - if self.local_vars_configuration.client_side_validation and data is None: # noqa: E501 - raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and data is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `data`, must not be `None`" + ) # noqa: E501 self._data = data @@ -134,18 +136,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/meta_index_object.py b/patch_api/models/meta_index_object.py index 5de83d5..cbc5313 100644 --- a/patch_api/models/meta_index_object.py +++ b/patch_api/models/meta_index_object.py @@ -33,17 +33,13 @@ class MetaIndexObject(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'prev_page': 'int', - 'next_page': 'int' - } + openapi_types = {"prev_page": "int", "next_page": "int"} - attribute_map = { - 'prev_page': 'prev_page', - 'next_page': 'next_page' - } + attribute_map = {"prev_page": "prev_page", "next_page": "next_page"} - def __init__(self, prev_page=None, next_page=None, local_vars_configuration=None): # noqa: E501 + def __init__( + self, prev_page=None, next_page=None, local_vars_configuration=None + ): # noqa: E501 """MetaIndexObject - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -105,18 +101,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/order.py b/patch_api/models/order.py index 35b1999..130d2d6 100644 --- a/patch_api/models/order.py +++ b/patch_api/models/order.py @@ -34,32 +34,45 @@ class Order(object): and the value is json key in definition. """ openapi_types = { - 'id': 'str', - 'mass_g': 'int', - 'production': 'bool', - 'state': 'str', - 'allocation_state': 'str', - 'price_cents_usd': 'int', - 'patch_fee_cents_usd': 'int', - 'allocations': 'list[Allocation]', - 'registry_url': 'str', - 'metadata': 'object' + "id": "str", + "mass_g": "int", + "production": "bool", + "state": "str", + "allocation_state": "str", + "price_cents_usd": "int", + "patch_fee_cents_usd": "int", + "allocations": "list[Allocation]", + "registry_url": "str", + "metadata": "object", } attribute_map = { - 'id': 'id', - 'mass_g': 'mass_g', - 'production': 'production', - 'state': 'state', - 'allocation_state': 'allocation_state', - 'price_cents_usd': 'price_cents_usd', - 'patch_fee_cents_usd': 'patch_fee_cents_usd', - 'allocations': 'allocations', - 'registry_url': 'registry_url', - 'metadata': 'metadata' + "id": "id", + "mass_g": "mass_g", + "production": "production", + "state": "state", + "allocation_state": "allocation_state", + "price_cents_usd": "price_cents_usd", + "patch_fee_cents_usd": "patch_fee_cents_usd", + "allocations": "allocations", + "registry_url": "registry_url", + "metadata": "metadata", } - def __init__(self, id=None, mass_g=None, production=None, state=None, allocation_state=None, price_cents_usd=None, patch_fee_cents_usd=None, allocations=None, registry_url=None, metadata=None, local_vars_configuration=None): # noqa: E501 + def __init__( + self, + id=None, + mass_g=None, + production=None, + state=None, + allocation_state=None, + price_cents_usd=None, + patch_fee_cents_usd=None, + allocations=None, + registry_url=None, + metadata=None, + local_vars_configuration=None, + ): # noqa: E501 """Order - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -109,7 +122,9 @@ def id(self, id): :param id: The id of this Order. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and id is None + ): # noqa: E501 raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -134,14 +149,28 @@ def mass_g(self, mass_g): :param mass_g: The mass_g of this Order. # noqa: E501 :type: int """ - if self.local_vars_configuration.client_side_validation and mass_g is None: # noqa: E501 - raise ValueError("Invalid value for `mass_g`, must not be `None`") # noqa: E501 - if (self.local_vars_configuration.client_side_validation and - mass_g is not None and mass_g > 2000000000): # noqa: E501 - raise ValueError("Invalid value for `mass_g`, must be a value less than or equal to `2000000000`") # noqa: E501 - if (self.local_vars_configuration.client_side_validation and - mass_g is not None and mass_g < 0): # noqa: E501 - raise ValueError("Invalid value for `mass_g`, must be a value greater than or equal to `0`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and mass_g is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `mass_g`, must not be `None`" + ) # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation + and mass_g is not None + and mass_g > 2000000000 + ): # noqa: E501 + raise ValueError( + "Invalid value for `mass_g`, must be a value less than or equal to `2000000000`" + ) # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation + and mass_g is not None + and mass_g < 0 + ): # noqa: E501 + raise ValueError( + "Invalid value for `mass_g`, must be a value greater than or equal to `0`" + ) # noqa: E501 self._mass_g = mass_g @@ -165,8 +194,12 @@ def production(self, production): :param production: The production of this Order. # noqa: E501 :type: bool """ - if self.local_vars_configuration.client_side_validation and production is None: # noqa: E501 - raise ValueError("Invalid value for `production`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and production is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `production`, must not be `None`" + ) # noqa: E501 self._production = production @@ -190,13 +223,27 @@ def state(self, state): :param state: The state of this Order. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and state is None: # noqa: E501 - raise ValueError("Invalid value for `state`, must not be `None`") # noqa: E501 - allowed_values = ["draft", "placed", "processing", "complete", "cancelled"] # noqa: E501 - if self.local_vars_configuration.client_side_validation and state not in allowed_values: # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and state is None + ): # noqa: E501 raise ValueError( - "Invalid value for `state` ({0}), must be one of {1}" # noqa: E501 - .format(state, allowed_values) + "Invalid value for `state`, must not be `None`" + ) # noqa: E501 + allowed_values = [ + "draft", + "placed", + "processing", + "complete", + "cancelled", + ] # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation + and state not in allowed_values + ): # noqa: E501 + raise ValueError( + "Invalid value for `state` ({0}), must be one of {1}".format( # noqa: E501 + state, allowed_values + ) ) self._state = state @@ -221,13 +268,22 @@ def allocation_state(self, allocation_state): :param allocation_state: The allocation_state of this Order. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and allocation_state is None: # noqa: E501 - raise ValueError("Invalid value for `allocation_state`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation + and allocation_state is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `allocation_state`, must not be `None`" + ) # noqa: E501 allowed_values = ["pending", "partially_allocated", "allocated"] # noqa: E501 - if self.local_vars_configuration.client_side_validation and allocation_state not in allowed_values: # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation + and allocation_state not in allowed_values + ): # noqa: E501 raise ValueError( - "Invalid value for `allocation_state` ({0}), must be one of {1}" # noqa: E501 - .format(allocation_state, allowed_values) + "Invalid value for `allocation_state` ({0}), must be one of {1}".format( # noqa: E501 + allocation_state, allowed_values + ) ) self._allocation_state = allocation_state @@ -298,8 +354,12 @@ def allocations(self, allocations): :param allocations: The allocations of this Order. # noqa: E501 :type: list[Allocation] """ - if self.local_vars_configuration.client_side_validation and allocations is None: # noqa: E501 - raise ValueError("Invalid value for `allocations`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and allocations is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `allocations`, must not be `None`" + ) # noqa: E501 self._allocations = allocations @@ -346,8 +406,12 @@ def metadata(self, metadata): :param metadata: The metadata of this Order. # noqa: E501 :type: object """ - if self.local_vars_configuration.client_side_validation and metadata is None: # noqa: E501 - raise ValueError("Invalid value for `metadata`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and metadata is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `metadata`, must not be `None`" + ) # noqa: E501 self._metadata = metadata @@ -358,18 +422,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/order_list_response.py b/patch_api/models/order_list_response.py index d9c6b4c..a558841 100644 --- a/patch_api/models/order_list_response.py +++ b/patch_api/models/order_list_response.py @@ -34,20 +34,27 @@ class OrderListResponse(object): and the value is json key in definition. """ openapi_types = { - 'success': 'bool', - 'error': 'object', - 'data': 'list[Order]', - 'meta': 'MetaIndexObject' + "success": "bool", + "error": "object", + "data": "list[Order]", + "meta": "MetaIndexObject", } attribute_map = { - 'success': 'success', - 'error': 'error', - 'data': 'data', - 'meta': 'meta' + "success": "success", + "error": "error", + "data": "data", + "meta": "meta", } - def __init__(self, success=None, error=None, data=None, meta=None, local_vars_configuration=None): # noqa: E501 + def __init__( + self, + success=None, + error=None, + data=None, + meta=None, + local_vars_configuration=None, + ): # noqa: E501 """OrderListResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -82,8 +89,12 @@ def success(self, success): :param success: The success of this OrderListResponse. # noqa: E501 :type: bool """ - if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 - raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and success is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `success`, must not be `None`" + ) # noqa: E501 self._success = success @@ -126,8 +137,12 @@ def data(self, data): :param data: The data of this OrderListResponse. # noqa: E501 :type: list[Order] """ - if self.local_vars_configuration.client_side_validation and data is None: # noqa: E501 - raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and data is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `data`, must not be `None`" + ) # noqa: E501 self._data = data @@ -149,8 +164,12 @@ def meta(self, meta): :param meta: The meta of this OrderListResponse. # noqa: E501 :type: MetaIndexObject """ - if self.local_vars_configuration.client_side_validation and meta is None: # noqa: E501 - raise ValueError("Invalid value for `meta`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and meta is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `meta`, must not be `None`" + ) # noqa: E501 self._meta = meta @@ -161,18 +180,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/order_response.py b/patch_api/models/order_response.py index ffc9f94..971e9a1 100644 --- a/patch_api/models/order_response.py +++ b/patch_api/models/order_response.py @@ -33,19 +33,13 @@ class OrderResponse(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'success': 'bool', - 'error': 'object', - 'data': 'Order' - } - - attribute_map = { - 'success': 'success', - 'error': 'error', - 'data': 'data' - } - - def __init__(self, success=None, error=None, data=None, local_vars_configuration=None): # noqa: E501 + openapi_types = {"success": "bool", "error": "object", "data": "Order"} + + attribute_map = {"success": "success", "error": "error", "data": "data"} + + def __init__( + self, success=None, error=None, data=None, local_vars_configuration=None + ): # noqa: E501 """OrderResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -78,8 +72,12 @@ def success(self, success): :param success: The success of this OrderResponse. # noqa: E501 :type: bool """ - if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 - raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and success is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `success`, must not be `None`" + ) # noqa: E501 self._success = success @@ -122,8 +120,12 @@ def data(self, data): :param data: The data of this OrderResponse. # noqa: E501 :type: Order """ - if self.local_vars_configuration.client_side_validation and data is None: # noqa: E501 - raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and data is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `data`, must not be `None`" + ) # noqa: E501 self._data = data @@ -134,18 +136,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/photo.py b/patch_api/models/photo.py index 7716e55..65be8bc 100644 --- a/patch_api/models/photo.py +++ b/patch_api/models/photo.py @@ -33,15 +33,9 @@ class Photo(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'url': 'str', - 'id': 'str' - } + openapi_types = {"url": "str", "id": "str"} - attribute_map = { - 'url': 'url', - 'id': 'id' - } + attribute_map = {"url": "url", "id": "id"} def __init__(self, url=None, id=None, local_vars_configuration=None): # noqa: E501 """Photo - a model defined in OpenAPI""" # noqa: E501 @@ -74,8 +68,12 @@ def url(self, url): :param url: The url of this Photo. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and url is None: # noqa: E501 - raise ValueError("Invalid value for `url`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and url is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `url`, must not be `None`" + ) # noqa: E501 self._url = url @@ -97,7 +95,9 @@ def id(self, id): :param id: The id of this Photo. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and id is None + ): # noqa: E501 raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -109,18 +109,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/preference.py b/patch_api/models/preference.py index ff30fc6..ad87aa0 100644 --- a/patch_api/models/preference.py +++ b/patch_api/models/preference.py @@ -33,19 +33,21 @@ class Preference(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'id': 'str', - 'allocation_percentage': 'int', - 'project': 'Project' - } + openapi_types = {"id": "str", "allocation_percentage": "int", "project": "Project"} attribute_map = { - 'id': 'id', - 'allocation_percentage': 'allocation_percentage', - 'project': 'project' + "id": "id", + "allocation_percentage": "allocation_percentage", + "project": "project", } - def __init__(self, id=None, allocation_percentage=None, project=None, local_vars_configuration=None): # noqa: E501 + def __init__( + self, + id=None, + allocation_percentage=None, + project=None, + local_vars_configuration=None, + ): # noqa: E501 """Preference - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -80,7 +82,9 @@ def id(self, id): :param id: The id of this Preference. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and id is None + ): # noqa: E501 raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -105,8 +109,13 @@ def allocation_percentage(self, allocation_percentage): :param allocation_percentage: The allocation_percentage of this Preference. # noqa: E501 :type: int """ - if self.local_vars_configuration.client_side_validation and allocation_percentage is None: # noqa: E501 - raise ValueError("Invalid value for `allocation_percentage`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation + and allocation_percentage is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `allocation_percentage`, must not be `None`" + ) # noqa: E501 self._allocation_percentage = allocation_percentage @@ -130,8 +139,12 @@ def project(self, project): :param project: The project of this Preference. # noqa: E501 :type: Project """ - if self.local_vars_configuration.client_side_validation and project is None: # noqa: E501 - raise ValueError("Invalid value for `project`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and project is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `project`, must not be `None`" + ) # noqa: E501 self._project = project @@ -142,18 +155,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/preference_list_response.py b/patch_api/models/preference_list_response.py index 7ed2d12..0e06bef 100644 --- a/patch_api/models/preference_list_response.py +++ b/patch_api/models/preference_list_response.py @@ -34,20 +34,27 @@ class PreferenceListResponse(object): and the value is json key in definition. """ openapi_types = { - 'success': 'bool', - 'error': 'object', - 'data': 'list[Preference]', - 'meta': 'MetaIndexObject' + "success": "bool", + "error": "object", + "data": "list[Preference]", + "meta": "MetaIndexObject", } attribute_map = { - 'success': 'success', - 'error': 'error', - 'data': 'data', - 'meta': 'meta' + "success": "success", + "error": "error", + "data": "data", + "meta": "meta", } - def __init__(self, success=None, error=None, data=None, meta=None, local_vars_configuration=None): # noqa: E501 + def __init__( + self, + success=None, + error=None, + data=None, + meta=None, + local_vars_configuration=None, + ): # noqa: E501 """PreferenceListResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -82,8 +89,12 @@ def success(self, success): :param success: The success of this PreferenceListResponse. # noqa: E501 :type: bool """ - if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 - raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and success is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `success`, must not be `None`" + ) # noqa: E501 self._success = success @@ -126,8 +137,12 @@ def data(self, data): :param data: The data of this PreferenceListResponse. # noqa: E501 :type: list[Preference] """ - if self.local_vars_configuration.client_side_validation and data is None: # noqa: E501 - raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and data is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `data`, must not be `None`" + ) # noqa: E501 self._data = data @@ -149,8 +164,12 @@ def meta(self, meta): :param meta: The meta of this PreferenceListResponse. # noqa: E501 :type: MetaIndexObject """ - if self.local_vars_configuration.client_side_validation and meta is None: # noqa: E501 - raise ValueError("Invalid value for `meta`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and meta is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `meta`, must not be `None`" + ) # noqa: E501 self._meta = meta @@ -161,18 +180,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/preference_response.py b/patch_api/models/preference_response.py index 4fa0965..73d5fc4 100644 --- a/patch_api/models/preference_response.py +++ b/patch_api/models/preference_response.py @@ -33,19 +33,13 @@ class PreferenceResponse(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'success': 'bool', - 'error': 'object', - 'data': 'Preference' - } - - attribute_map = { - 'success': 'success', - 'error': 'error', - 'data': 'data' - } - - def __init__(self, success=None, error=None, data=None, local_vars_configuration=None): # noqa: E501 + openapi_types = {"success": "bool", "error": "object", "data": "Preference"} + + attribute_map = {"success": "success", "error": "error", "data": "data"} + + def __init__( + self, success=None, error=None, data=None, local_vars_configuration=None + ): # noqa: E501 """PreferenceResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -78,8 +72,12 @@ def success(self, success): :param success: The success of this PreferenceResponse. # noqa: E501 :type: bool """ - if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 - raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and success is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `success`, must not be `None`" + ) # noqa: E501 self._success = success @@ -122,8 +120,12 @@ def data(self, data): :param data: The data of this PreferenceResponse. # noqa: E501 :type: Preference """ - if self.local_vars_configuration.client_side_validation and data is None: # noqa: E501 - raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and data is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `data`, must not be `None`" + ) # noqa: E501 self._data = data @@ -134,18 +136,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/project.py b/patch_api/models/project.py index 9c6dcb4..c1a9ffa 100644 --- a/patch_api/models/project.py +++ b/patch_api/models/project.py @@ -34,36 +34,51 @@ class Project(object): and the value is json key in definition. """ openapi_types = { - 'id': 'str', - 'production': 'bool', - 'name': 'str', - 'description': 'str', - 'type': 'str', - 'country': 'str', - 'developer': 'str', - 'photos': 'list[Photo]', - 'average_price_per_tonne_cents_usd': 'int', - 'remaining_mass_g': 'int', - 'standard': 'Standard', - 'sdgs': 'list[Sdg]' + "id": "str", + "production": "bool", + "name": "str", + "description": "str", + "type": "str", + "country": "str", + "developer": "str", + "photos": "list[Photo]", + "average_price_per_tonne_cents_usd": "int", + "remaining_mass_g": "int", + "standard": "Standard", + "sdgs": "list[Sdg]", } attribute_map = { - 'id': 'id', - 'production': 'production', - 'name': 'name', - 'description': 'description', - 'type': 'type', - 'country': 'country', - 'developer': 'developer', - 'photos': 'photos', - 'average_price_per_tonne_cents_usd': 'average_price_per_tonne_cents_usd', - 'remaining_mass_g': 'remaining_mass_g', - 'standard': 'standard', - 'sdgs': 'sdgs' + "id": "id", + "production": "production", + "name": "name", + "description": "description", + "type": "type", + "country": "country", + "developer": "developer", + "photos": "photos", + "average_price_per_tonne_cents_usd": "average_price_per_tonne_cents_usd", + "remaining_mass_g": "remaining_mass_g", + "standard": "standard", + "sdgs": "sdgs", } - def __init__(self, id=None, production=None, name=None, description=None, type=None, country=None, developer=None, photos=None, average_price_per_tonne_cents_usd=None, remaining_mass_g=None, standard=None, sdgs=None, local_vars_configuration=None): # noqa: E501 + def __init__( + self, + id=None, + production=None, + name=None, + description=None, + type=None, + country=None, + developer=None, + photos=None, + average_price_per_tonne_cents_usd=None, + remaining_mass_g=None, + standard=None, + sdgs=None, + local_vars_configuration=None, + ): # noqa: E501 """Project - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -117,7 +132,9 @@ def id(self, id): :param id: The id of this Project. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and id is None + ): # noqa: E501 raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -142,8 +159,12 @@ def production(self, production): :param production: The production of this Project. # noqa: E501 :type: bool """ - if self.local_vars_configuration.client_side_validation and production is None: # noqa: E501 - raise ValueError("Invalid value for `production`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and production is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `production`, must not be `None`" + ) # noqa: E501 self._production = production @@ -167,8 +188,12 @@ def name(self, name): :param name: The name of this Project. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and name is None: # noqa: E501 - raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and name is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `name`, must not be `None`" + ) # noqa: E501 self._name = name @@ -192,8 +217,12 @@ def description(self, description): :param description: The description of this Project. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and description is None: # noqa: E501 - raise ValueError("Invalid value for `description`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and description is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `description`, must not be `None`" + ) # noqa: E501 self._description = description @@ -217,11 +246,23 @@ def type(self, type): :param type: The type of this Project. # noqa: E501 :type: str """ - allowed_values = ["biomass", "dac", "forestry", "mineralization", "ocean", "renewables", "soil"] # noqa: E501 - if self.local_vars_configuration.client_side_validation and type not in allowed_values: # noqa: E501 + allowed_values = [ + "biomass", + "dac", + "forestry", + "mineralization", + "ocean", + "renewables", + "soil", + ] # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation + and type not in allowed_values + ): # noqa: E501 raise ValueError( - "Invalid value for `type` ({0}), must be one of {1}" # noqa: E501 - .format(type, allowed_values) + "Invalid value for `type` ({0}), must be one of {1}".format( # noqa: E501 + type, allowed_values + ) ) self._type = type @@ -246,8 +287,12 @@ def country(self, country): :param country: The country of this Project. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and country is None: # noqa: E501 - raise ValueError("Invalid value for `country`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and country is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `country`, must not be `None`" + ) # noqa: E501 self._country = country @@ -271,8 +316,12 @@ def developer(self, developer): :param developer: The developer of this Project. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and developer is None: # noqa: E501 - raise ValueError("Invalid value for `developer`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and developer is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `developer`, must not be `None`" + ) # noqa: E501 self._developer = developer @@ -319,8 +368,13 @@ def average_price_per_tonne_cents_usd(self, average_price_per_tonne_cents_usd): :param average_price_per_tonne_cents_usd: The average_price_per_tonne_cents_usd of this Project. # noqa: E501 :type: int """ - if self.local_vars_configuration.client_side_validation and average_price_per_tonne_cents_usd is None: # noqa: E501 - raise ValueError("Invalid value for `average_price_per_tonne_cents_usd`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation + and average_price_per_tonne_cents_usd is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `average_price_per_tonne_cents_usd`, must not be `None`" + ) # noqa: E501 self._average_price_per_tonne_cents_usd = average_price_per_tonne_cents_usd @@ -344,8 +398,13 @@ def remaining_mass_g(self, remaining_mass_g): :param remaining_mass_g: The remaining_mass_g of this Project. # noqa: E501 :type: int """ - if self.local_vars_configuration.client_side_validation and remaining_mass_g is None: # noqa: E501 - raise ValueError("Invalid value for `remaining_mass_g`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation + and remaining_mass_g is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `remaining_mass_g`, must not be `None`" + ) # noqa: E501 self._remaining_mass_g = remaining_mass_g @@ -402,18 +461,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/project_list_response.py b/patch_api/models/project_list_response.py index 7b627cd..466d482 100644 --- a/patch_api/models/project_list_response.py +++ b/patch_api/models/project_list_response.py @@ -34,20 +34,27 @@ class ProjectListResponse(object): and the value is json key in definition. """ openapi_types = { - 'success': 'bool', - 'error': 'object', - 'data': 'list[Project]', - 'meta': 'MetaIndexObject' + "success": "bool", + "error": "object", + "data": "list[Project]", + "meta": "MetaIndexObject", } attribute_map = { - 'success': 'success', - 'error': 'error', - 'data': 'data', - 'meta': 'meta' + "success": "success", + "error": "error", + "data": "data", + "meta": "meta", } - def __init__(self, success=None, error=None, data=None, meta=None, local_vars_configuration=None): # noqa: E501 + def __init__( + self, + success=None, + error=None, + data=None, + meta=None, + local_vars_configuration=None, + ): # noqa: E501 """ProjectListResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -82,8 +89,12 @@ def success(self, success): :param success: The success of this ProjectListResponse. # noqa: E501 :type: bool """ - if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 - raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and success is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `success`, must not be `None`" + ) # noqa: E501 self._success = success @@ -126,8 +137,12 @@ def data(self, data): :param data: The data of this ProjectListResponse. # noqa: E501 :type: list[Project] """ - if self.local_vars_configuration.client_side_validation and data is None: # noqa: E501 - raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and data is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `data`, must not be `None`" + ) # noqa: E501 self._data = data @@ -149,8 +164,12 @@ def meta(self, meta): :param meta: The meta of this ProjectListResponse. # noqa: E501 :type: MetaIndexObject """ - if self.local_vars_configuration.client_side_validation and meta is None: # noqa: E501 - raise ValueError("Invalid value for `meta`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and meta is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `meta`, must not be `None`" + ) # noqa: E501 self._meta = meta @@ -161,18 +180,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/project_response.py b/patch_api/models/project_response.py index 25a1b93..3de074c 100644 --- a/patch_api/models/project_response.py +++ b/patch_api/models/project_response.py @@ -33,19 +33,13 @@ class ProjectResponse(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'success': 'bool', - 'error': 'object', - 'data': 'Project' - } - - attribute_map = { - 'success': 'success', - 'error': 'error', - 'data': 'data' - } - - def __init__(self, success=None, error=None, data=None, local_vars_configuration=None): # noqa: E501 + openapi_types = {"success": "bool", "error": "object", "data": "Project"} + + attribute_map = {"success": "success", "error": "error", "data": "data"} + + def __init__( + self, success=None, error=None, data=None, local_vars_configuration=None + ): # noqa: E501 """ProjectResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -78,8 +72,12 @@ def success(self, success): :param success: The success of this ProjectResponse. # noqa: E501 :type: bool """ - if self.local_vars_configuration.client_side_validation and success is None: # noqa: E501 - raise ValueError("Invalid value for `success`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and success is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `success`, must not be `None`" + ) # noqa: E501 self._success = success @@ -122,8 +120,12 @@ def data(self, data): :param data: The data of this ProjectResponse. # noqa: E501 :type: Project """ - if self.local_vars_configuration.client_side_validation and data is None: # noqa: E501 - raise ValueError("Invalid value for `data`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and data is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `data`, must not be `None`" + ) # noqa: E501 self._data = data @@ -134,18 +136,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/sdg.py b/patch_api/models/sdg.py index 0faebdd..9c3e143 100644 --- a/patch_api/models/sdg.py +++ b/patch_api/models/sdg.py @@ -34,20 +34,27 @@ class Sdg(object): and the value is json key in definition. """ openapi_types = { - 'title': 'str', - 'number': 'int', - 'description': 'str', - 'url': 'str' + "title": "str", + "number": "int", + "description": "str", + "url": "str", } attribute_map = { - 'title': 'title', - 'number': 'number', - 'description': 'description', - 'url': 'url' + "title": "title", + "number": "number", + "description": "description", + "url": "url", } - def __init__(self, title=None, number=None, description=None, url=None, local_vars_configuration=None): # noqa: E501 + def __init__( + self, + title=None, + number=None, + description=None, + url=None, + local_vars_configuration=None, + ): # noqa: E501 """Sdg - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -84,8 +91,12 @@ def title(self, title): :param title: The title of this Sdg. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and title is None: # noqa: E501 - raise ValueError("Invalid value for `title`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and title is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `title`, must not be `None`" + ) # noqa: E501 self._title = title @@ -109,8 +120,12 @@ def number(self, number): :param number: The number of this Sdg. # noqa: E501 :type: int """ - if self.local_vars_configuration.client_side_validation and number is None: # noqa: E501 - raise ValueError("Invalid value for `number`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and number is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `number`, must not be `None`" + ) # noqa: E501 self._number = number @@ -134,8 +149,12 @@ def description(self, description): :param description: The description of this Sdg. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and description is None: # noqa: E501 - raise ValueError("Invalid value for `description`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and description is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `description`, must not be `None`" + ) # noqa: E501 self._description = description @@ -159,8 +178,12 @@ def url(self, url): :param url: The url of this Sdg. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and url is None: # noqa: E501 - raise ValueError("Invalid value for `url`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and url is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `url`, must not be `None`" + ) # noqa: E501 self._url = url @@ -171,18 +194,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/models/standard.py b/patch_api/models/standard.py index 42c874d..40f18a1 100644 --- a/patch_api/models/standard.py +++ b/patch_api/models/standard.py @@ -33,19 +33,13 @@ class Standard(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = { - 'type': 'str', - 'acronym': 'str', - 'description': 'str' - } - - attribute_map = { - 'type': 'type', - 'acronym': 'acronym', - 'description': 'description' - } - - def __init__(self, type=None, acronym=None, description=None, local_vars_configuration=None): # noqa: E501 + openapi_types = {"type": "str", "acronym": "str", "description": "str"} + + attribute_map = {"type": "type", "acronym": "acronym", "description": "description"} + + def __init__( + self, type=None, acronym=None, description=None, local_vars_configuration=None + ): # noqa: E501 """Standard - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration() @@ -80,8 +74,12 @@ def type(self, type): :param type: The type of this Standard. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and type is None: # noqa: E501 - raise ValueError("Invalid value for `type`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and type is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `type`, must not be `None`" + ) # noqa: E501 self._type = type @@ -105,8 +103,12 @@ def acronym(self, acronym): :param acronym: The acronym of this Standard. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and acronym is None: # noqa: E501 - raise ValueError("Invalid value for `acronym`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and acronym is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `acronym`, must not be `None`" + ) # noqa: E501 self._acronym = acronym @@ -130,8 +132,12 @@ def description(self, description): :param description: The description of this Standard. # noqa: E501 :type: str """ - if self.local_vars_configuration.client_side_validation and description is None: # noqa: E501 - raise ValueError("Invalid value for `description`, must not be `None`") # noqa: E501 + if ( + self.local_vars_configuration.client_side_validation and description is None + ): # noqa: E501 + raise ValueError( + "Invalid value for `description`, must not be `None`" + ) # noqa: E501 self._description = description @@ -142,18 +148,20 @@ def to_dict(self): for attr, _ in six.iteritems(self.openapi_types): value = getattr(self, attr) if isinstance(value, list): - result[attr] = list(map( - lambda x: x.to_dict() if hasattr(x, "to_dict") else x, - value - )) + result[attr] = list( + map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) + ) elif hasattr(value, "to_dict"): result[attr] = value.to_dict() elif isinstance(value, dict): - result[attr] = dict(map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") else item, - value.items() - )) + result[attr] = dict( + map( + lambda item: (item[0], item[1].to_dict()) + if hasattr(item[1], "to_dict") + else item, + value.items(), + ) + ) else: result[attr] = value diff --git a/patch_api/rest.py b/patch_api/rest.py index 3e7c44b..1648b30 100644 --- a/patch_api/rest.py +++ b/patch_api/rest.py @@ -20,19 +20,20 @@ import ssl import certifi + # python 2 and python 3 compatibility library import six from six.moves.urllib.parse import urlencode import urllib3 +import urllib.parse from patch_api.exceptions import ApiException, ApiValueError + logger = logging.getLogger(__name__) -import urllib.parse class RESTResponse(io.IOBase): - def __init__(self, resp): self.urllib3_response = resp self.status = resp.status @@ -49,7 +50,6 @@ def getheader(self, name, default=None): class RESTClientObject(object): - def __init__(self, api_key, configuration, pools_size=4, maxsize=None): # urllib3.PoolManager will pass all kw parameters to connectionpool # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 @@ -74,10 +74,12 @@ def __init__(self, api_key, configuration, pools_size=4, maxsize=None): addition_pool_args = {} if configuration.assert_hostname is not None: - addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 + addition_pool_args[ + "assert_hostname" + ] = configuration.assert_hostname # noqa: E501 if configuration.retries is not None: - addition_pool_args['retries'] = configuration.retries + addition_pool_args["retries"] = configuration.retries if maxsize is None: if configuration.connection_pool_maxsize is not None: @@ -116,31 +118,39 @@ def recursive_urlencode(self, d): >>> recursive_urlencode(data) u'a=b%26c&j=k&d[e][f%26g]=h%2Ai' """ + def recursion(d, base=[]): pairs = [] for key, value in d.items(): new_base = base + [key] - if hasattr(value, 'values'): + if hasattr(value, "values"): pairs += recursion(value, new_base) else: new_pair = None if len(new_base) > 1: first = urllib.parse.quote(new_base.pop(0)) rest = map(lambda x: urllib.parse.quote(x), new_base) - new_pair = "%s[%s]=%s" % (first, ']['.join(rest), urllib.parse.quote(str(value))) + new_pair = "%s[%s]=%s" % ( + first, + "][".join(rest), + urllib.parse.quote(str(value)), + ) else: - new_pair = "%s=%s" % (urllib.parse.quote(str(key)), urllib.parse.quote(str(value))) + new_pair = "%s=%s" % ( + urllib.parse.quote(str(key)), + urllib.parse.quote(str(value)), + ) pairs.append(new_pair) return pairs - return '&'.join(recursion(d)) + return "&".join(recursion(d)) def encoded_query_params(self, query_params): if not query_params: - return '' + return "" - final_query_params = '' + final_query_params = "" for key, value in query_params: if isinstance(value, dict): nested_param = {} @@ -149,13 +159,21 @@ def encoded_query_params(self, query_params): query_params.remove((key, value)) if query_params: - final_query_params += '&' + urlencode(query_params) - - return '?' + final_query_params - - def request(self, method, url, query_params=None, headers=None, - body=None, post_params=None, _preload_content=True, - _request_timeout=None): + final_query_params += "&" + urlencode(query_params) + + return "?" + final_query_params + + def request( + self, + method, + url, + query_params=None, + headers=None, + body=None, + post_params=None, + _preload_content=True, + _request_timeout=None, + ): """Perform requests. :param method: http request method @@ -175,8 +193,7 @@ def request(self, method, url, query_params=None, headers=None, (connection, read) timeouts. """ method = method.upper() - assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', - 'PATCH', 'OPTIONS'] + assert method in ["GET", "HEAD", "DELETE", "POST", "PUT", "PATCH", "OPTIONS"] if post_params and body: raise ApiValueError( @@ -188,64 +205,76 @@ def request(self, method, url, query_params=None, headers=None, timeout = None if _request_timeout: - if isinstance(_request_timeout, (int, ) if six.PY3 else (int, long)): # noqa: E501,F821 + if isinstance( + _request_timeout, (int,) if six.PY3 else (int, long) + ): # noqa: E501,F821 timeout = urllib3.Timeout(total=_request_timeout) - elif (isinstance(_request_timeout, tuple) and - len(_request_timeout) == 2): + elif isinstance(_request_timeout, tuple) and len(_request_timeout) == 2: timeout = urllib3.Timeout( - connect=_request_timeout[0], read=_request_timeout[1]) + connect=_request_timeout[0], read=_request_timeout[1] + ) - if 'Content-Type' not in headers: - headers['Content-Type'] = 'application/json' + if "Content-Type" not in headers: + headers["Content-Type"] = "application/json" - if 'Authorization' not in headers: - headers['Authorization'] = 'Bearer ' + self.api_key + if "Authorization" not in headers: + headers["Authorization"] = "Bearer " + self.api_key try: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` - if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: + if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]: url += self.encoded_query_params(query_params) - if re.search('json', headers['Content-Type'], re.IGNORECASE): + if re.search("json", headers["Content-Type"], re.IGNORECASE): request_body = None if body is not None: request_body = json.dumps(body) r = self.pool_manager.request( - method, url, + method, + url, body=request_body, preload_content=_preload_content, timeout=timeout, - headers=headers) - elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 + headers=headers, + ) + elif ( + headers["Content-Type"] == "application/x-www-form-urlencoded" + ): # noqa: E501 r = self.pool_manager.request( - method, url, + method, + url, fields=post_params, encode_multipart=False, preload_content=_preload_content, timeout=timeout, - headers=headers) - elif headers['Content-Type'] == 'multipart/form-data': + headers=headers, + ) + elif headers["Content-Type"] == "multipart/form-data": # must del headers['Content-Type'], or the correct # Content-Type which generated by urllib3 will be # overwritten. - del headers['Content-Type'] + del headers["Content-Type"] r = self.pool_manager.request( - method, url, + method, + url, fields=post_params, encode_multipart=True, preload_content=_preload_content, timeout=timeout, - headers=headers) + headers=headers, + ) # Pass a `string` parameter directly in the body to support # other content types than Json when `body` argument is # provided in serialized form elif isinstance(body, str) or isinstance(body, bytes): request_body = body r = self.pool_manager.request( - method, url, + method, + url, body=request_body, preload_content=_preload_content, timeout=timeout, - headers=headers) + headers=headers, + ) else: # Cannot generate the request from given parameters msg = """Cannot prepare a request message for provided @@ -255,10 +284,13 @@ def request(self, method, url, query_params=None, headers=None, # For `GET`, `HEAD` else: url += self.encoded_query_params(query_params) - r = self.pool_manager.request(method, url, - preload_content=_preload_content, - timeout=timeout, - headers=headers) + r = self.pool_manager.request( + method, + url, + preload_content=_preload_content, + timeout=timeout, + headers=headers, + ) except urllib3.exceptions.SSLError as e: msg = "{0}\n{1}".format(type(e).__name__, str(e)) raise ApiException(status=0, reason=msg) @@ -269,7 +301,7 @@ def request(self, method, url, query_params=None, headers=None, # In the python 3, the response.data is bytes. # we need to decode it to string. if six.PY3: - r.data = r.data.decode('utf8') + r.data = r.data.decode("utf8") # log response body logger.debug("response body: %s", r.data) @@ -279,67 +311,139 @@ def request(self, method, url, query_params=None, headers=None, return r - def GET(self, url, headers=None, query_params=None, _preload_content=True, - _request_timeout=None): - return self.request("GET", url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params) - - def HEAD(self, url, headers=None, query_params=None, _preload_content=True, - _request_timeout=None): - return self.request("HEAD", url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params) - - def OPTIONS(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None): - return self.request("OPTIONS", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def DELETE(self, url, headers=None, query_params=None, body=None, - _preload_content=True, _request_timeout=None): - return self.request("DELETE", url, - headers=headers, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def POST(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None): - return self.request("POST", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def PUT(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None): - return self.request("PUT", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) - - def PATCH(self, url, headers=None, query_params=None, post_params=None, - body=None, _preload_content=True, _request_timeout=None): - return self.request("PATCH", url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body) + def GET( + self, + url, + headers=None, + query_params=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "GET", + url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params, + ) + + def HEAD( + self, + url, + headers=None, + query_params=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "HEAD", + url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params, + ) + + def OPTIONS( + self, + url, + headers=None, + query_params=None, + post_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "OPTIONS", + url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) + + def DELETE( + self, + url, + headers=None, + query_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "DELETE", + url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) + + def POST( + self, + url, + headers=None, + query_params=None, + post_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "POST", + url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) + + def PUT( + self, + url, + headers=None, + query_params=None, + post_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "PUT", + url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) + + def PATCH( + self, + url, + headers=None, + query_params=None, + post_params=None, + body=None, + _preload_content=True, + _request_timeout=None, + ): + return self.request( + "PATCH", + url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body, + ) diff --git a/setup.py b/setup.py index 6e99589..2944ae0 100644 --- a/setup.py +++ b/setup.py @@ -21,9 +21,9 @@ # http://pypi.python.org/pypi/setuptools REQUIRES = [ - "urllib3 >= 1.25.3", - "python-dateutil", - "certifi", + "urllib3 >= 1.25.3", + "python-dateutil", + "certifi", ] setup( @@ -40,5 +40,5 @@ include_package_data=True, long_description="""\ The core API used to integrate with Patch's service # noqa: E501 - """ + """, ) diff --git a/test/test_orders_api.py b/test/test_orders_api.py index 541c6b8..2520384 100644 --- a/test/test_orders_api.py +++ b/test/test_orders_api.py @@ -80,17 +80,19 @@ def test_retrieve_orders(self): def test_create_and_retrieve_order_via_metadata(self): """Test case for create_order and retrieve_orders with metadata""" mass_g = 100 - metadata = { 'external_id': 'abc-123' } + metadata = {"external_id": "abc-123"} order = self.api.create_order(mass_g=mass_g, metadata=metadata) self.assertTrue(order) self.assertEqual(order.data.mass_g, 100) - self.assertEqual(order.data.metadata, { 'external_id': 'abc-123' }) + self.assertEqual(order.data.metadata, {"external_id": "abc-123"}) - retrieved_orders = self.api.retrieve_orders(metadata={ 'external_id': 'abc-' }).data + retrieved_orders = self.api.retrieve_orders( + metadata={"external_id": "abc-"} + ).data self.assertGreater(len(retrieved_orders), 0) for retrieved_order in retrieved_orders: - self.assertTrue('external_id' in retrieved_order.metadata) + self.assertTrue("external_id" in retrieved_order.metadata) if __name__ == "__main__": From 99da46d0fd3d67f735468ae288ab399a8056a706 Mon Sep 17 00:00:00 2001 From: James Klein Date: Tue, 17 Aug 2021 10:36:19 -0600 Subject: [PATCH 06/11] remove ignored files --- .../models/bulk_create_success_response.py | 155 ------------------ 1 file changed, 155 deletions(-) delete mode 100644 patch_api/models/bulk_create_success_response.py diff --git a/patch_api/models/bulk_create_success_response.py b/patch_api/models/bulk_create_success_response.py deleted file mode 100644 index 3e3a222..0000000 --- a/patch_api/models/bulk_create_success_response.py +++ /dev/null @@ -1,155 +0,0 @@ -# coding: utf-8 - -""" - Patch API V1 - - The core API used to integrate with Patch's service # noqa: E501 - - The version of the OpenAPI document: v1 - Contact: developers@usepatch.com - Generated by: https://openapi-generator.tech -""" - - -import pprint -import re # noqa: F401 - -import six - -from patch_api.configuration import Configuration - - -class BulkCreateSuccessResponse(object): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - """ - - """ - Attributes: - openapi_types (dict): The key is attribute name - and the value is attribute type. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - """ - openapi_types = {"success": "bool", "error": "Error"} - - attribute_map = {"success": "success", "error": "error"} - - def __init__( - self, success=None, error=None, local_vars_configuration=None - ): # noqa: E501 - """BulkCreateSuccessResponse - a model defined in OpenAPI""" # noqa: E501 - if local_vars_configuration is None: - local_vars_configuration = Configuration() - self.local_vars_configuration = local_vars_configuration - - self._success = None - self._error = None - self.discriminator = None - - self.success = success - self.error = error - - @property - def success(self): - """Gets the success of this BulkCreateSuccessResponse. # noqa: E501 - - - :return: The success of this BulkCreateSuccessResponse. # noqa: E501 - :rtype: bool - """ - return self._success - - @success.setter - def success(self, success): - """Sets the success of this BulkCreateSuccessResponse. - - - :param success: The success of this BulkCreateSuccessResponse. # noqa: E501 - :type: bool - """ - if ( - self.local_vars_configuration.client_side_validation and success is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `success`, must not be `None`" - ) # noqa: E501 - - self._success = success - - @property - def error(self): - """Gets the error of this BulkCreateSuccessResponse. # noqa: E501 - - - :return: The error of this BulkCreateSuccessResponse. # noqa: E501 - :rtype: Error - """ - return self._error - - @error.setter - def error(self, error): - """Sets the error of this BulkCreateSuccessResponse. - - - :param error: The error of this BulkCreateSuccessResponse. # noqa: E501 - :type: Error - """ - if ( - self.local_vars_configuration.client_side_validation and error is None - ): # noqa: E501 - raise ValueError( - "Invalid value for `error`, must not be `None`" - ) # noqa: E501 - - self._error = error - - def to_dict(self): - """Returns the model properties as a dict""" - result = {} - - for attr, _ in six.iteritems(self.openapi_types): - value = getattr(self, attr) - if isinstance(value, list): - result[attr] = list( - map(lambda x: x.to_dict() if hasattr(x, "to_dict") else x, value) - ) - elif hasattr(value, "to_dict"): - result[attr] = value.to_dict() - elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], item[1].to_dict()) - if hasattr(item[1], "to_dict") - else item, - value.items(), - ) - ) - else: - result[attr] = value - - return result - - def to_str(self): - """Returns the string representation of the model""" - return pprint.pformat(self.to_dict()) - - def __repr__(self): - """For `print` and `pprint`""" - return self.to_str() - - def __eq__(self, other): - """Returns true if both objects are equal""" - if not isinstance(other, BulkCreateSuccessResponse): - return False - - return self.to_dict() == other.to_dict() - - def __ne__(self, other): - """Returns true if both objects are not equal""" - if not isinstance(other, BulkCreateSuccessResponse): - return True - - return self.to_dict() != other.to_dict() From dd1260b8943765b99e067a3bafd70f2a4c8f0aba Mon Sep 17 00:00:00 2001 From: James Klein Date: Tue, 17 Aug 2021 10:43:33 -0600 Subject: [PATCH 07/11] bump version and update changelog --- CHANGELOG.md | 7 +++++++ patch_api/__init__.py | 2 +- patch_api/api_client.py | 2 +- patch_api/configuration.py | 2 +- setup.py | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c52b303..d752984 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ 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.9.0] - 2021-08-17 + +### Added + +- Fixed ability to create Orders with `metadata` +- Add support for querying Orders by `metadata` + ## [1.8.0] - 2021-07-20 ### Added diff --git a/patch_api/__init__.py b/patch_api/__init__.py index 32918e3..fffe9b3 100644 --- a/patch_api/__init__.py +++ b/patch_api/__init__.py @@ -15,7 +15,7 @@ from __future__ import absolute_import -__version__ = "1.8.0" +__version__ = "1.9.0" # import ApiClient from patch_api.api_client import ApiClient diff --git a/patch_api/api_client.py b/patch_api/api_client.py index 5beb1c3..c3e4256 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 = "OpenAPI-Generator/1.8.0/python" + self.user_agent = "OpenAPI-Generator/1.9.0/python" def __del__(self): if self._pool: diff --git a/patch_api/configuration.py b/patch_api/configuration.py index 80ed119..3ae9bee 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.8.0".format(env=sys.platform, pyversion=sys.version) + "SDK Package Version: 1.9.0".format(env=sys.platform, pyversion=sys.version) ) def get_host_settings(self): diff --git a/setup.py b/setup.py index 2944ae0..f4070af 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ from setuptools import setup, find_packages # noqa: H301 NAME = "patch-api" -VERSION = "1.8.0" +VERSION = "1.9.0" # To install the library, run the following # # python setup.py install From 120a79cca59c665cdc083d8188b79cd4f0062b1e Mon Sep 17 00:00:00 2001 From: James Klein Date: Tue, 17 Aug 2021 11:13:00 -0600 Subject: [PATCH 08/11] fix tests --- test/test_estimates_api.py | 6 +++--- test/test_projects_api.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_estimates_api.py b/test/test_estimates_api.py index 34be1fb..84f0c9b 100644 --- a/test/test_estimates_api.py +++ b/test/test_estimates_api.py @@ -53,8 +53,8 @@ def test_create_and_retrieve_flight_estimate(self): distance_m=distance_m, create_order=True ) self.assertEqual(estimate.data.type, "flight") - self.assertEqual(estimate.data.order.mass_g, 1031697) - self.assertEqual(estimate.data.mass_g, 1031697) + self.assertEqual(estimate.data.order.mass_g, 1000622) + self.assertEqual(estimate.data.mass_g, 1000622) retrieved_estimate = self.api.retrieve_estimate(id=estimate.data.id) self.assertTrue(retrieved_estimate) @@ -75,7 +75,7 @@ def test_create_and_retrieve_shipping_estimate(self): ) self.assertEqual(estimate.data.order, None) self.assertEqual(estimate.data.type, "shipping") - self.assertEqual(estimate.data.mass_g, 373) + self.assertEqual(estimate.data.mass_g, 249) retrieved_estimate = self.api.retrieve_estimate(id=estimate.data.id) self.assertTrue(retrieved_estimate) diff --git a/test/test_projects_api.py b/test/test_projects_api.py index a01aa6e..275da69 100644 --- a/test/test_projects_api.py +++ b/test/test_projects_api.py @@ -55,7 +55,7 @@ def test_retrieve_projects(self): self.assertGreater(project.average_price_per_tonne_cents_usd, 0) self.assertGreater(project.remaining_mass_g, 0) self.assertEqual(project.standard, None) - self.assertEqual(project.name, "Patch's Biomass Test Offset Project") + self.assertRegex(project.name, r'Test Offset Project') self.assertTrue(project.description) self.assertEqual(project.country, "US") self.assertEqual(project.type, "biomass") From 38080fbc12c3fac614573207664a40325badb941 Mon Sep 17 00:00:00 2001 From: James Klein Date: Tue, 17 Aug 2021 11:15:02 -0600 Subject: [PATCH 09/11] lint --- test/test_projects_api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_projects_api.py b/test/test_projects_api.py index 275da69..11f2d90 100644 --- a/test/test_projects_api.py +++ b/test/test_projects_api.py @@ -55,7 +55,7 @@ def test_retrieve_projects(self): self.assertGreater(project.average_price_per_tonne_cents_usd, 0) self.assertGreater(project.remaining_mass_g, 0) self.assertEqual(project.standard, None) - self.assertRegex(project.name, r'Test Offset Project') + self.assertRegex(project.name, r"Test Offset Project") self.assertTrue(project.description) self.assertEqual(project.country, "US") self.assertEqual(project.type, "biomass") From ae1bfcc2d81fd0365c14d3a24b0fd91b38753192 Mon Sep 17 00:00:00 2001 From: James Klein Date: Tue, 17 Aug 2021 18:18:08 -0600 Subject: [PATCH 10/11] update from swagger json, add to changelog, and add unit tests --- CHANGELOG.md | 1 + patch_api/api/orders_api.py | 20 ++++++------ patch_api/rest.py | 4 ++- test/test_rest.py | 61 +++++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 11 deletions(-) create mode 100644 test/test_rest.py diff --git a/CHANGELOG.md b/CHANGELOG.md index d752984..0e4245b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed ability to create Orders with `metadata` - Add support for querying Orders by `metadata` +- Added `transaction_value_eth_gwei` as an alternative way to compute transaction level emissions for ethereum ## [1.8.0] - 2021-07-20 diff --git a/patch_api/api/orders_api.py b/patch_api/api/orders_api.py index ecba096..ccaf0f6 100644 --- a/patch_api/api/orders_api.py +++ b/patch_api/api/orders_api.py @@ -620,8 +620,8 @@ def retrieve_orders(self, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param int page: :param str metadata: - :param str metadata_ext_id: - :param str metadata_disregarded: + :param str metadata_example1: + :param str metadata_example2: :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. @@ -648,8 +648,8 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 :param async_req bool: execute request asynchronously :param int page: :param str metadata: - :param str metadata_ext_id: - :param str metadata_disregarded: + :param str metadata_example1: + :param str metadata_example2: :param _return_http_data_only: response data without head status code and headers :param _preload_content: if False, the urllib3.HTTPResponse object will @@ -669,8 +669,8 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 all_params = [ "page", "metadata", - "metadata_ext_id", - "metadata_disregarded", + "metadata_example1", + "metadata_example2", ] # noqa: E501 all_params.append("async_req") all_params.append("_return_http_data_only") @@ -711,13 +711,13 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 query_params.append( ("metadata", local_var_params["metadata"]) ) # noqa: E501 - if "metadata_ext_id" in local_var_params: + if "metadata_example1" in local_var_params: query_params.append( - ("metadata[ext_id]", local_var_params["metadata_ext_id"]) + ("metadata[example1]", local_var_params["metadata_example1"]) ) # noqa: E501 - if "metadata_disregarded" in local_var_params: + if "metadata_example2" in local_var_params: query_params.append( - ("metadata[disregarded]", local_var_params["metadata_disregarded"]) + ("metadata[example2]", local_var_params["metadata_example2"]) ) # noqa: E501 # do not add duplicate keys to query_params list diff --git a/patch_api/rest.py b/patch_api/rest.py index 1648b30..20090ee 100644 --- a/patch_api/rest.py +++ b/patch_api/rest.py @@ -159,7 +159,9 @@ def encoded_query_params(self, query_params): query_params.remove((key, value)) if query_params: - final_query_params += "&" + urlencode(query_params) + if final_query_params: + final_query_params += "&" + final_query_params += urlencode(query_params) return "?" + final_query_params diff --git a/test/test_rest.py b/test/test_rest.py new file mode 100644 index 0000000..77f633e --- /dev/null +++ b/test/test_rest.py @@ -0,0 +1,61 @@ +from __future__ import absolute_import + +from patch_api.configuration import Configuration +from patch_api import rest + +import unittest +import os + +from patch_api.api_client import ApiClient + +class TestRESTClientObject(unittest.TestCase): + def test_recursive_urlencode(self): + """Test that the correct query params get encoded""" + + api_key = os.environ.get("SANDBOX_API_KEY") + configuration = Configuration() + client = rest.RESTClientObject(api_key, configuration) + + encoded_params = client.recursive_urlencode({}) + self.assertEqual(encoded_params, "") + + encoded_params = client.recursive_urlencode({"page": 1}) + self.assertEqual(encoded_params, "page=1") + + encoded_params = client.recursive_urlencode({"string": "value"}) + self.assertEqual(encoded_params, "string=value") + + encoded_params = client.recursive_urlencode( + {"multiple": "values", "top": "level"} + ) + self.assertEqual(encoded_params, "multiple=values&top=level") + + encoded_params = client.recursive_urlencode( + {"metadata": {"some": "arg"}} + ) + self.assertEqual(encoded_params, "metadata[some]=arg") + + encoded_params = client.recursive_urlencode( + {"deeply": {"nested": {"hash": {"of": "args"}}}} + ) + self.assertEqual(encoded_params, "deeply[nested][hash][of]=args") + + def test_encoded_query_params(self): + """Test that the correct query params get encoded""" + + api_key = os.environ.get("SANDBOX_API_KEY") + configuration = Configuration() + client = rest.RESTClientObject(api_key, configuration) + + encoded_params = client.encoded_query_params([]) + self.assertEqual(encoded_params, "") + + encoded_params = client.encoded_query_params([('mass_g', 100)]) + self.assertEqual(encoded_params, "?mass_g=100") + + encoded_params = client.encoded_query_params( + [('mass_g', 100), ('metadata', {'external_id': 'abc-123'})] + ) + self.assertEqual( + encoded_params, "?metadata[external_id]=abc-123&mass_g=100" + ) From 3d146f3bff24b82ac7b3bb25e2b3917a7f5a79ad Mon Sep 17 00:00:00 2001 From: James Klein Date: Wed, 18 Aug 2021 11:14:14 -0600 Subject: [PATCH 11/11] lint --- test/test_rest.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/test/test_rest.py b/test/test_rest.py index 77f633e..490b7a9 100644 --- a/test/test_rest.py +++ b/test/test_rest.py @@ -8,6 +8,7 @@ from patch_api.api_client import ApiClient + class TestRESTClientObject(unittest.TestCase): def test_recursive_urlencode(self): """Test that the correct query params get encoded""" @@ -30,9 +31,7 @@ def test_recursive_urlencode(self): ) self.assertEqual(encoded_params, "multiple=values&top=level") - encoded_params = client.recursive_urlencode( - {"metadata": {"some": "arg"}} - ) + encoded_params = client.recursive_urlencode({"metadata": {"some": "arg"}}) self.assertEqual(encoded_params, "metadata[some]=arg") encoded_params = client.recursive_urlencode( @@ -50,12 +49,10 @@ def test_encoded_query_params(self): encoded_params = client.encoded_query_params([]) self.assertEqual(encoded_params, "") - encoded_params = client.encoded_query_params([('mass_g', 100)]) + encoded_params = client.encoded_query_params([("mass_g", 100)]) self.assertEqual(encoded_params, "?mass_g=100") encoded_params = client.encoded_query_params( - [('mass_g', 100), ('metadata', {'external_id': 'abc-123'})] - ) - self.assertEqual( - encoded_params, "?metadata[external_id]=abc-123&mass_g=100" + [("mass_g", 100), ("metadata", {"external_id": "abc-123"})] ) + self.assertEqual(encoded_params, "?metadata[external_id]=abc-123&mass_g=100")