Skip to content

Commit acc2e37

Browse files
authored
Merge pull request #25 from patch-technology/lovisa/filter-projects
Filter Projects by remaining inventory
2 parents f52104d + 30c8353 commit acc2e37

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ 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-
- Adds filtering to Projects by country, type
13+
- Adds filtering to Projects by country, type, minimum_available_mass
1414

1515
### Changed
1616

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ When fetching Projects, you can add filters to the query to narrow the result. C
148148

149149
- `country`
150150
- `type`
151+
- `minimum_available_mass`
151152

152153
[API Reference](https://docs.usepatch.com/#/?id=projects)
153154

@@ -161,13 +162,17 @@ Patch::Project.retrieve_project(project_id)
161162
page = 1 # Pass in which page of projects you'd like
162163
Patch::Project.retrieve_projects(page: page)
163164

164-
# Retrieve a all projects from the United States
165-
country = 'US' # Pass in the country code of the country you'd like to get Projects from
165+
# Retrieve all projects from the United States
166+
country = 'US'
166167
Patch::Project.retrieve_projects(country: country)
167168

168-
# Retrieve a all biomass projects
169-
type = 'biomass' # Pass in the type of Projects you'd like to get
169+
# Retrieve all biomass projects
170+
type = 'biomass'
170171
Patch::Project.retrieve_projects(type: type)
172+
173+
# Retrieve a list of projects with at least 100 grams of available offsets
174+
minimum_available_mass = 100
175+
Patch::Project.retrieve_projects(minimum_available_mass: minimum_available_mass)
171176
```
172177

173178
### Preferences

lib/patch_ruby/api/projects_api.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def retrieve_project_with_http_info(id, opts = {})
9292
# @option opts [Integer] :page
9393
# @option opts [String] :country
9494
# @option opts [String] :type
95+
# @option opts [Integer] :minimum_available_mass
9596
# @return [ProjectListResponse]
9697
def retrieve_projects(opts = {})
9798
data, _status_code, _headers = retrieve_projects_with_http_info(opts)
@@ -104,6 +105,7 @@ def retrieve_projects(opts = {})
104105
# @option opts [Integer] :page
105106
# @option opts [String] :country
106107
# @option opts [String] :type
108+
# @option opts [Integer] :minimum_available_mass
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[:'minimum_available_mass'] = opts[:'minimum_available_mass'] if !opts[:'minimum_available_mass'].nil?
120123

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

spec/integration/projects_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
projects.data.map do |project|
3535
expect(project.type).to eq type
3636
end
37+
38+
minimum_available_mass = 100
39+
projects = Patch::Project.retrieve_projects(minimum_available_mass: minimum_available_mass)
40+
projects.data.map do |project|
41+
expect(project.remaining_mass_g >= minimum_available_mass).to be true
42+
end
3743
end
3844

3945
describe 'returned fields' do

0 commit comments

Comments
 (0)