From ba5c15473bcd4d0517437efae7c7256c4ce9dc5f Mon Sep 17 00:00:00 2001 From: Brett Holt Date: Mon, 7 Apr 2025 10:25:15 -0700 Subject: [PATCH] Remove /estimates/ecommerce endpoint calls --- patch_api/__init__.py | 2 +- patch_api/api/estimates_api.py | 201 --------------------------------- patch_api/api_client.py | 18 +-- patch_api/configuration.py | 2 +- patch_api/models/__init__.py | 3 - setup.py | 2 +- test/test_estimates_api.py | 31 +---- 7 files changed, 17 insertions(+), 242 deletions(-) diff --git a/patch_api/__init__.py b/patch_api/__init__.py index 005dbef..1a30ab7 100644 --- a/patch_api/__init__.py +++ b/patch_api/__init__.py @@ -15,7 +15,7 @@ from __future__ import absolute_import -__version__ = "2.3.0" +__version__ = "2.3.1" # 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 2fa3321..fea9c0f 100644 --- a/patch_api/api/estimates_api.py +++ b/patch_api/api/estimates_api.py @@ -485,207 +485,6 @@ def create_bitcoin_estimate_with_http_info( collection_formats=collection_formats, ) - def create_ecommerce_estimate( - self, create_ecommerce_estimate_request={}, **kwargs - ): # noqa: E501 - """Create an e-commerce estimate given the distance traveled in meters, package weight, and transportation method. # noqa: E501 - - Creates a e-commerce 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_ecommerce_estimate(create_ecommerce_estimate_request, async_req=True) - >>> result = thread.get() - - :param async_req bool: execute request asynchronously - :param CreateEcommerceEstimateRequest create_ecommerce_estimate_request: (required) - :param int patch_version: - :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_ecommerce_estimate_with_http_info( - create_ecommerce_estimate_request, **kwargs - ) # noqa: E501 - - def create_ecommerce_estimate_with_http_info( - self, create_ecommerce_estimate_request, **kwargs - ): # noqa: E501 - """Create an e-commerce estimate given the distance traveled in meters, package weight, and transportation method. # noqa: E501 - - Creates a e-commerce 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_ecommerce_estimate_with_http_info(create_ecommerce_estimate_request, async_req=True) - >>> result = thread.get() - - :param async_req bool: execute request asynchronously - :param CreateEcommerceEstimateRequest create_ecommerce_estimate_request: (required) - :param int patch_version: - :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_ecommerce_estimate_request", - "patch_version", - ] # noqa: E501 - all_params.append("async_req") - all_params.append("_return_http_data_only") - all_params.append("_preload_content") - all_params.append("_request_timeout") - all_params.append("mass_g") - all_params.append("total_price_cents_usd") - all_params.append("project_id") - all_params.append("metadata") - all_params.append("distance_m") - all_params.append("transportation_method") - all_params.append("package_mass_g") - all_params.append("create_order") - all_params.append("make") - all_params.append("model") - all_params.append("year") - all_params.append("transaction_value_btc_sats") - all_params.append("transaction_value_eth_gwei") - all_params.append("gas_used") - all_params.append("transaction_value_btc_sats") - all_params.append("average_daily_balance_btc_sats") - all_params.append("average_daily_balance_eth_gwei") - all_params.append("timestamp") - all_params.append("origin_airport") - all_params.append("destination_airport") - all_params.append("aircraft_code") - all_params.append("cabin_class") - all_params.append("passenger_count") - all_params.append("state") - all_params.append("country_code") - all_params.append("city") - all_params.append("region") - all_params.append("star_rating") - all_params.append("number_of_nights") - all_params.append("number_of_rooms") - all_params.append("vintage_year") - all_params.append("total_price") - all_params.append("currency") - all_params.append("amount") - all_params.append("unit") - all_params.append("issued_to") - all_params.append("cargo_type") - all_params.append("container_size_code") - all_params.append("destination_country_code") - all_params.append("destination_locode") - all_params.append("destination_postal_code") - all_params.append("emissions_scope") - all_params.append("freight_mass_g") - all_params.append("freight_volume_cubic_m") - all_params.append("fuel_type") - all_params.append("number_of_containers") - all_params.append("origin_country_code") - all_params.append("origin_locode") - all_params.append("origin_postal_code") - all_params.append("truck_weight_t") - all_params.append("vessel_imo") - all_params.append("vintage_start_year") - all_params.append("vintage_end_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_ecommerce_estimate" % key - ) - local_var_params[key] = val - del local_var_params["kwargs"] - # verify the required parameter 'create_ecommerce_estimate_request' is set - if ( - "create_ecommerce_estimate_request" not in local_var_params - or local_var_params["create_ecommerce_estimate_request"] is None - ): - raise ApiValueError( - "Missing the required parameter `create_ecommerce_estimate_request` when calling `create_ecommerce_estimate`" - ) # noqa: E501 - - collection_formats = {} - - path_params = {} - - query_params = [] - - # do not add duplicate keys to query_params list - existing_keys = [] - for param in query_params: - existing_keys.append(param[0]) - - for key in kwargs: - if key not in existing_keys: - query_params.append([key, kwargs.get(key)]) - - header_params = {} - if "patch_version" in local_var_params: - header_params["Patch-Version"] = local_var_params[ - "patch_version" - ] # noqa: E501 - - form_params = [] - local_var_files = {} - - body_params = None - if "create_ecommerce_estimate_request" in local_var_params: - body_params = local_var_params["create_ecommerce_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/ecommerce", - "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 diff --git a/patch_api/api_client.py b/patch_api/api_client.py index 50a1412..325bb1d 100644 --- a/patch_api/api_client.py +++ b/patch_api/api_client.py @@ -1,12 +1,12 @@ # coding: utf-8 """ - Patch API V2 +Patch API V2 - The core API used to integrate with Patch's service # noqa: E501 +The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: 2 - Contact: engineering@usepatch.com - Generated by: https://openapi-generator.tech +The version of the OpenAPI document: 2 +Contact: engineering@usepatch.com +Generated by: https://openapi-generator.tech """ from __future__ import absolute_import @@ -92,7 +92,7 @@ def __init__( self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = "patch-python/2.3.0" + self.user_agent = "patch-python/2.3.1" # Set default Patch-Version self.patch_version = 2 @@ -130,9 +130,6 @@ def user_agent(self): def user_agent(self, value): self.default_headers["User-Agent"] = value - def set_default_header(self, header_name, header_value): - self.default_headers[header_name] = header_value - @property def patch_version(self): """API version for this API client""" @@ -142,6 +139,9 @@ def patch_version(self): def patch_version(self, value): self.default_headers["Patch-Version"] = value + def set_default_header(self, header_name, header_value): + self.default_headers[header_name] = header_value + def __call_api( self, resource_path, diff --git a/patch_api/configuration.py b/patch_api/configuration.py index 48e1a11..08c270a 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: 2\n" - "SDK Package Version: 2.3.0".format(env=sys.platform, pyversion=sys.version) + "SDK Package Version: 2.3.1".format(env=sys.platform, pyversion=sys.version) ) def get_host_settings(self): diff --git a/patch_api/models/__init__.py b/patch_api/models/__init__.py index 5fe200a..0d61121 100644 --- a/patch_api/models/__init__.py +++ b/patch_api/models/__init__.py @@ -21,9 +21,6 @@ from patch_api.models.create_bitcoin_estimate_request import ( CreateBitcoinEstimateRequest, ) -from patch_api.models.create_ecommerce_estimate_request import ( - CreateEcommerceEstimateRequest, -) from patch_api.models.create_flight_estimate_request import CreateFlightEstimateRequest from patch_api.models.create_hotel_estimate_request import CreateHotelEstimateRequest from patch_api.models.create_mass_estimate_request import CreateMassEstimateRequest diff --git a/setup.py b/setup.py index 062c744..cf1db65 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ from setuptools import setup, find_packages # noqa: H301 NAME = "patch-api" -VERSION = "2.3.0" +VERSION = "2.3.1" # To install the library, run the following # # python setup.py install diff --git a/test/test_estimates_api.py b/test/test_estimates_api.py index 4dfec00..25149c2 100644 --- a/test/test_estimates_api.py +++ b/test/test_estimates_api.py @@ -1,13 +1,13 @@ # coding: utf-8 """ - Patch API V1 +Patch API V1 - The core API used to integrate with Patch's service # noqa: E501 +The core API used to integrate with Patch's service # noqa: E501 - The version of the OpenAPI document: v1 - Contact: developers@usepatch.com - Generated by: https://openapi-generator.tech +The version of the OpenAPI document: v1 +Contact: developers@usepatch.com +Generated by: https://openapi-generator.tech """ @@ -113,27 +113,6 @@ def test_create_hotel_estimate(self): estimate.data.mass_g, 15_000 ) # not setting an exact value since this is changing daily - def test_create_and_retrieve_ecommerce_estimate(self): - """Test case for create_ecommerce_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_ecommerce_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, "ecommerce") - self.assertGreater(estimate.data.mass_g, 200) - - retrieved_estimate = self.api.retrieve_estimate(id=estimate.data.id) - self.assertTrue(retrieved_estimate) - def test_create_air_shipping_estimate_airport_iatas(self): """Test case for create_air_shipping_estimate