Skip to content

Commit e1ff181

Browse files
committed
Remove opts arg
1 parent 70bf760 commit e1ff181

File tree

8 files changed

+146
-102
lines changed

8 files changed

+146
-102
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 & 18 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
@@ -58,11 +60,11 @@ def create_mass_estimate(
5860
"""
5961
kwargs["_return_http_data_only"] = True
6062
return self.create_mass_estimate_with_http_info(
61-
opts, create_mass_estimate_request, **kwargs
63+
create_mass_estimate_request, **kwargs
6264
) # noqa: E501
6365

6466
def create_mass_estimate_with_http_info(
65-
self, opts, create_mass_estimate_request, **kwargs
67+
self, create_mass_estimate_request, **kwargs
6668
): # noqa: E501
6769
"""Create an estimate based on mass of CO2 # noqa: E501
6870
@@ -74,7 +76,6 @@ def create_mass_estimate_with_http_info(
7476
7577
:param async_req bool: execute request asynchronously
7678
:param CreateMassEstimateRequest create_mass_estimate_request: (required)
77-
:param dict opts: dictionary holding the optional arguments for the query (required)
7879
:param _return_http_data_only: response data without head status code
7980
and headers
8081
:param _preload_content: if False, the urllib3.HTTPResponse object will
@@ -96,6 +97,10 @@ def create_mass_estimate_with_http_info(
9697
all_params.append("_return_http_data_only")
9798
all_params.append("_preload_content")
9899
all_params.append("_request_timeout")
100+
all_params.append("mass_g")
101+
all_params.append("price_cents_usd")
102+
all_params.append("project_id")
103+
all_params.append("metadata")
99104

100105
for key, val in six.iteritems(local_var_params["kwargs"]):
101106
if key not in all_params:
@@ -119,8 +124,8 @@ def create_mass_estimate_with_http_info(
119124
path_params = {}
120125

121126
query_params = []
122-
for key in opts:
123-
query_params.append([key, opts.get(key)])
127+
for key in kwargs:
128+
query_params.append([key, kwargs.get(key)])
124129

125130
header_params = {}
126131

@@ -165,7 +170,7 @@ def create_mass_estimate_with_http_info(
165170
collection_formats=collection_formats,
166171
)
167172

168-
def retrieve_estimate(self, opts={}, id={}, **kwargs): # noqa: E501
173+
def retrieve_estimate(self, id={}, **kwargs): # noqa: E501
169174
"""Retrieves an estimate # noqa: E501
170175
171176
Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for. # noqa: E501
@@ -189,9 +194,9 @@ def retrieve_estimate(self, opts={}, id={}, **kwargs): # noqa: E501
189194
returns the request thread.
190195
"""
191196
kwargs["_return_http_data_only"] = True
192-
return self.retrieve_estimate_with_http_info(opts, id, **kwargs) # noqa: E501
197+
return self.retrieve_estimate_with_http_info(id, **kwargs) # noqa: E501
193198

194-
def retrieve_estimate_with_http_info(self, opts, id, **kwargs): # noqa: E501
199+
def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501
195200
"""Retrieves an estimate # noqa: E501
196201
197202
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 +207,6 @@ def retrieve_estimate_with_http_info(self, opts, id, **kwargs): # noqa: E501
202207
203208
:param async_req bool: execute request asynchronously
204209
:param str id: (required)
205-
:param dict opts: dictionary holding the optional arguments for the query (required)
206210
:param _return_http_data_only: response data without head status code
207211
and headers
208212
:param _preload_content: if False, the urllib3.HTTPResponse object will
@@ -224,6 +228,10 @@ def retrieve_estimate_with_http_info(self, opts, id, **kwargs): # noqa: E501
224228
all_params.append("_return_http_data_only")
225229
all_params.append("_preload_content")
226230
all_params.append("_request_timeout")
231+
all_params.append("mass_g")
232+
all_params.append("price_cents_usd")
233+
all_params.append("project_id")
234+
all_params.append("metadata")
227235

228236
for key, val in six.iteritems(local_var_params["kwargs"]):
229237
if key not in all_params:
@@ -246,8 +254,8 @@ def retrieve_estimate_with_http_info(self, opts, id, **kwargs): # noqa: E501
246254
path_params["id"] = local_var_params["id"] # noqa: E501
247255

248256
query_params = []
249-
for key in opts:
250-
query_params.append([key, opts.get(key)])
257+
for key in kwargs:
258+
query_params.append([key, kwargs.get(key)])
251259

252260
header_params = {}
253261

@@ -283,7 +291,7 @@ def retrieve_estimate_with_http_info(self, opts, id, **kwargs): # noqa: E501
283291
collection_formats=collection_formats,
284292
)
285293

286-
def retrieve_estimates(self, opts={}, **kwargs): # noqa: E501
294+
def retrieve_estimates(self, **kwargs): # noqa: E501
287295
"""Retrieves a list of estimates # noqa: E501
288296
289297
Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for. # noqa: E501
@@ -307,9 +315,9 @@ def retrieve_estimates(self, opts={}, **kwargs): # noqa: E501
307315
returns the request thread.
308316
"""
309317
kwargs["_return_http_data_only"] = True
310-
return self.retrieve_estimates_with_http_info(opts, **kwargs) # noqa: E501
318+
return self.retrieve_estimates_with_http_info(**kwargs) # noqa: E501
311319

312-
def retrieve_estimates_with_http_info(self, opts, **kwargs): # noqa: E501
320+
def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501
313321
"""Retrieves a list of estimates # noqa: E501
314322
315323
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 +328,6 @@ def retrieve_estimates_with_http_info(self, opts, **kwargs): # noqa: E501
320328
321329
:param async_req bool: execute request asynchronously
322330
:param int page:
323-
:param dict opts: dictionary holding the optional arguments for the query (required)
324331
:param _return_http_data_only: response data without head status code
325332
and headers
326333
:param _preload_content: if False, the urllib3.HTTPResponse object will
@@ -342,6 +349,10 @@ def retrieve_estimates_with_http_info(self, opts, **kwargs): # noqa: E501
342349
all_params.append("_return_http_data_only")
343350
all_params.append("_preload_content")
344351
all_params.append("_request_timeout")
352+
all_params.append("mass_g")
353+
all_params.append("price_cents_usd")
354+
all_params.append("project_id")
355+
all_params.append("metadata")
345356

346357
for key, val in six.iteritems(local_var_params["kwargs"]):
347358
if key not in all_params:
@@ -357,8 +368,8 @@ def retrieve_estimates_with_http_info(self, opts, **kwargs): # noqa: E501
357368
path_params = {}
358369

359370
query_params = []
360-
for key in opts:
361-
query_params.append([key, opts.get(key)])
371+
for key in kwargs:
372+
query_params.append([key, kwargs.get(key)])
362373
if "page" in local_var_params:
363374
query_params.append(("page", local_var_params["page"])) # noqa: E501
364375

0 commit comments

Comments
 (0)