Skip to content

Commit 8bd3496

Browse files
committed
Add filtering to projects
1 parent 0cc9890 commit 8bd3496

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/patch_ruby/api/projects_api.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ def retrieve_project_with_http_info(id, opts = {})
9090
# Retrieves a list of projects available for purchase on Patch's platform.
9191
# @param [Hash] opts the optional parameters
9292
# @option opts [Integer] :page
93+
# @option opts [String] :country
94+
# @option opts [Integer] :type
9395
# @return [ProjectListResponse]
9496
def retrieve_projects(opts = {})
9597
data, _status_code, _headers = retrieve_projects_with_http_info(opts)
@@ -100,6 +102,8 @@ def retrieve_projects(opts = {})
100102
# Retrieves a list of projects available for purchase on Patch's platform.
101103
# @param [Hash] opts the optional parameters
102104
# @option opts [Integer] :page
105+
# @option opts [String] :country
106+
# @option opts [Integer] :type
103107
# @return [Array<(ProjectListResponse, Integer, Hash)>] ProjectListResponse data, response status code and response headers
104108
def retrieve_projects_with_http_info(opts = {})
105109
if @api_client.config.debugging
@@ -111,6 +115,8 @@ def retrieve_projects_with_http_info(opts = {})
111115
# query parameters
112116
query_params = opts[:query_params] || {}
113117
query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
118+
query_params[:'country'] = opts[:'country'] if !opts[:'country'].nil?
119+
query_params[:'type'] = opts[:'type'] if !opts[:'type'].nil?
114120

115121
# header parameters
116122
header_params = opts[:header_params] || {}

spec/integration/projects_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@
2222
expect(retrieve_project_response.data.id).to eq project_id
2323
end
2424

25+
it 'supports filtering projects' do
26+
country = 'US'
27+
projects = Patch::Project.retrieve_projects(country: country)
28+
projects.data.map do |project|
29+
expect(project.country).to eq country
30+
end
31+
32+
type = 'biomass'
33+
projects = Patch::Project.retrieve_projects(type: type)
34+
projects.data.map do |project|
35+
expect(project.type).to eq type
36+
end
37+
end
38+
2539
describe 'returned fields' do
2640
before do
2741
@project = Patch::Project.retrieve_projects(page: 1).data.first

0 commit comments

Comments
 (0)