Closed navidemad closed 1 week ago
Hi @navidemad , thanks for raising this issue! This endpoint is indeed missing CBP support which is added by https://github.com/zendesk/zendesk_api_client_rb/pull/582 - it's still a DRAFT PR, missing tests for now. One thing you could do while we don't merge it is to grab that change and test it on your own. I also have made a few suggestions on how to simplify your code. Basically you don't need to manually paginate through data (unless you want to).
# Your `call` method could have the following changes after our fix is in place:
zendesk_user_client = client.current_user # get the user you need
tickets = Set.new
zendesk_user_client.requested_tickets.all!{ |ticket| tickets.add ticket }
# This will take care of the pagination for you. The default will be 100 per page.
# No need to set per_page to 2.
tickets.sort_by{ |ticket| ticket.created_at }.reverse # most recent tickets at the top.
# notice that this line returns (from the method `call``) the sorted array
Let me know if you have any more questions. thanks again for raising the issue 🙏
@fbvilela
Alright i tested with your suggestions and a simple initializer to have your PR change, and it seems to be working fine :
# https://github.com/zendesk/zendesk_api_client_rb/pull/582
# config/initializers/zendesk_client.rb
Rails.application.config.to_prepare do
ZendeskAPI::Ticket.singleton_class.prepend(
Module.new do
def cbp_path_regexes
super | [%r{users/\d+/tickets/requested}]
end
end,
)
end
Problem solved for the requester, closing.
Context
rails: 7.1.3.4 zendesk_api: 3.1.0 ruby: 3.3.4
Goal
Fetching requested tickets from our customer
Problem
We are having the following warning when we followed the CBP example from: https://github.com/zendesk/zendesk_api_client_rb?tab=readme-ov-file#pagination
Debug
Our customer has 10 tickets. I used per_page(2) to make sure the pagination works fine, we will put 100 once we fixed this issue. I put some log on https://github.com/search?q=repo%3Azendesk%2Fzendesk_api_client_rb%20intentional_obp_request%3F&type=code
Code:
Question
Is there something we should change in our code ?
Thanks