Skip to content

Commit

Permalink
Add ETH estimates (#28)
Browse files Browse the repository at this point in the history
* Add ETH estimates

* Bump version
  • Loading branch information
pcothenet authored Jul 21, 2021
1 parent 9b6f0c7 commit 98757ec
Show file tree
Hide file tree
Showing 10 changed files with 192 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion patch_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
158 changes: 156 additions & 2 deletions patch_api/api/estimates_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class EstimatesApi(object):
"year",
"transaction_value_btc_sats",
"timestamp",
"gas_used",
]

def __init__(self, api_client=None):
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 6 additions & 0 deletions patch_api/api/orders_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class OrdersApi(object):
"year",
"transaction_value_btc_sats",
"timestamp",
"gas_used",
]

def __init__(self, api_client=None):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions patch_api/api/preferences_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class PreferencesApi(object):
"year",
"transaction_value_btc_sats",
"timestamp",
"gas_used",
]

def __init__(self, api_client=None):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions patch_api/api/projects_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class ProjectsApi(object):
"year",
"transaction_value_btc_sats",
"timestamp",
"gas_used",
]

def __init__(self, api_client=None):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion patch_api/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion patch_api/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 98757ec

Please sign in to comment.