Skip to content

Commit ca9a692

Browse files
committed
update Readme
1 parent 5b433e8 commit ca9a692

File tree

5 files changed

+29
-577
lines changed

5 files changed

+29
-577
lines changed

README.md

Lines changed: 28 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,13 @@ pip install patch_api
3232

3333
### Configuration
3434

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:
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. The `patch` object will be used to to make calls to the Patch API:
3636

3737
```python
3838
import patch_api
3939

40-
api_client = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
41-
```
42-
43-
The `api_client` will be used to instantiate other API objects for Patch resources, for example the `OrdersApi`:
44-
45-
```
46-
import patch_api
47-
from patch_api.api.orders_api import OrdersApi as Orders
48-
49-
api_client = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
50-
orders_api = Orders(api_client=api_client)
40+
patch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
41+
orders = patch.orders.retrieve_orders()
5142
```
5243

5344
### Orders
@@ -64,44 +55,42 @@ fulfill the order for you.
6455
#### Examples
6556
```python
6657
import patch_api
67-
from patch_api.api.orders_api import OrdersApi as Orders
6858

69-
api_client = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
70-
orders_api = Orders(api_client=api_client)
59+
patch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
7160

7261
# Create an order - you can create an order
7362
# providing either mass_g or total_price_cents_usd, but not both
7463

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

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

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

8675
## Orders also accept a metadata field (optional)
8776
metadata = {user: "john doe"}
88-
orders_api.create_order(opts={'metadata': metadata, 'mass_g': mass_g})
77+
patch.orders.create_order(opts={'metadata': metadata, 'mass_g': mass_g})
8978

9079
# Retrieve an order
9180
order_id = 'ord_test_1234' # Pass in the order's id
92-
orders_api.retrieve_order(id=order_id)
81+
patch.orders.retrieve_order(id=order_id)
9382

9483
# Place an order
9584
order_id = 'ord_test_1234' # Pass in the order's id
96-
orders_api.place_order(id=order_id)
85+
patch.orders.place_order(id=order_id)
9786

9887
# Cancel an order
9988
order_id = 'ord_test_1234' # Pass in the order's id
100-
orders_api.cancel_order(id=order_id)
89+
patch.orders.cancel_order(id=order_id)
10190

10291
# Retrieve a list of orders
10392
page = 1 # Pass in which page of orders you'd like
104-
orders_api.retrieve_orders(page=page)
93+
patch.orders.retrieve_orders(page=page)
10594
```
10695

10796
### Estimates
@@ -112,27 +101,25 @@ Estimates allow API users to get a quote for the cost of compensating a certain
112101
#### Examples
113102
```python
114103
import patch_api
115-
from patch_api.api.estimates_api import EstimatesApi as Estimates
116104

117-
api_client = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
118-
estimates_api = Estimates(api_client=api_client)
105+
patch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
119106

120107
# Create an estimate
121108

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

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

129116
# Retrieve an estimate
130117
estimate_id = 'est_test_1234'
131-
estimates_api.retrieve_estimate(id=estimate_id)
118+
patch.estimates.retrieve_estimate(id=estimate_id)
132119

133120
# Retrieve a list of estimates
134121
page = 1 # Pass in which page of estimates you'd like
135-
estimates_api.retrieve_estimates(page=page)
122+
patch.estimates.retrieve_estimates(page=page)
136123
```
137124

138125
### Projects
@@ -143,18 +130,16 @@ Projects are the ways Patch takes CO2 out of the air. They can represent refores
143130
#### Examples
144131
```python
145132
import patch_api
146-
from patch_api.api.projects_api import ProjectsApi as Projects
147133

148-
api_client = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
149-
projects_api = Projects(api_client=api_client)
134+
patch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
150135

151136
# Retrieve a project
152137
project_id = 'pro_test_1234' # Pass in the project's ID
153-
projects_api.retrieve_project(id=project_id)
138+
patch.projects.retrieve_project(id=project_id)
154139

155140
# Retrieve a list of projects
156141
page = 1 # Pass in which page of projects you'd like
157-
projects_api.retrieve_projects(page=page)
142+
patch.projects.retrieve_projects(page=page)
158143
```
159144

160145
### Preferences
@@ -165,27 +150,25 @@ Preferences are how you route your orders in Patch. If you don't have a preferen
165150
#### Examples
166151
```python
167152
import patch_api
168-
from patch_api.api.preferences_api import PreferencesApi as Preferences
169153

170-
api_client = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
171-
preferences_api = Preferences(api_client=api_client)
154+
patch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
172155

173156
# Create a preference
174157

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

178161
# Retrieve a preference
179162
preference_id = 'pre_test_1234' # Pass in the preferences's id
180-
preferences_api.retrieve_preference(preference_id=preference_id)
163+
patch.preferences.retrieve_preference(preference_id=preference_id)
181164

182165
# Delete a preference
183166
preference_id = 'pre_test_1234' # Pass in the preferences's id
184-
preferences_api.delete_preference(preference_id=preference_id)
167+
patch.preferences.delete_preference(preference_id=preference_id)
185168

186169
# Retrieve a list of preferences
187170
page = 1 # Pass in which page of preferences you'd like
188-
preferences_api.retrieve_preferences(page=page)
171+
patch.preferences.retrieve_preferences(page=page)
189172
```
190173

191174
## Development
@@ -231,15 +214,8 @@ To test the package locally, create a python file in a sibling directory and add
231214
import os
232215
import patch_api
233216

234-
# ..... your Patch API code goes here. See example below:
235-
236-
from patch_api.api.orders_api import OrdersApi as Orders
237-
238-
api_client = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
239-
orders = Orders(api_client=api_client)
240-
241-
list_orders = orders.retrieve_orders(opts={'page': 1})
217+
patch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
218+
orders = patch.orders.retrieve_orders(opts={'page': 1})
242219

243-
# Prints your organization's orders
244-
print(list_orders)
220+
print(orders)
245221
```

patch_api/models/create_mass_estimate_request.py

Lines changed: 0 additions & 166 deletions
This file was deleted.

0 commit comments

Comments
 (0)