Skip to content

Commit 94ce86e

Browse files
committed
improve README and add CBP support for Triggers
1 parent 6636393 commit 94ce86e

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,17 @@ client.tickets.all! do |resource, page_number|
189189
end
190190
```
191191

192+
### Cursor Based Pagination
193+
194+
A few endpoints related to organizations, tickets, triggers and groups will now make use of cursor based pagination by default.
195+
It is also recommended to use CBP whenever [the Zendesk developer documentation](https://developer.zendesk.com/api-reference) says it's supported.
196+
Pass `page[size]=number` in the parameters to attempt a CBP request, like the example below:
197+
198+
```ruby
199+
client.connection.get('/api/v2/suspended_tickets', page: { size: 100 }).body
200+
{"suspended_tickets"=>[...], "meta"=>{"has_more"=>true, "after_cursor"=>" ... ", "before_cursor"=>nil}, "links"=>{"prev"=>nil, "next"=>"..."}}
201+
```
202+
192203
### Callbacks
193204

194205
Callbacks can be added to the `ZendeskAPI::Client` instance and will be called (with the response env) after all response middleware on a successful request.

lib/zendesk_api/resources.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ class Trigger < Rule
604604
include Conditions
605605
include Actions
606606

607+
CBP_ACTIONS = [/triggers$/, %r{triggers/active$}].freeze
607608
has :execution, :class => RuleExecution
608609
end
609610

spec/live/cbp_support_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,18 @@
4141
end
4242
end
4343
end
44+
45+
describe ZendeskAPI::Trigger do
46+
describe '/triggers' do
47+
it_behaves_like 'an endpoint that supports CBP' do
48+
let(:collection) { client.triggers }
49+
end
50+
end
51+
52+
describe '/triggers/active' do
53+
it_behaves_like 'an endpoint that supports CBP' do
54+
let(:collection) { client.triggers.active }
55+
end
56+
end
57+
end
4458
end

0 commit comments

Comments
 (0)