Skip to content

Commit 3884675

Browse files
committed
update Readme
1 parent 5b433e8 commit 3884675

File tree

1 file changed

+28
-44
lines changed

1 file changed

+28
-44
lines changed

README.md

Lines changed: 28 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,13 @@ import patch_api
4040
api_client = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
4141
```
4242

43-
The `api_client` will be used to instantiate other API objects for Patch resources, for example the `OrdersApi`:
43+
The `api_client` will be used to to make calls to the Patch API:
4444

4545
```
4646
import patch_api
47-
from patch_api.api.orders_api import OrdersApi as Orders
4847
49-
api_client = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
50-
orders_api = Orders(api_client=api_client)
48+
patch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
49+
orders = patch.orders.retrieve_orders()
5150
```
5251

5352
### Orders
@@ -64,44 +63,42 @@ fulfill the order for you.
6463
#### Examples
6564
```python
6665
import patch_api
67-
from patch_api.api.orders_api import OrdersApi as Orders
6866

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

7269
# Create an order - you can create an order
7370
# providing either mass_g or total_price_cents_usd, but not both
7471

7572
# 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)
73+
patch.orders.create_order(opts={'mass_g': 1_000_000}) # Pass in the mass in grams (i.e. 1 metric tonne)
7774

7875
# Create an order with maximum total price
7976
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})
77+
patch.orders.create_order(opts={'total_price_cents_usd': total_price_cents_usd})
8178

8279
## You can also specify a project-id field (optional) to be used instead of the preferred one
8380
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})
81+
patch.orders.create_order(opts={'project_id': project_id, 'mass_g': mass_g})
8582

8683
## Orders also accept a metadata field (optional)
8784
metadata = {user: "john doe"}
88-
orders_api.create_order(opts={'metadata': metadata, 'mass_g': mass_g})
85+
patch.orders.create_order(opts={'metadata': metadata, 'mass_g': mass_g})
8986

9087
# Retrieve an order
9188
order_id = 'ord_test_1234' # Pass in the order's id
92-
orders_api.retrieve_order(id=order_id)
89+
patch.orders.retrieve_order(id=order_id)
9390

9491
# Place an order
9592
order_id = 'ord_test_1234' # Pass in the order's id
96-
orders_api.place_order(id=order_id)
93+
patch.orders.place_order(id=order_id)
9794

9895
# Cancel an order
9996
order_id = 'ord_test_1234' # Pass in the order's id
100-
orders_api.cancel_order(id=order_id)
97+
patch.orders.cancel_order(id=order_id)
10198

10299
# Retrieve a list of orders
103100
page = 1 # Pass in which page of orders you'd like
104-
orders_api.retrieve_orders(page=page)
101+
patch.orders.retrieve_orders(page=page)
105102
```
106103

107104
### Estimates
@@ -112,27 +109,25 @@ Estimates allow API users to get a quote for the cost of compensating a certain
112109
#### Examples
113110
```python
114111
import patch_api
115-
from patch_api.api.estimates_api import EstimatesApi as Estimates
116112

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

120115
# Create an estimate
121116

122117
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})
118+
patch.estimates.create_estimate(opts={'mass_g': mass_g})
124119

125120
## You can also specify a project-id field (optional) to be used instead of the preferred one
126121
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})
122+
patch.estimates.create_estimate(opts={'mass_g': mass_g, 'project_id': project_id})
128123

129124
# Retrieve an estimate
130125
estimate_id = 'est_test_1234'
131-
estimates_api.retrieve_estimate(id=estimate_id)
126+
patch.estimates.retrieve_estimate(id=estimate_id)
132127

133128
# Retrieve a list of estimates
134129
page = 1 # Pass in which page of estimates you'd like
135-
estimates_api.retrieve_estimates(page=page)
130+
patch.estimates.retrieve_estimates(page=page)
136131
```
137132

138133
### Projects
@@ -143,18 +138,16 @@ Projects are the ways Patch takes CO2 out of the air. They can represent refores
143138
#### Examples
144139
```python
145140
import patch_api
146-
from patch_api.api.projects_api import ProjectsApi as Projects
147141

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

151144
# Retrieve a project
152145
project_id = 'pro_test_1234' # Pass in the project's ID
153-
projects_api.retrieve_project(id=project_id)
146+
patch.projects.retrieve_project(id=project_id)
154147

155148
# Retrieve a list of projects
156149
page = 1 # Pass in which page of projects you'd like
157-
projects_api.retrieve_projects(page=page)
150+
patch.projects.retrieve_projects(page=page)
158151
```
159152

160153
### Preferences
@@ -165,27 +158,25 @@ Preferences are how you route your orders in Patch. If you don't have a preferen
165158
#### Examples
166159
```python
167160
import patch_api
168-
from patch_api.api.preferences_api import PreferencesApi as Preferences
169161

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

173164
# Create a preference
174165

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

178169
# Retrieve a preference
179170
preference_id = 'pre_test_1234' # Pass in the preferences's id
180-
preferences_api.retrieve_preference(preference_id=preference_id)
171+
patch.preferences.retrieve_preference(preference_id=preference_id)
181172

182173
# Delete a preference
183174
preference_id = 'pre_test_1234' # Pass in the preferences's id
184-
preferences_api.delete_preference(preference_id=preference_id)
175+
patch.preferences.delete_preference(preference_id=preference_id)
185176

186177
# Retrieve a list of preferences
187178
page = 1 # Pass in which page of preferences you'd like
188-
preferences_api.retrieve_preferences(page=page)
179+
patch.preferences.retrieve_preferences(page=page)
189180
```
190181

191182
## Development
@@ -231,15 +222,8 @@ To test the package locally, create a python file in a sibling directory and add
231222
import os
232223
import patch_api
233224

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})
225+
patch = patch_api.ApiClient(api_key=os.environ.get('SANDBOX_API_KEY'))
226+
orders = patch.orders.retrieve_orders(opts={'page': 1})
242227

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

0 commit comments

Comments
 (0)