From 77190eb3c53feb1c9c11d0a36028269ce1ce3f45 Mon Sep 17 00:00:00 2001 From: Paul Cothenet Date: Thu, 1 Jul 2021 17:44:42 -0700 Subject: [PATCH 1/9] Add bitcoin and registry_url --- patch_api/__init__.py | 2 +- patch_api/api/estimates_api.py | 703 ++++++++++--------- patch_api/api/orders_api.py | 418 +++++------ patch_api/api/preferences_api.py | 344 +++++---- patch_api/api/projects_api.py | 186 +++-- patch_api/api_client.py | 423 +++++------ patch_api/configuration.py | 84 ++- patch_api/exceptions.py | 12 +- patch_api/models/allocation.py | 60 +- 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 | 195 +++-- 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 | 10 +- 28 files changed, 1666 insertions(+), 2139 deletions(-) diff --git a/patch_api/__init__.py b/patch_api/__init__.py index ff02840..7c132ae 100644 --- a/patch_api/__init__.py +++ b/patch_api/__init__.py @@ -15,7 +15,7 @@ from __future__ import absolute_import -__version__ = "1.5.2" +__version__ = "1.6.0" # import ApiClient from patch_api.api_client import ApiClient diff --git a/patch_api/api/estimates_api.py b/patch_api/api/estimates_api.py index cad0c13..7f46cc3 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,25 +32,148 @@ 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", + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year" ] def __init__(self, api_client=None): self.api_client = api_client - def create_flight_estimate( - self, create_flight_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 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.create_bitcoin_estimate(create_bitcoin_estimate_request, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param CreateBitcoinEstimateRequest create_bitcoin_estimate_request: (required) + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: EstimateResponse + 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 + """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 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.create_bitcoin_estimate_with_http_info(create_bitcoin_estimate_request, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param CreateBitcoinEstimateRequest create_bitcoin_estimate_request: (required) + :param _return_http_data_only: response data without head status code + and headers + :param _preload_content: if False, the urllib3.HTTPResponse object will + be returned without reading/decoding response + data. Default is True. + :param _request_timeout: timeout setting for this request. If one + number provided, it will be total request + timeout. It can also be a pair (tuple) of + (connection, read) timeouts. + :return: tuple(EstimateResponse, status_code(int), headers(HTTPHeaderDict)) + If the method is called asynchronously, + returns the request thread. + """ + + 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') + + 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'] + # 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 + + collection_formats = {} + + path_params = {} + + query_params = [] + for key in kwargs: + query_params.append([key, kwargs.get(key)]) + + header_params = {} + + form_params = [] + local_var_files = {} + + body_params = None + 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 + + # HTTP header `Content-Type` + 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 + + return self.api_client.call_api( + '/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 + 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 """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 @@ -69,14 +195,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 @@ -103,39 +225,35 @@ 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") - - 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') + + 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 = {} @@ -151,46 +269,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 @@ -212,14 +320,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 @@ -246,39 +350,35 @@ 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") - - 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') + + 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 = {} @@ -294,46 +394,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 @@ -355,14 +445,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 @@ -389,39 +475,35 @@ 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") - - 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') + + 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 = {} @@ -437,46 +519,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 @@ -498,14 +570,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 @@ -532,39 +600,35 @@ 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") - - 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') + + 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 = {} @@ -580,42 +644,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 @@ -639,7 +695,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 @@ -669,42 +725,41 @@ 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") - - 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') + + 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: @@ -717,32 +772,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 @@ -766,7 +816,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 @@ -796,31 +846,31 @@ 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") - - 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') + + 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 = {} @@ -829,8 +879,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 = {} @@ -839,29 +889,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 96175f1..43e8753 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,17 +32,17 @@ 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", + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year" ] def __init__(self, api_client=None): @@ -48,7 +51,7 @@ def __init__(self, api_client=None): def cancel_order(self, id={}, **kwargs): # noqa: E501 """Cancel an order # noqa: E501 - Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` state can be cancelled. # noqa: E501 + Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` or `placed` state can be cancelled. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.cancel_order(id, async_req=True) @@ -67,13 +70,13 @@ 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 """Cancel an order # noqa: E501 - Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` state can be cancelled. # noqa: E501 + Cancelling an order removes the associated offset allocation from an order. You will not be charged for cancelled orders. Only orders in the `draft` or `placed` state can be cancelled. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.cancel_order_with_http_info(id, async_req=True) @@ -97,42 +100,41 @@ 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") - - 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') + + 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: @@ -145,32 +147,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 @@ -194,10 +191,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 @@ -226,39 +221,35 @@ 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") - - 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') + + 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 = {} @@ -274,42 +265,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 @@ -333,7 +316,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 @@ -363,42 +346,41 @@ 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") - - 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') + + 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: @@ -411,32 +393,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 @@ -460,7 +437,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 @@ -490,42 +467,41 @@ 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") - - 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') + + 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: @@ -538,32 +514,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 @@ -587,7 +558,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 @@ -617,31 +588,31 @@ 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") - - 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') + + 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 = {} @@ -650,8 +621,8 @@ 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 header_params = {} @@ -660,29 +631,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 188fa57..1d872f0 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,17 +32,17 @@ 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", + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year" ] def __init__(self, api_client=None): @@ -67,14 +70,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 @@ -101,39 +100,35 @@ 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") - - 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') + + 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 = {} @@ -149,42 +144,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 @@ -208,7 +195,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 @@ -238,42 +225,41 @@ 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") - - 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') + + 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: @@ -286,32 +272,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 @@ -335,7 +316,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 @@ -365,42 +346,41 @@ 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") - - 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') + + 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: @@ -413,32 +393,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 @@ -462,7 +437,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 @@ -492,31 +467,31 @@ 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") - - 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') + + 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 = {} @@ -525,8 +500,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 = {} @@ -535,29 +510,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 9111de5..0f41cea 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,17 +32,17 @@ 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", + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year" ] def __init__(self, api_client=None): @@ -67,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 @@ -97,42 +100,41 @@ 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") - - 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') + + 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: @@ -145,32 +147,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 @@ -197,7 +194,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 @@ -230,31 +227,31 @@ 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") - - 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') + + 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 = {} @@ -263,16 +260,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 = {} @@ -281,29 +276,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 12c37cd..b4fbed9 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.5.2/python" + self.user_agent = 'OpenAPI-Generator/1.6.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,24 +635,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 82120b3..ab479cb 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.5.2".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.6.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/error_response.py b/patch_api/models/error_response.py index 8303054..efb6ee8 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': '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() @@ -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 @@ -99,12 +101,8 @@ 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 @@ -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..0d98c3a 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 @@ -153,12 +139,8 @@ 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 @@ -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 8274f28..576958f 100644 --- a/patch_api/models/order.py +++ b/patch_api/models/order.py @@ -34,42 +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": "str", - "patch_fee_cents_usd": "str", - "allocations": "list[Allocation]", - "metadata": "object", + 'id': 'str', + 'mass_g': 'int', + 'production': 'bool', + 'state': 'str', + 'allocation_state': 'str', + 'price_cents_usd': 'str', + 'patch_fee_cents_usd': 'str', + '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", - "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, - 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() @@ -83,6 +73,7 @@ def __init__( self._price_cents_usd = None self._patch_fee_cents_usd = None self._allocations = None + self._registry_url = None self._metadata = None self.discriminator = None @@ -94,6 +85,8 @@ def __init__( self.price_cents_usd = price_cents_usd self.patch_fee_cents_usd = patch_fee_cents_usd self.allocations = allocations + if registry_url is not None: + self.registry_url = registry_url self.metadata = metadata @property @@ -116,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 @@ -143,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 @@ -188,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 @@ -217,21 +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 - raise ValueError( - "Invalid value for `state`, must not be `None`" - ) # noqa: E501 - allowed_values = ["draft", "placed", "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`, 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 @@ -256,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 @@ -342,15 +298,34 @@ 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 + @property + def registry_url(self): + """Gets the registry_url of this Order. # noqa: E501 + + The url of this order in the public registry. # noqa: E501 + + :return: The registry_url of this Order. # noqa: E501 + :rtype: str + """ + return self._registry_url + + @registry_url.setter + def registry_url(self, registry_url): + """Sets the registry_url of this Order. + + The url of this order in the public registry. # noqa: E501 + + :param registry_url: The registry_url of this Order. # noqa: E501 + :type: str + """ + + self._registry_url = registry_url + @property def metadata(self): """Gets the metadata of this Order. # noqa: E501 @@ -371,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 @@ -387,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 ac958ec..9ca67a6 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ from setuptools import setup, find_packages # noqa: H301 NAME = "patch-api" -VERSION = "1.5.2" +VERSION = "1.6.0" # To install the library, run the following # # python setup.py install @@ -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 dcff65d99e79cafa06747955644a5b804209519f Mon Sep 17 00:00:00 2001 From: Paul Cothenet Date: Wed, 14 Jul 2021 00:12:01 +0200 Subject: [PATCH 2/9] Fix existing test --- .github/workflows/black.yml | 13 ------------- .github/workflows/test.yml | 7 +++++++ CHANGELOG.md | 7 +++++++ Makefile | 3 --- README.md | 30 +++++++++++++++++------------- test/test_projects_api.py | 4 ++-- 6 files changed, 33 insertions(+), 31 deletions(-) delete mode 100644 .github/workflows/black.yml diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml deleted file mode 100644 index 9f371ef..0000000 --- a/.github/workflows/black.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: Lint -on: - push: - branches: - - main - pull_request: -jobs: - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - - uses: psf/black@stable diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f8dbf2a..4457110 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,6 +6,13 @@ on: pull_request: jobs: + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - uses: psf/black@stable + build-and-test: runs-on: ubuntu-latest name: Python Library tests diff --git a/CHANGELOG.md b/CHANGELOG.md index c036929..a7163ee 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.6.0] - 2021-07-14 + +### Added + +- Order responses return a `registry_url` field +- Add support for Bitcoin estimates + ## [1.5.2] - 2021-03-30 ### Fixed diff --git a/Makefile b/Makefile index 1cebf71..8de6c50 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,6 @@ build: pip install -r requirements.txt && \ python setup.py install -lint: - pre-commit - test: pip install -r test-requirements.txt && \ pip install -r requirements.txt && \ diff --git a/README.md b/README.md index 6475a9f..83fdfda 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,10 @@ model = "Corolla" year = 1995 patch.estimates.create_mass_estimate(distance_m=distance_m, make=make, model=model, year=year) +# Create a bitcoin estimate +transaction_value_btc_sats = 1000; # [Optional] Pass in the transaction value in satoshis +patch.estimates.create_bitcoin_estimate(transaction_value_btc_sats=transaction_value_btc_sats) + # Retrieve an estimate estimate_id = 'est_test_1234' patch.estimates.retrieve_estimate(id=estimate_id) @@ -222,41 +226,41 @@ patch.preferences.retrieve_preferences(page=page) Set up the required environment variable: -``` -$ export SANDBOX_API_KEY= +```bash +export SANDBOX_API_KEY= ``` Run tests: -``` -$ make test +```bash +make test ``` To run an individual test: -``` -$ python -m unittest +```bash +python -m unittest ``` ### Testing the built package locally To build the library locally, run: -``` -$ make build +```bash +make build ``` In another directory, create a file called `patch.py` and install the local package in this directory: -``` -$ touch patch.py -$ pip install ../patch-python +```bash +touch patch.py +pip install ../patch-python ``` Set up the required environment variable: -``` -$ export SANDBOX_API_KEY= +```bash +export SANDBOX_API_KEY= ``` To test the package locally, create a python file in a sibling directory and add the following: diff --git a/test/test_projects_api.py b/test/test_projects_api.py index 7f58ff6..a01aa6e 100644 --- a/test/test_projects_api.py +++ b/test/test_projects_api.py @@ -55,11 +55,11 @@ 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, "Carbo Culture Biochar") + self.assertEqual(project.name, "Patch's Biomass Test Offset Project") self.assertTrue(project.description) self.assertEqual(project.country, "US") self.assertEqual(project.type, "biomass") - self.assertEqual(project.developer, "Carbo Culture") + self.assertEqual(project.developer, "Patch Sandbox Supplier Test") self.assertTrue(isinstance(project.photos, list)) def test_retrieve_biomass_projects(self): From a40c57ec4c7dc09766b8ef8418df54f8ccf29be6 Mon Sep 17 00:00:00 2001 From: Paul Cothenet Date: Wed, 14 Jul 2021 15:04:55 +0200 Subject: [PATCH 3/9] Reformat files --- patch_api/api/estimates_api.py | 680 +++++++++++-------- patch_api/api/orders_api.py | 414 +++++------ patch_api/api/preferences_api.py | 344 +++++----- patch_api/api/projects_api.py | 186 ++--- patch_api/api_client.py | 423 +++++++----- patch_api/configuration.py | 84 +-- patch_api/exceptions.py | 12 +- patch_api/models/allocation.py | 60 +- 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 | 297 +++++--- setup.py | 8 +- 27 files changed, 2204 insertions(+), 1553 deletions(-) diff --git a/patch_api/api/estimates_api.py b/patch_api/api/estimates_api.py index 7f46cc3..1d366cd 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,23 +29,25 @@ 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" + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year", ] 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 @@ -70,10 +69,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 @@ -100,35 +103,39 @@ 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') - - 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") + + 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 = {} @@ -144,36 +151,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_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 @@ -195,10 +212,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 @@ -225,35 +246,39 @@ 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') - - 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") + + 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 = {} @@ -269,36 +294,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 @@ -320,10 +355,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 @@ -350,35 +389,39 @@ 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') - - 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") + + 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 = {} @@ -394,36 +437,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 @@ -445,10 +498,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 @@ -475,35 +532,39 @@ 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') - - 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") + + 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 = {} @@ -519,36 +580,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 @@ -570,10 +641,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 @@ -600,35 +675,39 @@ 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') - - 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") + + 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 = {} @@ -644,34 +723,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 @@ -695,7 +782,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 @@ -725,41 +812,42 @@ 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') - - 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") + + 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: @@ -772,27 +860,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 @@ -816,7 +909,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 @@ -846,31 +939,31 @@ 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') - - 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") + + 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 = {} @@ -879,8 +972,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 = {} @@ -889,24 +982,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 43e8753..6c62010 100644 --- a/patch_api/api/orders_api.py +++ b/patch_api/api/orders_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 OrdersApi(object): @@ -32,17 +29,17 @@ 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" + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year", ] def __init__(self, api_client=None): @@ -70,7 +67,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,41 +97,42 @@ 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') - - 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") + + 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: @@ -147,27 +145,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 @@ -191,8 +194,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 @@ -221,35 +226,39 @@ 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') - - 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") + + 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 = {} @@ -265,34 +274,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 @@ -316,7 +333,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 @@ -346,41 +363,42 @@ 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') - - 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") + + 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: @@ -393,27 +411,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 @@ -437,7 +460,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 @@ -467,41 +490,42 @@ 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') - - 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") + + 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: @@ -514,27 +538,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 @@ -558,7 +587,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 @@ -588,31 +617,31 @@ 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') - - 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") + + 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 = {} @@ -621,8 +650,8 @@ 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 header_params = {} @@ -631,24 +660,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 1d872f0..188fa57 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,17 +29,17 @@ 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" + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year", ] def __init__(self, api_client=None): @@ -70,10 +67,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 @@ -100,35 +101,39 @@ 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') - - 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") + + 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 = {} @@ -144,34 +149,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 @@ -195,7 +208,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 @@ -225,41 +238,42 @@ 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') - - 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") + + 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: @@ -272,27 +286,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 @@ -316,7 +335,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 @@ -346,41 +365,42 @@ 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') - - 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") + + 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: @@ -393,27 +413,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 @@ -437,7 +462,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 @@ -467,31 +492,31 @@ 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') - - 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") + + 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 = {} @@ -500,8 +525,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 = {} @@ -510,24 +535,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 0f41cea..9111de5 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,17 +29,17 @@ 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" + "mass_g", + "total_price_cents_usd", + "project_id", + "page", + "distance_m", + "transportation_method", + "package_mass_g", + "create_order", + "model", + "make", + "year", ] def __init__(self, api_client=None): @@ -70,7 +67,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,41 +97,42 @@ 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') - - 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") + + 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: @@ -147,27 +145,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 @@ -194,7 +197,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 @@ -227,31 +230,31 @@ 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') - - 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") + + 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 = {} @@ -260,14 +263,16 @@ 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 = {} @@ -276,24 +281,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 b4fbed9..2d57a77 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.6.0/python' + self.user_agent = "OpenAPI-Generator/1.6.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 ab479cb..97c5995 100644 --- a/patch_api/configuration.py +++ b/patch_api/configuration.py @@ -56,13 +56,16 @@ 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 """ @@ -98,7 +101,7 @@ def __init__(self, host="https://api.patch.io", """ 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="https://api.patch.io", 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.6.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.6.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/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 0d98c3a..e767292 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 576958f..c9559d9 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': 'str', - 'patch_fee_cents_usd': 'str', - 'allocations': 'list[Allocation]', - 'registry_url': 'str', - 'metadata': 'object' + "id": "str", + "mass_g": "int", + "production": "bool", + "state": "str", + "allocation_state": "str", + "price_cents_usd": "str", + "patch_fee_cents_usd": "str", + "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 f415203..f67e65f 100644 --- a/patch_api/rest.py +++ b/patch_api/rest.py @@ -20,6 +20,7 @@ import ssl import certifi + # python 2 and python 3 compatibility library import six from six.moves.urllib.parse import urlencode @@ -32,7 +33,6 @@ class RESTResponse(io.IOBase): - def __init__(self, resp): self.urllib3_response = resp self.status = resp.status @@ -49,7 +49,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 +73,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: @@ -109,9 +110,17 @@ 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 @@ -131,8 +140,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( @@ -144,65 +152,77 @@ 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"]: 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 @@ -211,11 +231,14 @@ def request(self, method, url, query_params=None, headers=None, 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) @@ -226,7 +249,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) @@ -236,67 +259,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 9ca67a6..7993f67 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 aa607cd0a26266d4a6253613c28d34c6b6eeed0b Mon Sep 17 00:00:00 2001 From: Paul Cothenet Date: Wed, 14 Jul 2021 15:12:58 +0200 Subject: [PATCH 4/9] Inline black --- Makefile | 4 ++++ README.md | 8 ++++++++ test-requirements.txt | 1 + 3 files changed, 13 insertions(+) diff --git a/Makefile b/Makefile index 8de6c50..5d1db3e 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,10 @@ build: pip install -r requirements.txt && \ python setup.py install +lint: + pip install -r test-requirements.txt && \ + black . + test: pip install -r test-requirements.txt && \ pip install -r requirements.txt && \ diff --git a/README.md b/README.md index 83fdfda..e5ef808 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,14 @@ patch.preferences.retrieve_preferences(page=page) ## Development +### Linter + +This project uses black for code formatting. To run the automatic formatting, run: + +```bash +make lint +``` + ### Running tests Set up the required environment variable: diff --git a/test-requirements.txt b/test-requirements.txt index 4ed3991..86f8e70 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,3 +1,4 @@ +black>=21.6b0 pytest~=4.6.7 # needed for python 2.7+3.4 pytest-cov>=2.8.1 pytest-randomly==1.2.3 # needed for python 2.7+3.4 From e267c6f5a9ea63d7e8d757a2fce62697b3e08a80 Mon Sep 17 00:00:00 2001 From: Paul Cothenet Date: Wed, 14 Jul 2021 15:29:05 +0200 Subject: [PATCH 5/9] Add bitcoin test --- README.md | 2 +- patch_api/api/estimates_api.py | 16 ++++++++++++++++ patch_api/api/orders_api.py | 12 ++++++++++++ patch_api/api/preferences_api.py | 10 ++++++++++ patch_api/api/projects_api.py | 6 ++++++ test-requirements.txt | 1 - test/test_estimates_api.py | 23 +++++++++++++++++++++++ 7 files changed, 68 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e5ef808..9ef809b 100644 --- a/README.md +++ b/README.md @@ -247,7 +247,7 @@ make test To run an individual test: ```bash -python -m unittest +python -m unittest test/xxx_test.py ``` ### Testing the built package locally diff --git a/patch_api/api/estimates_api.py b/patch_api/api/estimates_api.py index 1d366cd..e4b6070 100644 --- a/patch_api/api/estimates_api.py +++ b/patch_api/api/estimates_api.py @@ -40,6 +40,8 @@ class EstimatesApi(object): "model", "make", "year", + "transaction_value_btc_sats", + "timestamp", ] def __init__(self, api_client=None): @@ -119,6 +121,8 @@ def create_bitcoin_estimate_with_http_info( all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -262,6 +266,8 @@ def create_flight_estimate_with_http_info( all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -405,6 +411,8 @@ def create_mass_estimate_with_http_info( all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -548,6 +556,8 @@ def create_shipping_estimate_with_http_info( all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -691,6 +701,8 @@ def create_vehicle_estimate_with_http_info( all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -828,6 +840,8 @@ def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -955,6 +969,8 @@ def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501 all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: diff --git a/patch_api/api/orders_api.py b/patch_api/api/orders_api.py index 6c62010..995e1a1 100644 --- a/patch_api/api/orders_api.py +++ b/patch_api/api/orders_api.py @@ -40,6 +40,8 @@ class OrdersApi(object): "model", "make", "year", + "transaction_value_btc_sats", + "timestamp", ] def __init__(self, api_client=None): @@ -113,6 +115,8 @@ def cancel_order_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -242,6 +246,8 @@ def create_order_with_http_info(self, create_order_request, **kwargs): # noqa: all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -379,6 +385,8 @@ def place_order_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -506,6 +514,8 @@ def retrieve_order_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -633,6 +643,8 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: diff --git a/patch_api/api/preferences_api.py b/patch_api/api/preferences_api.py index 188fa57..bcac4e0 100644 --- a/patch_api/api/preferences_api.py +++ b/patch_api/api/preferences_api.py @@ -40,6 +40,8 @@ class PreferencesApi(object): "model", "make", "year", + "transaction_value_btc_sats", + "timestamp", ] def __init__(self, api_client=None): @@ -117,6 +119,8 @@ def create_preference_with_http_info( all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -254,6 +258,8 @@ def delete_preference_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -381,6 +387,8 @@ def retrieve_preference_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -508,6 +516,8 @@ def retrieve_preferences_with_http_info(self, **kwargs): # noqa: E501 all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: diff --git a/patch_api/api/projects_api.py b/patch_api/api/projects_api.py index 9111de5..4374966 100644 --- a/patch_api/api/projects_api.py +++ b/patch_api/api/projects_api.py @@ -40,6 +40,8 @@ class ProjectsApi(object): "model", "make", "year", + "transaction_value_btc_sats", + "timestamp", ] def __init__(self, api_client=None): @@ -113,6 +115,8 @@ def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -246,6 +250,8 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501 all_params.append("make") all_params.append("model") all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: diff --git a/test-requirements.txt b/test-requirements.txt index 86f8e70..4ed3991 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,4 +1,3 @@ -black>=21.6b0 pytest~=4.6.7 # needed for python 2.7+3.4 pytest-cov>=2.8.1 pytest-randomly==1.2.3 # needed for python 2.7+3.4 diff --git a/test/test_estimates_api.py b/test/test_estimates_api.py index d987032..0efca3b 100644 --- a/test/test_estimates_api.py +++ b/test/test_estimates_api.py @@ -115,6 +115,29 @@ def test_create_and_retrieve_vehicle_estimate_best_match(self): retrieved_estimate = self.api.retrieve_estimate(id=estimate.data.id) self.assertTrue(retrieved_estimate) + def test_create_bitcoin_estimate_no_params(self): + """Test case for create_bitcoin_estimate + + Create an estimate based on a transaction amount # noqa: E501 + """ + transaction_value_btc_sats = 100000 + + estimate = self.api.create_bitcoin_estimate() + self.assertEqual(estimate.data.type, "bitcoin") + self.assertGreater(estimate.data.mass_g, 200) # not setting an exact value since this is changing daily + + def test_create_bitcoin_estimate_transaction_value(self): + """Test case for create_bitcoin_estimate + + Create an estimate based on a transaction amount # noqa: E501 + """ + transaction_value_btc_sats = 100000 + + estimate = self.api.create_bitcoin_estimate( + transaction_value_btc_sats=transaction_value_btc_sats + ) + self.assertEqual(estimate.data.type, "bitcoin") + self.assertGreater(estimate.data.mass_g, 200) # not setting an exact value since this is changing daily if __name__ == "__main__": unittest.main() From 0a7659d28556f68686e8e43f723b2f568e54fc23 Mon Sep 17 00:00:00 2001 From: Paul Cothenet Date: Wed, 14 Jul 2021 15:38:11 +0200 Subject: [PATCH 6/9] Autoformat --- test/test_estimates_api.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/test/test_estimates_api.py b/test/test_estimates_api.py index 0efca3b..c09905c 100644 --- a/test/test_estimates_api.py +++ b/test/test_estimates_api.py @@ -124,7 +124,9 @@ def test_create_bitcoin_estimate_no_params(self): estimate = self.api.create_bitcoin_estimate() self.assertEqual(estimate.data.type, "bitcoin") - self.assertGreater(estimate.data.mass_g, 200) # not setting an exact value since this is changing daily + self.assertGreater( + estimate.data.mass_g, 200 + ) # not setting an exact value since this is changing daily def test_create_bitcoin_estimate_transaction_value(self): """Test case for create_bitcoin_estimate @@ -137,7 +139,10 @@ def test_create_bitcoin_estimate_transaction_value(self): transaction_value_btc_sats=transaction_value_btc_sats ) self.assertEqual(estimate.data.type, "bitcoin") - self.assertGreater(estimate.data.mass_g, 200) # not setting an exact value since this is changing daily + self.assertGreater( + estimate.data.mass_g, 200 + ) # not setting an exact value since this is changing daily + if __name__ == "__main__": unittest.main() From 6292ee39f84b9347b094155bfc93fb6fcd55f3f3 Mon Sep 17 00:00:00 2001 From: Paul Cothenet Date: Wed, 14 Jul 2021 15:43:53 +0200 Subject: [PATCH 7/9] Pre-commit instructions --- .pre-commit-config.yaml | 16 ++++++++-------- README.md | 7 +++++++ test-requirements.txt | 1 + 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 53ad7c4..5c59878 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,11 @@ repos: -- repo: https://github.com/ambv/black - rev: stable - hooks: - - id: black - language_version: python3.6 - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v1.2.3 + rev: v2.3.0 + hooks: + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace +- repo: https://github.com/psf/black + rev: 21.6b0 hooks: - - id: flake8 - args: ['--config=.flake8'] + - id: black diff --git a/README.md b/README.md index 9ef809b..ef15b0e 100644 --- a/README.md +++ b/README.md @@ -222,6 +222,13 @@ patch.preferences.retrieve_preferences(page=page) ## Development +### Pre-commit + +This project uses pre-commit to automatically lint code on commit. Set-up lint commit the first time around using +``` +pre-commit install +``` + ### Linter This project uses black for code formatting. To run the automatic formatting, run: diff --git a/test-requirements.txt b/test-requirements.txt index 4ed3991..86f8e70 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,3 +1,4 @@ +black>=21.6b0 pytest~=4.6.7 # needed for python 2.7+3.4 pytest-cov>=2.8.1 pytest-randomly==1.2.3 # needed for python 2.7+3.4 From 6777e3fe0b583637fd757f38f66c56767d93dd99 Mon Sep 17 00:00:00 2001 From: Paul Cothenet Date: Wed, 14 Jul 2021 15:48:16 +0200 Subject: [PATCH 8/9] Fix flake8 --- .pre-commit-config.yaml | 10 ++++++---- test/test_estimates_api.py | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5c59878..39aaa05 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,10 +2,12 @@ repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v2.3.0 hooks: - - id: check-yaml - - id: end-of-file-fixer - - id: trailing-whitespace + - id: check-yaml + - id: end-of-file-fixer + - id: trailing-whitespace + - id: flake8 + args: ['--config=.flake8'] - repo: https://github.com/psf/black rev: 21.6b0 hooks: - - id: black + - id: black diff --git a/test/test_estimates_api.py b/test/test_estimates_api.py index c09905c..65af346 100644 --- a/test/test_estimates_api.py +++ b/test/test_estimates_api.py @@ -120,7 +120,6 @@ def test_create_bitcoin_estimate_no_params(self): Create an estimate based on a transaction amount # noqa: E501 """ - transaction_value_btc_sats = 100000 estimate = self.api.create_bitcoin_estimate() self.assertEqual(estimate.data.type, "bitcoin") From e71d93795ff5818e00d816796f4243896b11763d Mon Sep 17 00:00:00 2001 From: Paul Cothenet Date: Wed, 14 Jul 2021 18:36:04 +0200 Subject: [PATCH 9/9] Remove ; --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ef15b0e..29e6ab7 100644 --- a/README.md +++ b/README.md @@ -140,7 +140,7 @@ year = 1995 patch.estimates.create_mass_estimate(distance_m=distance_m, make=make, model=model, year=year) # Create a bitcoin estimate -transaction_value_btc_sats = 1000; # [Optional] Pass in the transaction value in satoshis +transaction_value_btc_sats = 1000 # [Optional] Pass in the transaction value in satoshis patch.estimates.create_bitcoin_estimate(transaction_value_btc_sats=transaction_value_btc_sats) # Retrieve an estimate