Skip to content

Commit 456ba16

Browse files
committed
Remove opts arg
1 parent 70bf760 commit 456ba16

File tree

8 files changed

+146
-116
lines changed

8 files changed

+146
-116
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,19 @@ patch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
6262
# providing either mass_g or total_price_cents_usd, but not both
6363

6464
# Create order with mass
65-
patch.orders.create_order(opts={'mass_g': 1_000_000}) # Pass in the mass in grams (i.e. 1 metric tonne)
65+
patch.orders.create_order(mass_g=1_000_000) # Pass in the mass in grams (i.e. 1 metric tonne)
6666

6767
# Create an order with maximum total price
6868
total_price_cents_usd = 5_00 # Pass in the total price in cents (i.e. 5 dollars)
69-
patch.orders.create_order(opts={'total_price_cents_usd': total_price_cents_usd})
69+
patch.orders.create_order(total_price_cents_usd=total_price_cents_usd)
7070

7171
## You can also specify a project-id field (optional) to be used instead of the preferred one
7272
project_id = 'pro_test_1234' # Pass in the project's ID
73-
patch.orders.create_order(opts={'project_id': project_id, 'mass_g': mass_g})
73+
patch.orders.create_order(project_id=project_id, mass_g=mass_g)
7474

7575
## Orders also accept a metadata field (optional)
7676
metadata = {user: "john doe"}
77-
patch.orders.create_order(opts={'metadata': metadata, 'mass_g': mass_g})
77+
patch.orders.create_order(metadata=metadata, mass_g=mass_g)
7878

7979
# Retrieve an order
8080
order_id = 'ord_test_1234' # Pass in the order's id
@@ -107,11 +107,11 @@ patch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
107107
# Create an estimate
108108

109109
mass_g = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
110-
patch.estimates.create_estimate(opts={'mass_g': mass_g})
110+
patch.estimates.create_estimate(mass_g=mass_g)
111111

112112
## You can also specify a project-id field (optional) to be used instead of the preferred one
113113
project_id = 'pro_test_1234' # Pass in the project's ID
114-
patch.estimates.create_estimate(opts={'mass_g': mass_g, 'project_id': project_id})
114+
patch.estimates.create_estimate(mass_g=mass_g, project_id=project_id)
115115

116116
# Retrieve an estimate
117117
estimate_id = 'est_test_1234'
@@ -156,7 +156,7 @@ patch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
156156
# Create a preference
157157

158158
project_id = 'pro_test_1234' # Pass in the project_id for your preference
159-
patch.preferences.create_preference(opts={'project_id': project_id})
159+
patch.preferences.create_preference(project_id=project_id)
160160

161161
# Retrieve a preference
162162
preference_id = 'pre_test_1234' # Pass in the preferences's id
@@ -215,7 +215,7 @@ import os
215215
import patch_api
216216

217217
patch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
218-
orders = patch.orders.retrieve_orders(opts={'page': 1})
218+
orders = patch.orders.retrieve_orders(page=1)
219219

220220
print(orders)
221221
```

patch_api/api/estimates_api.py

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ class EstimatesApi(object):
2828
Do not edit the class manually.
2929
"""
3030

31+
ALLOWED_QUERY_PARAMS = ["mass_g", "price_cents_usd", "project_id", "page"]
32+
3133
def __init__(self, api_client=None):
3234
self.api_client = api_client
3335

3436
def create_mass_estimate(
35-
self, opts={}, create_mass_estimate_request={}, **kwargs
37+
self, create_mass_estimate_request={}, **kwargs
3638
): # noqa: E501
3739
"""Create an estimate based on mass of CO2 # noqa: E501
3840
@@ -44,7 +46,6 @@ def create_mass_estimate(
4446
4547
:param async_req bool: execute request asynchronously
4648
:param CreateMassEstimateRequest create_mass_estimate_request: (required)
47-
:param dict opts: dictionary holding the optional arguments for the query (optional)
4849
:param _preload_content: if False, the urllib3.HTTPResponse object will
4950
be returned without reading/decoding response
5051
data. Default is True.
@@ -58,11 +59,11 @@ def create_mass_estimate(
5859
"""
5960
kwargs["_return_http_data_only"] = True
6061
return self.create_mass_estimate_with_http_info(
61-
opts, create_mass_estimate_request, **kwargs
62+
create_mass_estimate_request, **kwargs
6263
) # noqa: E501
6364

6465
def create_mass_estimate_with_http_info(
65-
self, opts, create_mass_estimate_request, **kwargs
66+
self, create_mass_estimate_request, **kwargs
6667
): # noqa: E501
6768
"""Create an estimate based on mass of CO2 # noqa: E501
6869
@@ -74,7 +75,6 @@ def create_mass_estimate_with_http_info(
7475
7576
:param async_req bool: execute request asynchronously
7677
:param CreateMassEstimateRequest create_mass_estimate_request: (required)
77-
:param dict opts: dictionary holding the optional arguments for the query (required)
7878
:param _return_http_data_only: response data without head status code
7979
and headers
8080
:param _preload_content: if False, the urllib3.HTTPResponse object will
@@ -96,6 +96,10 @@ def create_mass_estimate_with_http_info(
9696
all_params.append("_return_http_data_only")
9797
all_params.append("_preload_content")
9898
all_params.append("_request_timeout")
99+
all_params.append("mass_g")
100+
all_params.append("price_cents_usd")
101+
all_params.append("project_id")
102+
all_params.append("metadata")
99103

100104
for key, val in six.iteritems(local_var_params["kwargs"]):
101105
if key not in all_params:
@@ -119,8 +123,8 @@ def create_mass_estimate_with_http_info(
119123
path_params = {}
120124

121125
query_params = []
122-
for key in opts:
123-
query_params.append([key, opts.get(key)])
126+
for key in kwargs:
127+
query_params.append([key, kwargs.get(key)])
124128

125129
header_params = {}
126130

@@ -165,7 +169,7 @@ def create_mass_estimate_with_http_info(
165169
collection_formats=collection_formats,
166170
)
167171

168-
def retrieve_estimate(self, opts={}, id={}, **kwargs): # noqa: E501
172+
def retrieve_estimate(self, id={}, **kwargs): # noqa: E501
169173
"""Retrieves an estimate # noqa: E501
170174
171175
Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for. # noqa: E501
@@ -176,7 +180,6 @@ def retrieve_estimate(self, opts={}, id={}, **kwargs): # noqa: E501
176180
177181
:param async_req bool: execute request asynchronously
178182
:param str id: (required)
179-
:param dict opts: dictionary holding the optional arguments for the query (optional)
180183
:param _preload_content: if False, the urllib3.HTTPResponse object will
181184
be returned without reading/decoding response
182185
data. Default is True.
@@ -189,9 +192,9 @@ def retrieve_estimate(self, opts={}, id={}, **kwargs): # noqa: E501
189192
returns the request thread.
190193
"""
191194
kwargs["_return_http_data_only"] = True
192-
return self.retrieve_estimate_with_http_info(opts, id, **kwargs) # noqa: E501
195+
return self.retrieve_estimate_with_http_info(id, **kwargs) # noqa: E501
193196

194-
def retrieve_estimate_with_http_info(self, opts, id, **kwargs): # noqa: E501
197+
def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501
195198
"""Retrieves an estimate # noqa: E501
196199
197200
Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for. # noqa: E501
@@ -202,7 +205,6 @@ def retrieve_estimate_with_http_info(self, opts, id, **kwargs): # noqa: E501
202205
203206
:param async_req bool: execute request asynchronously
204207
:param str id: (required)
205-
:param dict opts: dictionary holding the optional arguments for the query (required)
206208
:param _return_http_data_only: response data without head status code
207209
and headers
208210
:param _preload_content: if False, the urllib3.HTTPResponse object will
@@ -224,6 +226,10 @@ def retrieve_estimate_with_http_info(self, opts, id, **kwargs): # noqa: E501
224226
all_params.append("_return_http_data_only")
225227
all_params.append("_preload_content")
226228
all_params.append("_request_timeout")
229+
all_params.append("mass_g")
230+
all_params.append("price_cents_usd")
231+
all_params.append("project_id")
232+
all_params.append("metadata")
227233

228234
for key, val in six.iteritems(local_var_params["kwargs"]):
229235
if key not in all_params:
@@ -246,8 +252,8 @@ def retrieve_estimate_with_http_info(self, opts, id, **kwargs): # noqa: E501
246252
path_params["id"] = local_var_params["id"] # noqa: E501
247253

248254
query_params = []
249-
for key in opts:
250-
query_params.append([key, opts.get(key)])
255+
for key in kwargs:
256+
query_params.append([key, kwargs.get(key)])
251257

252258
header_params = {}
253259

@@ -283,7 +289,7 @@ def retrieve_estimate_with_http_info(self, opts, id, **kwargs): # noqa: E501
283289
collection_formats=collection_formats,
284290
)
285291

286-
def retrieve_estimates(self, opts={}, **kwargs): # noqa: E501
292+
def retrieve_estimates(self, **kwargs): # noqa: E501
287293
"""Retrieves a list of estimates # noqa: E501
288294
289295
Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for. # noqa: E501
@@ -294,7 +300,6 @@ def retrieve_estimates(self, opts={}, **kwargs): # noqa: E501
294300
295301
:param async_req bool: execute request asynchronously
296302
:param int page:
297-
:param dict opts: dictionary holding the optional arguments for the query (optional)
298303
:param _preload_content: if False, the urllib3.HTTPResponse object will
299304
be returned without reading/decoding response
300305
data. Default is True.
@@ -307,9 +312,9 @@ def retrieve_estimates(self, opts={}, **kwargs): # noqa: E501
307312
returns the request thread.
308313
"""
309314
kwargs["_return_http_data_only"] = True
310-
return self.retrieve_estimates_with_http_info(opts, **kwargs) # noqa: E501
315+
return self.retrieve_estimates_with_http_info(**kwargs) # noqa: E501
311316

312-
def retrieve_estimates_with_http_info(self, opts, **kwargs): # noqa: E501
317+
def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501
313318
"""Retrieves a list of estimates # noqa: E501
314319
315320
Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for. # noqa: E501
@@ -320,7 +325,6 @@ def retrieve_estimates_with_http_info(self, opts, **kwargs): # noqa: E501
320325
321326
:param async_req bool: execute request asynchronously
322327
:param int page:
323-
:param dict opts: dictionary holding the optional arguments for the query (required)
324328
:param _return_http_data_only: response data without head status code
325329
and headers
326330
:param _preload_content: if False, the urllib3.HTTPResponse object will
@@ -342,6 +346,10 @@ def retrieve_estimates_with_http_info(self, opts, **kwargs): # noqa: E501
342346
all_params.append("_return_http_data_only")
343347
all_params.append("_preload_content")
344348
all_params.append("_request_timeout")
349+
all_params.append("mass_g")
350+
all_params.append("price_cents_usd")
351+
all_params.append("project_id")
352+
all_params.append("metadata")
345353

346354
for key, val in six.iteritems(local_var_params["kwargs"]):
347355
if key not in all_params:
@@ -357,8 +365,8 @@ def retrieve_estimates_with_http_info(self, opts, **kwargs): # noqa: E501
357365
path_params = {}
358366

359367
query_params = []
360-
for key in opts:
361-
query_params.append([key, opts.get(key)])
368+
for key in kwargs:
369+
query_params.append([key, kwargs.get(key)])
362370
if "page" in local_var_params:
363371
query_params.append(("page", local_var_params["page"])) # noqa: E501
364372

0 commit comments

Comments
 (0)