Skip to content

Commit 2ed1719

Browse files
committed
Doc improvement
1 parent 5d3b72a commit 2ed1719

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,17 @@ zendesk_api_client_rb $ bundle console
166166
`ZendeskAPI::Collections` can be paginated:
167167

168168
```ruby
169+
# Note that CBP (cursor based pagination) is the default and preferred way
170+
# and has fewer limitations on deep pagination
171+
tickets = client.tickets.per_page(3)
172+
page1 = tickets.fetch! # GET /api/v2/tickets?page[after]={cursor}&page[size]=3
173+
page2 = tickets.next # GET /api/v2/tickets?page[after]={cursor}&page[size]=3
174+
# ...
175+
176+
# OR...
177+
# Note that OBP (offset based pagination) can incur to various limitations
169178
tickets = client.tickets.page(2).per_page(3)
179+
170180
next_page = tickets.next # => 3
171181
tickets.fetch! # GET /api/v2/tickets?page=3&per_page=3
172182
previous_page = tickets.prev # => 2
@@ -221,7 +231,7 @@ ticket.attributes # => { "priority" => "urgent" }
221231
ticket.save! # Will PUT => true
222232
ticket.destroy! # => true
223233

224-
ZendeskAPI::Ticket.new(client, { :priority => "urgent" })
234+
ZendeskAPI::Ticket.new(client, { priority: "urgent" })
225235
ticket.new_record? # => true
226236
ticket.save! # Will POST
227237
```
@@ -455,7 +465,7 @@ bundle exec rubocop # Runs the lint (use `--fix` for autocorrect)
455465

456466
1. Fork the project.
457467
2. Make your feature addition or bug fix.
458-
3. Add tests for it. This is important so that we don't break it in a future
468+
3. **Add tests for it**. This is important so that we don't break it in a future
459469
version unintentionally.
460470
4. Commit. Do not alter `Rakefile`, version, or history. (If you want to have
461471
your own version, that is fine, but bump version in a commit by itself that
@@ -464,6 +474,17 @@ bundle exec rubocop # Runs the lint (use `--fix` for autocorrect)
464474

465475
**Note:** Live specs will likely fail for external contributors. The Zendesk devs can help with that. If you have permissions and some live specs unexpectedly fail, that might be a data error, see the REPL for that.
466476

477+
## Merging contributors pull requests
478+
479+
External contributions don't run live specs, so we need to use a workaround. Assuming a PR from `author:author/branch` to `default_branch`:
480+
481+
1. Create a branch in our repo `author_branch`
482+
2. Change the destination branch of the PR to `author_branch`
483+
3. Merge
484+
4. Create a pr in our repo from `default_branch`
485+
- Make sure they know the commits still carry their name
486+
- [Example](https://github.com/zendesk/zendesk_api_client_rb/pull/553)
487+
467488
## Copyright and license
468489

469490
Copyright 2015-2023 Zendesk

lib/zendesk_api/collection.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def next
225225
clear_cache
226226
@options["page"] = @options["page"].to_i + 1
227227
elsif (@query = @next_page)
228-
# Send _only_ url param "?after=token" to get the next page
228+
# Send _only_ url param "?page[after]=token" to get the next page
229229
@options.page&.delete("before")
230230
fetch(true)
231231
else
@@ -243,7 +243,7 @@ def prev
243243
clear_cache
244244
@options["page"] -= 1
245245
elsif (@query = @prev_page)
246-
# Send _only_ url param "?before=token" to get the prev page
246+
# Send _only_ url param "?page[before]=token" to get the prev page
247247
@options.page&.delete("after")
248248
fetch(true)
249249
else
@@ -465,7 +465,7 @@ def array_method(name, *args, &block)
465465
def next_collection(name, *args, &block)
466466
opts = args.last.is_a?(Hash) ? args.last : {}
467467
opts.merge!(collection_path: [*@collection_path, name], page: nil)
468-
# why page: nil ?
468+
# Why `page: nil`?
469469
# when you do client.tickets.fetch followed by client.tickets.foos => the request to /tickets/foos will
470470
# have the options page set to whatever the last options were for the tickets collection
471471
self.class.new(@client, @resource_class, @options.merge(opts))

0 commit comments

Comments
 (0)