Skip to content

Commit

Permalink
add cbp support to more endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
fbvilela committed Sep 5, 2023
1 parent bae6482 commit ff10583
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/zendesk_api/resources.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
61 changes: 61 additions & 0 deletions spec/live/cbp_support_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit ff10583

Please sign in to comment.