diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b5662c..397c077 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,10 +5,16 @@ 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.3.0] - 2021-02-08 + +### Added + +- Adds support for creating Shipping/Flight/Vehicle estimates. +- Sets the library version to 1.3.0 to track the [Patch Ruby SDK](https://github.com/patch-technology/patch-ruby) and [Patch Node SDK](https://github.com/patch-technology/patch-node). + ## [1.0.1] - 2021-01-22 ### Added - Pre-release of v1 Library - Adds support for Orders, Estimates, Projects and Preferences - diff --git a/Makefile b/Makefile index fc29b0b..1cebf71 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ SHELL = /bin/bash build: - pip install -r requirements.txt \ + pip install -r requirements.txt && \ python setup.py install lint: @@ -12,4 +12,4 @@ test: pip install -r requirements.txt && \ python -m unittest discover test/ -.PHONY: build test lint publish +.PHONY: build lint test diff --git a/README.md b/README.md index bdee7fc..f5c31b7 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ For a complete API reference, check out [Patch's API Reference.](https://docs.us Add the library to your `requirements.txt` file: ```txt -patch_api >= 1.0.1 +patch_api >= 1.3.0 ``` Then run: @@ -105,7 +105,6 @@ import patch_api patch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY')) # Create an estimate - mass_g = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne) patch.estimates.create_estimate(mass_g=mass_g) @@ -113,6 +112,23 @@ patch.estimates.create_estimate(mass_g=mass_g) project_id = 'pro_test_1234' # Pass in the project's ID patch.estimates.create_estimate(mass_g=mass_g, project_id=project_id) +# Create a flight estimate +distance_m = 1_000_000 # Pass in the distance traveled in meters +patch.estimates.create_estimate(distance_m=distance_m) + +# Create a shipping estimate +distance_m = 1_000_000 # Pass in the distance traveled in meters +transportation_method = "rail" +package_mass_g = 5000 +patch.estimates.create_estimate(distance_m=distance_m, transportation_method=transportation_method, package_mass_g=package_mass_g) + +# Create a vehicle estimate +distance_m = 1_000_000 # Pass in the distance traveled in meters +make = "Toyota" +model = "Corolla" +year = 1995 +patch.estimates.create_estimate(distance_m=distance_m, make=make, model=model, year=year) + # Retrieve an estimate estimate_id = 'est_test_1234' patch.estimates.retrieve_estimate(id=estimate_id) diff --git a/patch_api/__init__.py b/patch_api/__init__.py index 5cb843d..186e10c 100644 --- a/patch_api/__init__.py +++ b/patch_api/__init__.py @@ -15,7 +15,7 @@ from __future__ import absolute_import -__version__ = "1.0.0" +__version__ = "1.3.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 07f42ac..2ac3624 100644 --- a/patch_api/api/estimates_api.py +++ b/patch_api/api/estimates_api.py @@ -28,11 +28,166 @@ class EstimatesApi(object): Do not edit the class manually. """ - ALLOWED_QUERY_PARAMS = ["mass_g", "price_cents_usd", "project_id", "page"] + ALLOWED_QUERY_PARAMS = [ + "mass_g", + "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 + """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 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.create_flight_estimate(create_flight_estimate_request, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param CreateFlightEstimateRequest create_flight_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_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 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.create_flight_estimate_with_http_info(create_flight_estimate_request, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param CreateFlightEstimateRequest create_flight_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_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("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"] + # 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 + + 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_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 + + # 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/flight", + "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_mass_estimate( self, create_mass_estimate_request={}, **kwargs ): # noqa: E501 @@ -100,6 +255,13 @@ def create_mass_estimate_with_http_info( all_params.append("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: @@ -169,6 +331,292 @@ def create_mass_estimate_with_http_info( 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 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.create_shipping_estimate(create_shipping_estimate_request, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param CreateShippingEstimateRequest create_shipping_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_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 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.create_shipping_estimate_with_http_info(create_shipping_estimate_request, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param CreateShippingEstimateRequest create_shipping_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_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("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"] + # 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 + + 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_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 + + # 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/shipping", + "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_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 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.create_vehicle_estimate(create_vehicle_estimate_request, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param CreateVehicleEstimateRequest create_vehicle_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_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 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.create_vehicle_estimate_with_http_info(create_vehicle_estimate_request, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param CreateVehicleEstimateRequest create_vehicle_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_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("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"] + # 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 + + 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_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 + + # 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/vehicle", + "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 retrieve_estimate(self, id={}, **kwargs): # noqa: E501 """Retrieves an estimate # noqa: E501 @@ -230,6 +678,13 @@ def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("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: @@ -350,6 +805,13 @@ def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501 all_params.append("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: diff --git a/patch_api/api/orders_api.py b/patch_api/api/orders_api.py index 6e22be6..015c140 100644 --- a/patch_api/api/orders_api.py +++ b/patch_api/api/orders_api.py @@ -28,7 +28,19 @@ class OrdersApi(object): Do not edit the class manually. """ - ALLOWED_QUERY_PARAMS = ["mass_g", "price_cents_usd", "project_id", "page"] + ALLOWED_QUERY_PARAMS = [ + "mass_g", + "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 @@ -94,6 +106,13 @@ def cancel_order_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("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: @@ -216,6 +235,13 @@ def create_order_with_http_info(self, create_order_request, **kwargs): # noqa: all_params.append("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: @@ -346,6 +372,13 @@ def place_order_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("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: @@ -466,6 +499,13 @@ def retrieve_order_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("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: @@ -586,6 +626,13 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 all_params.append("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: diff --git a/patch_api/api/preferences_api.py b/patch_api/api/preferences_api.py index 5efddc3..fbd78ae 100644 --- a/patch_api/api/preferences_api.py +++ b/patch_api/api/preferences_api.py @@ -28,7 +28,19 @@ class PreferencesApi(object): Do not edit the class manually. """ - ALLOWED_QUERY_PARAMS = ["mass_g", "price_cents_usd", "project_id", "page"] + ALLOWED_QUERY_PARAMS = [ + "mass_g", + "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 @@ -98,6 +110,13 @@ def create_preference_with_http_info( all_params.append("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: @@ -228,6 +247,13 @@ def delete_preference_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("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: @@ -348,6 +374,13 @@ def retrieve_preference_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("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: @@ -468,6 +501,13 @@ def retrieve_preferences_with_http_info(self, **kwargs): # noqa: E501 all_params.append("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: diff --git a/patch_api/api/projects_api.py b/patch_api/api/projects_api.py index 4a6e3fe..9497918 100644 --- a/patch_api/api/projects_api.py +++ b/patch_api/api/projects_api.py @@ -28,7 +28,19 @@ class ProjectsApi(object): Do not edit the class manually. """ - ALLOWED_QUERY_PARAMS = ["mass_g", "price_cents_usd", "project_id", "page"] + ALLOWED_QUERY_PARAMS = [ + "mass_g", + "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 @@ -94,6 +106,13 @@ def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("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: @@ -214,6 +233,13 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501 all_params.append("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: diff --git a/patch_api/api_client.py b/patch_api/api_client.py index d57c691..1fa730a 100644 --- a/patch_api/api_client.py +++ b/patch_api/api_client.py @@ -91,7 +91,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = "OpenAPI-Generator/1.0.0/python" + self.user_agent = "OpenAPI-Generator/1.3.0/python" def __del__(self): if self._pool: diff --git a/patch_api/configuration.py b/patch_api/configuration.py index 4da45bf..8de8d55 100644 --- a/patch_api/configuration.py +++ b/patch_api/configuration.py @@ -341,7 +341,7 @@ def to_debug_report(self): "OS: {env}\n" "Python Version: {pyversion}\n" "Version of the API: v1\n" - "SDK Package Version: 1.0.0".format(env=sys.platform, pyversion=sys.version) + "SDK Package Version: 1.3.0".format(env=sys.platform, pyversion=sys.version) ) def get_host_settings(self): diff --git a/patch_api/models/estimate.py b/patch_api/models/estimate.py index b64185f..e767292 100644 --- a/patch_api/models/estimate.py +++ b/patch_api/models/estimate.py @@ -33,12 +33,19 @@ class Estimate(object): attribute_map (dict): The key is attribute name and the value is json key in definition. """ - openapi_types = {"id": "str", "production": "bool", "type": "str", "order": "Order"} + openapi_types = { + "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", } @@ -47,6 +54,7 @@ def __init__( id=None, production=None, type=None, + mass_g=None, order=None, local_vars_configuration=None, ): # noqa: E501 @@ -58,12 +66,15 @@ def __init__( self._id = None self._production = None self._type = None + self._mass_g = None self._order = None self.discriminator = None self.id = id self.production = production self.type = type + if mass_g is not None: + self.mass_g = mass_g self.order = order @property @@ -126,7 +137,7 @@ def production(self, production): def type(self): """Gets the type of this Estimate. # noqa: E501 - The type of estimate. Currently mass is the only supported value. # noqa: E501 + The type of estimate. Available types are mass, flight, shipping, and vehicle. # noqa: E501 :return: The type of this Estimate. # noqa: E501 :rtype: str @@ -137,7 +148,7 @@ def type(self): def type(self, type): """Sets the type of this Estimate. - The type of estimate. Currently mass is the only supported value. # noqa: E501 + The type of estimate. Available types are mass, flight, shipping, and vehicle. # noqa: E501 :param type: The type of this Estimate. # noqa: E501 :type: str @@ -151,6 +162,29 @@ def type(self, type): self._type = type + @property + def mass_g(self): + """Gets the mass_g of this Estimate. # noqa: E501 + + The estimated mass in grams for this estimate. # noqa: E501 + + :return: The mass_g of this Estimate. # noqa: E501 + :rtype: int + """ + return self._mass_g + + @mass_g.setter + def mass_g(self, mass_g): + """Sets the mass_g of this Estimate. + + The estimated mass in grams for this estimate. # noqa: E501 + + :param mass_g: The mass_g of this Estimate. # noqa: E501 + :type: int + """ + + self._mass_g = mass_g + @property def order(self): """Gets the order of this Estimate. # noqa: E501 diff --git a/requirements.txt b/requirements.txt index 26e1a7b..186bea6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,4 @@ six >= 1.10 python_dateutil >= 2.5.3 setuptools >= 21.0.0 urllib3 >= 1.15.1 -pre-commit >= 2.9.3 +pre-commit >= 2.10.0 diff --git a/setup.py b/setup.py index cff5def..924139e 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ from setuptools import setup, find_packages # noqa: H301 NAME = "patch-api" -VERSION = "1.0.1" +VERSION = "1.3.0" # To install the library, run the following # # python setup.py install @@ -20,7 +20,10 @@ # prerequisite: setuptools # http://pypi.python.org/pypi/setuptools -REQUIRES = ["urllib3 >= 1.25.3", "python-dateutil", "certifi"] +REQUIRES = [ + "urllib3 >= 1.25.3", + "python-dateutil", +] setup( name=NAME, @@ -35,7 +38,6 @@ packages=find_packages(exclude=["test", "tests"]), include_package_data=True, long_description="""\ - The core API used to integrate with Patch's service. + The core API used to integrate with Patch's service # noqa: E501 """, - long_description_content_type="text/x-rst", ) diff --git a/test/test_estimates_api.py b/test/test_estimates_api.py index 9e5ffe3..1480c64 100644 --- a/test/test_estimates_api.py +++ b/test/test_estimates_api.py @@ -43,6 +43,61 @@ def test_create_and_retrieve_mass_estimate(self): retrieved_estimate = self.api.retrieve_estimate(id=estimate.data.id) self.assertTrue(retrieved_estimate) + def test_create_and_retrieve_flight_estimate(self): + """Test case for create_flight_estimate + + Create an estimate based on the distance in meters flown by an airplane # noqa: E501 + """ + distance_m = 10000000 + estimate = self.api.create_flight_estimate( + distance_m=distance_m, create_order=True + ) + self.assertEqual(estimate.data.type, "flight") + self.assertEqual(estimate.data.order.mass_g, 1032000) + self.assertEqual(estimate.data.mass_g, 1032000) + + retrieved_estimate = self.api.retrieve_estimate(id=estimate.data.id) + self.assertTrue(retrieved_estimate) + + def test_create_and_retrieve_shipping_estimate(self): + """Test case for create_shipping_estimate + + Create an estimate based on the shipping distance, transportation method, and package mass # noqa: E501 + """ + distance_m = 10000000 + package_mass_g = 1000 + transportation_method = "sea" + estimate = self.api.create_shipping_estimate( + distance_m=distance_m, + package_mass_g=package_mass_g, + transportation_method=transportation_method, + create_order=False, + ) + self.assertEqual(estimate.data.order, None) + self.assertEqual(estimate.data.type, "shipping") + self.assertEqual(estimate.data.mass_g, 373) + + retrieved_estimate = self.api.retrieve_estimate(id=estimate.data.id) + self.assertTrue(retrieved_estimate) + + def test_create_and_retrieve_vehicle_estimate(self): + """Test case for create_vehicle_estimate + + Create an estimate based on the vehicle distance, transportation method, and package mass # noqa: E501 + """ + distance_m = 10000000 + make = "Toyota" + model = "Corolla" + year = 1995 + estimate = self.api.create_vehicle_estimate( + distance_m=distance_m, model=model, make=make, year=year + ) + self.assertEqual(estimate.data.type, "vehicle") + self.assertEqual(estimate.data.mass_g, 5719674) + + retrieved_estimate = self.api.retrieve_estimate(id=estimate.data.id) + self.assertTrue(retrieved_estimate) + if __name__ == "__main__": unittest.main() diff --git a/test/test_projects_api.py b/test/test_projects_api.py index 4be6581..f4b4379 100644 --- a/test/test_projects_api.py +++ b/test/test_projects_api.py @@ -59,7 +59,7 @@ def test_retrieve_projects(self): self.assertTrue(project.description) self.assertEqual(project.country, "US") self.assertEqual(project.type, "biomass") - self.assertEqual(project.developer, "Carbo Culture Biochar") + self.assertEqual(project.developer, "Carbo Culture") self.assertTrue(isinstance(project.photos, list))