diff --git a/CHANGELOG.md b/CHANGELOG.md index b88df63..c52b303 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.8.0] - 2021-07-20 + +### Added + +- Add support for Ethereum estimates + ## [1.7.0] - 2021-07-14 ### Changed diff --git a/patch_api/__init__.py b/patch_api/__init__.py index 968e78a..32918e3 100644 --- a/patch_api/__init__.py +++ b/patch_api/__init__.py @@ -15,7 +15,7 @@ from __future__ import absolute_import -__version__ = "1.7.0" +__version__ = "1.8.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 e4b6070..95d1af0 100644 --- a/patch_api/api/estimates_api.py +++ b/patch_api/api/estimates_api.py @@ -42,6 +42,7 @@ class EstimatesApi(object): "year", "transaction_value_btc_sats", "timestamp", + "gas_used", ] def __init__(self, api_client=None): @@ -52,7 +53,7 @@ def create_bitcoin_estimate( ): # 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 + 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) @@ -81,7 +82,7 @@ def create_bitcoin_estimate_with_http_info( ): # 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 + 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) @@ -123,6 +124,7 @@ def create_bitcoin_estimate_with_http_info( all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -192,6 +194,152 @@ def create_bitcoin_estimate_with_http_info( collection_formats=collection_formats, ) + def create_ethereum_estimate( + self, create_ethereum_estimate_request={}, **kwargs + ): # noqa: E501 + """Create an ethereum estimate given a timestamp and gas used # noqa: E501 + + Creates an ethereum estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.create_ethereum_estimate(create_ethereum_estimate_request, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param CreateEthereumEstimateRequest create_ethereum_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_ethereum_estimate_with_http_info( + create_ethereum_estimate_request, **kwargs + ) # noqa: E501 + + def create_ethereum_estimate_with_http_info( + self, create_ethereum_estimate_request, **kwargs + ): # noqa: E501 + """Create an ethereum estimate given a timestamp and gas used # noqa: E501 + + Creates an ethereum estimate for the amount of CO2 to be compensated. An order in the `draft` state may be created based on the parameters, linked to the estimate. # noqa: E501 + This method makes a synchronous HTTP request by default. To make an + asynchronous HTTP request, please pass async_req=True + >>> thread = api.create_ethereum_estimate_with_http_info(create_ethereum_estimate_request, async_req=True) + >>> result = thread.get() + + :param async_req bool: execute request asynchronously + :param CreateEthereumEstimateRequest create_ethereum_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_ethereum_estimate_request"] # noqa: E501 + all_params.append("async_req") + all_params.append("_return_http_data_only") + all_params.append("_preload_content") + all_params.append("_request_timeout") + all_params.append("mass_g") + all_params.append("total_price_cents_usd") + all_params.append("project_id") + all_params.append("metadata") + all_params.append("distance_m") + all_params.append("transportation_method") + all_params.append("package_mass_g") + all_params.append("create_order") + all_params.append("make") + all_params.append("model") + all_params.append("year") + all_params.append("transaction_value_btc_sats") + all_params.append("timestamp") + all_params.append("gas_used") + + for key, val in six.iteritems(local_var_params["kwargs"]): + if key not in all_params: + raise ApiTypeError( + "Got an unexpected keyword argument '%s'" + " to method create_ethereum_estimate" % key + ) + local_var_params[key] = val + del local_var_params["kwargs"] + # verify the required parameter 'create_ethereum_estimate_request' is set + if ( + "create_ethereum_estimate_request" not in local_var_params + or local_var_params["create_ethereum_estimate_request"] is None + ): + raise ApiValueError( + "Missing the required parameter `create_ethereum_estimate_request` when calling `create_ethereum_estimate`" + ) # noqa: E501 + + 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_ethereum_estimate_request" in local_var_params: + body_params = local_var_params["create_ethereum_estimate_request"] + # HTTP header `Accept` + header_params["Accept"] = self.api_client.select_header_accept( + ["application/json"] + ) # noqa: E501 + + # 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/eth", + "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 @@ -268,6 +416,7 @@ def create_flight_estimate_with_http_info( all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -413,6 +562,7 @@ def create_mass_estimate_with_http_info( all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -558,6 +708,7 @@ def create_shipping_estimate_with_http_info( all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -703,6 +854,7 @@ def create_vehicle_estimate_with_http_info( all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -842,6 +994,7 @@ def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -971,6 +1124,7 @@ def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501 all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: diff --git a/patch_api/api/orders_api.py b/patch_api/api/orders_api.py index 995e1a1..2bf0532 100644 --- a/patch_api/api/orders_api.py +++ b/patch_api/api/orders_api.py @@ -42,6 +42,7 @@ class OrdersApi(object): "year", "transaction_value_btc_sats", "timestamp", + "gas_used", ] def __init__(self, api_client=None): @@ -117,6 +118,7 @@ def cancel_order_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -248,6 +250,7 @@ def create_order_with_http_info(self, create_order_request, **kwargs): # noqa: all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -387,6 +390,7 @@ def place_order_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -516,6 +520,7 @@ def retrieve_order_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -645,6 +650,7 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501 all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: diff --git a/patch_api/api/preferences_api.py b/patch_api/api/preferences_api.py index bcac4e0..d45e3fb 100644 --- a/patch_api/api/preferences_api.py +++ b/patch_api/api/preferences_api.py @@ -42,6 +42,7 @@ class PreferencesApi(object): "year", "transaction_value_btc_sats", "timestamp", + "gas_used", ] def __init__(self, api_client=None): @@ -121,6 +122,7 @@ def create_preference_with_http_info( all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -260,6 +262,7 @@ def delete_preference_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -389,6 +392,7 @@ def retrieve_preference_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -518,6 +522,7 @@ def retrieve_preferences_with_http_info(self, **kwargs): # noqa: E501 all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: diff --git a/patch_api/api/projects_api.py b/patch_api/api/projects_api.py index 4374966..64fa2b4 100644 --- a/patch_api/api/projects_api.py +++ b/patch_api/api/projects_api.py @@ -42,6 +42,7 @@ class ProjectsApi(object): "year", "transaction_value_btc_sats", "timestamp", + "gas_used", ] def __init__(self, api_client=None): @@ -117,6 +118,7 @@ def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501 all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: @@ -252,6 +254,7 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501 all_params.append("year") all_params.append("transaction_value_btc_sats") all_params.append("timestamp") + all_params.append("gas_used") for key, val in six.iteritems(local_var_params["kwargs"]): if key not in all_params: diff --git a/patch_api/api_client.py b/patch_api/api_client.py index cd4f077..5beb1c3 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.7.0/python" + self.user_agent = "OpenAPI-Generator/1.8.0/python" def __del__(self): if self._pool: diff --git a/patch_api/configuration.py b/patch_api/configuration.py index 048eb87..80ed119 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.7.0".format(env=sys.platform, pyversion=sys.version) + "SDK Package Version: 1.8.0".format(env=sys.platform, pyversion=sys.version) ) def get_host_settings(self): diff --git a/setup.py b/setup.py index 0721947..2944ae0 100644 --- a/setup.py +++ b/setup.py @@ -12,7 +12,7 @@ from setuptools import setup, find_packages # noqa: H301 NAME = "patch-api" -VERSION = "1.7.0" +VERSION = "1.8.0" # 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 65af346..34be1fb 100644 --- a/test/test_estimates_api.py +++ b/test/test_estimates_api.py @@ -142,6 +142,18 @@ def test_create_bitcoin_estimate_transaction_value(self): estimate.data.mass_g, 200 ) # not setting an exact value since this is changing daily + def test_create_ethereum_estimate_transaction_value(self): + """Test case for create_ethereum_estimate + + Create an estimate based on a transaction amount # noqa: E501 + """ + + estimate = self.api.create_ethereum_estimate(gas_used=1000) + self.assertEqual(estimate.data.type, "ethereum") + self.assertGreater( + estimate.data.mass_g, 1 + ) # not setting an exact value since this is changing daily + if __name__ == "__main__": unittest.main()