Skip to content

Commit 41ad85e

Browse files
authored
Merge pull request #560 from zendesk/fvilela/more_cbp_work
[RED-1894] Add cbp support to more endpoints
2 parents bae6482 + e7b18e6 commit 41ad85e

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

lib/zendesk_api/resources.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ def self.cbp_path_regexes
167167
end
168168

169169
class Brand < Resource
170+
def self.cbp_path_regexes
171+
[/^brands$/]
172+
end
173+
170174
def destroy!
171175
self.active = false
172176
save!
@@ -407,7 +411,7 @@ class Ticket < Resource
407411
extend DestroyMany
408412

409413
def self.cbp_path_regexes
410-
[/^tickets$/]
414+
[/^tickets$/, %r{organizations/\d+/tickets}]
411415
end
412416

413417
# Unlike other attributes, "comment" is not a property of the ticket,
@@ -428,6 +432,10 @@ class Event < Data
428432
has :author, :class => User
429433

430434
has_many Event
435+
436+
def self.cbp_path_regexes
437+
[%r{^tickets/\d+/audits$}]
438+
end
431439
end
432440

433441
class Comment < DataResource
@@ -740,6 +748,10 @@ class Identity < Resource
740748
put :request_verification
741749
end
742750

751+
def self.cbp_path_regexes
752+
[/^users$/, %r{^organizations/\d+/users$}]
753+
end
754+
743755
any :password
744756

745757
# Set a user's password

spec/live/cbp_support_spec.rb

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,40 @@
9898
end
9999
end
100100

101+
describe ZendeskAPI::Ticket do
102+
describe '/tickets' do
103+
it_behaves_like 'an endpoint that supports CBP' do
104+
let(:collection) { client.tickets }
105+
end
106+
end
107+
108+
describe '/organizations/:id/tickets' do
109+
let(:organization) do
110+
VCR.use_cassette("cbp_#{described_class}_organization_fetch") do
111+
client.organizations.fetch.first
112+
end
113+
end
114+
115+
it_behaves_like 'an endpoint that supports CBP' do
116+
let(:collection) { organization.tickets }
117+
end
118+
end
119+
end
120+
121+
describe ZendeskAPI::Ticket::Audit do
122+
describe '/tickets/:id/audits' do
123+
let(:ticket) do
124+
VCR.use_cassette("cbp_#{described_class}_ticket_fetch") do
125+
client.tickets.fetch.first
126+
end
127+
end
128+
129+
it_behaves_like 'an endpoint that supports CBP' do
130+
let(:collection) { ticket.audits }
131+
end
132+
end
133+
end
134+
101135
describe ZendeskAPI::TicketMetric do
102136
describe '/ticket_metrics' do
103137
it_behaves_like 'an endpoint that supports CBP' do
@@ -161,4 +195,31 @@
161195
end
162196
end
163197
end
198+
199+
describe ZendeskAPI::Brand do
200+
describe '/brands' do
201+
it_behaves_like 'an endpoint that supports CBP' do
202+
let(:collection) { client.brands }
203+
end
204+
end
205+
end
206+
207+
describe ZendeskAPI::User do
208+
describe '/users' do
209+
it_behaves_like 'an endpoint that supports CBP' do
210+
let(:collection) { client.users }
211+
end
212+
end
213+
214+
describe '/organizations/:id/users' do
215+
let(:organization) do
216+
VCR.use_cassette("cbp_#{described_class}_organization_fetch") do
217+
client.organizations.fetch.first
218+
end
219+
end
220+
it_behaves_like 'an endpoint that supports CBP' do
221+
let(:collection) { organization.users }
222+
end
223+
end
224+
end
164225
end

0 commit comments

Comments
 (0)