zendesk_api 1.4.4 → 1.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/zendesk_api/association.rb +27 -2
- data/lib/zendesk_api/client.rb +6 -26
- data/lib/zendesk_api/resources.rb +39 -17
- data/lib/zendesk_api/version.rb +1 -1
- data/spec/core/association_spec.rb +14 -0
- data/spec/fixtures/zendesk.rb +7 -0
- data/spec/live/dynamic_content/item_spec.rb +16 -0
- data/spec/live/dynamic_content/variant_spec.rb +19 -0
- metadata +6 -4
- data/spec/live/mobile_device_spec.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7021e19badde0fd416969c1bc4be207caaf5834
|
4
|
+
data.tar.gz: ea01dab8e9c693b241f54f5041d2c7ce99f9a8a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d873f7e34fded76987026be01fa1150d04985928c1a56a349f8e58aabe3fcbc00af0d1e5cafdaaa7bad4833bc60775b26d3d5892559377b0c30633353478397
|
7
|
+
data.tar.gz: a1237c1049bcafe8331e6ed6e2e1c7eeeaf88c6ce59e548e874035dd2ff72e823c0f89e3534a01f164a8d83971d1a09ec198af63a4159b914fd71745ffbe732b
|
data/Gemfile.lock
CHANGED
@@ -4,6 +4,31 @@ module ZendeskAPI
|
|
4
4
|
# Represents an association between two resources
|
5
5
|
# @private
|
6
6
|
class Association
|
7
|
+
class << self
|
8
|
+
def namespaces
|
9
|
+
[ZendeskAPI] + ZendeskAPI::DataNamespace.descendants
|
10
|
+
end
|
11
|
+
|
12
|
+
def class_from_namespace(klass_as_string)
|
13
|
+
namespaces.each do |ns|
|
14
|
+
if module_defines_class?(ns, klass_as_string)
|
15
|
+
return ns.const_get(klass_as_string)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
|
22
|
+
# 1.9+ changed default to search ancestors, added flag to disable behavior.
|
23
|
+
def module_defines_class?(mod, klass_as_string)
|
24
|
+
if RUBY_VERSION < '1.9'
|
25
|
+
mod.const_defined?(klass_as_string)
|
26
|
+
else
|
27
|
+
mod.const_defined?(klass_as_string, false)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
7
32
|
# @return [Hash] Options passed into the association
|
8
33
|
attr_reader :options
|
9
34
|
|
@@ -39,10 +64,10 @@ module ZendeskAPI
|
|
39
64
|
has_parent = namespace.size > 1 || (options[:with_parent] && @options.parent)
|
40
65
|
|
41
66
|
if has_parent
|
42
|
-
parent_class = @options.parent ? @options.parent.class :
|
67
|
+
parent_class = @options.parent ? @options.parent.class : Association.class_from_namespace(ZendeskAPI::Helpers.modulize_string(namespace[0]))
|
43
68
|
parent_namespace = build_parent_namespace(parent_class, instance, options, original_options)
|
44
69
|
namespace[1..1] = parent_namespace if parent_namespace
|
45
|
-
namespace[0] = parent_class.
|
70
|
+
namespace[0] = parent_class.resource_path
|
46
71
|
else
|
47
72
|
namespace[0] = @options.path || @options[:class].resource_path
|
48
73
|
end
|
data/lib/zendesk_api/client.rb
CHANGED
@@ -116,8 +116,11 @@ module ZendeskAPI
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
-
|
120
|
-
|
119
|
+
ZendeskAPI::DataNamespace.descendants.each do |namespace|
|
120
|
+
delegator = ZendeskAPI::Helpers.snakecase_string(namespace.to_s.split("::").last)
|
121
|
+
define_method delegator do |*| # takes arguments, but doesn't do anything with them
|
122
|
+
Delegator.new(self)
|
123
|
+
end
|
121
124
|
end
|
122
125
|
|
123
126
|
protected
|
@@ -171,32 +174,9 @@ module ZendeskAPI
|
|
171
174
|
|
172
175
|
private
|
173
176
|
|
174
|
-
def class_from_namespace(klass_as_string)
|
175
|
-
namespaces.each do |ns|
|
176
|
-
if module_defines_class?(ns, klass_as_string)
|
177
|
-
return ns.const_get(klass_as_string)
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
nil
|
182
|
-
end
|
183
|
-
|
184
|
-
# 1.9+ changed default to search ancestors, added flag to disable behavior.
|
185
|
-
def module_defines_class?(mod, klass_as_string)
|
186
|
-
if RUBY_VERSION < '1.9'
|
187
|
-
mod.const_defined?(klass_as_string)
|
188
|
-
else
|
189
|
-
mod.const_defined?(klass_as_string, false)
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
def namespaces
|
194
|
-
[ZendeskAPI] + ZendeskAPI::DataNamespace.descendants
|
195
|
-
end
|
196
|
-
|
197
177
|
def method_as_class(method)
|
198
178
|
klass_as_string = ZendeskAPI::Helpers.modulize_string(Inflection.singular(method.to_s))
|
199
|
-
class_from_namespace(klass_as_string)
|
179
|
+
ZendeskAPI::Association.class_from_namespace(klass_as_string)
|
200
180
|
end
|
201
181
|
|
202
182
|
def check_url
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module ZendeskAPI
|
2
2
|
# @internal The following are redefined later, but needed by some circular resources (e.g. Ticket -> User, User -> Ticket)
|
3
3
|
|
4
|
+
|
4
5
|
class Ticket < Resource; end
|
5
6
|
class Forum < Resource; end
|
6
7
|
class User < Resource; end
|
@@ -102,21 +103,9 @@ module ZendeskAPI
|
|
102
103
|
end
|
103
104
|
end
|
104
105
|
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
def self.included(klass)
|
110
|
-
klass.has_many :uploads, :class => Attachment, :inline => true
|
111
|
-
klass.has :author, :class => User
|
112
|
-
end
|
113
|
-
|
114
|
-
def save
|
115
|
-
save_associations
|
116
|
-
true
|
117
|
-
end
|
118
|
-
|
119
|
-
alias :save! :save
|
106
|
+
class MobileDevice < Resource
|
107
|
+
# Clears this devices' badge
|
108
|
+
put :clear_badge
|
120
109
|
end
|
121
110
|
|
122
111
|
class Organization < Resource
|
@@ -302,7 +291,17 @@ module ZendeskAPI
|
|
302
291
|
|
303
292
|
class Request < Resource
|
304
293
|
class Comment < DataResource
|
305
|
-
include
|
294
|
+
include Save
|
295
|
+
|
296
|
+
has_many :uploads, :class => Attachment, :inline => true
|
297
|
+
has :author, :class => User
|
298
|
+
|
299
|
+
def save
|
300
|
+
save_associations
|
301
|
+
true
|
302
|
+
end
|
303
|
+
|
304
|
+
alias :save! :save
|
306
305
|
end
|
307
306
|
|
308
307
|
has Comment, :inline => true
|
@@ -344,7 +343,17 @@ module ZendeskAPI
|
|
344
343
|
end
|
345
344
|
|
346
345
|
class Comment < DataResource
|
347
|
-
include
|
346
|
+
include Save
|
347
|
+
|
348
|
+
has_many :uploads, :class => Attachment, :inline => true
|
349
|
+
has :author, :class => User
|
350
|
+
|
351
|
+
def save
|
352
|
+
save_associations
|
353
|
+
true
|
354
|
+
end
|
355
|
+
|
356
|
+
alias :save! :save
|
348
357
|
end
|
349
358
|
|
350
359
|
put :mark_as_spam
|
@@ -738,4 +747,17 @@ module ZendeskAPI
|
|
738
747
|
@attributes.replace(response.body) if response.body
|
739
748
|
end
|
740
749
|
end
|
750
|
+
|
751
|
+
module DynamicContent
|
752
|
+
include DataNamespace
|
753
|
+
|
754
|
+
class Item < ZendeskAPI::Resource
|
755
|
+
namespace 'dynamic_content'
|
756
|
+
|
757
|
+
class Variant < ZendeskAPI::Resource
|
758
|
+
end
|
759
|
+
|
760
|
+
has_many Variant
|
761
|
+
end
|
762
|
+
end
|
741
763
|
end
|
data/lib/zendesk_api/version.rb
CHANGED
@@ -180,6 +180,20 @@ describe ZendeskAPI::Association do
|
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
183
|
+
context "when parent has a namespace" do
|
184
|
+
before(:each) do
|
185
|
+
instance.class.namespace 'hello'
|
186
|
+
end
|
187
|
+
|
188
|
+
after(:each) do
|
189
|
+
instance.class.namespace nil
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should generate a specific nested resource path" do
|
193
|
+
expect(subject.generate_path(child)).to eq("hello/test_resources/1/children/1")
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
183
197
|
context "with a specified path" do
|
184
198
|
before(:each) { subject.options[:path] = "blergh" }
|
185
199
|
|
data/spec/fixtures/zendesk.rb
CHANGED
@@ -98,5 +98,12 @@ module ZendeskAPI
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
101
|
+
|
102
|
+
def dynamic_content_item
|
103
|
+
VCR.use_cassette('valid_brand') do
|
104
|
+
@item ||= client.dynamic_content.items.first
|
105
|
+
@item ||= client.dynamic_content.items.create!(:name => 'Test Item', :content => 'Testing')
|
106
|
+
end
|
107
|
+
end
|
101
108
|
end
|
102
109
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'core/spec_helper'
|
2
|
+
|
3
|
+
describe ZendeskAPI::DynamicContent::Item, :delete_after do
|
4
|
+
def valid_attributes
|
5
|
+
{
|
6
|
+
:name => "Snowboard Problem",
|
7
|
+
:default_locale_id => 1,
|
8
|
+
:content => "Snowboard Problem variant"
|
9
|
+
}
|
10
|
+
end
|
11
|
+
|
12
|
+
it_should_be_readable :dynamic_content, :items, :create => true
|
13
|
+
it_should_be_creatable
|
14
|
+
it_should_be_updatable :name
|
15
|
+
it_should_be_deletable
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'core/spec_helper'
|
2
|
+
|
3
|
+
describe ZendeskAPI::DynamicContent::Item::Variant, :delete_after do
|
4
|
+
def valid_attributes
|
5
|
+
{
|
6
|
+
:locale_id => 127,
|
7
|
+
:active => true,
|
8
|
+
:default => false,
|
9
|
+
:content => 'Mon dieu!'
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
under dynamic_content_item do
|
14
|
+
it_should_be_readable dynamic_content_item, :variants, :create => true
|
15
|
+
it_should_be_creatable
|
16
|
+
it_should_be_updatable :content
|
17
|
+
it_should_be_deletable
|
18
|
+
end
|
19
|
+
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: 1.4.
|
4
|
+
version: 1.4.5
|
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: 2014-10-
|
12
|
+
date: 2014-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bump
|
@@ -285,6 +285,8 @@ files:
|
|
285
285
|
- spec/live/category_spec.rb
|
286
286
|
- spec/live/collection_spec.rb
|
287
287
|
- spec/live/custom_role_spec.rb
|
288
|
+
- spec/live/dynamic_content/item_spec.rb
|
289
|
+
- spec/live/dynamic_content/variant_spec.rb
|
288
290
|
- spec/live/forum_spec.rb
|
289
291
|
- spec/live/forum_subscription_spec.rb
|
290
292
|
- spec/live/group_membership_spec.rb
|
@@ -292,7 +294,6 @@ files:
|
|
292
294
|
- spec/live/identity_spec.rb
|
293
295
|
- spec/live/locale_spec.rb
|
294
296
|
- spec/live/macro_spec.rb
|
295
|
-
- spec/live/mobile_device_spec.rb
|
296
297
|
- spec/live/organization_field_spec.rb
|
297
298
|
- spec/live/organization_spec.rb
|
298
299
|
- spec/live/request_spec.rb
|
@@ -397,6 +398,8 @@ test_files:
|
|
397
398
|
- spec/live/category_spec.rb
|
398
399
|
- spec/live/collection_spec.rb
|
399
400
|
- spec/live/custom_role_spec.rb
|
401
|
+
- spec/live/dynamic_content/item_spec.rb
|
402
|
+
- spec/live/dynamic_content/variant_spec.rb
|
400
403
|
- spec/live/forum_spec.rb
|
401
404
|
- spec/live/forum_subscription_spec.rb
|
402
405
|
- spec/live/group_membership_spec.rb
|
@@ -404,7 +407,6 @@ test_files:
|
|
404
407
|
- spec/live/identity_spec.rb
|
405
408
|
- spec/live/locale_spec.rb
|
406
409
|
- spec/live/macro_spec.rb
|
407
|
-
- spec/live/mobile_device_spec.rb
|
408
410
|
- spec/live/organization_field_spec.rb
|
409
411
|
- spec/live/organization_spec.rb
|
410
412
|
- spec/live/request_spec.rb
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require 'core/spec_helper'
|
2
|
-
|
3
|
-
describe ZendeskAPI::MobileDevice do
|
4
|
-
def valid_attributes
|
5
|
-
{ :device_type => "iPhone", :token => "5D41402ABC4B2A76B9719D911017C592" }
|
6
|
-
end
|
7
|
-
|
8
|
-
it_should_be_creatable
|
9
|
-
it_should_be_deletable
|
10
|
-
it_should_be_readable :mobile_devices, :create => true
|
11
|
-
end
|