Skip to content

Commit 62c7102

Browse files
committed
Filter by remaining mass g
1 parent 8bd3496 commit 62c7102

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- Adds Sustainable Development Goals (SDGs) field to projects
13-
13+
- Adds filtering to Projects by country, type, remaining inventory
14+
,
1415
### Changed
1516

1617
- vehicle estimates now support optional `make`, `model` and `year` fields.

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ Patch::Estimate.retrieve_estimates(page: page)
144144
### Projects
145145
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.
146146

147+
When fetching Projects, you can add filters to the query to narrow the result. Currently supported filters are:
148+
149+
- `country`
150+
- `type`
151+
- `remaining_mass_g`
152+
147153
[API Reference](https://docs.usepatch.com/#/?id=projects)
148154

149155
#### Examples
@@ -155,6 +161,18 @@ Patch::Project.retrieve_project(project_id)
155161
# Retrieve a list of projects
156162
page = 1 # Pass in which page of projects you'd like
157163
Patch::Project.retrieve_projects(page: page)
164+
165+
# Retrieve all projects from the United States
166+
country = 'US' # Pass in the country code of the country you'd like to get Projects from
167+
Patch::Project.retrieve_projects(country: country)
168+
169+
# Retrieve all biomass projects
170+
type = 'biomass' # Pass in the type of Projects you'd like to get
171+
Patch::Project.retrieve_projects(type: type)
172+
173+
# Retrieve a list of projects with at least 100 grams of available offsets
174+
type = 'biomass' # Pass in the type of Projects you'd like to get
175+
Patch::Project.retrieve_projects(type: type)
158176
```
159177

160178
### Preferences

lib/patch_ruby/api/projects_api.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ def retrieve_project_with_http_info(id, opts = {})
9191
# @param [Hash] opts the optional parameters
9292
# @option opts [Integer] :page
9393
# @option opts [String] :country
94-
# @option opts [Integer] :type
94+
# @option opts [String] :type
95+
# @option opts [Integer] :remainaing_mass_g
9596
# @return [ProjectListResponse]
9697
def retrieve_projects(opts = {})
9798
data, _status_code, _headers = retrieve_projects_with_http_info(opts)
@@ -103,7 +104,8 @@ def retrieve_projects(opts = {})
103104
# @param [Hash] opts the optional parameters
104105
# @option opts [Integer] :page
105106
# @option opts [String] :country
106-
# @option opts [Integer] :type
107+
# @option opts [String] :type
108+
# @option opts [Integer] :remainaing_mass_g
107109
# @return [Array<(ProjectListResponse, Integer, Hash)>] ProjectListResponse data, response status code and response headers
108110
def retrieve_projects_with_http_info(opts = {})
109111
if @api_client.config.debugging
@@ -117,6 +119,7 @@ def retrieve_projects_with_http_info(opts = {})
117119
query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
118120
query_params[:'country'] = opts[:'country'] if !opts[:'country'].nil?
119121
query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
122+
query_params[:'remainaing_mass_g'] = opts[:'remainaing_mass_g'] if !opts[:'remainaing_mass_g'].nil?
120123

121124
# header parameters
122125
header_params = opts[:header_params] || {}

spec/integration/projects_spec.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,17 @@
2929
expect(project.country).to eq country
3030
end
3131

32-
type = 'biomass'
32+
type = 'dac'
3333
projects = Patch::Project.retrieve_projects(type: type)
3434
projects.data.map do |project|
3535
expect(project.type).to eq type
3636
end
37+
38+
remaining_mass_g = 100
39+
projects = Patch::Project.retrieve_projects(remaining_mass_g: remaining_mass_g)
40+
projects.data.map do |project|
41+
expect(project.remaining_mass_g >= remaining_mass_g).to be true
42+
end
3743
end
3844

3945
describe 'returned fields' do

0 commit comments

Comments
 (0)