Skip to content

Commit 98757ec

Browse files
authoredJul 21, 2021
Add ETH estimates (#28)
* Add ETH estimates * Bump version
1 parent 9b6f0c7 commit 98757ec

10 files changed

+192
-6
lines changed
 

‎CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.8.0] - 2021-07-20
9+
10+
### Added
11+
12+
- Add support for Ethereum estimates
13+
814
## [1.7.0] - 2021-07-14
915

1016
### Changed

‎patch_api/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from __future__ import absolute_import
1717

18-
__version__ = "1.7.0"
18+
__version__ = "1.8.0"
1919

2020
# import ApiClient
2121
from patch_api.api_client import ApiClient

‎patch_api/api/estimates_api.py

+156-2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class EstimatesApi(object):
4242
"year",
4343
"transaction_value_btc_sats",
4444
"timestamp",
45+
"gas_used",
4546
]
4647

4748
def __init__(self, api_client=None):
@@ -52,7 +53,7 @@ def create_bitcoin_estimate(
5253
): # noqa: E501
5354
"""Create a bitcoin estimate given a timestamp and transaction value # noqa: E501
5455
55-
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
56+
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
5657
This method makes a synchronous HTTP request by default. To make an
5758
asynchronous HTTP request, please pass async_req=True
5859
>>> thread = api.create_bitcoin_estimate(create_bitcoin_estimate_request, async_req=True)
@@ -81,7 +82,7 @@ def create_bitcoin_estimate_with_http_info(
8182
): # noqa: E501
8283
"""Create a bitcoin estimate given a timestamp and transaction value # noqa: E501
8384
84-
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
85+
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
8586
This method makes a synchronous HTTP request by default. To make an
8687
asynchronous HTTP request, please pass async_req=True
8788
>>> 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(
123124
all_params.append("year")
124125
all_params.append("transaction_value_btc_sats")
125126
all_params.append("timestamp")
127+
all_params.append("gas_used")
126128

127129
for key, val in six.iteritems(local_var_params["kwargs"]):
128130
if key not in all_params:
@@ -192,6 +194,152 @@ def create_bitcoin_estimate_with_http_info(
192194
collection_formats=collection_formats,
193195
)
194196

197+
def create_ethereum_estimate(
198+
self, create_ethereum_estimate_request={}, **kwargs
199+
): # noqa: E501
200+
"""Create an ethereum estimate given a timestamp and gas used # noqa: E501
201+
202+
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
203+
This method makes a synchronous HTTP request by default. To make an
204+
asynchronous HTTP request, please pass async_req=True
205+
>>> thread = api.create_ethereum_estimate(create_ethereum_estimate_request, async_req=True)
206+
>>> result = thread.get()
207+
208+
:param async_req bool: execute request asynchronously
209+
:param CreateEthereumEstimateRequest create_ethereum_estimate_request: (required)
210+
:param _preload_content: if False, the urllib3.HTTPResponse object will
211+
be returned without reading/decoding response
212+
data. Default is True.
213+
:param _request_timeout: timeout setting for this request. If one
214+
number provided, it will be total request
215+
timeout. It can also be a pair (tuple) of
216+
(connection, read) timeouts.
217+
:return: EstimateResponse
218+
If the method is called asynchronously,
219+
returns the request thread.
220+
"""
221+
kwargs["_return_http_data_only"] = True
222+
return self.create_ethereum_estimate_with_http_info(
223+
create_ethereum_estimate_request, **kwargs
224+
) # noqa: E501
225+
226+
def create_ethereum_estimate_with_http_info(
227+
self, create_ethereum_estimate_request, **kwargs
228+
): # noqa: E501
229+
"""Create an ethereum estimate given a timestamp and gas used # noqa: E501
230+
231+
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
232+
This method makes a synchronous HTTP request by default. To make an
233+
asynchronous HTTP request, please pass async_req=True
234+
>>> thread = api.create_ethereum_estimate_with_http_info(create_ethereum_estimate_request, async_req=True)
235+
>>> result = thread.get()
236+
237+
:param async_req bool: execute request asynchronously
238+
:param CreateEthereumEstimateRequest create_ethereum_estimate_request: (required)
239+
:param _return_http_data_only: response data without head status code
240+
and headers
241+
:param _preload_content: if False, the urllib3.HTTPResponse object will
242+
be returned without reading/decoding response
243+
data. Default is True.
244+
:param _request_timeout: timeout setting for this request. If one
245+
number provided, it will be total request
246+
timeout. It can also be a pair (tuple) of
247+
(connection, read) timeouts.
248+
:return: tuple(EstimateResponse, status_code(int), headers(HTTPHeaderDict))
249+
If the method is called asynchronously,
250+
returns the request thread.
251+
"""
252+
253+
local_var_params = locals()
254+
255+
all_params = ["create_ethereum_estimate_request"] # noqa: E501
256+
all_params.append("async_req")
257+
all_params.append("_return_http_data_only")
258+
all_params.append("_preload_content")
259+
all_params.append("_request_timeout")
260+
all_params.append("mass_g")
261+
all_params.append("total_price_cents_usd")
262+
all_params.append("project_id")
263+
all_params.append("metadata")
264+
all_params.append("distance_m")
265+
all_params.append("transportation_method")
266+
all_params.append("package_mass_g")
267+
all_params.append("create_order")
268+
all_params.append("make")
269+
all_params.append("model")
270+
all_params.append("year")
271+
all_params.append("transaction_value_btc_sats")
272+
all_params.append("timestamp")
273+
all_params.append("gas_used")
274+
275+
for key, val in six.iteritems(local_var_params["kwargs"]):
276+
if key not in all_params:
277+
raise ApiTypeError(
278+
"Got an unexpected keyword argument '%s'"
279+
" to method create_ethereum_estimate" % key
280+
)
281+
local_var_params[key] = val
282+
del local_var_params["kwargs"]
283+
# verify the required parameter 'create_ethereum_estimate_request' is set
284+
if (
285+
"create_ethereum_estimate_request" not in local_var_params
286+
or local_var_params["create_ethereum_estimate_request"] is None
287+
):
288+
raise ApiValueError(
289+
"Missing the required parameter `create_ethereum_estimate_request` when calling `create_ethereum_estimate`"
290+
) # noqa: E501
291+
292+
collection_formats = {}
293+
294+
path_params = {}
295+
296+
query_params = []
297+
for key in kwargs:
298+
query_params.append([key, kwargs.get(key)])
299+
300+
header_params = {}
301+
302+
form_params = []
303+
local_var_files = {}
304+
305+
body_params = None
306+
if "create_ethereum_estimate_request" in local_var_params:
307+
body_params = local_var_params["create_ethereum_estimate_request"]
308+
# HTTP header `Accept`
309+
header_params["Accept"] = self.api_client.select_header_accept(
310+
["application/json"]
311+
) # noqa: E501
312+
313+
# HTTP header `Content-Type`
314+
header_params[
315+
"Content-Type"
316+
] = self.api_client.select_header_content_type( # noqa: E501
317+
["application/json"]
318+
) # noqa: E501
319+
320+
# Authentication setting
321+
auth_settings = ["bearer_auth"] # noqa: E501
322+
323+
return self.api_client.call_api(
324+
"/v1/estimates/crypto/eth",
325+
"POST",
326+
path_params,
327+
query_params,
328+
header_params,
329+
body=body_params,
330+
post_params=form_params,
331+
files=local_var_files,
332+
response_type="EstimateResponse", # noqa: E501
333+
auth_settings=auth_settings,
334+
async_req=local_var_params.get("async_req"),
335+
_return_http_data_only=local_var_params.get(
336+
"_return_http_data_only"
337+
), # noqa: E501
338+
_preload_content=local_var_params.get("_preload_content", True),
339+
_request_timeout=local_var_params.get("_request_timeout"),
340+
collection_formats=collection_formats,
341+
)
342+
195343
def create_flight_estimate(
196344
self, create_flight_estimate_request={}, **kwargs
197345
): # noqa: E501
@@ -268,6 +416,7 @@ def create_flight_estimate_with_http_info(
268416
all_params.append("year")
269417
all_params.append("transaction_value_btc_sats")
270418
all_params.append("timestamp")
419+
all_params.append("gas_used")
271420

272421
for key, val in six.iteritems(local_var_params["kwargs"]):
273422
if key not in all_params:
@@ -413,6 +562,7 @@ def create_mass_estimate_with_http_info(
413562
all_params.append("year")
414563
all_params.append("transaction_value_btc_sats")
415564
all_params.append("timestamp")
565+
all_params.append("gas_used")
416566

417567
for key, val in six.iteritems(local_var_params["kwargs"]):
418568
if key not in all_params:
@@ -558,6 +708,7 @@ def create_shipping_estimate_with_http_info(
558708
all_params.append("year")
559709
all_params.append("transaction_value_btc_sats")
560710
all_params.append("timestamp")
711+
all_params.append("gas_used")
561712

562713
for key, val in six.iteritems(local_var_params["kwargs"]):
563714
if key not in all_params:
@@ -703,6 +854,7 @@ def create_vehicle_estimate_with_http_info(
703854
all_params.append("year")
704855
all_params.append("transaction_value_btc_sats")
705856
all_params.append("timestamp")
857+
all_params.append("gas_used")
706858

707859
for key, val in six.iteritems(local_var_params["kwargs"]):
708860
if key not in all_params:
@@ -842,6 +994,7 @@ def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501
842994
all_params.append("year")
843995
all_params.append("transaction_value_btc_sats")
844996
all_params.append("timestamp")
997+
all_params.append("gas_used")
845998

846999
for key, val in six.iteritems(local_var_params["kwargs"]):
8471000
if key not in all_params:
@@ -971,6 +1124,7 @@ def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501
9711124
all_params.append("year")
9721125
all_params.append("transaction_value_btc_sats")
9731126
all_params.append("timestamp")
1127+
all_params.append("gas_used")
9741128

9751129
for key, val in six.iteritems(local_var_params["kwargs"]):
9761130
if key not in all_params:

‎patch_api/api/orders_api.py

+6
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class OrdersApi(object):
4242
"year",
4343
"transaction_value_btc_sats",
4444
"timestamp",
45+
"gas_used",
4546
]
4647

4748
def __init__(self, api_client=None):
@@ -117,6 +118,7 @@ def cancel_order_with_http_info(self, id, **kwargs): # noqa: E501
117118
all_params.append("year")
118119
all_params.append("transaction_value_btc_sats")
119120
all_params.append("timestamp")
121+
all_params.append("gas_used")
120122

121123
for key, val in six.iteritems(local_var_params["kwargs"]):
122124
if key not in all_params:
@@ -248,6 +250,7 @@ def create_order_with_http_info(self, create_order_request, **kwargs): # noqa:
248250
all_params.append("year")
249251
all_params.append("transaction_value_btc_sats")
250252
all_params.append("timestamp")
253+
all_params.append("gas_used")
251254

252255
for key, val in six.iteritems(local_var_params["kwargs"]):
253256
if key not in all_params:
@@ -387,6 +390,7 @@ def place_order_with_http_info(self, id, **kwargs): # noqa: E501
387390
all_params.append("year")
388391
all_params.append("transaction_value_btc_sats")
389392
all_params.append("timestamp")
393+
all_params.append("gas_used")
390394

391395
for key, val in six.iteritems(local_var_params["kwargs"]):
392396
if key not in all_params:
@@ -516,6 +520,7 @@ def retrieve_order_with_http_info(self, id, **kwargs): # noqa: E501
516520
all_params.append("year")
517521
all_params.append("transaction_value_btc_sats")
518522
all_params.append("timestamp")
523+
all_params.append("gas_used")
519524

520525
for key, val in six.iteritems(local_var_params["kwargs"]):
521526
if key not in all_params:
@@ -645,6 +650,7 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501
645650
all_params.append("year")
646651
all_params.append("transaction_value_btc_sats")
647652
all_params.append("timestamp")
653+
all_params.append("gas_used")
648654

649655
for key, val in six.iteritems(local_var_params["kwargs"]):
650656
if key not in all_params:

‎patch_api/api/preferences_api.py

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class PreferencesApi(object):
4242
"year",
4343
"transaction_value_btc_sats",
4444
"timestamp",
45+
"gas_used",
4546
]
4647

4748
def __init__(self, api_client=None):
@@ -121,6 +122,7 @@ def create_preference_with_http_info(
121122
all_params.append("year")
122123
all_params.append("transaction_value_btc_sats")
123124
all_params.append("timestamp")
125+
all_params.append("gas_used")
124126

125127
for key, val in six.iteritems(local_var_params["kwargs"]):
126128
if key not in all_params:
@@ -260,6 +262,7 @@ def delete_preference_with_http_info(self, id, **kwargs): # noqa: E501
260262
all_params.append("year")
261263
all_params.append("transaction_value_btc_sats")
262264
all_params.append("timestamp")
265+
all_params.append("gas_used")
263266

264267
for key, val in six.iteritems(local_var_params["kwargs"]):
265268
if key not in all_params:
@@ -389,6 +392,7 @@ def retrieve_preference_with_http_info(self, id, **kwargs): # noqa: E501
389392
all_params.append("year")
390393
all_params.append("transaction_value_btc_sats")
391394
all_params.append("timestamp")
395+
all_params.append("gas_used")
392396

393397
for key, val in six.iteritems(local_var_params["kwargs"]):
394398
if key not in all_params:
@@ -518,6 +522,7 @@ def retrieve_preferences_with_http_info(self, **kwargs): # noqa: E501
518522
all_params.append("year")
519523
all_params.append("transaction_value_btc_sats")
520524
all_params.append("timestamp")
525+
all_params.append("gas_used")
521526

522527
for key, val in six.iteritems(local_var_params["kwargs"]):
523528
if key not in all_params:

‎patch_api/api/projects_api.py

+3
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class ProjectsApi(object):
4242
"year",
4343
"transaction_value_btc_sats",
4444
"timestamp",
45+
"gas_used",
4546
]
4647

4748
def __init__(self, api_client=None):
@@ -117,6 +118,7 @@ def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501
117118
all_params.append("year")
118119
all_params.append("transaction_value_btc_sats")
119120
all_params.append("timestamp")
121+
all_params.append("gas_used")
120122

121123
for key, val in six.iteritems(local_var_params["kwargs"]):
122124
if key not in all_params:
@@ -252,6 +254,7 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501
252254
all_params.append("year")
253255
all_params.append("transaction_value_btc_sats")
254256
all_params.append("timestamp")
257+
all_params.append("gas_used")
255258

256259
for key, val in six.iteritems(local_var_params["kwargs"]):
257260
if key not in all_params:

‎patch_api/api_client.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __init__(
9191
self.default_headers[header_name] = header_value
9292
self.cookie = cookie
9393
# Set default User-Agent.
94-
self.user_agent = "OpenAPI-Generator/1.7.0/python"
94+
self.user_agent = "OpenAPI-Generator/1.8.0/python"
9595

9696
def __del__(self):
9797
if self._pool:

‎patch_api/configuration.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ def to_debug_report(self):
341341
"OS: {env}\n"
342342
"Python Version: {pyversion}\n"
343343
"Version of the API: v1\n"
344-
"SDK Package Version: 1.7.0".format(env=sys.platform, pyversion=sys.version)
344+
"SDK Package Version: 1.8.0".format(env=sys.platform, pyversion=sys.version)
345345
)
346346

347347
def get_host_settings(self):

‎setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from setuptools import setup, find_packages # noqa: H301
1313

1414
NAME = "patch-api"
15-
VERSION = "1.7.0"
15+
VERSION = "1.8.0"
1616
# To install the library, run the following
1717
#
1818
# python setup.py install

‎test/test_estimates_api.py

+12
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,18 @@ def test_create_bitcoin_estimate_transaction_value(self):
142142
estimate.data.mass_g, 200
143143
) # not setting an exact value since this is changing daily
144144

145+
def test_create_ethereum_estimate_transaction_value(self):
146+
"""Test case for create_ethereum_estimate
147+
148+
Create an estimate based on a transaction amount # noqa: E501
149+
"""
150+
151+
estimate = self.api.create_ethereum_estimate(gas_used=1000)
152+
self.assertEqual(estimate.data.type, "ethereum")
153+
self.assertGreater(
154+
estimate.data.mass_g, 1
155+
) # not setting an exact value since this is changing daily
156+
145157

146158
if __name__ == "__main__":
147159
unittest.main()

0 commit comments

Comments
 (0)
Please sign in to comment.