Skip to content

Commit 672df0c

Browse files
committed
wip
1 parent f7679cf commit 672df0c

32 files changed

+148
-1332
lines changed

README.md

Lines changed: 28 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -32,27 +32,24 @@ pip install patch
3232

3333
### Configuration
3434

35-
After installing the gem, you'll have to configure it with your API key which is available from the API key page in the Patch dashboard:
35+
After installing the gem, you'll have to initialize it with your API key which is available from the API key page in the Patch dashboard:
3636

3737
```python
3838
import patch_api
3939

40-
configuration = patch_api.Configuration(api_key=os.environ.get('SANDBOX_API_KEY'))
41-
api_client = patch_api.ApiClient(configuration)
40+
api_client = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
4241
```
4342

4443
The `api_client` will be used to instantiate other API objects for Patch resources, for example the `OrdersApi`:
4544

4645
```
4746
import patch_api
48-
from patch_api.api.orders_api import OrdersApi
47+
from patch_api.api.orders_api import OrdersApi as Orders
4948
50-
configuration = patch_api.Configuration(api_key=os.environ.get('SANDBOX_API_KEY'))
51-
api_client = patch_api.ApiClient(configuration)
52-
orders_api = OrdersApi(api_client=api_client)
49+
api_client = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
50+
orders_api = Orders(api_client=api_client)
5351
```
5452

55-
5653
### Orders
5754
In Patch, orders represent a purchase of carbon offsets or negative emissions by mass. Place orders directly if you know the amount of carbon dioxide you would like to sequester. If you do not know how much to purchase, use an estimate.
5855

@@ -69,45 +66,38 @@ fulfill the order for you.
6966
# Create an order - you can create an order
7067
# providing either mass_g or total_price_cents_usd, but not both
7168

72-
from patch_api.models.create_order_request import CreateOrderRequest
69+
from patch_api.api.orders_api import OrdersApi as Orders
7370

7471
# Create order with mass
75-
mass_g = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
76-
create_order_request = CreateOrderRequest(mass_g=mass_g)
77-
OrdersApi.create_order(create_order_request)
72+
Orders.create_order(opts={'mass_g': 1_000_000}) # Pass in the mass in grams (i.e. 1 metric tonne)
7873

7974
# Create an order with maximum total price
8075
total_price_cents_usd = 5_00 # Pass in the total price in cents (i.e. 5 dollars)
81-
create_order_request = CreateOrderRequest(total_price_cents_usd=total_price_cents_usd)
82-
OrdersApi.create_order(create_order_request)
76+
Orders.create_order(opts={'total_price_cents_usd': total_price_cents_usd})
8377

8478
## You can also specify a project-id field (optional) to be used instead of the preferred one
8579
project_id = 'pro_test_1234' # Pass in the project's ID
86-
create_order_request = CreateOrderRequest(project_id=project_id, mass_g=mass_g)
87-
OrdersApi.create_order(create_order_request)
88-
80+
Orders.create_order(opts={'project_id': project_id, 'mass_g': mass_g})
8981

9082
## Orders also accept a metadata field (optional)
9183
metadata = {user: "john doe"}
92-
create_order_request = CreateOrderRequest(metadata=metadata, mass_g=mass_g)
93-
OrdersApi.create_order(create_order_request)
94-
84+
Orders.create_order(opts={'metadata': metadata, 'mass_g': mass_g})
9585

9686
# Retrieve an order
9787
order_id = 'ord_test_1234' # Pass in the order's id
98-
OrdersApi.retrieve_order(id=order_id)
88+
Orders.retrieve_order(id=order_id)
9989

10090
# Place an order
10191
order_id = 'ord_test_1234' # Pass in the order's id
102-
OrdersApi.place_order(id=order_id)
92+
Orders.place_order(id=order_id)
10393

10494
# Cancel an order
10595
order_id = 'ord_test_1234' # Pass in the order's id
106-
OrdersApi.cancel_order(id=order_id)
96+
Orders.cancel_order(id=order_id)
10797

10898
# Retrieve a list of orders
10999
page = 1 # Pass in which page of orders you'd like
110-
OrdersApi.retrieve_orders(page=page)
100+
Orders.retrieve_orders(page=page)
111101
```
112102

113103
### Estimates
@@ -118,24 +108,22 @@ Estimates allow API users to get a quote for the cost of compensating a certain
118108
#### Examples
119109
```python
120110
# Create an estimate
121-
from patch_api.models.create_estimate_request import CreateEstimateRequest
111+
from patch_api.api.estimates_api import EstimatesApi as Estimates
122112

123113
mass_g = 1_000_000 # Pass in the mass in grams (i.e. 1 metric tonne)
124-
create_estimate_request = CreateEstimateRequest(mass_g=mass_g)
125-
EstimatesApi.create_estimate(create_estimate_request)
114+
Estimates.create_estimate(opts={'mass_g': mass_g})
126115

127116
## You can also specify a project-id field (optional) to be used instead of the preferred one
128117
project_id = 'pro_test_1234' # Pass in the project's ID
129-
create_estimate_request = CreateEstimateRequest(mass_g=mass_g, project_id=project_id)
130-
EstimatesApi.create_estimate(create_estimate_request)
118+
Estimates.create_estimate(opts={'mass_g': mass_g, 'project_id': project_id})
131119

132120
# Retrieve an estimate
133121
estimate_id = 'est_test_1234'
134-
EstimatesApi.retrieve_estimate(id=estimate_id)
122+
Estimates.retrieve_estimate(id=estimate_id)
135123

136124
# Retrieve a list of estimates
137125
page = 1 # Pass in which page of estimates you'd like
138-
EstimatesApi.retrieve_estimates(page=page)
126+
Estimates.retrieve_estimates(page=page)
139127
```
140128

141129
### Projects
@@ -145,13 +133,15 @@ Projects are the ways Patch takes CO2 out of the air. They can represent refores
145133

146134
#### Examples
147135
```python
136+
from patch_api.api.projects_api import ProjectsApi as Projects
137+
148138
# Retrieve a project
149139
project_id = 'pro_test_1234' # Pass in the project's ID
150-
ProjectsApi.retrieve_project(id=project_id)
140+
Projects.retrieve_project(id=project_id)
151141

152142
# Retrieve a list of projects
153143
page = 1 # Pass in which page of projects you'd like
154-
ProjectsApi.retrieve_projects(page=page)
144+
Projects.retrieve_projects(page=page)
155145
```
156146

157147
### Preferences
@@ -162,23 +152,22 @@ Preferences are how you route your orders in Patch. If you don't have a preferen
162152
#### Examples
163153
```python
164154
# Create a preference
165-
from patch_api.models.create_preference_request import CreatePreferenceRequest
155+
from patch_api.api.preferences_api import PreferencesApi as Preferences
166156

167157
project_id = 'pro_test_1234' # Pass in the project_id for your preference
168-
create_preference_request = CreatePreferenceRequest(project_id=project_id)
169-
PreferencesApi.create_preference(create_preference_request)
158+
Preferences.create_preference(opts={'project_id': project_id})
170159

171160
# Retrieve a preference
172161
preference_id = 'pre_test_1234' # Pass in the preferences's id
173-
PreferencesApi.retrieve_preference(preference_id=preference_id)
162+
Preferences.retrieve_preference(preference_id=preference_id)
174163

175164
# Delete a preference
176165
preference_id = 'pre_test_1234' # Pass in the preferences's id
177-
PreferencesApi.delete_preference(preference_id=preference_id)
166+
Preferences.delete_preference(preference_id=preference_id)
178167

179168
# Retrieve a list of preferences
180169
page = 1 # Pass in which page of preferences you'd like
181-
PreferencesApi.retrieve_preferences(page=page)
170+
Preferences.retrieve_preferences(page=page)
182171
```
183172

184173
## Development

patch_api/__init__.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@
1717

1818
__version__ = "1.0.0"
1919

20-
# import apis into sdk package
21-
from patch_api.api.estimates_api import EstimatesApi
22-
from patch_api.api.orders_api import OrdersApi
23-
from patch_api.api.photos_api import PhotosApi
24-
from patch_api.api.preferences_api import PreferencesApi
25-
from patch_api.api.projects_api import ProjectsApi
26-
2720
# import ApiClient
2821
from patch_api.api_client import ApiClient
2922
from patch_api.configuration import Configuration
@@ -32,44 +25,3 @@
3225
from patch_api.exceptions import ApiValueError
3326
from patch_api.exceptions import ApiKeyError
3427
from patch_api.exceptions import ApiException
35-
36-
# import models into sdk package
37-
from patch_api.models.allocation import Allocation
38-
from patch_api.models.create_mass_estimate_request import CreateMassEstimateRequest
39-
from patch_api.models.create_membership_request import CreateMembershipRequest
40-
from patch_api.models.create_offset_request import CreateOffsetRequest
41-
from patch_api.models.create_order_request import CreateOrderRequest
42-
from patch_api.models.create_organization_request import CreateOrganizationRequest
43-
from patch_api.models.create_photo_request import CreatePhotoRequest
44-
from patch_api.models.create_preference_request import CreatePreferenceRequest
45-
from patch_api.models.create_project_request import CreateProjectRequest
46-
from patch_api.models.error_response import ErrorResponse
47-
from patch_api.models.estimate import Estimate
48-
from patch_api.models.estimate_list_response import EstimateListResponse
49-
from patch_api.models.estimate_response import EstimateResponse
50-
from patch_api.models.fulfill_offset_request import FulfillOffsetRequest
51-
from patch_api.models.membership import Membership
52-
from patch_api.models.membership_response import MembershipResponse
53-
from patch_api.models.meta_index_object import MetaIndexObject
54-
from patch_api.models.offset import Offset
55-
from patch_api.models.offset_list_response import OffsetListResponse
56-
from patch_api.models.offset_response import OffsetResponse
57-
from patch_api.models.order import Order
58-
from patch_api.models.order_list_response import OrderListResponse
59-
from patch_api.models.order_response import OrderResponse
60-
from patch_api.models.organization import Organization
61-
from patch_api.models.organization_list_response import OrganizationListResponse
62-
from patch_api.models.organization_response import OrganizationResponse
63-
from patch_api.models.photo import Photo
64-
from patch_api.models.photo_response import PhotoResponse
65-
from patch_api.models.preference import Preference
66-
from patch_api.models.preference_list_response import PreferenceListResponse
67-
from patch_api.models.preference_response import PreferenceResponse
68-
from patch_api.models.project import Project
69-
from patch_api.models.project_list_response import ProjectListResponse
70-
from patch_api.models.project_response import ProjectResponse
71-
from patch_api.models.project_type_list_response import ProjectTypeListResponse
72-
from patch_api.models.standard import Standard
73-
from patch_api.models.standard_list_response import StandardListResponse
74-
from patch_api.models.update_offset_request import UpdateOffsetRequest
75-
from patch_api.models.update_project_request import UpdateProjectRequest

patch_api/api/__init__.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +0,0 @@
1-
from __future__ import absolute_import
2-
3-
# flake8: noqa
4-
5-
# import apis into api package
6-
from patch_api.api.estimates_api import EstimatesApi
7-
from patch_api.api.orders_api import OrdersApi
8-
from patch_api.api.photos_api import PhotosApi
9-
from patch_api.api.preferences_api import PreferencesApi
10-
from patch_api.api.projects_api import ProjectsApi

patch_api/api/estimates_api.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(self, api_client=None):
3535
self.api_client = api_client
3636

3737
def create_mass_estimate(
38-
self, create_mass_estimate_request, **kwargs
38+
self, opts={}, create_mass_estimate_request={}, **kwargs
3939
): # noqa: E501
4040
"""Create an estimate based on mass of CO2 # noqa: E501
4141
@@ -47,6 +47,7 @@ def create_mass_estimate(
4747
4848
:param async_req bool: execute request asynchronously
4949
:param CreateMassEstimateRequest create_mass_estimate_request: (required)
50+
:param dict opts: dictionary holding the optional arguments for the query (optional)
5051
:param _preload_content: if False, the urllib3.HTTPResponse object will
5152
be returned without reading/decoding response
5253
data. Default is True.
@@ -60,11 +61,11 @@ def create_mass_estimate(
6061
"""
6162
kwargs["_return_http_data_only"] = True
6263
return self.create_mass_estimate_with_http_info(
63-
create_mass_estimate_request, **kwargs
64+
opts, create_mass_estimate_request, **kwargs
6465
) # noqa: E501
6566

6667
def create_mass_estimate_with_http_info(
67-
self, create_mass_estimate_request, **kwargs
68+
self, opts, create_mass_estimate_request, **kwargs
6869
): # noqa: E501
6970
"""Create an estimate based on mass of CO2 # noqa: E501
7071
@@ -76,6 +77,7 @@ def create_mass_estimate_with_http_info(
7677
7778
:param async_req bool: execute request asynchronously
7879
:param CreateMassEstimateRequest create_mass_estimate_request: (required)
80+
:param dict opts: dictionary holding the optional arguments for the query (required)
7981
:param _return_http_data_only: response data without head status code
8082
and headers
8183
:param _preload_content: if False, the urllib3.HTTPResponse object will
@@ -120,6 +122,8 @@ def create_mass_estimate_with_http_info(
120122
path_params = {}
121123

122124
query_params = []
125+
for key in opts:
126+
query_params.append([key, opts.get(key)])
123127

124128
header_params = {}
125129

@@ -164,7 +168,7 @@ def create_mass_estimate_with_http_info(
164168
collection_formats=collection_formats,
165169
)
166170

167-
def retrieve_estimate(self, id, **kwargs): # noqa: E501
171+
def retrieve_estimate(self, opts={}, id={}, **kwargs): # noqa: E501
168172
"""Retrieves an estimate # noqa: E501
169173
170174
Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for. # noqa: E501
@@ -175,6 +179,7 @@ def retrieve_estimate(self, id, **kwargs): # noqa: E501
175179
176180
:param async_req bool: execute request asynchronously
177181
:param str id: (required)
182+
:param dict opts: dictionary holding the optional arguments for the query (optional)
178183
:param _preload_content: if False, the urllib3.HTTPResponse object will
179184
be returned without reading/decoding response
180185
data. Default is True.
@@ -187,9 +192,9 @@ def retrieve_estimate(self, id, **kwargs): # noqa: E501
187192
returns the request thread.
188193
"""
189194
kwargs["_return_http_data_only"] = True
190-
return self.retrieve_estimate_with_http_info(id, **kwargs) # noqa: E501
195+
return self.retrieve_estimate_with_http_info(opts, id, **kwargs) # noqa: E501
191196

192-
def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501
197+
def retrieve_estimate_with_http_info(self, opts, id, **kwargs): # noqa: E501
193198
"""Retrieves an estimate # noqa: E501
194199
195200
Retrieves a given estimate and its associated order. You can only retrieve estimates associated with the organization you are querying for. # noqa: E501
@@ -200,6 +205,7 @@ def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501
200205
201206
:param async_req bool: execute request asynchronously
202207
:param str id: (required)
208+
:param dict opts: dictionary holding the optional arguments for the query (required)
203209
:param _return_http_data_only: response data without head status code
204210
and headers
205211
:param _preload_content: if False, the urllib3.HTTPResponse object will
@@ -243,6 +249,8 @@ def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501
243249
path_params["id"] = local_var_params["id"] # noqa: E501
244250

245251
query_params = []
252+
for key in opts:
253+
query_params.append([key, opts.get(key)])
246254

247255
header_params = {}
248256

@@ -278,7 +286,7 @@ def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501
278286
collection_formats=collection_formats,
279287
)
280288

281-
def retrieve_estimates(self, **kwargs): # noqa: E501
289+
def retrieve_estimates(self, opts={}, **kwargs): # noqa: E501
282290
"""Retrieves a list of estimates # noqa: E501
283291
284292
Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for. # noqa: E501
@@ -289,6 +297,7 @@ def retrieve_estimates(self, **kwargs): # noqa: E501
289297
290298
:param async_req bool: execute request asynchronously
291299
:param int page:
300+
:param dict opts: dictionary holding the optional arguments for the query (optional)
292301
:param _preload_content: if False, the urllib3.HTTPResponse object will
293302
be returned without reading/decoding response
294303
data. Default is True.
@@ -301,9 +310,9 @@ def retrieve_estimates(self, **kwargs): # noqa: E501
301310
returns the request thread.
302311
"""
303312
kwargs["_return_http_data_only"] = True
304-
return self.retrieve_estimates_with_http_info(**kwargs) # noqa: E501
313+
return self.retrieve_estimates_with_http_info(opts, **kwargs) # noqa: E501
305314

306-
def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501
315+
def retrieve_estimates_with_http_info(self, opts, **kwargs): # noqa: E501
307316
"""Retrieves a list of estimates # noqa: E501
308317
309318
Retrieves a list of estimates and their associated orders. You can only retrieve estimates associated with the organization you are querying for. # noqa: E501
@@ -314,6 +323,7 @@ def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501
314323
315324
:param async_req bool: execute request asynchronously
316325
:param int page:
326+
:param dict opts: dictionary holding the optional arguments for the query (required)
317327
:param _return_http_data_only: response data without head status code
318328
and headers
319329
:param _preload_content: if False, the urllib3.HTTPResponse object will
@@ -350,6 +360,8 @@ def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501
350360
path_params = {}
351361

352362
query_params = []
363+
for key in opts:
364+
query_params.append([key, opts.get(key)])
353365
if "page" in local_var_params:
354366
query_params.append(("page", local_var_params["page"])) # noqa: E501
355367

0 commit comments

Comments
 (0)