zendesk_api 3.0.1 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1d55a2716fcbc1751d58a23796282e5b5689ac4fe193bdf0e5abc800605c200
4
- data.tar.gz: fae9a5e9c62eb4ef7cfd61e01af12b5fd3fbcca709271f2bf00552863a22972c
3
+ metadata.gz: 8b226059359e4f834ccada53be52fbe72e0d73c26aa045fcfd011bd8afe3c1c2
4
+ data.tar.gz: c006d69a0b16716c7f093cd5a14454652661d4234f9a515a6a7724f977145c89
5
5
  SHA512:
6
- metadata.gz: d70b174c454944498d191d962036890c654ae25ed8c6e5a310aaecbc7364b21b203246052b311702fc564ee3be4c00b92f3f6b57ca29367bcb79039bef16cac2
7
- data.tar.gz: 702de99c18e0f256f4871a8fa31a588de67d7da46402c8a14f77d97cd1c1f90fdbead7481bdcb26d2e5c6e0176c5e2c739c954b6162808b1b6ff38edc6028864
6
+ metadata.gz: 9080f2d1cb5c4fae6145c37dfe2fa4e3e81c1bd3afa1d565cd41e350e36b97dff9247c9a5028f3e78e27c1516fe406df80980a21c60b3f716898bcaddb026b0e
7
+ data.tar.gz: e616e3ee6b1ba647952265b5dad953181eaeb5940d6954d37cfe1934232df7abb4547d8de7cbc22dc9dcceda1d849c6c103fc87f85514cba42e64e2cf48f6c50
@@ -37,24 +37,25 @@ module ZendeskAPI
37
37
  def method_missing(method, *args, &block)
38
38
  method = method.to_s
39
39
  options = args.last.is_a?(Hash) ? args.pop : {}
40
-
41
40
  unless config.use_resource_cache
42
- raise "Resource for #{method} does not exist" unless method_as_class(method)
43
- return ZendeskAPI::Collection.new(self, method_as_class(method), options)
41
+ resource_class = resource_class_for(method)
42
+ raise "Resource for #{method} does not exist" unless resource_class
43
+ return ZendeskAPI::Collection.new(self, resource_class, options)
44
44
  end
45
45
 
46
46
  @resource_cache[method] ||= { :class => nil, :cache => ZendeskAPI::LRUCache.new }
47
47
  if !options.delete(:reload) && (cached = @resource_cache[method][:cache].read(options.hash))
48
48
  cached
49
49
  else
50
- @resource_cache[method][:class] ||= method_as_class(method)
50
+ @resource_cache[method][:class] ||= resource_class_for(method)
51
51
  raise "Resource for #{method} does not exist" unless @resource_cache[method][:class]
52
52
  @resource_cache[method][:cache].write(options.hash, ZendeskAPI::Collection.new(self, @resource_cache[method][:class], options))
53
53
  end
54
54
  end
55
55
 
56
56
  def respond_to?(method, *args)
57
- ((cache = @resource_cache[method]) && cache[:class]) || !method_as_class(method).nil? || super
57
+ cache = @resource_cache[method]
58
+ !!(cache.to_h[:class] || resource_class_for(method) || super)
58
59
  end
59
60
 
60
61
  # Returns the current user (aka me)
@@ -184,9 +185,9 @@ module ZendeskAPI
184
185
 
185
186
  private
186
187
 
187
- def method_as_class(method)
188
- klass_as_string = ZendeskAPI::Helpers.modulize_string(Inflection.singular(method.to_s.gsub(/\W/, '')))
189
- ZendeskAPI::Association.class_from_namespace(klass_as_string)
188
+ def resource_class_for(method)
189
+ resource_name = ZendeskAPI::Helpers.modulize_string(Inflection.singular(method.to_s.gsub(/\W/, '')))
190
+ ZendeskAPI::Association.class_from_namespace(resource_name)
190
191
  end
191
192
 
192
193
  def check_url
@@ -1,14 +1,14 @@
1
1
  require 'zendesk_api/resource'
2
2
  require 'zendesk_api/resources'
3
3
  require 'zendesk_api/search'
4
+ require 'zendesk_api/pagination'
4
5
 
5
6
  module ZendeskAPI
6
7
  # Represents a collection of resources. Lazily loaded, resources aren't
7
8
  # actually fetched until explicitly needed (e.g. #each, {#fetch}).
8
9
  class Collection
9
- DEFAULT_PAGE_SIZE = 100
10
-
11
10
  include ZendeskAPI::Sideloading
11
+ include Pagination
12
12
 
13
13
  # Options passed in that are automatically converted from an array to a comma-separated list.
14
14
  SPECIALLY_JOINED_PARAMS = [:ids, :only]
@@ -116,30 +116,6 @@ module ZendeskAPI
116
116
  @count || -1
117
117
  end
118
118
 
119
- # Changes the per_page option. Returns self, so it can be chained. No execution.
120
- # @return [Collection] self
121
- def per_page(count)
122
- clear_cache if count
123
- @options["per_page"] = count
124
- self
125
- end
126
-
127
- # Changes the page option. Returns self, so it can be chained. No execution.
128
- # @return [Collection] self
129
- def page(number)
130
- clear_cache if number
131
- @options["page"] = number
132
- self
133
- end
134
-
135
- def first_page?
136
- !@prev_page
137
- end
138
-
139
- def last_page?
140
- !@next_page || @next_page == @query
141
- end
142
-
143
119
  # Saves all newly created resources stored in this collection.
144
120
  # @return [Collection] self
145
121
  def save
@@ -249,7 +225,7 @@ module ZendeskAPI
249
225
  clear_cache
250
226
  @options["page"] = @options["page"].to_i + 1
251
227
  elsif (@query = @next_page)
252
- # Send _only_ url param "?after=token" to get the next page
228
+ # Send _only_ url param "?page[after]=token" to get the next page
253
229
  @options.page&.delete("before")
254
230
  fetch(true)
255
231
  else
@@ -267,7 +243,7 @@ module ZendeskAPI
267
243
  clear_cache
268
244
  @options["page"] -= 1
269
245
  elsif (@query = @prev_page)
270
- # Send _only_ url param "?before=token" to get the prev page
246
+ # Send _only_ url param "?page[before]=token" to get the prev page
271
247
  @options.page&.delete("after")
272
248
  fetch(true)
273
249
  else
@@ -323,11 +299,6 @@ module ZendeskAPI
323
299
  map(&:to_param)
324
300
  end
325
301
 
326
- def more_results?(response)
327
- Helpers.present?(response["meta"]) && response["meta"]["has_more"]
328
- end
329
- alias_method :has_more_results?, :more_results? # For backward compatibility with 1.33.0 and 1.34.0
330
-
331
302
  def get_next_page_data(original_response_body)
332
303
  link = original_response_body["links"]["next"]
333
304
  result_key = @resource_class.model_key || "results"
@@ -344,42 +315,14 @@ module ZendeskAPI
344
315
 
345
316
  private
346
317
 
347
- def cbp_response?(body)
348
- !!(body["meta"] && body["links"])
349
- end
350
-
351
- def cbp_request?
352
- @options["page"].is_a?(Hash)
353
- end
354
-
355
- def intentional_obp_request?
356
- Helpers.present?(@options["page"]) && !cbp_request?
357
- end
358
-
359
- def should_try_cbp?(path_query_link)
360
- not_supported_endpoints = %w[show_many]
361
- not_supported_endpoints.none? { |endpoint| path_query_link.end_with?(endpoint) }
362
- end
363
-
364
318
  def get_resources(path_query_link)
365
319
  if intentional_obp_request?
366
320
  warn "Offset Based Pagination will be deprecated soon"
367
- elsif @next_page.nil? && should_try_cbp?(path_query_link)
368
- @options_per_page_was = @options.delete("per_page")
369
- # Default to CBP by using the page param as a map
370
- @options.page = { size: (@options_per_page_was || DEFAULT_PAGE_SIZE) }
371
- end
372
-
373
- begin
374
- # Try CBP first, unless the user explicitly asked for OBP
375
- @response = get_response(path_query_link)
376
- rescue ZendeskAPI::Error::NetworkError => e
377
- raise e if intentional_obp_request?
378
- # Fallback to OBP if CBP didn't work, using per_page param
379
- @options.per_page = @options_per_page_was
380
- @options.page = nil
381
- @response = get_response(path_query_link)
321
+ elsif supports_cbp? && first_cbp_request?
322
+ # only set cbp options if it's the first request, otherwise the options would be already in place
323
+ set_cbp_options
382
324
  end
325
+ @response = get_response(path_query_link)
383
326
 
384
327
  # Keep pre-existing behaviour for search/export
385
328
  if path_query_link == "search/export"
@@ -389,29 +332,6 @@ module ZendeskAPI
389
332
  end
390
333
  end
391
334
 
392
- def set_page_and_count(body)
393
- @count = (body["count"] || @resources.size).to_i
394
- @next_page, @prev_page = page_links(body)
395
-
396
- if cbp_response?(body)
397
- # We'll delete the one we don't need in #next or #prev
398
- @options["page"]["after"] = body["meta"]["after_cursor"]
399
- @options["page"]["before"] = body["meta"]["before_cursor"]
400
- elsif @next_page =~ /page=(\d+)/
401
- @options["page"] = $1.to_i - 1
402
- elsif @prev_page =~ /page=(\d+)/
403
- @options["page"] = $1.to_i + 1
404
- end
405
- end
406
-
407
- def page_links(body)
408
- if body["meta"] && body["links"]
409
- [body["links"]["next"], body["links"]["prev"]]
410
- else
411
- [body["next_page"], body["previous_page"]]
412
- end
413
- end
414
-
415
335
  def _all(start_page = @options["page"], bang = false, &block)
416
336
  raise(ArgumentError, "must pass a block") unless block
417
337
 
@@ -541,9 +461,13 @@ module ZendeskAPI
541
461
  to_a.public_send(name, *args, &block)
542
462
  end
543
463
 
464
+ # If you call client.tickets.foo - and foo is not an attribute nor an association, it ends up here, as a new collection
544
465
  def next_collection(name, *args, &block)
545
466
  opts = args.last.is_a?(Hash) ? args.last : {}
546
- opts.merge!(:collection_path => @collection_path.dup.push(name))
467
+ opts.merge!(collection_path: [*@collection_path, name], page: nil)
468
+ # Why `page: nil`?
469
+ # when you do client.tickets.fetch followed by client.tickets.foos => the request to /tickets/foos will
470
+ # have the options page set to whatever the last options were for the tickets collection
547
471
  self.class.new(@client, @resource_class, @options.merge(opts))
548
472
  end
549
473
 
@@ -0,0 +1,99 @@
1
+ module ZendeskAPI
2
+ class Collection
3
+ # Contains all methods related to pagination in an attempt to slim down collection.rb
4
+ module Pagination
5
+ DEFAULT_PAGE_SIZE = 100
6
+ def more_results?(response)
7
+ Helpers.present?(response["meta"]) && response["meta"]["has_more"]
8
+ end
9
+ alias has_more_results? more_results? # For backward compatibility with 1.33.0 and 1.34.0
10
+
11
+ # Changes the per_page option. Returns self, so it can be chained. No execution.
12
+ # @return [Collection] self
13
+ def per_page(count)
14
+ clear_cache if count
15
+ @options["per_page"] = count
16
+ self
17
+ end
18
+
19
+ # Changes the page option. Returns self, so it can be chained. No execution.
20
+ # @return [Collection] self
21
+ def page(number)
22
+ clear_cache if number
23
+ @options["page"] = number
24
+ self
25
+ end
26
+
27
+ def first_page?
28
+ !@prev_page
29
+ end
30
+
31
+ def last_page?
32
+ !@next_page || @next_page == @query
33
+ end
34
+
35
+ private
36
+
37
+ def page_links(body)
38
+ if body["meta"] && body["links"]
39
+ [body["links"]["next"], body["links"]["prev"]]
40
+ else
41
+ [body["next_page"], body["previous_page"]]
42
+ end
43
+ end
44
+
45
+ def cbp_response?(body)
46
+ !!(body["meta"] && body["links"])
47
+ end
48
+
49
+ def set_cbp_options
50
+ @options_per_page_was = @options.delete("per_page")
51
+ # Default to CBP by using the page param as a map
52
+ @options.page = { size: (@options_per_page_was || DEFAULT_PAGE_SIZE) }
53
+ end
54
+
55
+ # CBP requests look like: `/resources?page[size]=100`
56
+ # OBP requests look like: `/resources?page=2`
57
+ def cbp_request?
58
+ @options["page"].is_a?(Hash)
59
+ end
60
+
61
+ def intentional_obp_request?
62
+ Helpers.present?(@options["page"]) && !cbp_request?
63
+ end
64
+
65
+ def supports_cbp?
66
+ @resource_class.cbp_path_regexes.any? { |supported_path_regex| path.match?(supported_path_regex) }
67
+ end
68
+
69
+ def first_cbp_request?
70
+ # @next_page will be nil when making the first cbp request
71
+ @next_page.nil?
72
+ end
73
+
74
+ def set_page_and_count(body)
75
+ @count = (body["count"] || @resources.size).to_i
76
+ @next_page, @prev_page = page_links(body)
77
+
78
+ if cbp_response?(body)
79
+ set_cbp_response_options(body)
80
+ elsif @next_page =~ /page=(\d+)/
81
+ @options["page"] = Regexp.last_match(1).to_i - 1
82
+ elsif @prev_page =~ /page=(\d+)/
83
+ @options["page"] = Regexp.last_match(1).to_i + 1
84
+ end
85
+ end
86
+
87
+ def set_cbp_response_options(body)
88
+ @options.page = {} unless cbp_request?
89
+ # the line above means an intentional CBP request where page[size] is passed on the query
90
+ # this is to cater for CBP responses where we don't specify page[size] but the endpoint
91
+ # responds CBP by default. i.e `client.trigger_categories.fetch`
92
+ @options.page.merge!(
93
+ before: body["meta"]["before_cursor"],
94
+ after: body["meta"]["after_cursor"]
95
+ )
96
+ end
97
+ end
98
+ end
99
+ end
@@ -39,6 +39,14 @@ module ZendeskAPI
39
39
  def namespace(namespace)
40
40
  @namespace = namespace
41
41
  end
42
+
43
+ def new_from_response(client, response, includes = nil)
44
+ new(client).tap do |resource|
45
+ resource.handle_response(response)
46
+ resource.set_includes(resource, includes, response.body) if includes
47
+ resource.attributes.clear_changes
48
+ end
49
+ end
42
50
  end
43
51
 
44
52
  # @return [Hash] The resource's attributes
@@ -123,19 +131,16 @@ module ZendeskAPI
123
131
 
124
132
  # Compares resources by class and id. If id is nil, then by object_id
125
133
  def ==(other)
134
+ return false unless other
135
+
126
136
  return true if other.object_id == object_id
127
137
 
128
- if other && !(other.is_a?(Data) || other.is_a?(Integer))
129
- warn "Trying to compare #{other.class} to a Resource from #{caller.first}"
130
- end
138
+ return other.id && (other.id == id) if other.is_a?(Data)
131
139
 
132
- if other.is_a?(Data)
133
- other.id && other.id == id
134
- elsif other.is_a?(Integer)
135
- id == other
136
- else
137
- false
138
- end
140
+ return id == other if other.is_a?(Integer)
141
+
142
+ warn "Trying to compare #{other.class} to a Resource
143
+ from #{caller.first}"
139
144
  end
140
145
  alias :eql :==
141
146
 
@@ -163,6 +168,10 @@ module ZendeskAPI
163
168
  class DataResource < Data
164
169
  attr_accessor :error, :error_message
165
170
  extend Verbs
171
+
172
+ def self.cbp_path_regexes
173
+ []
174
+ end
166
175
  end
167
176
 
168
177
  # Represents a resource that can only GET
@@ -24,6 +24,10 @@ module ZendeskAPI
24
24
 
25
25
  class Topic < Resource
26
26
  class << self
27
+ def cbp_path_regexes
28
+ [%r{^community/topics$}]
29
+ end
30
+
27
31
  def resource_path
28
32
  "community/topics"
29
33
  end
@@ -83,6 +87,10 @@ module ZendeskAPI
83
87
  def attributes_for_save
84
88
  { self.class.resource_name => [id] }
85
89
  end
90
+
91
+ def self.cbp_path_regexes
92
+ [/^tags$/]
93
+ end
86
94
  end
87
95
 
88
96
  class Attachment < ReadResource
@@ -152,6 +160,10 @@ module ZendeskAPI
152
160
  def self.incremental_export(client, start_time)
153
161
  ZendeskAPI::Collection.new(client, self, :path => "incremental/organizations?start_time=#{start_time.to_i}")
154
162
  end
163
+
164
+ def self.cbp_path_regexes
165
+ [/^organizations$/]
166
+ end
155
167
  end
156
168
 
157
169
  class Brand < Resource
@@ -180,6 +192,10 @@ module ZendeskAPI
180
192
 
181
193
  has User
182
194
  has Organization
195
+
196
+ def self.cbp_path_regexes
197
+ [%r{^organizations/\d+/subscriptions$}]
198
+ end
183
199
  end
184
200
 
185
201
  class Category < Resource
@@ -258,15 +274,19 @@ module ZendeskAPI
258
274
  end
259
275
 
260
276
  class Topic < Resource
261
- has_many :subscriptions, :class => TopicSubscription, :inline => true
262
- has_many Tag, :extend => Tag::Update, :inline => :create
277
+ has_many :subscriptions, class: TopicSubscription, inline: true
278
+ has_many Tag, extend: Tag::Update, inline: :create
263
279
  has_many Attachment
264
- has_many :uploads, :class => Attachment, :inline => true
280
+ has_many :uploads, class: Attachment, inline: true
265
281
  end
266
282
 
267
283
  class Activity < Resource
268
284
  has User
269
285
  has :actor, :class => User
286
+
287
+ def self.cbp_path_regexes
288
+ [/^activities$/]
289
+ end
270
290
  end
271
291
 
272
292
  class Setting < UpdateResource
@@ -318,7 +338,7 @@ module ZendeskAPI
318
338
  class Comment < DataResource
319
339
  include Save
320
340
 
321
- has_many :uploads, :class => Attachment, :inline => true
341
+ has_many :uploads, class: Attachment, inline: true
322
342
  has :author, :class => User
323
343
 
324
344
  def save
@@ -349,10 +369,18 @@ module ZendeskAPI
349
369
  namespace 'portal'
350
370
  end
351
371
 
352
- class TicketField < Resource; end
372
+ class TicketField < Resource
373
+ def self.cbp_path_regexes
374
+ [/^ticket_fields$/]
375
+ end
376
+ end
353
377
 
354
378
  class TicketMetric < DataResource
355
379
  include Read
380
+
381
+ def self.cbp_path_regexes
382
+ [/^ticket_metrics$/]
383
+ end
356
384
  end
357
385
 
358
386
  class TicketRelated < DataResource; end
@@ -360,7 +388,7 @@ module ZendeskAPI
360
388
  class TicketEvent < DataResource
361
389
  class Event < Data; end
362
390
 
363
- has_many :child_events, :class => Event
391
+ has_many :child_events, class: Event
364
392
  has Ticket
365
393
  has :updater, :class => User
366
394
 
@@ -378,6 +406,10 @@ module ZendeskAPI
378
406
  extend UpdateMany
379
407
  extend DestroyMany
380
408
 
409
+ def self.cbp_path_regexes
410
+ [/^tickets$/]
411
+ end
412
+
381
413
  # Unlike other attributes, "comment" is not a property of the ticket,
382
414
  # but is used as a "comment on save", so it should be kept unchanged,
383
415
  # See https://github.com/zendesk/zendesk_api_client_rb/issues/321
@@ -401,8 +433,8 @@ module ZendeskAPI
401
433
  class Comment < DataResource
402
434
  include Save
403
435
 
404
- has_many :uploads, :class => Attachment, :inline => true
405
- has :author, :class => User
436
+ has_many :uploads, class: Attachment, inline: true
437
+ has :author, class: User
406
438
 
407
439
  def save
408
440
  if new_record?
@@ -429,35 +461,35 @@ module ZendeskAPI
429
461
  has :submitter, :class => User
430
462
  has :assignee, :class => User
431
463
 
432
- has_many :collaborators, :class => User, :inline => true, :extend => (Module.new do
464
+ has_many :collaborators, class: User, inline: true, extend: (Module.new do
433
465
  def to_param
434
466
  map(&:id)
435
467
  end
436
468
  end)
437
469
 
438
470
  has_many Audit
439
- has :metrics, :class => TicketMetric
471
+ has :metrics, class: TicketMetric
440
472
  has Group
441
473
  has Organization
442
474
  has Brand
443
- has :related, :class => TicketRelated
475
+ has :related, class: TicketRelated
444
476
 
445
- has Comment, :inline => true
477
+ has Comment, inline: true
446
478
  has_many Comment
447
479
 
448
- has :last_comment, :class => Comment, :inline => true
449
- has_many :last_comments, :class => Comment, :inline => true
480
+ has :last_comment, class: Comment, inline: true
481
+ has_many :last_comments, class: Comment, inline: true
450
482
 
451
- has_many Tag, :extend => Tag::Update, :inline => :create
483
+ has_many Tag, extend: Tag::Update, inline: :create
452
484
 
453
- has_many :incidents, :class => Ticket
485
+ has_many :incidents, class: Ticket
454
486
 
455
487
  # Gets a incremental export of tickets from the start_time until now.
456
488
  # @param [Client] client The {Client} object to be used
457
489
  # @param [Integer] start_time The start_time parameter
458
490
  # @return [Collection] Collection of {Ticket}
459
491
  def self.incremental_export(client, start_time)
460
- ZendeskAPI::Collection.new(client, self, :path => "incremental/tickets?start_time=#{start_time.to_i}")
492
+ ZendeskAPI::Collection.new(client, self, path: "incremental/tickets?start_time=#{start_time.to_i}")
461
493
  end
462
494
 
463
495
  # Imports a ticket through the imports/tickets endpoint using save!
@@ -466,7 +498,7 @@ module ZendeskAPI
466
498
  # @return [Ticket] Created object or nil
467
499
  def self.import!(client, attributes)
468
500
  new(client, attributes).tap do |ticket|
469
- ticket.save!(:path => "imports/tickets")
501
+ ticket.save!(path: "imports/tickets")
470
502
  end
471
503
  end
472
504
 
@@ -476,7 +508,7 @@ module ZendeskAPI
476
508
  # @return [Ticket] Created object or nil
477
509
  def self.import(client, attributes)
478
510
  ticket = new(client, attributes)
479
- return unless ticket.save(:path => "imports/tickets")
511
+ return unless ticket.save(path: "imports/tickets")
480
512
  ticket
481
513
  end
482
514
  end
@@ -486,6 +518,10 @@ module ZendeskAPI
486
518
 
487
519
  # Recovers this suspended ticket to an actual ticket
488
520
  put :recover
521
+
522
+ def self.cbp_path_regexes
523
+ [/^suspended_tickets$/]
524
+ end
489
525
  end
490
526
 
491
527
  class DeletedTicket < ReadResource
@@ -495,6 +531,10 @@ module ZendeskAPI
495
531
  # Restores this previously deleted ticket to an actual ticket
496
532
  put :restore
497
533
  put :restore_many
534
+
535
+ def self.cbp_path_regexes
536
+ [/^deleted_tickets$/]
537
+ end
498
538
  end
499
539
 
500
540
  class UserViewRow < DataResource
@@ -510,9 +550,9 @@ module ZendeskAPI
510
550
  # @internal Optional columns
511
551
 
512
552
  has Group
513
- has :assignee, :class => User
514
- has :requester, :class => User
515
- has :submitter, :class => User
553
+ has :assignee, class: User
554
+ has :requester, class: User
555
+ has :submitter, class: User
516
556
  has Organization
517
557
 
518
558
  def self.model_key
@@ -592,6 +632,10 @@ module ZendeskAPI
592
632
  def self.preview(client, options = {})
593
633
  Collection.new(client, ViewRow, options.merge(:path => "views/preview", :verb => :post))
594
634
  end
635
+
636
+ def self.cbp_path_regexes
637
+ [/^views$/]
638
+ end
595
639
  end
596
640
 
597
641
  class Trigger < Rule
@@ -599,6 +643,10 @@ module ZendeskAPI
599
643
  include Actions
600
644
 
601
645
  has :execution, :class => RuleExecution
646
+
647
+ def self.cbp_path_regexes
648
+ [/^triggers$/, %r{^triggers/active$}]
649
+ end
602
650
  end
603
651
 
604
652
  class Automation < Rule
@@ -606,6 +654,10 @@ module ZendeskAPI
606
654
  include Actions
607
655
 
608
656
  has :execution, :class => RuleExecution
657
+
658
+ def self.cbp_path_regexes
659
+ [/^automations$/]
660
+ end
609
661
  end
610
662
 
611
663
  class Macro < Rule
@@ -613,6 +665,10 @@ module ZendeskAPI
613
665
 
614
666
  has :execution, :class => RuleExecution
615
667
 
668
+ def self.cbp_path_regexes
669
+ [/^macros$/]
670
+ end
671
+
616
672
  # Returns the update to a ticket that happens when a macro will be applied.
617
673
  # @param [Ticket] ticket Optional {Ticket} to apply this macro to.
618
674
  # @raise [Faraday::ClientError] Raised for any non-200 response.
@@ -648,6 +704,18 @@ module ZendeskAPI
648
704
 
649
705
  has User
650
706
  has Group
707
+
708
+ def self.cbp_path_regexes
709
+ [%r{^groups/\d+/memberships$}]
710
+ end
711
+ end
712
+
713
+ class Group < Resource
714
+ has_many :memberships, class: GroupMembership, path: "memberships"
715
+
716
+ def self.cbp_path_regexes
717
+ [/^groups$/, %r{^groups/assignable$}]
718
+ end
651
719
  end
652
720
 
653
721
  class User < Resource
@@ -789,6 +857,10 @@ module ZendeskAPI
789
857
  def self.singular_resource_name
790
858
  "client"
791
859
  end
860
+
861
+ def self.cbp_path_regexes
862
+ [%r{^oauth/clients$}]
863
+ end
792
864
  end
793
865
 
794
866
  class OauthToken < ReadResource
@@ -25,6 +25,10 @@ module ZendeskAPI
25
25
  (klass || Result).new(client, attributes)
26
26
  end
27
27
 
28
+ def self.cbp_path_regexes
29
+ []
30
+ end
31
+
28
32
  class Result < Data; end
29
33
 
30
34
  class << self
@@ -1,3 +1,3 @@
1
1
  module ZendeskAPI
2
- VERSION = "3.0.1"
2
+ VERSION = "3.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zendesk_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Davidovitz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-07-14 00:00:00.000000000 Z
12
+ date: 2023-08-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -136,6 +136,7 @@ files:
136
136
  - lib/zendesk_api/middleware/response/parse_json.rb
137
137
  - lib/zendesk_api/middleware/response/raise_error.rb
138
138
  - lib/zendesk_api/middleware/response/sanitize_response.rb
139
+ - lib/zendesk_api/pagination.rb
139
140
  - lib/zendesk_api/resource.rb
140
141
  - lib/zendesk_api/resources.rb
141
142
  - lib/zendesk_api/search.rb
@@ -152,9 +153,9 @@ licenses:
152
153
  - Apache-2.0
153
154
  metadata:
154
155
  bug_tracker_uri: https://github.com/zendesk/zendesk_api_client_rb/issues
155
- changelog_uri: https://github.com/zendesk/zendesk_api_client_rb/blob/v3.0.1/CHANGELOG.md
156
- documentation_uri: https://www.rubydoc.info/gems/zendesk_api/3.0.1
157
- source_code_uri: https://github.com/zendesk/zendesk_api_client_rb/tree/v3.0.1
156
+ changelog_uri: https://github.com/zendesk/zendesk_api_client_rb/blob/v3.0.4/CHANGELOG.md
157
+ documentation_uri: https://www.rubydoc.info/gems/zendesk_api/3.0.4
158
+ source_code_uri: https://github.com/zendesk/zendesk_api_client_rb/tree/v3.0.4
158
159
  wiki_uri: https://github.com/zendesk/zendesk_api_client_rb/wiki
159
160
  post_install_message:
160
161
  rdoc_options: []