zendesk_api 3.1.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/zendesk_api/actions.rb +31 -31
- data/lib/zendesk_api/association.rb +8 -8
- data/lib/zendesk_api/associations.rb +30 -30
- data/lib/zendesk_api/client.rb +77 -36
- data/lib/zendesk_api/collection.rb +41 -40
- data/lib/zendesk_api/configuration.rb +11 -8
- data/lib/zendesk_api/core_ext/inflection.rb +2 -2
- data/lib/zendesk_api/delegator.rb +1 -1
- data/lib/zendesk_api/helpers.rb +10 -10
- data/lib/zendesk_api/middleware/request/api_token_impersonate.rb +29 -0
- data/lib/zendesk_api/middleware/request/encode_json.rb +3 -4
- data/lib/zendesk_api/middleware/request/etag_cache.rb +27 -4
- data/lib/zendesk_api/middleware/request/raise_rate_limited.rb +3 -3
- data/lib/zendesk_api/middleware/request/retry.rb +56 -20
- data/lib/zendesk_api/middleware/request/upload.rb +1 -1
- data/lib/zendesk_api/middleware/request/url_based_access_token.rb +2 -2
- data/lib/zendesk_api/middleware/response/deflate.rb +1 -1
- data/lib/zendesk_api/middleware/response/gzip.rb +3 -3
- data/lib/zendesk_api/middleware/response/logger.rb +3 -3
- data/lib/zendesk_api/middleware/response/parse_iso_dates.rb +1 -1
- data/lib/zendesk_api/middleware/response/parse_json.rb +3 -3
- data/lib/zendesk_api/middleware/response/raise_error.rb +1 -1
- data/lib/zendesk_api/middleware/response/sanitize_response.rb +1 -1
- data/lib/zendesk_api/middleware/response/zendesk_request_event.rb +72 -0
- data/lib/zendesk_api/pagination.rb +3 -3
- data/lib/zendesk_api/resource.rb +22 -22
- data/lib/zendesk_api/resources.rb +127 -82
- data/lib/zendesk_api/search.rb +6 -6
- data/lib/zendesk_api/silent_mash.rb +1 -1
- data/lib/zendesk_api/track_changes.rb +2 -2
- data/lib/zendesk_api/trackie.rb +3 -3
- data/lib/zendesk_api/version.rb +1 -1
- data/lib/zendesk_api.rb +5 -5
- data/util/resource_handler.rb +5 -5
- data/util/verb_handler.rb +1 -1
- metadata +27 -16
|
@@ -20,7 +20,7 @@ module ZendeskAPI
|
|
|
20
20
|
|
|
21
21
|
class Channel < Resource
|
|
22
22
|
def work_items
|
|
23
|
-
@work_items ||= attributes.fetch(
|
|
23
|
+
@work_items ||= attributes.fetch("relationships", {}).fetch("work_items", {}).fetch("data", []).map do |work_item_attributes|
|
|
24
24
|
WorkItem.new(@client, work_item_attributes)
|
|
25
25
|
end
|
|
26
26
|
end
|
|
@@ -35,7 +35,7 @@ module ZendeskAPI
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
def initialize(client, attributes = {})
|
|
38
|
-
nested_attributes = attributes.delete(
|
|
38
|
+
nested_attributes = attributes.delete("attributes")
|
|
39
39
|
super(client, attributes.merge(nested_attributes))
|
|
40
40
|
end
|
|
41
41
|
|
|
@@ -59,9 +59,9 @@ module ZendeskAPI
|
|
|
59
59
|
|
|
60
60
|
def channels
|
|
61
61
|
@channels ||= begin
|
|
62
|
-
channel_attributes_array = @client.connection.get(attributes[
|
|
62
|
+
channel_attributes_array = @client.connection.get(attributes["links"]["self"]).body.fetch("included")
|
|
63
63
|
channel_attributes_array.map do |channel_attributes|
|
|
64
|
-
nested_attributes = channel_attributes.delete(
|
|
64
|
+
nested_attributes = channel_attributes.delete("attributes")
|
|
65
65
|
Channel.new(@client, channel_attributes.merge(nested_attributes))
|
|
66
66
|
end
|
|
67
67
|
end
|
|
@@ -100,12 +100,12 @@ module ZendeskAPI
|
|
|
100
100
|
include Update
|
|
101
101
|
include Destroy
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
alias_method :name, :id
|
|
104
|
+
alias_method :to_param, :id
|
|
105
105
|
|
|
106
106
|
def path(opts = {})
|
|
107
107
|
raise "tags must have parent resource" unless association.options.parent
|
|
108
|
-
super(opts.merge(:
|
|
108
|
+
super(opts.merge(with_parent: true, with_id: false))
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
def changed?
|
|
@@ -123,7 +123,7 @@ module ZendeskAPI
|
|
|
123
123
|
return self unless @resources
|
|
124
124
|
|
|
125
125
|
@client.connection.post(path) do |req|
|
|
126
|
-
req.body = {
|
|
126
|
+
req.body = {tags: @resources.reject(&:destroyed?).map(&:id)}
|
|
127
127
|
end
|
|
128
128
|
|
|
129
129
|
true
|
|
@@ -137,7 +137,7 @@ module ZendeskAPI
|
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
def attributes_for_save
|
|
140
|
-
{
|
|
140
|
+
{self.class.resource_name => [id]}
|
|
141
141
|
end
|
|
142
142
|
|
|
143
143
|
def self.cbp_path_regexes
|
|
@@ -195,13 +195,13 @@ module ZendeskAPI
|
|
|
195
195
|
extend CreateOrUpdate
|
|
196
196
|
extend DestroyMany
|
|
197
197
|
|
|
198
|
-
has Ability, :
|
|
198
|
+
has Ability, inline: true
|
|
199
199
|
has Group
|
|
200
|
-
has :related, :
|
|
200
|
+
has :related, class: OrganizationRelated
|
|
201
201
|
|
|
202
202
|
has_many Ticket
|
|
203
203
|
has_many User
|
|
204
|
-
has_many Tag, :
|
|
204
|
+
has_many Tag, extend: Tag::Update, inline: :create
|
|
205
205
|
has_many OrganizationMembership
|
|
206
206
|
has_many :subscriptions, class: OrganizationSubscription
|
|
207
207
|
|
|
@@ -210,7 +210,7 @@ module ZendeskAPI
|
|
|
210
210
|
# @param [Integer] start_time The start_time parameter
|
|
211
211
|
# @return [Collection] Collection of {Organization}
|
|
212
212
|
def self.incremental_export(client, start_time)
|
|
213
|
-
ZendeskAPI::Collection.new(client, self, :
|
|
213
|
+
ZendeskAPI::Collection.new(client, self, path: "incremental/organizations?start_time=#{start_time.to_i}")
|
|
214
214
|
end
|
|
215
215
|
|
|
216
216
|
def self.cbp_path_regexes
|
|
@@ -263,6 +263,7 @@ module ZendeskAPI
|
|
|
263
263
|
|
|
264
264
|
class Section < Resource
|
|
265
265
|
end
|
|
266
|
+
|
|
266
267
|
class Translation < Resource; end
|
|
267
268
|
|
|
268
269
|
has_many Section
|
|
@@ -280,6 +281,7 @@ module ZendeskAPI
|
|
|
280
281
|
|
|
281
282
|
class Vote < Resource; end
|
|
282
283
|
class Translation < Resource; end
|
|
284
|
+
|
|
283
285
|
class Article < Resource
|
|
284
286
|
has_many Vote
|
|
285
287
|
has_many Translation
|
|
@@ -325,7 +327,7 @@ module ZendeskAPI
|
|
|
325
327
|
has User
|
|
326
328
|
|
|
327
329
|
def path(options = {})
|
|
328
|
-
super(options.merge(:
|
|
330
|
+
super(options.merge(with_parent: true))
|
|
329
331
|
end
|
|
330
332
|
end
|
|
331
333
|
|
|
@@ -338,7 +340,7 @@ module ZendeskAPI
|
|
|
338
340
|
|
|
339
341
|
class Activity < Resource
|
|
340
342
|
has User
|
|
341
|
-
has :actor, :
|
|
343
|
+
has :actor, class: User
|
|
342
344
|
|
|
343
345
|
def self.cbp_path_regexes
|
|
344
346
|
[/^activities$/]
|
|
@@ -350,10 +352,14 @@ module ZendeskAPI
|
|
|
350
352
|
|
|
351
353
|
def initialize(client, attributes = {})
|
|
352
354
|
# Try and find the root key
|
|
353
|
-
@on = (attributes.keys.map(&:to_s) - %w
|
|
355
|
+
@on = (attributes.keys.map(&:to_s) - %w[association options]).first
|
|
354
356
|
|
|
355
|
-
#
|
|
356
|
-
attributes.
|
|
357
|
+
# Namespaced settings (e.g. "lotus", "admin_center") nest their values in a
|
|
358
|
+
# Hash, which we hoist up to be the root attributes. Some settings are
|
|
359
|
+
# top-level scalars or arrays (e.g. "shared_views_order",
|
|
360
|
+
# "agent_home_pinned_views") - leave those under @on rather than merging,
|
|
361
|
+
# which would raise "no implicit conversion of Array into Hash".
|
|
362
|
+
attributes.merge!(attributes.delete(@on)) if attributes[@on].is_a?(Hash)
|
|
357
363
|
|
|
358
364
|
super
|
|
359
365
|
end
|
|
@@ -363,17 +369,17 @@ module ZendeskAPI
|
|
|
363
369
|
end
|
|
364
370
|
|
|
365
371
|
def path(options = {})
|
|
366
|
-
super(options.merge(:
|
|
372
|
+
super(options.merge(with_parent: true))
|
|
367
373
|
end
|
|
368
374
|
|
|
369
375
|
def attributes_for_save
|
|
370
|
-
{
|
|
376
|
+
{self.class.resource_name => {@on => attributes.changes}}
|
|
371
377
|
end
|
|
372
378
|
end
|
|
373
379
|
|
|
374
380
|
class SatisfactionRating < ReadResource
|
|
375
|
-
has :assignee, :
|
|
376
|
-
has :requester, :
|
|
381
|
+
has :assignee, class: User
|
|
382
|
+
has :requester, class: User
|
|
377
383
|
has Ticket
|
|
378
384
|
has Group
|
|
379
385
|
end
|
|
@@ -395,7 +401,7 @@ module ZendeskAPI
|
|
|
395
401
|
include Save
|
|
396
402
|
|
|
397
403
|
has_many :uploads, class: Attachment, inline: true
|
|
398
|
-
has :author, :
|
|
404
|
+
has :author, class: User
|
|
399
405
|
|
|
400
406
|
def save
|
|
401
407
|
if new_record?
|
|
@@ -406,23 +412,23 @@ module ZendeskAPI
|
|
|
406
412
|
end
|
|
407
413
|
end
|
|
408
414
|
|
|
409
|
-
|
|
415
|
+
alias_method :save!, :save
|
|
410
416
|
end
|
|
411
417
|
|
|
412
|
-
has Comment, :
|
|
418
|
+
has Comment, inline: true
|
|
413
419
|
has_many Comment
|
|
414
420
|
|
|
415
421
|
has Organization
|
|
416
422
|
has Group
|
|
417
|
-
has :requester, :
|
|
423
|
+
has :requester, class: User
|
|
418
424
|
end
|
|
419
425
|
|
|
420
426
|
class AnonymousRequest < CreateResource
|
|
421
427
|
def self.singular_resource_name
|
|
422
|
-
|
|
428
|
+
"request"
|
|
423
429
|
end
|
|
424
430
|
|
|
425
|
-
namespace
|
|
431
|
+
namespace "portal"
|
|
426
432
|
end
|
|
427
433
|
|
|
428
434
|
class TicketField < Resource
|
|
@@ -446,14 +452,14 @@ module ZendeskAPI
|
|
|
446
452
|
|
|
447
453
|
has_many :child_events, class: Event
|
|
448
454
|
has Ticket
|
|
449
|
-
has :updater, :
|
|
455
|
+
has :updater, class: User
|
|
450
456
|
|
|
451
457
|
# Gets a incremental export of ticket events from the start_time until now.
|
|
452
458
|
# @param [Client] client The {Client} object to be used
|
|
453
459
|
# @param [Integer] start_time The start_time parameter
|
|
454
460
|
# @return [Collection] Collection of {TicketEvent}
|
|
455
461
|
def self.incremental_export(client, start_time)
|
|
456
|
-
ZendeskAPI::Collection.new(client, self, :
|
|
462
|
+
ZendeskAPI::Collection.new(client, self, path: "incremental/ticket_events?start_time=#{start_time.to_i}")
|
|
457
463
|
end
|
|
458
464
|
end
|
|
459
465
|
|
|
@@ -475,13 +481,13 @@ module ZendeskAPI
|
|
|
475
481
|
|
|
476
482
|
class Audit < DataResource
|
|
477
483
|
class Event < Data
|
|
478
|
-
has :author, :
|
|
484
|
+
has :author, class: User
|
|
479
485
|
end
|
|
480
486
|
|
|
481
487
|
put :trust
|
|
482
488
|
|
|
483
489
|
# need this to support SideLoading
|
|
484
|
-
has :author, :
|
|
490
|
+
has :author, class: User
|
|
485
491
|
|
|
486
492
|
has_many Event
|
|
487
493
|
|
|
@@ -505,27 +511,27 @@ module ZendeskAPI
|
|
|
505
511
|
end
|
|
506
512
|
end
|
|
507
513
|
|
|
508
|
-
|
|
514
|
+
alias_method :save!, :save
|
|
509
515
|
end
|
|
510
516
|
|
|
511
517
|
class SatisfactionRating < CreateResource
|
|
512
518
|
class << self
|
|
513
|
-
|
|
519
|
+
alias_method :resource_name, :singular_resource_name
|
|
514
520
|
end
|
|
515
521
|
end
|
|
516
522
|
|
|
517
523
|
put :mark_as_spam
|
|
518
524
|
post :merge
|
|
519
525
|
|
|
520
|
-
has :requester, :
|
|
521
|
-
has :submitter, :
|
|
522
|
-
has :assignee, :
|
|
526
|
+
has :requester, class: User, inline: :create
|
|
527
|
+
has :submitter, class: User
|
|
528
|
+
has :assignee, class: User
|
|
523
529
|
|
|
524
|
-
has_many :collaborators, class: User, inline: true, extend:
|
|
530
|
+
has_many :collaborators, class: User, inline: true, extend: Module.new do
|
|
525
531
|
def to_param
|
|
526
532
|
map(&:id)
|
|
527
533
|
end
|
|
528
|
-
end
|
|
534
|
+
end
|
|
529
535
|
|
|
530
536
|
has_many Audit
|
|
531
537
|
has :metrics, class: TicketMetric
|
|
@@ -544,6 +550,43 @@ module ZendeskAPI
|
|
|
544
550
|
|
|
545
551
|
has_many :incidents, class: Ticket
|
|
546
552
|
|
|
553
|
+
class CustomFieldAccessor
|
|
554
|
+
def initialize(ticket)
|
|
555
|
+
@ticket = ticket
|
|
556
|
+
end
|
|
557
|
+
|
|
558
|
+
def [](field_name)
|
|
559
|
+
find_by_name(field_name)["value"]
|
|
560
|
+
end
|
|
561
|
+
|
|
562
|
+
def []=(field_name, value)
|
|
563
|
+
find_by_name(field_name)["value"] = value
|
|
564
|
+
end
|
|
565
|
+
|
|
566
|
+
private
|
|
567
|
+
|
|
568
|
+
def find_by_name(field_name)
|
|
569
|
+
@ticket.refresh_custom_fields_metadata unless @ticket.account_data.has_key?(:custom_fields)
|
|
570
|
+
|
|
571
|
+
custom_field_id = @ticket.account_data[:custom_fields][field_name]
|
|
572
|
+
raise ArgumentError, "No custom field named '#{field_name}' found in field definitions" if custom_field_id.nil?
|
|
573
|
+
|
|
574
|
+
custom_field = @ticket.custom_fields.find { |cf| cf["id"] == custom_field_id }
|
|
575
|
+
raise ArgumentError, "No custom field with id #{custom_field_id} found. Field name: '#{field_name}'" if custom_field.nil?
|
|
576
|
+
|
|
577
|
+
custom_field
|
|
578
|
+
end
|
|
579
|
+
end
|
|
580
|
+
|
|
581
|
+
# Returns a custom field accessor that supports bracket notation.
|
|
582
|
+
# Usage:
|
|
583
|
+
# ticket.custom_field["field name"] # get
|
|
584
|
+
# ticket.custom_field["field name"] = "value" # set
|
|
585
|
+
# You need to call `save!` on a ticket after changing a custom field value.
|
|
586
|
+
def custom_field
|
|
587
|
+
@custom_field_accessor ||= CustomFieldAccessor.new(self)
|
|
588
|
+
end
|
|
589
|
+
|
|
547
590
|
# Gets a incremental export of tickets from the start_time until now.
|
|
548
591
|
# @param [Client] client The {Client} object to be used
|
|
549
592
|
# @param [Integer] start_time The start_time parameter
|
|
@@ -621,7 +664,7 @@ module ZendeskAPI
|
|
|
621
664
|
end
|
|
622
665
|
|
|
623
666
|
class RuleExecution < Data
|
|
624
|
-
has_many :custom_fields, :
|
|
667
|
+
has_many :custom_fields, class: TicketField
|
|
625
668
|
end
|
|
626
669
|
|
|
627
670
|
class ViewCount < DataResource; end
|
|
@@ -631,7 +674,7 @@ module ZendeskAPI
|
|
|
631
674
|
|
|
632
675
|
def attributes_for_save
|
|
633
676
|
to_save = [:conditions, :actions, :output].inject({}) { |h, k| h.merge(k => send(k)) }
|
|
634
|
-
{
|
|
677
|
+
{self.class.singular_resource_name.to_sym => attributes.changes.merge(to_save)}
|
|
635
678
|
end
|
|
636
679
|
end
|
|
637
680
|
|
|
@@ -651,32 +694,32 @@ module ZendeskAPI
|
|
|
651
694
|
def add_all_condition(field, operator, value)
|
|
652
695
|
self.conditions ||= {}
|
|
653
696
|
self.conditions[:all] ||= []
|
|
654
|
-
self.conditions[:all] << {
|
|
697
|
+
self.conditions[:all] << {field: field, operator: operator, value: value}
|
|
655
698
|
end
|
|
656
699
|
|
|
657
700
|
def add_any_condition(field, operator, value)
|
|
658
701
|
self.conditions ||= {}
|
|
659
702
|
self.conditions[:any] ||= []
|
|
660
|
-
self.conditions[:any] << {
|
|
703
|
+
self.conditions[:any] << {field: field, operator: operator, value: value}
|
|
661
704
|
end
|
|
662
705
|
end
|
|
663
706
|
|
|
664
707
|
module Actions
|
|
665
708
|
def add_action(field, value)
|
|
666
709
|
self.actions ||= []
|
|
667
|
-
self.actions << {
|
|
710
|
+
self.actions << {field: field, value: value}
|
|
668
711
|
end
|
|
669
712
|
end
|
|
670
713
|
|
|
671
714
|
class View < Rule
|
|
672
715
|
include Conditions
|
|
673
716
|
|
|
674
|
-
has_many :tickets, :
|
|
675
|
-
has_many :feed, :
|
|
717
|
+
has_many :tickets, class: Ticket
|
|
718
|
+
has_many :feed, class: Ticket, path: "feed"
|
|
676
719
|
|
|
677
|
-
has_many :rows, :
|
|
678
|
-
has :execution, :
|
|
679
|
-
has ViewCount, :
|
|
720
|
+
has_many :rows, class: ViewRow, path: "execute"
|
|
721
|
+
has :execution, class: RuleExecution
|
|
722
|
+
has ViewCount, path: "count"
|
|
680
723
|
|
|
681
724
|
def add_column(column)
|
|
682
725
|
columns = execution.columns.map(&:id)
|
|
@@ -690,7 +733,7 @@ module ZendeskAPI
|
|
|
690
733
|
end
|
|
691
734
|
|
|
692
735
|
def self.preview(client, options = {})
|
|
693
|
-
Collection.new(client, ViewRow, options.merge(:
|
|
736
|
+
Collection.new(client, ViewRow, options.merge(path: "views/preview", verb: :post))
|
|
694
737
|
end
|
|
695
738
|
|
|
696
739
|
def self.cbp_path_regexes
|
|
@@ -702,7 +745,7 @@ module ZendeskAPI
|
|
|
702
745
|
include Conditions
|
|
703
746
|
include Actions
|
|
704
747
|
|
|
705
|
-
has :execution, :
|
|
748
|
+
has :execution, class: RuleExecution
|
|
706
749
|
|
|
707
750
|
def self.cbp_path_regexes
|
|
708
751
|
[/^triggers$/, %r{^triggers/active$}]
|
|
@@ -713,7 +756,7 @@ module ZendeskAPI
|
|
|
713
756
|
include Conditions
|
|
714
757
|
include Actions
|
|
715
758
|
|
|
716
|
-
has :execution, :
|
|
759
|
+
has :execution, class: RuleExecution
|
|
717
760
|
|
|
718
761
|
def self.cbp_path_regexes
|
|
719
762
|
[/^automations$/]
|
|
@@ -723,7 +766,7 @@ module ZendeskAPI
|
|
|
723
766
|
class Macro < Rule
|
|
724
767
|
include Actions
|
|
725
768
|
|
|
726
|
-
has :execution, :
|
|
769
|
+
has :execution, class: RuleExecution
|
|
727
770
|
|
|
728
771
|
def self.cbp_path_regexes
|
|
729
772
|
[/^macros$/]
|
|
@@ -754,7 +797,7 @@ module ZendeskAPI
|
|
|
754
797
|
|
|
755
798
|
class UserView < Rule
|
|
756
799
|
def self.preview(client, options = {})
|
|
757
|
-
Collection.new(client, UserViewRow, options.merge!(:
|
|
800
|
+
Collection.new(client, UserViewRow, options.merge!(path: "user_views/preview", verb: :post))
|
|
758
801
|
end
|
|
759
802
|
end
|
|
760
803
|
|
|
@@ -808,22 +851,22 @@ module ZendeskAPI
|
|
|
808
851
|
|
|
809
852
|
# Set a user's password
|
|
810
853
|
def set_password(opts = {})
|
|
811
|
-
password(opts.merge(:
|
|
854
|
+
password(opts.merge(verb: :post))
|
|
812
855
|
end
|
|
813
856
|
|
|
814
857
|
# Change a user's password
|
|
815
858
|
def change_password(opts = {})
|
|
816
|
-
password(opts.merge(:
|
|
859
|
+
password(opts.merge(verb: :put))
|
|
817
860
|
end
|
|
818
861
|
|
|
819
862
|
# Set a user's password
|
|
820
863
|
def set_password!(opts = {})
|
|
821
|
-
password!(opts.merge(:
|
|
864
|
+
password!(opts.merge(verb: :post))
|
|
822
865
|
end
|
|
823
866
|
|
|
824
867
|
# Change a user's password
|
|
825
868
|
def change_password!(opts = {})
|
|
826
|
-
password!(opts.merge(:
|
|
869
|
+
password!(opts.merge(verb: :put))
|
|
827
870
|
end
|
|
828
871
|
|
|
829
872
|
# Gets a incremental export of users from the start_time until now.
|
|
@@ -831,7 +874,7 @@ module ZendeskAPI
|
|
|
831
874
|
# @param [Integer] start_time The start_time parameter
|
|
832
875
|
# @return [Collection] Collection of {User}
|
|
833
876
|
def self.incremental_export(client, start_time)
|
|
834
|
-
ZendeskAPI::Collection.new(client, self, :
|
|
877
|
+
ZendeskAPI::Collection.new(client, self, path: "incremental/users?start_time=#{start_time.to_i}")
|
|
835
878
|
end
|
|
836
879
|
|
|
837
880
|
has Organization
|
|
@@ -842,23 +885,23 @@ module ZendeskAPI
|
|
|
842
885
|
class CurrentSession < SingularResource
|
|
843
886
|
class << self
|
|
844
887
|
def singular_resource_name
|
|
845
|
-
|
|
888
|
+
"session"
|
|
846
889
|
end
|
|
847
890
|
|
|
848
|
-
|
|
891
|
+
alias_method :resource_name, :singular_resource_name
|
|
849
892
|
end
|
|
850
893
|
end
|
|
851
894
|
|
|
852
895
|
has_many Session
|
|
853
896
|
|
|
854
897
|
def current_session
|
|
855
|
-
ZendeskAPI::User::CurrentSession.find(@client, :
|
|
898
|
+
ZendeskAPI::User::CurrentSession.find(@client, user_id: "me")
|
|
856
899
|
end
|
|
857
900
|
|
|
858
901
|
delete :logout
|
|
859
902
|
|
|
860
903
|
def clear_sessions!
|
|
861
|
-
@client.connection.delete(path
|
|
904
|
+
@client.connection.delete("#{path}/sessions")
|
|
862
905
|
end
|
|
863
906
|
|
|
864
907
|
def clear_sessions
|
|
@@ -869,17 +912,17 @@ module ZendeskAPI
|
|
|
869
912
|
|
|
870
913
|
put :merge
|
|
871
914
|
|
|
872
|
-
has CustomRole, :
|
|
873
|
-
has Role, :
|
|
874
|
-
has Ability, :
|
|
875
|
-
has :related, :
|
|
915
|
+
has CustomRole, inline: true, include: :roles
|
|
916
|
+
has Role, inline: true, include_key: :name
|
|
917
|
+
has Ability, inline: true
|
|
918
|
+
has :related, class: UserRelated
|
|
876
919
|
|
|
877
920
|
has_many Identity
|
|
878
921
|
|
|
879
922
|
has_many Request
|
|
880
|
-
has_many :requested_tickets, :
|
|
881
|
-
has_many :assigned_tickets, :
|
|
882
|
-
has_many :ccd_tickets, :
|
|
923
|
+
has_many :requested_tickets, class: Ticket, path: "tickets/requested"
|
|
924
|
+
has_many :assigned_tickets, class: Ticket, path: "tickets/assigned"
|
|
925
|
+
has_many :ccd_tickets, class: Ticket, path: "tickets/ccd"
|
|
883
926
|
|
|
884
927
|
has_many Group
|
|
885
928
|
has_many GroupMembership
|
|
@@ -887,7 +930,7 @@ module ZendeskAPI
|
|
|
887
930
|
has_many OrganizationSubscription
|
|
888
931
|
|
|
889
932
|
has_many Setting
|
|
890
|
-
has_many Tag, :
|
|
933
|
+
has_many Tag, extend: Tag::Update, inline: :create
|
|
891
934
|
|
|
892
935
|
def attributes_for_save
|
|
893
936
|
# Don't send role_id, it's necessary
|
|
@@ -897,7 +940,7 @@ module ZendeskAPI
|
|
|
897
940
|
k == "role_id"
|
|
898
941
|
end
|
|
899
942
|
|
|
900
|
-
{
|
|
943
|
+
{self.class.singular_resource_name => attrs}
|
|
901
944
|
end
|
|
902
945
|
|
|
903
946
|
def handle_response(*)
|
|
@@ -929,6 +972,7 @@ module ZendeskAPI
|
|
|
929
972
|
|
|
930
973
|
class OauthToken < ReadResource
|
|
931
974
|
include Destroy
|
|
975
|
+
|
|
932
976
|
namespace "oauth"
|
|
933
977
|
|
|
934
978
|
def self.singular_resource_name
|
|
@@ -939,6 +983,7 @@ module ZendeskAPI
|
|
|
939
983
|
class Target < Resource; end
|
|
940
984
|
|
|
941
985
|
class Invocation < Resource; end
|
|
986
|
+
|
|
942
987
|
class Webhook < Resource
|
|
943
988
|
has_many Invocation
|
|
944
989
|
end
|
|
@@ -976,7 +1021,7 @@ module ZendeskAPI
|
|
|
976
1021
|
|
|
977
1022
|
def self.display!(client, options)
|
|
978
1023
|
new(client, options).tap do |resource|
|
|
979
|
-
resource.save!(path: resource.path
|
|
1024
|
+
resource.save!(path: "#{resource.path}/display")
|
|
980
1025
|
end
|
|
981
1026
|
end
|
|
982
1027
|
end
|
|
@@ -1031,9 +1076,9 @@ module ZendeskAPI
|
|
|
1031
1076
|
super
|
|
1032
1077
|
end
|
|
1033
1078
|
|
|
1034
|
-
def self.create!(client, attributes = {}, &
|
|
1035
|
-
if file_path = attributes.delete(:upload)
|
|
1036
|
-
attributes[:upload_id] = client.apps.uploads.create!(:
|
|
1079
|
+
def self.create!(client, attributes = {}, &)
|
|
1080
|
+
if (file_path = attributes.delete(:upload))
|
|
1081
|
+
attributes[:upload_id] = client.apps.uploads.create!(file: file_path).id
|
|
1037
1082
|
end
|
|
1038
1083
|
|
|
1039
1084
|
super
|
|
@@ -1075,15 +1120,15 @@ module ZendeskAPI
|
|
|
1075
1120
|
end
|
|
1076
1121
|
end
|
|
1077
1122
|
|
|
1078
|
-
def self.uploads(client,
|
|
1079
|
-
ZendeskAPI::Collection.new(client, Upload,
|
|
1123
|
+
def self.uploads(client, ...)
|
|
1124
|
+
ZendeskAPI::Collection.new(client, Upload, ...)
|
|
1080
1125
|
end
|
|
1081
1126
|
|
|
1082
|
-
def self.installations(client,
|
|
1083
|
-
ZendeskAPI::Collection.new(client, AppInstallation,
|
|
1127
|
+
def self.installations(client, ...)
|
|
1128
|
+
ZendeskAPI::Collection.new(client, AppInstallation, ...)
|
|
1084
1129
|
end
|
|
1085
1130
|
|
|
1086
|
-
has Upload, :
|
|
1131
|
+
has Upload, path: "uploads"
|
|
1087
1132
|
has_many Plan
|
|
1088
1133
|
|
|
1089
1134
|
# Don't nest attributes
|
|
@@ -1100,7 +1145,7 @@ module ZendeskAPI
|
|
|
1100
1145
|
include DataNamespace
|
|
1101
1146
|
|
|
1102
1147
|
class Item < ZendeskAPI::Resource
|
|
1103
|
-
namespace
|
|
1148
|
+
namespace "dynamic_content"
|
|
1104
1149
|
|
|
1105
1150
|
class Variant < ZendeskAPI::Resource
|
|
1106
1151
|
end
|
data/lib/zendesk_api/search.rb
CHANGED
|
@@ -17,10 +17,10 @@ module ZendeskAPI
|
|
|
17
17
|
present_result_type = (attributes[:result_type] || attributes["result_type"]).to_s
|
|
18
18
|
result_type = ZendeskAPI::Helpers.modulize_string(present_result_type)
|
|
19
19
|
klass = begin
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
ZendeskAPI.const_get(result_type)
|
|
21
|
+
rescue NameError
|
|
22
|
+
Result
|
|
23
|
+
end
|
|
24
24
|
|
|
25
25
|
(klass || Result).new(client, attributes)
|
|
26
26
|
end
|
|
@@ -35,7 +35,7 @@ module ZendeskAPI
|
|
|
35
35
|
def resource_name
|
|
36
36
|
"search"
|
|
37
37
|
end
|
|
38
|
-
|
|
38
|
+
alias_method :resource_path, :resource_name
|
|
39
39
|
|
|
40
40
|
def model_key
|
|
41
41
|
"results"
|
|
@@ -49,7 +49,7 @@ module ZendeskAPI
|
|
|
49
49
|
def resource_name
|
|
50
50
|
"search/export"
|
|
51
51
|
end
|
|
52
|
-
|
|
52
|
+
alias_method :resource_path, :resource_name
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
end
|
|
@@ -49,7 +49,7 @@ module ZendeskAPI
|
|
|
49
49
|
value
|
|
50
50
|
else
|
|
51
51
|
changes[key] = value
|
|
52
|
-
defined?(_store) ? _store(key, value) : super
|
|
52
|
+
defined?(_store) ? _store(key, value) : super
|
|
53
53
|
end
|
|
54
54
|
end
|
|
55
55
|
|
|
@@ -79,7 +79,7 @@ module ZendeskAPI
|
|
|
79
79
|
end
|
|
80
80
|
end
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
alias_method :dirty?, :changed?
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
end
|
data/lib/zendesk_api/trackie.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
require_relative "track_changes"
|
|
2
|
+
require_relative "silent_mash"
|
|
3
3
|
|
|
4
4
|
module ZendeskAPI
|
|
5
5
|
# @private
|
|
@@ -7,7 +7,7 @@ module ZendeskAPI
|
|
|
7
7
|
include ZendeskAPI::TrackChanges
|
|
8
8
|
|
|
9
9
|
def size
|
|
10
|
-
self[
|
|
10
|
+
self["size"]
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
end
|
data/lib/zendesk_api/version.rb
CHANGED
data/lib/zendesk_api.rb
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
module ZendeskAPI; end
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "faraday"
|
|
4
|
+
require "faraday/multipart"
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
require_relative "zendesk_api/helpers"
|
|
7
|
+
require_relative "zendesk_api/core_ext/inflection"
|
|
8
|
+
require_relative "zendesk_api/client"
|