zendesk_api 1.4.0 → 1.4.2
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/README.md +1 -0
- data/lib/zendesk_api/actions.rb +1 -1
- data/lib/zendesk_api/collection.rb +1 -1
- data/lib/zendesk_api/middleware/response/deflate.rb +1 -1
- data/lib/zendesk_api/middleware/response/gzip.rb +1 -1
- data/lib/zendesk_api/middleware/response/parse_json.rb +3 -3
- data/lib/zendesk_api/resources.rb +13 -7
- data/lib/zendesk_api/version.rb +1 -1
- data/spec/core/middleware/response/parse_iso_dates_spec.rb +1 -1
- data/spec/core/middleware/response/parse_json_spec.rb +6 -6
- data/spec/fixtures/zendesk.rb +3 -1
- data/spec/live/brand_spec.rb +5 -3
- data/spec/live/macro_spec.rb +5 -3
- data/spec/live/ticket_spec.rb +0 -1
- data/spec/macros/resource_macros.rb +15 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c3a7d321889f60c5c4d0f0c2c4170351b271c6b
|
4
|
+
data.tar.gz: 2de81c86986e49e8f925fb52ee77eee475bf18e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7127ae993715fe0b818ba71e55f0287847d671bd08d0920a2188e58211dac67643a1b09b5647790cca95e225c35f75bd7f0d030dcb72cff98a27d1f37358d9dd
|
7
|
+
data.tar.gz: fdf856dbb4229b36059b96cce96bc1db1037482ced53b33eed92f161ed7ed6dc9e18aad7abd6da880ca196b4c60c95e7c581723699f4b9aca43f14bf8131a958
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -16,6 +16,7 @@ Please check out the [wiki](https://github.com/zendesk/zendesk_api_client_rb/wik
|
|
16
16
|
* Version 1.0.0 changes the way errors are handled. Please see the [wiki page](https://github.com/zendesk/zendesk_api_client_rb/wiki/Errors) for more info.
|
17
17
|
* Version 1.3.0 updates the Faraday dependency to 0.9. Since Faraday did not bump a major version we have not either, but there is no guarantee >= 1.3.0 works with Faraday < 0.9
|
18
18
|
* Version 1.3.8 had a bug where attachments were created, but the response was not handled properly
|
19
|
+
* Version >= 1.0 and < 1.4.2 had a bug where non application/json response bodies were discarded
|
19
20
|
|
20
21
|
## Installation
|
21
22
|
|
data/lib/zendesk_api/actions.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module ZendeskAPI
|
2
2
|
module ResponseHandler
|
3
3
|
def handle_response(response)
|
4
|
-
if response.body && response.body[self.class.singular_resource_name]
|
4
|
+
if response.body.is_a?(Hash) && response.body[self.class.singular_resource_name]
|
5
5
|
@attributes.replace(@attributes.deep_merge(response.body[self.class.singular_resource_name]))
|
6
6
|
end
|
7
7
|
end
|
@@ -7,7 +7,7 @@ module ZendeskAPI
|
|
7
7
|
# @private
|
8
8
|
class Deflate < Faraday::Response::Middleware
|
9
9
|
def on_complete(env)
|
10
|
-
if
|
10
|
+
if !env.body.strip.empty? && env[:response_headers]['content-encoding'] == "deflate"
|
11
11
|
env.body = Zlib::Inflate.inflate(env.body)
|
12
12
|
end
|
13
13
|
end
|
@@ -9,7 +9,7 @@ module ZendeskAPI
|
|
9
9
|
# Faraday middleware to handle content-encoding = gzip
|
10
10
|
class Gzip < Faraday::Response::Middleware
|
11
11
|
def on_complete(env)
|
12
|
-
if
|
12
|
+
if !env[:body].strip.empty? && env[:response_headers]['content-encoding'] == "gzip"
|
13
13
|
env[:body] = Zlib::GzipReader.new(StringIO.new(env[:body])).read
|
14
14
|
end
|
15
15
|
end
|
@@ -12,10 +12,10 @@ module ZendeskAPI
|
|
12
12
|
type = type.split(';', 2).first if type.index(';')
|
13
13
|
type
|
14
14
|
|
15
|
-
|
15
|
+
return unless type == 'application/json'
|
16
|
+
|
17
|
+
unless env[:body].strip.empty?
|
16
18
|
env[:body] = JSON.parse(env[:body])
|
17
|
-
else
|
18
|
-
env[:body] = nil
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -118,6 +118,12 @@ module ZendeskAPI
|
|
118
118
|
end
|
119
119
|
|
120
120
|
class Brand < Resource
|
121
|
+
def destroy!
|
122
|
+
self.active = false
|
123
|
+
save!
|
124
|
+
|
125
|
+
super
|
126
|
+
end
|
121
127
|
end
|
122
128
|
|
123
129
|
class ForumSubscription < Resource
|
@@ -511,13 +517,6 @@ module ZendeskAPI
|
|
511
517
|
put :request_verification
|
512
518
|
end
|
513
519
|
|
514
|
-
def initialize(*)
|
515
|
-
super
|
516
|
-
|
517
|
-
# Needed for proper Role sideloading
|
518
|
-
self.role_id = role.name if key?(:role)
|
519
|
-
end
|
520
|
-
|
521
520
|
any :password
|
522
521
|
|
523
522
|
# Set a user's password
|
@@ -573,6 +572,13 @@ module ZendeskAPI
|
|
573
572
|
|
574
573
|
{ self.class.singular_resource_name => attrs }
|
575
574
|
end
|
575
|
+
|
576
|
+
def handle_response(*)
|
577
|
+
super
|
578
|
+
|
579
|
+
# Needed for proper Role sideloading
|
580
|
+
self.role_id = role.name if key?(:role)
|
581
|
+
end
|
576
582
|
end
|
577
583
|
|
578
584
|
class UserField < Resource; end
|
data/lib/zendesk_api/version.rb
CHANGED
@@ -11,8 +11,8 @@ describe ZendeskAPI::Middleware::Response::ParseJson do
|
|
11
11
|
)
|
12
12
|
end
|
13
13
|
|
14
|
-
it "should return nil body" do
|
15
|
-
expect(client.connection.get("blergh").body).to
|
14
|
+
it "should not return nil body" do
|
15
|
+
expect(client.connection.get("blergh").body).to eql('<nope></nope>')
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -29,16 +29,16 @@ describe ZendeskAPI::Middleware::Response::ParseJson do
|
|
29
29
|
context "with a nil body" do
|
30
30
|
let(:body) { nil }
|
31
31
|
|
32
|
-
it "should return
|
33
|
-
expect(client.connection.get("blergh").body).to
|
32
|
+
it "should return empty body" do
|
33
|
+
expect(client.connection.get("blergh").body).to eql('')
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
context "with a empty body" do
|
38
38
|
let(:body) { '' }
|
39
39
|
|
40
|
-
it "should return
|
41
|
-
expect(client.connection.get("blergh").body).to
|
40
|
+
it "should return empty body" do
|
41
|
+
expect(client.connection.get("blergh").body).to eql('')
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
data/spec/fixtures/zendesk.rb
CHANGED
data/spec/live/brand_spec.rb
CHANGED
@@ -2,11 +2,13 @@ require 'core/spec_helper'
|
|
2
2
|
|
3
3
|
describe ZendeskAPI::Brand, :delete_after do
|
4
4
|
def valid_attributes
|
5
|
-
{ :name => "
|
5
|
+
{ :name => "awesomesauce", :subdomain => "zendeskapi#{SecureRandom.hex(3)}" }
|
6
6
|
end
|
7
7
|
|
8
8
|
it_should_be_creatable
|
9
9
|
it_should_be_updatable :name
|
10
|
-
|
11
|
-
|
10
|
+
it_should_be_readable :brands
|
11
|
+
|
12
|
+
# Deleted brands are still findable by id, but in the index action
|
13
|
+
it_should_be_deletable :find => nil
|
12
14
|
end
|
data/spec/live/macro_spec.rb
CHANGED
@@ -13,15 +13,17 @@ describe ZendeskAPI::Macro, :delete_after do
|
|
13
13
|
it_should_be_deletable
|
14
14
|
|
15
15
|
describe "application", :vcr do
|
16
|
-
subject
|
16
|
+
subject { @object }
|
17
|
+
|
18
|
+
before :all do
|
17
19
|
VCR.use_cassette("#{described_class.to_s}_application_create") do
|
18
|
-
described_class.create(client, valid_attributes.merge(default_options))
|
20
|
+
@object = described_class.create(client, valid_attributes.merge(default_options))
|
19
21
|
end
|
20
22
|
end
|
21
23
|
|
22
24
|
after :all do
|
23
25
|
VCR.use_cassette("#{described_class.to_s}_application_delete") do
|
24
|
-
|
26
|
+
@object.destroy
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
data/spec/live/ticket_spec.rb
CHANGED
@@ -21,7 +21,6 @@ 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
|
25
24
|
|
26
25
|
context "recent tickets" do
|
27
26
|
before(:all) do
|
@@ -96,14 +96,14 @@ module ResourceMacros
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
-
it "should be destroyable" do
|
99
|
+
it "should be destroyable" do |example|
|
100
100
|
expect(@object.destroy).to be(true)
|
101
101
|
expect(@object.destroyed?).to be(true)
|
102
102
|
|
103
103
|
if (!options.key?(:find) || options[:find]) && !example.metadata[:not_findable]
|
104
104
|
opts = default_options
|
105
105
|
opts.merge!(:id => @object.id) unless described_class.ancestors.include?(ZendeskAPI::SingularResource)
|
106
|
-
obj =
|
106
|
+
obj = described_class.find(client, opts)
|
107
107
|
|
108
108
|
if options[:find]
|
109
109
|
expect(obj.send(options[:find].first)).to eq(options[:find].last)
|
@@ -134,14 +134,23 @@ module ResourceMacros
|
|
134
134
|
end
|
135
135
|
end if create
|
136
136
|
|
137
|
-
it "should be findable" do
|
137
|
+
it "should be findable" do |example|
|
138
138
|
result = klass
|
139
139
|
args.each {|a| result = result.send(a, options) }
|
140
140
|
|
141
141
|
if result.is_a?(ZendeskAPI::Collection)
|
142
|
-
|
143
|
-
|
144
|
-
|
142
|
+
if create
|
143
|
+
object = nil
|
144
|
+
|
145
|
+
result.all do |o|
|
146
|
+
object = o if @object == o
|
147
|
+
end
|
148
|
+
|
149
|
+
expect(object).to_not be_nil
|
150
|
+
else
|
151
|
+
expect(result.fetch(true)).to_not be_empty
|
152
|
+
object = result.first
|
153
|
+
end
|
145
154
|
else
|
146
155
|
expect(result).to_not be_nil
|
147
156
|
expect(result).to eq(@object) if create
|
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.2
|
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-08-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bump
|