zendesk_api 1.37.0 → 1.38.0.rc2
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 +19 -16
- 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/resources.rb +6 -0
- data/lib/zendesk_api/verbs.rb +6 -8
- data/lib/zendesk_api/version.rb +1 -1
- data/lib/zendesk_api.rb +3 -0
- metadata +22 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0761624b8c620d76a906657fd12245feb7e4d413e5023d6dfaa2fc080a07be13
|
4
|
+
data.tar.gz: ac1e4d18a7f28760a1fd484b91942197d4f6d7b00021fee5d38f316a98906b89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b4a6c4c0ce022dc38d19602068e6db2ee7f313649a284bef183aff7e09be969dbd144343a7b637f486687010872e1ee9650220ebd50eab2b04b512434dd9def
|
7
|
+
data.tar.gz: f6142c76b05f5f439c334d311096d9fbeee4ab2a9a0932be1461d9a461810ab0d42abdd143f9d2f04d9fe5e15bb4740a044ee58de19fa74905d2b15792dd21ce
|
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.
|
@@ -155,7 +150,6 @@ module ZendeskAPI
|
|
155
150
|
builder.use ZendeskAPI::Middleware::Response::ParseIsoDates
|
156
151
|
builder.use ZendeskAPI::Middleware::Response::ParseJson
|
157
152
|
builder.use ZendeskAPI::Middleware::Response::SanitizeResponse
|
158
|
-
|
159
153
|
adapter = config.adapter || Faraday.default_adapter
|
160
154
|
|
161
155
|
unless GZIP_EXCEPTIONS.include?(adapter)
|
@@ -163,14 +157,7 @@ module ZendeskAPI
|
|
163
157
|
builder.use ZendeskAPI::Middleware::Response::Deflate
|
164
158
|
end
|
165
159
|
|
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
|
160
|
+
set_authentication(builder, config)
|
174
161
|
|
175
162
|
if config.cache
|
176
163
|
builder.use ZendeskAPI::Middleware::Request::EtagCache, :cache => config.cache
|
@@ -181,12 +168,17 @@ module ZendeskAPI
|
|
181
168
|
builder.use ZendeskAPI::Middleware::Request::EncodeJson
|
182
169
|
|
183
170
|
# Should always be first in the stack
|
184
|
-
|
171
|
+
if config.retry
|
172
|
+
builder.use ZendeskAPI::Middleware::Request::Retry,
|
173
|
+
:logger => config.logger,
|
174
|
+
:retry_codes => config.retry_codes,
|
175
|
+
:retry_on_exception => config.retry_on_exception
|
176
|
+
end
|
185
177
|
if config.raise_error_when_rate_limited
|
186
178
|
builder.use ZendeskAPI::Middleware::Request::RaiseRateLimited, :logger => config.logger
|
187
179
|
end
|
188
180
|
|
189
|
-
builder.adapter(*adapter)
|
181
|
+
builder.adapter(*adapter, &config.adapter_proc)
|
190
182
|
end
|
191
183
|
end
|
192
184
|
|
@@ -239,5 +231,16 @@ module ZendeskAPI
|
|
239
231
|
end
|
240
232
|
end
|
241
233
|
end
|
234
|
+
|
235
|
+
# See https://lostisland.github.io/faraday/middleware/authentication
|
236
|
+
def set_authentication(builder, config)
|
237
|
+
if config.access_token && !config.url_based_access_token
|
238
|
+
builder.request :authorization, "Bearer", config.access_token
|
239
|
+
elsif config.access_token
|
240
|
+
builder.use ZendeskAPI::Middleware::Request::UrlBasedAccessToken, config.access_token
|
241
|
+
else
|
242
|
+
builder.request :authorization, :basic, config.username, config.password
|
243
|
+
end
|
244
|
+
end
|
242
245
|
end
|
243
246
|
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
|
@@ -228,6 +228,12 @@ module ZendeskAPI
|
|
228
228
|
has_many Vote
|
229
229
|
class Translation < Resource; end
|
230
230
|
has_many Translation
|
231
|
+
class Label < DataResource
|
232
|
+
include Read
|
233
|
+
include Create
|
234
|
+
include Destroy
|
235
|
+
end
|
236
|
+
has_many Label
|
231
237
|
end
|
232
238
|
|
233
239
|
class TopicSubscription < Resource
|
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.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Davidovitz
|
@@ -9,28 +9,36 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-03-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
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.rc2/CHANGELOG.md
|
156
|
+
documentation_uri: https://www.rubydoc.info/gems/zendesk_api/1.38.0.rc2
|
157
|
+
source_code_uri: https://github.com/zendesk/zendesk_api_client_rb/tree/v1.38.0.rc2
|
150
158
|
wiki_uri: https://github.com/zendesk/zendesk_api_client_rb/wiki
|
151
159
|
post_install_message:
|
152
160
|
rdoc_options: []
|
@@ -156,14 +164,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
156
164
|
requirements:
|
157
165
|
- - ">="
|
158
166
|
- !ruby/object:Gem::Version
|
159
|
-
version: '2.
|
167
|
+
version: '2.7'
|
160
168
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
169
|
requirements:
|
162
170
|
- - ">="
|
163
171
|
- !ruby/object:Gem::Version
|
164
172
|
version: 1.3.6
|
165
173
|
requirements: []
|
166
|
-
rubygems_version: 3.
|
174
|
+
rubygems_version: 3.4.7
|
167
175
|
signing_key:
|
168
176
|
specification_version: 4
|
169
177
|
summary: Zendesk REST API Client
|