Skip to content

Commit 1915845

Browse files
committed
Merge branch 'main' into lovisa/add-test-for-filtering
2 parents 835ca57 + 8fec6da commit 1915845

11 files changed

+63
-49
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.4.0] - 2021-02-15
9+
10+
### Added
11+
12+
- Adds Sustainable Development Goals (SDGs) field to projects
13+
- Adds the ability to filter Projects on country, type
14+
15+
### Changed
16+
17+
- vehicle estimates now support optional `make`, `model` and `year` fields.
18+
819
## [1.3.1] - 2021-02-09
920

1021
### Fixed

README.md

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,38 @@
11
# Patch Python SDK
2+
23
![Test](https://github.com/patch-technology/patch-python/workflows/Test/badge.svg)
34
[![PyPI version](https://badge.fury.io/py/patch-api.svg)](https://badge.fury.io/py/patch-api)
45
[![Discord](https://img.shields.io/discord/733029448558837792)](https://discord.gg/AU8543D)
56

67
The official Python library for the [Patch API](https://www.usepatch.com).
78

89
## Documentation
10+
911
For a complete API reference, check out [Patch's API Reference.](https://docs.usepatch.com/).
1012

1113
## Installation
1214

1315
Add the library to your `requirements.txt` file:
16+
1417
```txt
15-
patch_api >= 1.3.1
18+
patch_api >= 1.4.0
1619
```
1720

1821
Then run:
22+
1923
```shell
2024
pip install -r requirements.txt
2125
```
2226

2327
Or install it directly with
28+
2429
```shell
2530
pip install patch-api
2631
```
2732

2833
### Requirements
29-
- Python 3.6.0
34+
35+
- Python 3.6.1
3036

3137
## Usage
3238

@@ -42,6 +48,7 @@ orders = patch.orders.retrieve_orders()
4248
```
4349

4450
### Orders
51+
4552
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.
4653

4754
In Patch, orders represent a purchase of carbon offsets or negative emissions by mass.
@@ -53,6 +60,7 @@ fulfill the order for you.
5360
[API Reference](https://docs.usepatch.com/#/?id=orders)
5461

5562
#### Examples
63+
5664
```python
5765
import patch_api
5866

@@ -94,11 +102,13 @@ patch.orders.retrieve_orders(page=page)
94102
```
95103

96104
### Estimates
105+
97106
Estimates allow API users to get a quote for the cost of compensating a certain amount of CO2. When creating an estimate, an order in the `draft` state will also be created, reserving the allocation of a project for 5 minutes. If you don't place your draft order within those 5 minutes, the order will automatically be cancelled.
98107

99108
[API Reference](https://docs.usepatch.com/#/?id=estimates)
100109

101110
#### Examples
111+
102112
```python
103113
import patch_api
104114

@@ -139,6 +149,7 @@ patch.estimates.retrieve_estimates(page=page)
139149
```
140150

141151
### Projects
152+
142153
Projects are the ways Patch takes CO2 out of the air. They can represent reforestation, enhanced weathering, direct air carbon capture, etc. When you place an order via Patch, it is allocated to a project.
143154

144155
When fetching projects, you can supply filters to the query to narrow your result. Currently supported filters are:
@@ -148,6 +159,7 @@ When fetching projects, you can supply filters to the query to narrow your resul
148159
[API Reference](https://docs.usepatch.com/#/?id=projects)
149160

150161
#### Examples
162+
151163
```python
152164
import patch_api
153165

@@ -169,11 +181,13 @@ patch.projects.retrieve_projects(country="CA")
169181
```
170182

171183
### Preferences
184+
172185
Preferences are how you route your orders in Patch. If you don't have a preference, Patch will allocate your order to the least expensive option. If you do have a preference, all of your orders will be sent to that project. You can set your preferences via API, or through the [Patch Dashboard](https://dashboard.usepatch.com/projects).
173186

174187
[API Reference](https://docs.usepatch.com/#/?id=preferences)
175188

176189
#### Examples
190+
177191
```python
178192
import patch_api
179193

@@ -202,23 +216,27 @@ patch.preferences.retrieve_preferences(page=page)
202216
### Running tests
203217

204218
Set up the required environment variable:
219+
205220
```
206221
$ export SANDBOX_API_KEY=<SANDBOX API KEY>
207222
```
208223

209224
Run tests:
225+
210226
```
211227
$ make test
212228
```
213229

214230
To run an individual test:
231+
215232
```
216233
$ python -m unittest
217234
```
218235

219236
### Testing the built package locally
220237

221238
To build the library locally, run:
239+
222240
```
223241
$ make build
224242
```
@@ -231,11 +249,13 @@ $ pip install ../patch-python
231249
```
232250

233251
Set up the required environment variable:
252+
234253
```
235254
$ export SANDBOX_API_KEY=<SANDBOX API KEY>
236255
```
237256

238257
To test the package locally, create a python file in a sibling directory and add the following:
258+
239259
```python
240260
import os
241261
import patch_api

patch_api/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from __future__ import absolute_import
1717

18-
__version__ = "1.3.1"
18+
__version__ = "1.4.0"
1919

2020
# import ApiClient
2121
from patch_api.api_client import ApiClient

patch_api/api/estimates_api.py

-14
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ class EstimatesApi(object):
4040
"model",
4141
"make",
4242
"year",
43-
"type",
44-
"country",
4543
]
4644

4745
def __init__(self, api_client=None):
@@ -121,8 +119,6 @@ def create_flight_estimate_with_http_info(
121119
all_params.append("make")
122120
all_params.append("model")
123121
all_params.append("year")
124-
all_params.append("type")
125-
all_params.append("country")
126122

127123
for key, val in six.iteritems(local_var_params["kwargs"]):
128124
if key not in all_params:
@@ -266,8 +262,6 @@ def create_mass_estimate_with_http_info(
266262
all_params.append("make")
267263
all_params.append("model")
268264
all_params.append("year")
269-
all_params.append("type")
270-
all_params.append("country")
271265

272266
for key, val in six.iteritems(local_var_params["kwargs"]):
273267
if key not in all_params:
@@ -411,8 +405,6 @@ def create_shipping_estimate_with_http_info(
411405
all_params.append("make")
412406
all_params.append("model")
413407
all_params.append("year")
414-
all_params.append("type")
415-
all_params.append("country")
416408

417409
for key, val in six.iteritems(local_var_params["kwargs"]):
418410
if key not in all_params:
@@ -556,8 +548,6 @@ def create_vehicle_estimate_with_http_info(
556548
all_params.append("make")
557549
all_params.append("model")
558550
all_params.append("year")
559-
all_params.append("type")
560-
all_params.append("country")
561551

562552
for key, val in six.iteritems(local_var_params["kwargs"]):
563553
if key not in all_params:
@@ -695,8 +685,6 @@ def retrieve_estimate_with_http_info(self, id, **kwargs): # noqa: E501
695685
all_params.append("make")
696686
all_params.append("model")
697687
all_params.append("year")
698-
all_params.append("type")
699-
all_params.append("country")
700688

701689
for key, val in six.iteritems(local_var_params["kwargs"]):
702690
if key not in all_params:
@@ -824,8 +812,6 @@ def retrieve_estimates_with_http_info(self, **kwargs): # noqa: E501
824812
all_params.append("make")
825813
all_params.append("model")
826814
all_params.append("year")
827-
all_params.append("type")
828-
all_params.append("country")
829815

830816
for key, val in six.iteritems(local_var_params["kwargs"]):
831817
if key not in all_params:

patch_api/api/orders_api.py

-12
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ class OrdersApi(object):
4040
"model",
4141
"make",
4242
"year",
43-
"type",
44-
"country",
4543
]
4644

4745
def __init__(self, api_client=None):
@@ -115,8 +113,6 @@ def cancel_order_with_http_info(self, id, **kwargs): # noqa: E501
115113
all_params.append("make")
116114
all_params.append("model")
117115
all_params.append("year")
118-
all_params.append("type")
119-
all_params.append("country")
120116

121117
for key, val in six.iteritems(local_var_params["kwargs"]):
122118
if key not in all_params:
@@ -246,8 +242,6 @@ def create_order_with_http_info(self, create_order_request, **kwargs): # noqa:
246242
all_params.append("make")
247243
all_params.append("model")
248244
all_params.append("year")
249-
all_params.append("type")
250-
all_params.append("country")
251245

252246
for key, val in six.iteritems(local_var_params["kwargs"]):
253247
if key not in all_params:
@@ -385,8 +379,6 @@ def place_order_with_http_info(self, id, **kwargs): # noqa: E501
385379
all_params.append("make")
386380
all_params.append("model")
387381
all_params.append("year")
388-
all_params.append("type")
389-
all_params.append("country")
390382

391383
for key, val in six.iteritems(local_var_params["kwargs"]):
392384
if key not in all_params:
@@ -514,8 +506,6 @@ def retrieve_order_with_http_info(self, id, **kwargs): # noqa: E501
514506
all_params.append("make")
515507
all_params.append("model")
516508
all_params.append("year")
517-
all_params.append("type")
518-
all_params.append("country")
519509

520510
for key, val in six.iteritems(local_var_params["kwargs"]):
521511
if key not in all_params:
@@ -643,8 +633,6 @@ def retrieve_orders_with_http_info(self, **kwargs): # noqa: E501
643633
all_params.append("make")
644634
all_params.append("model")
645635
all_params.append("year")
646-
all_params.append("type")
647-
all_params.append("country")
648636

649637
for key, val in six.iteritems(local_var_params["kwargs"]):
650638
if key not in all_params:

patch_api/api/preferences_api.py

-10
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ class PreferencesApi(object):
4040
"model",
4141
"make",
4242
"year",
43-
"type",
44-
"country",
4543
]
4644

4745
def __init__(self, api_client=None):
@@ -119,8 +117,6 @@ def create_preference_with_http_info(
119117
all_params.append("make")
120118
all_params.append("model")
121119
all_params.append("year")
122-
all_params.append("type")
123-
all_params.append("country")
124120

125121
for key, val in six.iteritems(local_var_params["kwargs"]):
126122
if key not in all_params:
@@ -258,8 +254,6 @@ def delete_preference_with_http_info(self, id, **kwargs): # noqa: E501
258254
all_params.append("make")
259255
all_params.append("model")
260256
all_params.append("year")
261-
all_params.append("type")
262-
all_params.append("country")
263257

264258
for key, val in six.iteritems(local_var_params["kwargs"]):
265259
if key not in all_params:
@@ -387,8 +381,6 @@ def retrieve_preference_with_http_info(self, id, **kwargs): # noqa: E501
387381
all_params.append("make")
388382
all_params.append("model")
389383
all_params.append("year")
390-
all_params.append("type")
391-
all_params.append("country")
392384

393385
for key, val in six.iteritems(local_var_params["kwargs"]):
394386
if key not in all_params:
@@ -516,8 +508,6 @@ def retrieve_preferences_with_http_info(self, **kwargs): # noqa: E501
516508
all_params.append("make")
517509
all_params.append("model")
518510
all_params.append("year")
519-
all_params.append("type")
520-
all_params.append("country")
521511

522512
for key, val in six.iteritems(local_var_params["kwargs"]):
523513
if key not in all_params:

patch_api/api/projects_api.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ class ProjectsApi(object):
4040
"model",
4141
"make",
4242
"year",
43-
"type",
44-
"country",
4543
]
4644

4745
def __init__(self, api_client=None):
@@ -115,8 +113,6 @@ def retrieve_project_with_http_info(self, id, **kwargs): # noqa: E501
115113
all_params.append("make")
116114
all_params.append("model")
117115
all_params.append("year")
118-
all_params.append("type")
119-
all_params.append("country")
120116

121117
for key, val in six.iteritems(local_var_params["kwargs"]):
122118
if key not in all_params:
@@ -187,6 +183,8 @@ def retrieve_projects(self, **kwargs): # noqa: E501
187183
188184
:param async_req bool: execute request asynchronously
189185
:param int page:
186+
:param str country:
187+
:param str type:
190188
:param _preload_content: if False, the urllib3.HTTPResponse object will
191189
be returned without reading/decoding response
192190
data. Default is True.
@@ -212,6 +210,8 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501
212210
213211
:param async_req bool: execute request asynchronously
214212
:param int page:
213+
:param str country:
214+
:param str type:
215215
:param _return_http_data_only: response data without head status code
216216
and headers
217217
:param _preload_content: if False, the urllib3.HTTPResponse object will
@@ -228,7 +228,7 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501
228228

229229
local_var_params = locals()
230230

231-
all_params = ["page"] # noqa: E501
231+
all_params = ["page", "country", "type"] # noqa: E501
232232
all_params.append("async_req")
233233
all_params.append("_return_http_data_only")
234234
all_params.append("_preload_content")
@@ -244,8 +244,6 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501
244244
all_params.append("make")
245245
all_params.append("model")
246246
all_params.append("year")
247-
all_params.append("type")
248-
all_params.append("country")
249247

250248
for key, val in six.iteritems(local_var_params["kwargs"]):
251249
if key not in all_params:
@@ -265,6 +263,10 @@ def retrieve_projects_with_http_info(self, **kwargs): # noqa: E501
265263
query_params.append([key, kwargs.get(key)])
266264
if "page" in local_var_params:
267265
query_params.append(("page", local_var_params["page"])) # noqa: E501
266+
if "country" in local_var_params:
267+
query_params.append(("country", local_var_params["country"])) # noqa: E501
268+
if "type" in local_var_params:
269+
query_params.append(("type", local_var_params["type"])) # noqa: E501
268270

269271
header_params = {}
270272

0 commit comments

Comments
 (0)