Skip to content

Commit

Permalink
improve README and add CBP support for Triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
fbvilela committed Jul 31, 2023
1 parent 6636393 commit 94ce86e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,17 @@ client.tickets.all! do |resource, page_number|
end
```

### Cursor Based Pagination

A few endpoints related to organizations, tickets, triggers and groups will now make use of cursor based pagination by default.
It is also recommended to use CBP whenever [the Zendesk developer documentation](https://developer.zendesk.com/api-reference) says it's supported.
Pass `page[size]=number` in the parameters to attempt a CBP request, like the example below:

```ruby
client.connection.get('/api/v2/suspended_tickets', page: { size: 100 }).body
{"suspended_tickets"=>[...], "meta"=>{"has_more"=>true, "after_cursor"=>" ... ", "before_cursor"=>nil}, "links"=>{"prev"=>nil, "next"=>"..."}}
```

### Callbacks

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.
Expand Down
1 change: 1 addition & 0 deletions lib/zendesk_api/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ class Trigger < Rule
include Conditions
include Actions

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

Expand Down
14 changes: 14 additions & 0 deletions spec/live/cbp_support_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,18 @@
end
end
end

describe ZendeskAPI::Trigger do
describe '/triggers' do
it_behaves_like 'an endpoint that supports CBP' do
let(:collection) { client.triggers }
end
end

describe '/triggers/active' do
it_behaves_like 'an endpoint that supports CBP' do
let(:collection) { client.triggers.active }
end
end
end
end

0 comments on commit 94ce86e

Please sign in to comment.