zendesk_api 1.37.0 → 1.38.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zendesk_api/client.rb +15 -15
- data/lib/zendesk_api/configuration.rb +3 -0
- data/lib/zendesk_api/middleware/request/encode_json.rb +0 -1
- data/lib/zendesk_api/middleware/response/callback.rb +1 -1
- data/lib/zendesk_api/middleware/response/deflate.rb +5 -4
- data/lib/zendesk_api/middleware/response/gzip.rb +5 -4
- data/lib/zendesk_api/middleware/response/parse_iso_dates.rb +1 -1
- data/lib/zendesk_api/middleware/response/parse_json.rb +1 -2
- data/lib/zendesk_api/middleware/response/sanitize_response.rb +1 -1
- data/lib/zendesk_api/verbs.rb +6 -8
- data/lib/zendesk_api/version.rb +1 -1
- data/lib/zendesk_api.rb +3 -0
- metadata +20 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d882067cdc76fd3a3d9b637081938d7aac2c2f9e0638b5f9532e1263209ded4
|
4
|
+
data.tar.gz: dbe86053eb280e432cc50d83c412a1e30114ac9448aac6fb818f2ef36f19da75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 906d14b5d6922ae062d0056b3ad186975afc284cb9fe0a1a654d10c73174101c92c8dd72fab287cb87a0c3a7c74fda99764557b7020aeed358280109508de434
|
7
|
+
data.tar.gz: 1712eb0890655f184273f6713cda84e4373faa5e660b0ea37323fe6d49d2c8556d6c54d4cca8f639e3f0cf28e59dcf8ae5e1e6145fbf5d61898a54a171f17586
|
data/lib/zendesk_api/client.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
|
3
1
|
require 'zendesk_api/version'
|
4
2
|
require 'zendesk_api/sideloading'
|
5
3
|
require 'zendesk_api/configuration'
|
@@ -100,9 +98,7 @@ module ZendeskAPI
|
|
100
98
|
config.retry = !!config.retry # nil -> false
|
101
99
|
|
102
100
|
set_raise_error_when_rated_limited
|
103
|
-
|
104
101
|
set_token_auth
|
105
|
-
|
106
102
|
set_default_logger
|
107
103
|
add_warning_callback
|
108
104
|
end
|
@@ -112,7 +108,6 @@ module ZendeskAPI
|
|
112
108
|
# @return [Faraday::Connection] Faraday connection for the client
|
113
109
|
def connection
|
114
110
|
@connection ||= build_connection
|
115
|
-
return @connection
|
116
111
|
end
|
117
112
|
|
118
113
|
# Pushes a callback onto the stack. Callbacks are executed on responses, last in the Faraday middleware stack.
|
@@ -148,6 +143,8 @@ module ZendeskAPI
|
|
148
143
|
# Retry middleware if retry is true
|
149
144
|
def build_connection
|
150
145
|
Faraday.new(config.options) do |builder|
|
146
|
+
builder.request :multipart
|
147
|
+
|
151
148
|
# response
|
152
149
|
builder.use ZendeskAPI::Middleware::Response::RaiseError
|
153
150
|
builder.use ZendeskAPI::Middleware::Response::Callback, self
|
@@ -155,7 +152,6 @@ module ZendeskAPI
|
|
155
152
|
builder.use ZendeskAPI::Middleware::Response::ParseIsoDates
|
156
153
|
builder.use ZendeskAPI::Middleware::Response::ParseJson
|
157
154
|
builder.use ZendeskAPI::Middleware::Response::SanitizeResponse
|
158
|
-
|
159
155
|
adapter = config.adapter || Faraday.default_adapter
|
160
156
|
|
161
157
|
unless GZIP_EXCEPTIONS.include?(adapter)
|
@@ -163,14 +159,7 @@ module ZendeskAPI
|
|
163
159
|
builder.use ZendeskAPI::Middleware::Response::Deflate
|
164
160
|
end
|
165
161
|
|
166
|
-
|
167
|
-
if config.access_token && !config.url_based_access_token
|
168
|
-
builder.request(:authorization, "Bearer", config.access_token)
|
169
|
-
elsif config.access_token
|
170
|
-
builder.use ZendeskAPI::Middleware::Request::UrlBasedAccessToken, config.access_token
|
171
|
-
else
|
172
|
-
builder.use Faraday::Request::BasicAuthentication, config.username, config.password
|
173
|
-
end
|
162
|
+
set_authentication(builder, config)
|
174
163
|
|
175
164
|
if config.cache
|
176
165
|
builder.use ZendeskAPI::Middleware::Request::EtagCache, :cache => config.cache
|
@@ -186,7 +175,7 @@ module ZendeskAPI
|
|
186
175
|
builder.use ZendeskAPI::Middleware::Request::RaiseRateLimited, :logger => config.logger
|
187
176
|
end
|
188
177
|
|
189
|
-
builder.adapter(*adapter)
|
178
|
+
builder.adapter(*adapter, &config.adapter_proc)
|
190
179
|
end
|
191
180
|
end
|
192
181
|
|
@@ -239,5 +228,16 @@ module ZendeskAPI
|
|
239
228
|
end
|
240
229
|
end
|
241
230
|
end
|
231
|
+
|
232
|
+
# See https://lostisland.github.io/faraday/middleware/authentication
|
233
|
+
def set_authentication(builder, config)
|
234
|
+
if config.access_token && !config.url_based_access_token
|
235
|
+
builder.request :authorization, "Bearer", config.access_token
|
236
|
+
elsif config.access_token
|
237
|
+
builder.use ZendeskAPI::Middleware::Request::UrlBasedAccessToken, config.access_token
|
238
|
+
else
|
239
|
+
builder.request :authorization, :basic, config.username, config.password
|
240
|
+
end
|
241
|
+
end
|
242
242
|
end
|
243
243
|
end
|
@@ -28,6 +28,9 @@ module ZendeskAPI
|
|
28
28
|
# @return [Symbol] Faraday adapter
|
29
29
|
attr_accessor :adapter
|
30
30
|
|
31
|
+
# @return [Proc] Faraday adapter proc
|
32
|
+
attr_accessor :adapter_proc
|
33
|
+
|
31
34
|
# @return [Boolean] Whether to allow non-HTTPS connections for development purposes.
|
32
35
|
attr_accessor :allow_http
|
33
36
|
|
@@ -5,11 +5,12 @@ module ZendeskAPI
|
|
5
5
|
module Response
|
6
6
|
# Faraday middleware to handle content-encoding = inflate
|
7
7
|
# @private
|
8
|
-
class Deflate < Faraday::
|
8
|
+
class Deflate < Faraday::Middleware
|
9
9
|
def on_complete(env)
|
10
|
-
if
|
11
|
-
|
12
|
-
|
10
|
+
return if env[:response_headers]['content-encoding'] != "deflate"
|
11
|
+
return if env.body.strip.empty?
|
12
|
+
|
13
|
+
env.body = Zlib::Inflate.inflate(env.body)
|
13
14
|
end
|
14
15
|
end
|
15
16
|
end
|
@@ -7,11 +7,12 @@ module ZendeskAPI
|
|
7
7
|
# @private
|
8
8
|
module Response
|
9
9
|
# Faraday middleware to handle content-encoding = gzip
|
10
|
-
class Gzip < Faraday::
|
10
|
+
class Gzip < Faraday::Middleware
|
11
11
|
def on_complete(env)
|
12
|
-
if
|
13
|
-
|
14
|
-
|
12
|
+
return if env[:response_headers]['content-encoding'] != "gzip"
|
13
|
+
return if env[:body].force_encoding(Encoding::BINARY).strip.empty?
|
14
|
+
|
15
|
+
env[:body] = Zlib::GzipReader.new(StringIO.new(env[:body])).read
|
15
16
|
end
|
16
17
|
end
|
17
18
|
end
|
@@ -6,7 +6,7 @@ module ZendeskAPI
|
|
6
6
|
module Response
|
7
7
|
# Parse ISO dates from response body
|
8
8
|
# @private
|
9
|
-
class ParseIsoDates < Faraday::
|
9
|
+
class ParseIsoDates < Faraday::Middleware
|
10
10
|
def call(env)
|
11
11
|
@app.call(env).on_complete do |env|
|
12
12
|
parse_dates!(env[:body])
|
@@ -3,9 +3,8 @@ module ZendeskAPI
|
|
3
3
|
module Middleware
|
4
4
|
# @private
|
5
5
|
module Response
|
6
|
-
class ParseJson < Faraday::
|
6
|
+
class ParseJson < Faraday::Middleware
|
7
7
|
CONTENT_TYPE = 'Content-Type'.freeze
|
8
|
-
dependency 'json'
|
9
8
|
|
10
9
|
def on_complete(env)
|
11
10
|
type = env[:response_headers][CONTENT_TYPE].to_s
|
data/lib/zendesk_api/verbs.rb
CHANGED
@@ -44,14 +44,12 @@ module ZendeskAPI
|
|
44
44
|
end
|
45
45
|
|
46
46
|
define_method method do |*method_args|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
false
|
54
|
-
end
|
47
|
+
send("#{method}!", *method_args)
|
48
|
+
rescue ZendeskAPI::Error::RecordInvalid => e
|
49
|
+
@errors = e.errors
|
50
|
+
false
|
51
|
+
rescue ZendeskAPI::Error::ClientError
|
52
|
+
false
|
55
53
|
end
|
56
54
|
end
|
57
55
|
end
|
data/lib/zendesk_api/version.rb
CHANGED
data/lib/zendesk_api.rb
CHANGED
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
|
+
version: 1.38.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Davidovitz
|
@@ -15,22 +15,30 @@ dependencies:
|
|
15
15
|
name: faraday
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: 0.9.0
|
21
|
-
- - "<"
|
18
|
+
- - ">"
|
22
19
|
- !ruby/object:Gem::Version
|
23
20
|
version: 2.0.0
|
24
21
|
type: :runtime
|
25
22
|
prerelease: false
|
26
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 2.0.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: faraday-multipart
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
27
31
|
requirements:
|
28
32
|
- - ">="
|
29
33
|
- !ruby/object:Gem::Version
|
30
|
-
version: 0
|
31
|
-
|
34
|
+
version: '0'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
32
40
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
41
|
+
version: '0'
|
34
42
|
- !ruby/object:Gem::Dependency
|
35
43
|
name: hashie
|
36
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,9 +152,9 @@ licenses:
|
|
144
152
|
- Apache-2.0
|
145
153
|
metadata:
|
146
154
|
bug_tracker_uri: https://github.com/zendesk/zendesk_api_client_rb/issues
|
147
|
-
changelog_uri: https://github.com/zendesk/zendesk_api_client_rb/blob/v1.
|
148
|
-
documentation_uri: https://www.rubydoc.info/gems/zendesk_api/1.
|
149
|
-
source_code_uri: https://github.com/zendesk/zendesk_api_client_rb/tree/v1.
|
155
|
+
changelog_uri: https://github.com/zendesk/zendesk_api_client_rb/blob/v1.38.0.rc1/CHANGELOG.md
|
156
|
+
documentation_uri: https://www.rubydoc.info/gems/zendesk_api/1.38.0.rc1
|
157
|
+
source_code_uri: https://github.com/zendesk/zendesk_api_client_rb/tree/v1.38.0.rc1
|
150
158
|
wiki_uri: https://github.com/zendesk/zendesk_api_client_rb/wiki
|
151
159
|
post_install_message:
|
152
160
|
rdoc_options: []
|
@@ -156,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
164
|
requirements:
|
157
165
|
- - ">="
|
158
166
|
- !ruby/object:Gem::Version
|
159
|
-
version: '2.
|
167
|
+
version: '2.6'
|
160
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
169
|
requirements:
|
162
170
|
- - ">="
|