zendesk_api 3.1.1 → 4.0.0.pre.1
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 +69 -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 +16 -24
- data/lib/zendesk_api/resources.rb +84 -80
- 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,7 +352,7 @@ 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
357
|
# Make what's inside that key the root attributes
|
|
356
358
|
attributes.merge!(attributes.delete(@on))
|
|
@@ -363,17 +365,17 @@ module ZendeskAPI
|
|
|
363
365
|
end
|
|
364
366
|
|
|
365
367
|
def path(options = {})
|
|
366
|
-
super(options.merge(:
|
|
368
|
+
super(options.merge(with_parent: true))
|
|
367
369
|
end
|
|
368
370
|
|
|
369
371
|
def attributes_for_save
|
|
370
|
-
{
|
|
372
|
+
{self.class.resource_name => {@on => attributes.changes}}
|
|
371
373
|
end
|
|
372
374
|
end
|
|
373
375
|
|
|
374
376
|
class SatisfactionRating < ReadResource
|
|
375
|
-
has :assignee, :
|
|
376
|
-
has :requester, :
|
|
377
|
+
has :assignee, class: User
|
|
378
|
+
has :requester, class: User
|
|
377
379
|
has Ticket
|
|
378
380
|
has Group
|
|
379
381
|
end
|
|
@@ -395,7 +397,7 @@ module ZendeskAPI
|
|
|
395
397
|
include Save
|
|
396
398
|
|
|
397
399
|
has_many :uploads, class: Attachment, inline: true
|
|
398
|
-
has :author, :
|
|
400
|
+
has :author, class: User
|
|
399
401
|
|
|
400
402
|
def save
|
|
401
403
|
if new_record?
|
|
@@ -406,23 +408,23 @@ module ZendeskAPI
|
|
|
406
408
|
end
|
|
407
409
|
end
|
|
408
410
|
|
|
409
|
-
|
|
411
|
+
alias_method :save!, :save
|
|
410
412
|
end
|
|
411
413
|
|
|
412
|
-
has Comment, :
|
|
414
|
+
has Comment, inline: true
|
|
413
415
|
has_many Comment
|
|
414
416
|
|
|
415
417
|
has Organization
|
|
416
418
|
has Group
|
|
417
|
-
has :requester, :
|
|
419
|
+
has :requester, class: User
|
|
418
420
|
end
|
|
419
421
|
|
|
420
422
|
class AnonymousRequest < CreateResource
|
|
421
423
|
def self.singular_resource_name
|
|
422
|
-
|
|
424
|
+
"request"
|
|
423
425
|
end
|
|
424
426
|
|
|
425
|
-
namespace
|
|
427
|
+
namespace "portal"
|
|
426
428
|
end
|
|
427
429
|
|
|
428
430
|
class TicketField < Resource
|
|
@@ -446,14 +448,14 @@ module ZendeskAPI
|
|
|
446
448
|
|
|
447
449
|
has_many :child_events, class: Event
|
|
448
450
|
has Ticket
|
|
449
|
-
has :updater, :
|
|
451
|
+
has :updater, class: User
|
|
450
452
|
|
|
451
453
|
# Gets a incremental export of ticket events from the start_time until now.
|
|
452
454
|
# @param [Client] client The {Client} object to be used
|
|
453
455
|
# @param [Integer] start_time The start_time parameter
|
|
454
456
|
# @return [Collection] Collection of {TicketEvent}
|
|
455
457
|
def self.incremental_export(client, start_time)
|
|
456
|
-
ZendeskAPI::Collection.new(client, self, :
|
|
458
|
+
ZendeskAPI::Collection.new(client, self, path: "incremental/ticket_events?start_time=#{start_time.to_i}")
|
|
457
459
|
end
|
|
458
460
|
end
|
|
459
461
|
|
|
@@ -475,13 +477,13 @@ module ZendeskAPI
|
|
|
475
477
|
|
|
476
478
|
class Audit < DataResource
|
|
477
479
|
class Event < Data
|
|
478
|
-
has :author, :
|
|
480
|
+
has :author, class: User
|
|
479
481
|
end
|
|
480
482
|
|
|
481
483
|
put :trust
|
|
482
484
|
|
|
483
485
|
# need this to support SideLoading
|
|
484
|
-
has :author, :
|
|
486
|
+
has :author, class: User
|
|
485
487
|
|
|
486
488
|
has_many Event
|
|
487
489
|
|
|
@@ -505,27 +507,27 @@ module ZendeskAPI
|
|
|
505
507
|
end
|
|
506
508
|
end
|
|
507
509
|
|
|
508
|
-
|
|
510
|
+
alias_method :save!, :save
|
|
509
511
|
end
|
|
510
512
|
|
|
511
513
|
class SatisfactionRating < CreateResource
|
|
512
514
|
class << self
|
|
513
|
-
|
|
515
|
+
alias_method :resource_name, :singular_resource_name
|
|
514
516
|
end
|
|
515
517
|
end
|
|
516
518
|
|
|
517
519
|
put :mark_as_spam
|
|
518
520
|
post :merge
|
|
519
521
|
|
|
520
|
-
has :requester, :
|
|
521
|
-
has :submitter, :
|
|
522
|
-
has :assignee, :
|
|
522
|
+
has :requester, class: User, inline: :create
|
|
523
|
+
has :submitter, class: User
|
|
524
|
+
has :assignee, class: User
|
|
523
525
|
|
|
524
|
-
has_many :collaborators, class: User, inline: true, extend:
|
|
526
|
+
has_many :collaborators, class: User, inline: true, extend: Module.new do
|
|
525
527
|
def to_param
|
|
526
528
|
map(&:id)
|
|
527
529
|
end
|
|
528
|
-
end
|
|
530
|
+
end
|
|
529
531
|
|
|
530
532
|
has_many Audit
|
|
531
533
|
has :metrics, class: TicketMetric
|
|
@@ -621,7 +623,7 @@ module ZendeskAPI
|
|
|
621
623
|
end
|
|
622
624
|
|
|
623
625
|
class RuleExecution < Data
|
|
624
|
-
has_many :custom_fields, :
|
|
626
|
+
has_many :custom_fields, class: TicketField
|
|
625
627
|
end
|
|
626
628
|
|
|
627
629
|
class ViewCount < DataResource; end
|
|
@@ -631,7 +633,7 @@ module ZendeskAPI
|
|
|
631
633
|
|
|
632
634
|
def attributes_for_save
|
|
633
635
|
to_save = [:conditions, :actions, :output].inject({}) { |h, k| h.merge(k => send(k)) }
|
|
634
|
-
{
|
|
636
|
+
{self.class.singular_resource_name.to_sym => attributes.changes.merge(to_save)}
|
|
635
637
|
end
|
|
636
638
|
end
|
|
637
639
|
|
|
@@ -651,32 +653,32 @@ module ZendeskAPI
|
|
|
651
653
|
def add_all_condition(field, operator, value)
|
|
652
654
|
self.conditions ||= {}
|
|
653
655
|
self.conditions[:all] ||= []
|
|
654
|
-
self.conditions[:all] << {
|
|
656
|
+
self.conditions[:all] << {field: field, operator: operator, value: value}
|
|
655
657
|
end
|
|
656
658
|
|
|
657
659
|
def add_any_condition(field, operator, value)
|
|
658
660
|
self.conditions ||= {}
|
|
659
661
|
self.conditions[:any] ||= []
|
|
660
|
-
self.conditions[:any] << {
|
|
662
|
+
self.conditions[:any] << {field: field, operator: operator, value: value}
|
|
661
663
|
end
|
|
662
664
|
end
|
|
663
665
|
|
|
664
666
|
module Actions
|
|
665
667
|
def add_action(field, value)
|
|
666
668
|
self.actions ||= []
|
|
667
|
-
self.actions << {
|
|
669
|
+
self.actions << {field: field, value: value}
|
|
668
670
|
end
|
|
669
671
|
end
|
|
670
672
|
|
|
671
673
|
class View < Rule
|
|
672
674
|
include Conditions
|
|
673
675
|
|
|
674
|
-
has_many :tickets, :
|
|
675
|
-
has_many :feed, :
|
|
676
|
+
has_many :tickets, class: Ticket
|
|
677
|
+
has_many :feed, class: Ticket, path: "feed"
|
|
676
678
|
|
|
677
|
-
has_many :rows, :
|
|
678
|
-
has :execution, :
|
|
679
|
-
has ViewCount, :
|
|
679
|
+
has_many :rows, class: ViewRow, path: "execute"
|
|
680
|
+
has :execution, class: RuleExecution
|
|
681
|
+
has ViewCount, path: "count"
|
|
680
682
|
|
|
681
683
|
def add_column(column)
|
|
682
684
|
columns = execution.columns.map(&:id)
|
|
@@ -690,7 +692,7 @@ module ZendeskAPI
|
|
|
690
692
|
end
|
|
691
693
|
|
|
692
694
|
def self.preview(client, options = {})
|
|
693
|
-
Collection.new(client, ViewRow, options.merge(:
|
|
695
|
+
Collection.new(client, ViewRow, options.merge(path: "views/preview", verb: :post))
|
|
694
696
|
end
|
|
695
697
|
|
|
696
698
|
def self.cbp_path_regexes
|
|
@@ -702,7 +704,7 @@ module ZendeskAPI
|
|
|
702
704
|
include Conditions
|
|
703
705
|
include Actions
|
|
704
706
|
|
|
705
|
-
has :execution, :
|
|
707
|
+
has :execution, class: RuleExecution
|
|
706
708
|
|
|
707
709
|
def self.cbp_path_regexes
|
|
708
710
|
[/^triggers$/, %r{^triggers/active$}]
|
|
@@ -713,7 +715,7 @@ module ZendeskAPI
|
|
|
713
715
|
include Conditions
|
|
714
716
|
include Actions
|
|
715
717
|
|
|
716
|
-
has :execution, :
|
|
718
|
+
has :execution, class: RuleExecution
|
|
717
719
|
|
|
718
720
|
def self.cbp_path_regexes
|
|
719
721
|
[/^automations$/]
|
|
@@ -723,7 +725,7 @@ module ZendeskAPI
|
|
|
723
725
|
class Macro < Rule
|
|
724
726
|
include Actions
|
|
725
727
|
|
|
726
|
-
has :execution, :
|
|
728
|
+
has :execution, class: RuleExecution
|
|
727
729
|
|
|
728
730
|
def self.cbp_path_regexes
|
|
729
731
|
[/^macros$/]
|
|
@@ -754,7 +756,7 @@ module ZendeskAPI
|
|
|
754
756
|
|
|
755
757
|
class UserView < Rule
|
|
756
758
|
def self.preview(client, options = {})
|
|
757
|
-
Collection.new(client, UserViewRow, options.merge!(:
|
|
759
|
+
Collection.new(client, UserViewRow, options.merge!(path: "user_views/preview", verb: :post))
|
|
758
760
|
end
|
|
759
761
|
end
|
|
760
762
|
|
|
@@ -808,22 +810,22 @@ module ZendeskAPI
|
|
|
808
810
|
|
|
809
811
|
# Set a user's password
|
|
810
812
|
def set_password(opts = {})
|
|
811
|
-
password(opts.merge(:
|
|
813
|
+
password(opts.merge(verb: :post))
|
|
812
814
|
end
|
|
813
815
|
|
|
814
816
|
# Change a user's password
|
|
815
817
|
def change_password(opts = {})
|
|
816
|
-
password(opts.merge(:
|
|
818
|
+
password(opts.merge(verb: :put))
|
|
817
819
|
end
|
|
818
820
|
|
|
819
821
|
# Set a user's password
|
|
820
822
|
def set_password!(opts = {})
|
|
821
|
-
password!(opts.merge(:
|
|
823
|
+
password!(opts.merge(verb: :post))
|
|
822
824
|
end
|
|
823
825
|
|
|
824
826
|
# Change a user's password
|
|
825
827
|
def change_password!(opts = {})
|
|
826
|
-
password!(opts.merge(:
|
|
828
|
+
password!(opts.merge(verb: :put))
|
|
827
829
|
end
|
|
828
830
|
|
|
829
831
|
# Gets a incremental export of users from the start_time until now.
|
|
@@ -831,7 +833,7 @@ module ZendeskAPI
|
|
|
831
833
|
# @param [Integer] start_time The start_time parameter
|
|
832
834
|
# @return [Collection] Collection of {User}
|
|
833
835
|
def self.incremental_export(client, start_time)
|
|
834
|
-
ZendeskAPI::Collection.new(client, self, :
|
|
836
|
+
ZendeskAPI::Collection.new(client, self, path: "incremental/users?start_time=#{start_time.to_i}")
|
|
835
837
|
end
|
|
836
838
|
|
|
837
839
|
has Organization
|
|
@@ -842,23 +844,23 @@ module ZendeskAPI
|
|
|
842
844
|
class CurrentSession < SingularResource
|
|
843
845
|
class << self
|
|
844
846
|
def singular_resource_name
|
|
845
|
-
|
|
847
|
+
"session"
|
|
846
848
|
end
|
|
847
849
|
|
|
848
|
-
|
|
850
|
+
alias_method :resource_name, :singular_resource_name
|
|
849
851
|
end
|
|
850
852
|
end
|
|
851
853
|
|
|
852
854
|
has_many Session
|
|
853
855
|
|
|
854
856
|
def current_session
|
|
855
|
-
ZendeskAPI::User::CurrentSession.find(@client, :
|
|
857
|
+
ZendeskAPI::User::CurrentSession.find(@client, user_id: "me")
|
|
856
858
|
end
|
|
857
859
|
|
|
858
860
|
delete :logout
|
|
859
861
|
|
|
860
862
|
def clear_sessions!
|
|
861
|
-
@client.connection.delete(path
|
|
863
|
+
@client.connection.delete("#{path}/sessions")
|
|
862
864
|
end
|
|
863
865
|
|
|
864
866
|
def clear_sessions
|
|
@@ -869,17 +871,17 @@ module ZendeskAPI
|
|
|
869
871
|
|
|
870
872
|
put :merge
|
|
871
873
|
|
|
872
|
-
has CustomRole, :
|
|
873
|
-
has Role, :
|
|
874
|
-
has Ability, :
|
|
875
|
-
has :related, :
|
|
874
|
+
has CustomRole, inline: true, include: :roles
|
|
875
|
+
has Role, inline: true, include_key: :name
|
|
876
|
+
has Ability, inline: true
|
|
877
|
+
has :related, class: UserRelated
|
|
876
878
|
|
|
877
879
|
has_many Identity
|
|
878
880
|
|
|
879
881
|
has_many Request
|
|
880
|
-
has_many :requested_tickets, :
|
|
881
|
-
has_many :assigned_tickets, :
|
|
882
|
-
has_many :ccd_tickets, :
|
|
882
|
+
has_many :requested_tickets, class: Ticket, path: "tickets/requested"
|
|
883
|
+
has_many :assigned_tickets, class: Ticket, path: "tickets/assigned"
|
|
884
|
+
has_many :ccd_tickets, class: Ticket, path: "tickets/ccd"
|
|
883
885
|
|
|
884
886
|
has_many Group
|
|
885
887
|
has_many GroupMembership
|
|
@@ -887,7 +889,7 @@ module ZendeskAPI
|
|
|
887
889
|
has_many OrganizationSubscription
|
|
888
890
|
|
|
889
891
|
has_many Setting
|
|
890
|
-
has_many Tag, :
|
|
892
|
+
has_many Tag, extend: Tag::Update, inline: :create
|
|
891
893
|
|
|
892
894
|
def attributes_for_save
|
|
893
895
|
# Don't send role_id, it's necessary
|
|
@@ -897,7 +899,7 @@ module ZendeskAPI
|
|
|
897
899
|
k == "role_id"
|
|
898
900
|
end
|
|
899
901
|
|
|
900
|
-
{
|
|
902
|
+
{self.class.singular_resource_name => attrs}
|
|
901
903
|
end
|
|
902
904
|
|
|
903
905
|
def handle_response(*)
|
|
@@ -929,6 +931,7 @@ module ZendeskAPI
|
|
|
929
931
|
|
|
930
932
|
class OauthToken < ReadResource
|
|
931
933
|
include Destroy
|
|
934
|
+
|
|
932
935
|
namespace "oauth"
|
|
933
936
|
|
|
934
937
|
def self.singular_resource_name
|
|
@@ -939,6 +942,7 @@ module ZendeskAPI
|
|
|
939
942
|
class Target < Resource; end
|
|
940
943
|
|
|
941
944
|
class Invocation < Resource; end
|
|
945
|
+
|
|
942
946
|
class Webhook < Resource
|
|
943
947
|
has_many Invocation
|
|
944
948
|
end
|
|
@@ -976,7 +980,7 @@ module ZendeskAPI
|
|
|
976
980
|
|
|
977
981
|
def self.display!(client, options)
|
|
978
982
|
new(client, options).tap do |resource|
|
|
979
|
-
resource.save!(path: resource.path
|
|
983
|
+
resource.save!(path: "#{resource.path}/display")
|
|
980
984
|
end
|
|
981
985
|
end
|
|
982
986
|
end
|
|
@@ -1031,9 +1035,9 @@ module ZendeskAPI
|
|
|
1031
1035
|
super
|
|
1032
1036
|
end
|
|
1033
1037
|
|
|
1034
|
-
def self.create!(client, attributes = {}, &
|
|
1035
|
-
if file_path = attributes.delete(:upload)
|
|
1036
|
-
attributes[:upload_id] = client.apps.uploads.create!(:
|
|
1038
|
+
def self.create!(client, attributes = {}, &)
|
|
1039
|
+
if (file_path = attributes.delete(:upload))
|
|
1040
|
+
attributes[:upload_id] = client.apps.uploads.create!(file: file_path).id
|
|
1037
1041
|
end
|
|
1038
1042
|
|
|
1039
1043
|
super
|
|
@@ -1075,15 +1079,15 @@ module ZendeskAPI
|
|
|
1075
1079
|
end
|
|
1076
1080
|
end
|
|
1077
1081
|
|
|
1078
|
-
def self.uploads(client,
|
|
1079
|
-
ZendeskAPI::Collection.new(client, Upload,
|
|
1082
|
+
def self.uploads(client, ...)
|
|
1083
|
+
ZendeskAPI::Collection.new(client, Upload, ...)
|
|
1080
1084
|
end
|
|
1081
1085
|
|
|
1082
|
-
def self.installations(client,
|
|
1083
|
-
ZendeskAPI::Collection.new(client, AppInstallation,
|
|
1086
|
+
def self.installations(client, ...)
|
|
1087
|
+
ZendeskAPI::Collection.new(client, AppInstallation, ...)
|
|
1084
1088
|
end
|
|
1085
1089
|
|
|
1086
|
-
has Upload, :
|
|
1090
|
+
has Upload, path: "uploads"
|
|
1087
1091
|
has_many Plan
|
|
1088
1092
|
|
|
1089
1093
|
# Don't nest attributes
|
|
@@ -1100,7 +1104,7 @@ module ZendeskAPI
|
|
|
1100
1104
|
include DataNamespace
|
|
1101
1105
|
|
|
1102
1106
|
class Item < ZendeskAPI::Resource
|
|
1103
|
-
namespace
|
|
1107
|
+
namespace "dynamic_content"
|
|
1104
1108
|
|
|
1105
1109
|
class Variant < ZendeskAPI::Resource
|
|
1106
1110
|
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"
|
data/util/resource_handler.rb
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "zendesk_api"
|
|
2
2
|
|
|
3
3
|
class ResourceHandler < YARD::Handlers::Ruby::Base
|
|
4
4
|
handles method_call(:has), method_call(:has_many)
|
|
@@ -39,21 +39,21 @@ class ResourceHandler < YARD::Handlers::Ruby::Base
|
|
|
39
39
|
|
|
40
40
|
if many
|
|
41
41
|
reader.signature = "def #{name}=(options = {})"
|
|
42
|
-
reader.parameters = [[
|
|
42
|
+
reader.parameters = [["options", {}]]
|
|
43
43
|
reader.docstring.add_tag(YARD::Tags::Tag.new(:param, "Options to pass to the collection object", "Hash", "options"))
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
writer = YARD::CodeObjects::MethodObject.new(namespace, "#{name}=")
|
|
47
47
|
register(writer)
|
|
48
48
|
writer.signature = "def #{name}=(value)"
|
|
49
|
-
writer.parameters = [[
|
|
49
|
+
writer.parameters = [["value", nil]]
|
|
50
50
|
writer.dynamic = true
|
|
51
51
|
writer.docstring.add_tag(YARD::Tags::Tag.new(:return, "The associated object", klass.name))
|
|
52
52
|
writer.docstring.add_tag(YARD::Tags::Tag.new(:param, "The associated object or its attributes", "Hash or #{klass.name}", "value"))
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def walk_namespace(namespace)
|
|
56
|
-
namespace.to_s.split(
|
|
56
|
+
namespace.to_s.split("::").inject(ZendeskAPI) do |klass, namespace|
|
|
57
57
|
klass.const_get(namespace)
|
|
58
58
|
end
|
|
59
59
|
end
|
|
@@ -62,7 +62,7 @@ class ResourceHandler < YARD::Handlers::Ruby::Base
|
|
|
62
62
|
statement.traverse do |node|
|
|
63
63
|
if node.type == :assoc && node.jump(:kw).source == "class"
|
|
64
64
|
node.traverse do |value|
|
|
65
|
-
if
|
|
65
|
+
if [:const_path_ref, :var_ref].include?(value.type)
|
|
66
66
|
return value.source
|
|
67
67
|
end
|
|
68
68
|
end
|
data/util/verb_handler.rb
CHANGED
|
@@ -10,7 +10,7 @@ class VerbHandler < YARD::Handlers::Ruby::Base
|
|
|
10
10
|
verb.docstring.add_tag(YARD::Tags::Tag.new(:return, "Success of this call", "Boolean"))
|
|
11
11
|
|
|
12
12
|
verb.signature = "def #{name}=(options = {})"
|
|
13
|
-
verb.parameters = [[
|
|
13
|
+
verb.parameters = [["options", {}]]
|
|
14
14
|
verb.docstring.add_tag(YARD::Tags::Tag.new(:param, "Options to pass to the request", "Hash", "options"))
|
|
15
15
|
end
|
|
16
16
|
end
|