Skip to content

Commit

Permalink
Support passing params to list queries
Browse files Browse the repository at this point in the history
Adding this option to support passing query params when
listing customers as per:

https://developer.helpscout.com/mailbox-api/endpoints/customers/list/
  • Loading branch information
jorgemanrubia committed Dec 15, 2020
1 parent 0149201 commit 918008e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/help_scout/modules/listable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

module HelpScout
module Listable
def list(id: HelpScout.default_mailbox, page: nil)
HelpScout.api.get(list_path(id), page: page).embedded_list.map { |e| new e }
def list(id: HelpScout.default_mailbox, page: nil, **params)
HelpScout.api.get(list_path(id), { page: page }.merge(params)).embedded_list.map { |e| new e }
end

def list_path(_)
base_path
end
end
end

8 changes: 8 additions & 0 deletions spec/integration/customer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,12 @@

include_examples 'getable integration'
include_examples 'listable integration'

describe 'list' do
it "finds customers filtered with query" do
result = described_class.list(query: '(email="[email protected]")')
expect(result).to be_a Array
expect(result).to all(be_a(described_class))
end
end
end

0 comments on commit 918008e

Please sign in to comment.