From ff1058326e1e1d3a9b2f6665cdcb34ce824bc5f0 Mon Sep 17 00:00:00 2001 From: Fabio Vilela Date: Tue, 5 Sep 2023 16:20:42 +1000 Subject: [PATCH 1/2] add cbp support to more endpoints --- lib/zendesk_api/resources.rb | 14 +++++++- spec/live/cbp_support_spec.rb | 61 +++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/lib/zendesk_api/resources.rb b/lib/zendesk_api/resources.rb index abbb6dea..52c0f0de 100644 --- a/lib/zendesk_api/resources.rb +++ b/lib/zendesk_api/resources.rb @@ -167,6 +167,10 @@ def self.cbp_path_regexes end class Brand < Resource + def self.cbp_path_regexes + [/^brands$/] + end + def destroy! self.active = false save! @@ -407,7 +411,7 @@ class Ticket < Resource extend DestroyMany def self.cbp_path_regexes - [/^tickets$/] + [/^tickets$/, %r{organizations/\d+/tickets}] end # Unlike other attributes, "comment" is not a property of the ticket, @@ -428,6 +432,10 @@ class Event < Data has :author, :class => User has_many Event + + def self.cbp_path_regexes + [%r{^tickets/\d+/audits$}] + end end class Comment < DataResource @@ -740,6 +748,10 @@ class Identity < Resource put :request_verification end + def self.cbp_path_regexes + [/^users$/, %r{^organizations/\d+/users$}] + end + any :password # Set a user's password diff --git a/spec/live/cbp_support_spec.rb b/spec/live/cbp_support_spec.rb index 0a69d4fc..a906b3bf 100644 --- a/spec/live/cbp_support_spec.rb +++ b/spec/live/cbp_support_spec.rb @@ -98,6 +98,40 @@ end end + describe ZendeskAPI::Ticket do + describe '/tickets' do + it_behaves_like 'an endpoint that supports CBP' do + let(:collection) { client.tickets } + end + end + + describe '/organiozations/:id/tickets' do + let(:organization) do + VCR.use_cassette("cbp_#{described_class}_organization_fetch") do + client.organizations.fetch.first + end + end + + it_behaves_like 'an endpoint that supports CBP' do + let(:collection) { organization.tickets } + end + end + end + + describe ZendeskAPI::Ticket::Audit do + describe '/tickets/:id/audits' do + let(:ticket) do + VCR.use_cassette("cbp_#{described_class}_ticket_fetch") do + client.tickets.fetch.first + end + end + + it_behaves_like 'an endpoint that supports CBP' do + let(:collection) { ticket.audits } + end + end + end + describe ZendeskAPI::TicketMetric do describe '/ticket_metrics' do it_behaves_like 'an endpoint that supports CBP' do @@ -161,4 +195,31 @@ end end end + + describe ZendeskAPI::Brand do + describe '/brands' do + it_behaves_like 'an endpoint that supports CBP' do + let(:collection) { client.brands } + end + end + end + + describe ZendeskAPI::User do + describe '/users' do + it_behaves_like 'an endpoint that supports CBP' do + let(:collection) { client.users } + end + end + + describe '/organizations/:id/users' do + let(:organization) do + VCR.use_cassette("cbp_#{described_class}_organization_fetch") do + client.organizations.fetch.first + end + end + it_behaves_like 'an endpoint that supports CBP' do + let(:collection) { organization.users } + end + end + end end From e7b18e6ec38585d8259d869bfab1208131425fd4 Mon Sep 17 00:00:00 2001 From: Fabio Vilela Date: Wed, 6 Sep 2023 14:07:41 +1000 Subject: [PATCH 2/2] fix mispelling --- spec/live/cbp_support_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/live/cbp_support_spec.rb b/spec/live/cbp_support_spec.rb index a906b3bf..aa07d15d 100644 --- a/spec/live/cbp_support_spec.rb +++ b/spec/live/cbp_support_spec.rb @@ -105,7 +105,7 @@ end end - describe '/organiozations/:id/tickets' do + describe '/organizations/:id/tickets' do let(:organization) do VCR.use_cassette("cbp_#{described_class}_organization_fetch") do client.organizations.fetch.first