zendesk_api 1.3.7 → 1.3.8
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/Gemfile.lock +2 -2
- data/lib/zendesk_api/actions.rb +3 -8
- data/lib/zendesk_api/resource.rb +6 -0
- data/lib/zendesk_api/resources.rb +11 -11
- data/lib/zendesk_api/version.rb +1 -1
- data/spec/core/client_spec.rb +5 -5
- data/spec/core/collection_spec.rb +2 -2
- data/spec/core/read_resource_spec.rb +24 -0
- data/spec/core/resource_spec.rb +5 -1
- data/spec/core/spec_helper.rb +8 -2
- data/spec/fixtures/zendesk.rb +6 -0
- data/spec/live/app_installation_spec.rb +1 -0
- data/spec/live/app_spec.rb +1 -0
- data/spec/live/brand_spec.rb +12 -0
- data/spec/live/ticket_spec.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9b5cc8be9234d6da4cd1b90cbdf4462bf7d1fa7
|
4
|
+
data.tar.gz: ae424a078cd9a89561d9acc2be8e31b979611139
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fc5f11d463221cb917757de68241566ea3ea972ccacb68a10d8e2ecd4f7a17101493af05de639f18cc04263fe02d292083bff7acbdfb60f21fb2c9712730083
|
7
|
+
data.tar.gz: 40bbdf4e474b4662f395deaf59c04ccd854c74d609da8af4187be052c30d79ebc54c3a0671efb15d22a02eb1e0a6d656b866c71d1e8072fecff6d8fc2ea18881
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
zendesk_api (1.3.
|
4
|
+
zendesk_api (1.3.8)
|
5
5
|
faraday (~> 0.9)
|
6
6
|
hashie (>= 1.2)
|
7
7
|
inflection
|
@@ -38,7 +38,7 @@ GEM
|
|
38
38
|
erubis (2.7.0)
|
39
39
|
faraday (0.9.0)
|
40
40
|
multipart-post (>= 1.2, < 3)
|
41
|
-
hashie (
|
41
|
+
hashie (3.0.0)
|
42
42
|
hike (1.2.3)
|
43
43
|
i18n (0.6.9)
|
44
44
|
inflection (1.0.0)
|
data/lib/zendesk_api/actions.rb
CHANGED
@@ -25,7 +25,7 @@ module ZendeskAPI
|
|
25
25
|
yield req if block_given?
|
26
26
|
end
|
27
27
|
|
28
|
-
handle_response
|
28
|
+
handle_response(@response)
|
29
29
|
|
30
30
|
@attributes.clear_changes
|
31
31
|
clear_associations
|
@@ -70,12 +70,6 @@ module ZendeskAPI
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
73
|
-
|
74
|
-
def handle_response
|
75
|
-
if @response.body && @response.body[self.class.singular_resource_name]
|
76
|
-
@attributes.replace @attributes.deep_merge(@response.body[self.class.singular_resource_name] || {})
|
77
|
-
end
|
78
|
-
end
|
79
73
|
end
|
80
74
|
|
81
75
|
module Read
|
@@ -102,7 +96,8 @@ module ZendeskAPI
|
|
102
96
|
yield req if block_given?
|
103
97
|
end
|
104
98
|
|
105
|
-
new(client
|
99
|
+
new(client).tap do |resource|
|
100
|
+
resource.handle_response(response)
|
106
101
|
resource.set_includes(resource, includes, response.body)
|
107
102
|
resource.attributes.clear_changes
|
108
103
|
end
|
data/lib/zendesk_api/resource.rb
CHANGED
@@ -143,6 +143,12 @@ module ZendeskAPI
|
|
143
143
|
class DataResource < Data
|
144
144
|
attr_accessor :error, :error_message
|
145
145
|
extend Verbs
|
146
|
+
|
147
|
+
def handle_response(response)
|
148
|
+
if response.body && response.body[self.class.singular_resource_name]
|
149
|
+
@attributes.replace(@attributes.deep_merge(response.body[self.class.singular_resource_name]))
|
150
|
+
end
|
151
|
+
end
|
146
152
|
end
|
147
153
|
|
148
154
|
# Represents a resource that can only GET
|
@@ -117,6 +117,9 @@ module ZendeskAPI
|
|
117
117
|
has_many Tag, :extend => Tag::Update, :inline => :create
|
118
118
|
end
|
119
119
|
|
120
|
+
class Brand < Resource
|
121
|
+
end
|
122
|
+
|
120
123
|
class ForumSubscription < Resource
|
121
124
|
has Forum
|
122
125
|
has User
|
@@ -347,6 +350,7 @@ module ZendeskAPI
|
|
347
350
|
has Group
|
348
351
|
has :forum_topic, :class => Topic
|
349
352
|
has Organization
|
353
|
+
has Brand
|
350
354
|
has :related, :class => TicketRelated
|
351
355
|
|
352
356
|
has Comment, :inline => true
|
@@ -628,8 +632,8 @@ module ZendeskAPI
|
|
628
632
|
attributes.changes
|
629
633
|
end
|
630
634
|
|
631
|
-
def handle_response
|
632
|
-
@attributes.replace(
|
635
|
+
def handle_response(response)
|
636
|
+
@attributes.replace(response.body) if response.body
|
633
637
|
end
|
634
638
|
end
|
635
639
|
|
@@ -645,16 +649,12 @@ module ZendeskAPI
|
|
645
649
|
attributes.changes
|
646
650
|
end
|
647
651
|
|
648
|
-
def handle_response
|
649
|
-
@attributes.replace(
|
652
|
+
def handle_response(response)
|
653
|
+
@attributes.replace(response.body) if response.body
|
650
654
|
end
|
651
655
|
end
|
652
656
|
|
653
|
-
class App <
|
654
|
-
include Create
|
655
|
-
include Update
|
656
|
-
include Destroy
|
657
|
-
|
657
|
+
class App < Resource
|
658
658
|
def initialize(client, attributes = {})
|
659
659
|
attributes[:upload_id] ||= nil
|
660
660
|
|
@@ -717,8 +717,8 @@ module ZendeskAPI
|
|
717
717
|
attributes.changes
|
718
718
|
end
|
719
719
|
|
720
|
-
def handle_response
|
721
|
-
@attributes.replace(
|
720
|
+
def handle_response(response)
|
721
|
+
@attributes.replace(response.body) if response.body
|
722
722
|
end
|
723
723
|
end
|
724
724
|
end
|
data/lib/zendesk_api/version.rb
CHANGED
data/spec/core/client_spec.rb
CHANGED
@@ -34,7 +34,7 @@ describe ZendeskAPI::Client do
|
|
34
34
|
it "should handle valid url" do
|
35
35
|
expect do
|
36
36
|
ZendeskAPI::Client.new do |config|
|
37
|
-
config.url = "https://example.zendesk.com/"
|
37
|
+
config.url = "https://example.zendesk.com/api/v2"
|
38
38
|
end.to_not raise_error
|
39
39
|
end
|
40
40
|
end
|
@@ -42,7 +42,7 @@ describe ZendeskAPI::Client do
|
|
42
42
|
context "basic_auth" do
|
43
43
|
subject do
|
44
44
|
ZendeskAPI::Client.new do |config|
|
45
|
-
config.url = "https://example.zendesk.com"
|
45
|
+
config.url = "https://example.zendesk.com/api/v2"
|
46
46
|
config.username = "hello"
|
47
47
|
config.password = "token"
|
48
48
|
end
|
@@ -60,7 +60,7 @@ describe ZendeskAPI::Client do
|
|
60
60
|
context "access token" do
|
61
61
|
subject do
|
62
62
|
ZendeskAPI::Client.new do |config|
|
63
|
-
config.url = "https://example.zendesk.com"
|
63
|
+
config.url = "https://example.zendesk.com/api/v2"
|
64
64
|
config.access_token = "hello"
|
65
65
|
end
|
66
66
|
end
|
@@ -77,7 +77,7 @@ describe ZendeskAPI::Client do
|
|
77
77
|
context "#token" do
|
78
78
|
let(:client) do
|
79
79
|
ZendeskAPI::Client.new do |config|
|
80
|
-
config.url = "https://example.zendesk.com"
|
80
|
+
config.url = "https://example.zendesk.com/api/v2"
|
81
81
|
config.username = username
|
82
82
|
config.token = "token"
|
83
83
|
end
|
@@ -116,7 +116,7 @@ describe ZendeskAPI::Client do
|
|
116
116
|
context "#logger" do
|
117
117
|
before(:each) do
|
118
118
|
@client = ZendeskAPI::Client.new do |config|
|
119
|
-
config.url = "https://example.zendesk.com/"
|
119
|
+
config.url = "https://example.zendesk.com/api/v2"
|
120
120
|
config.logger = subject
|
121
121
|
end
|
122
122
|
|
@@ -391,7 +391,7 @@ describe ZendeskAPI::Collection do
|
|
391
391
|
end
|
392
392
|
|
393
393
|
context "with a hash" do
|
394
|
-
let(:object) {
|
394
|
+
let(:object) { double('ZendeskAPI::TestResource', :changes => [:xxx], :changed? => true, :destroyed? => false) }
|
395
395
|
|
396
396
|
it "should call create with those options" do
|
397
397
|
ZendeskAPI::TestResource.should_receive(:new).
|
@@ -425,7 +425,7 @@ describe ZendeskAPI::Collection do
|
|
425
425
|
|
426
426
|
context "with everything else" do
|
427
427
|
it "should pass to new, since this is how attachment handles it" do
|
428
|
-
attachment =
|
428
|
+
attachment = double(:changes => [:xxx], :changed? => true, :destroyed? => false)
|
429
429
|
ZendeskAPI::TestResource.should_receive(:new).
|
430
430
|
with(client, :id => "img.jpg", :association => instance_of(ZendeskAPI::Association)).
|
431
431
|
and_return attachment
|
@@ -21,6 +21,30 @@ describe ZendeskAPI::ReadResource do
|
|
21
21
|
}.to raise_error("No :id given")
|
22
22
|
end
|
23
23
|
|
24
|
+
context "with overriden handle_response" do
|
25
|
+
subject do
|
26
|
+
Class.new(ZendeskAPI::TestResource) do
|
27
|
+
def self.singular_resource_name
|
28
|
+
'hello'
|
29
|
+
end
|
30
|
+
|
31
|
+
def handle_response(response)
|
32
|
+
@attributes.replace(response.body)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
before(:each) do
|
38
|
+
stub_json_request(:get, %r{hellos/#{id}}, json(:testing => 1))
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return instance of resource" do
|
42
|
+
object = subject.find(client, :id => id)
|
43
|
+
object.should be_instance_of(subject)
|
44
|
+
object.testing.should == 1
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
24
48
|
context "with side loads" do
|
25
49
|
before(:each) do
|
26
50
|
stub_json_request(:get, %r{test_resources/#{id}\?include=nil_resource}, json(
|
data/spec/core/resource_spec.rb
CHANGED
@@ -496,10 +496,14 @@ describe ZendeskAPI::Resource do
|
|
496
496
|
|
497
497
|
context "SingularTestResource" do
|
498
498
|
context "#find" do
|
499
|
+
before do
|
500
|
+
stub_json_request(:get, %r{/singular_test_resource})
|
501
|
+
end
|
502
|
+
|
499
503
|
it "should not require an id" do
|
500
504
|
expect do
|
501
505
|
ZendeskAPI::SingularTestResource.find(client)
|
502
|
-
end.to_not raise_error
|
506
|
+
end.to_not raise_error
|
503
507
|
end
|
504
508
|
end
|
505
509
|
|
data/spec/core/spec_helper.rb
CHANGED
@@ -23,6 +23,8 @@ require File.join(File.dirname(__FILE__), '..', 'macros', 'resource_macros')
|
|
23
23
|
require File.join(File.dirname(__FILE__), '..', 'fixtures', 'zendesk')
|
24
24
|
require File.join(File.dirname(__FILE__), '..', 'fixtures', 'test_resources')
|
25
25
|
|
26
|
+
$credentials_warning = false
|
27
|
+
|
26
28
|
# tests fail when this is included in a Module (someone else also defines client)
|
27
29
|
def client
|
28
30
|
credentials = File.join(File.dirname(__FILE__), '..', 'fixtures', 'credentials.yml')
|
@@ -60,8 +62,12 @@ def client
|
|
60
62
|
config.allow_http = true
|
61
63
|
end
|
62
64
|
else
|
63
|
-
|
64
|
-
|
65
|
+
unless $credentials_warning
|
66
|
+
STDERR.puts "using default credentials: live specs will fail."
|
67
|
+
STDERR.puts "add your credentials to spec/fixtures/credentials.yml (see: spec/fixtures/credentials.yml.example)"
|
68
|
+
$credentials_warning = true
|
69
|
+
end
|
70
|
+
|
65
71
|
config.username = "please.change"
|
66
72
|
config.password = "me"
|
67
73
|
config.url = "https://my.zendesk.com/api/v2"
|
data/spec/fixtures/zendesk.rb
CHANGED
@@ -42,6 +42,7 @@ describe ZendeskAPI::AppInstallation do
|
|
42
42
|
|
43
43
|
installations = client.app.installations
|
44
44
|
VCR.use_cassette("app_install_fetch") { installations.fetch! }
|
45
|
+
VCR.use_cassette("app_install_find") { client.app.installations.find!(:id => install.id) }
|
45
46
|
|
46
47
|
installations.should include(install)
|
47
48
|
|
data/spec/live/app_spec.rb
CHANGED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'core/spec_helper'
|
2
|
+
|
3
|
+
describe ZendeskAPI::Brand, :delete_after do
|
4
|
+
def valid_attributes
|
5
|
+
{ :name => "Awesome-O" }
|
6
|
+
end
|
7
|
+
|
8
|
+
it_should_be_creatable
|
9
|
+
it_should_be_updatable :name
|
10
|
+
it_should_be_deletable
|
11
|
+
it_should_be_readable :brands, :create => true
|
12
|
+
end
|
data/spec/live/ticket_spec.rb
CHANGED
@@ -21,6 +21,7 @@ describe ZendeskAPI::Ticket do
|
|
21
21
|
it_should_be_readable user, :requested_tickets
|
22
22
|
it_should_be_readable agent, :ccd_tickets
|
23
23
|
it_should_be_readable organization, :tickets
|
24
|
+
it_should_be_readable brand, :tickets
|
24
25
|
|
25
26
|
context "recent tickets" do
|
26
27
|
before(:all) do
|
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.3.
|
4
|
+
version: 1.3.8
|
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-
|
12
|
+
date: 2014-06-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bump
|
@@ -274,6 +274,7 @@ files:
|
|
274
274
|
- spec/live/audit_spec.rb
|
275
275
|
- spec/live/automation_spec.rb
|
276
276
|
- spec/live/bookmark_spec.rb
|
277
|
+
- spec/live/brand_spec.rb
|
277
278
|
- spec/live/category_spec.rb
|
278
279
|
- spec/live/collection_spec.rb
|
279
280
|
- spec/live/custom_role_spec.rb
|
@@ -384,6 +385,7 @@ test_files:
|
|
384
385
|
- spec/live/audit_spec.rb
|
385
386
|
- spec/live/automation_spec.rb
|
386
387
|
- spec/live/bookmark_spec.rb
|
388
|
+
- spec/live/brand_spec.rb
|
387
389
|
- spec/live/category_spec.rb
|
388
390
|
- spec/live/collection_spec.rb
|
389
391
|
- spec/live/custom_role_spec.rb
|