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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c5a2ced45e0201f6f9a45e5b8f7cf6951ca92c15ce893283c2289d0b260dc77
4
- data.tar.gz: 31fa7566865e7191f49dadf6a5e01573264f4fc62ddfd4f635f8f7edd4be9ab2
3
+ metadata.gz: 0761624b8c620d76a906657fd12245feb7e4d413e5023d6dfaa2fc080a07be13
4
+ data.tar.gz: ac1e4d18a7f28760a1fd484b91942197d4f6d7b00021fee5d38f316a98906b89
5
5
  SHA512:
6
- metadata.gz: a1b355c67c8126f69f32ff6cd24d03b81b75eec27a0a72044383d0e06a871ba5bd18778119523a013725162048393d7a6bf58f075013e852303255b78bccb73f
7
- data.tar.gz: 78ecdd8fd4d2fd889df06aea1ac98df7c68e6f89378f1358594b30853b23b3179f304ee4d87a781bda0047bc1970b8c28dfd147907d74223e28ffceb1676d1b1
6
+ metadata.gz: 8b4a6c4c0ce022dc38d19602068e6db2ee7f313649a284bef183aff7e09be969dbd144343a7b637f486687010872e1ee9650220ebd50eab2b04b512434dd9def
7
+ data.tar.gz: f6142c76b05f5f439c334d311096d9fbeee4ab2a9a0932be1461d9a461810ab0d42abdd143f9d2f04d9fe5e15bb4740a044ee58de19fa74905d2b15792dd21ce
@@ -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
- # request
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
- builder.use ZendeskAPI::Middleware::Request::Retry, :logger => config.logger, :retry_codes => config.retry_codes, :retry_on_exception => config.retry_on_exception if config.retry
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
 
@@ -6,7 +6,6 @@ module ZendeskAPI
6
6
  class EncodeJson < Faraday::Middleware
7
7
  CONTENT_TYPE = 'Content-Type'.freeze
8
8
  MIME_TYPE = 'application/json'.freeze
9
- dependency 'json'
10
9
 
11
10
  def call(env)
12
11
  type = env[:request_headers][CONTENT_TYPE].to_s
@@ -4,7 +4,7 @@ module ZendeskAPI
4
4
  module Middleware
5
5
  module Response
6
6
  # @private
7
- class Callback < Faraday::Response::Middleware
7
+ class Callback < Faraday::Middleware
8
8
  def initialize(app, client)
9
9
  super(app)
10
10
  @client = client
@@ -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::Response::Middleware
8
+ class Deflate < Faraday::Middleware
9
9
  def on_complete(env)
10
- if !env.body.strip.empty? && env[:response_headers]['content-encoding'] == "deflate"
11
- env.body = Zlib::Inflate.inflate(env.body)
12
- end
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::Response::Middleware
10
+ class Gzip < Faraday::Middleware
11
11
  def on_complete(env)
12
- if !env[:body].strip.empty? && env[:response_headers]['content-encoding'] == "gzip"
13
- env[:body] = Zlib::GzipReader.new(StringIO.new(env[:body])).read
14
- end
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::Response::Middleware
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::Response::Middleware
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
@@ -1,7 +1,7 @@
1
1
  module ZendeskAPI
2
2
  module Middleware
3
3
  module Response
4
- class SanitizeResponse < Faraday::Response::Middleware
4
+ class SanitizeResponse < Faraday::Middleware
5
5
  def on_complete(env)
6
6
  env[:body].scrub!('')
7
7
  end
@@ -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
@@ -44,14 +44,12 @@ module ZendeskAPI
44
44
  end
45
45
 
46
46
  define_method method do |*method_args|
47
- begin
48
- send("#{method}!", *method_args)
49
- rescue ZendeskAPI::Error::RecordInvalid => e
50
- @errors = e.errors
51
- false
52
- rescue ZendeskAPI::Error::ClientError
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
@@ -1,3 +1,3 @@
1
1
  module ZendeskAPI
2
- VERSION = "1.37.0"
2
+ VERSION = "1.38.0.rc2"
3
3
  end
data/lib/zendesk_api.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  module ZendeskAPI; end
2
2
 
3
+ require 'faraday'
4
+ require 'faraday/multipart'
5
+
3
6
  require 'zendesk_api/core_ext/inflection'
4
7
  require 'zendesk_api/client'
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.37.0
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: 2022-09-07 00:00:00.000000000 Z
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.9.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: 2.0.0
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.37.0/CHANGELOG.md
148
- documentation_uri: https://www.rubydoc.info/gems/zendesk_api/1.37.0
149
- source_code_uri: https://github.com/zendesk/zendesk_api_client_rb/tree/v1.37.0
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.3'
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.0.3
174
+ rubygems_version: 3.4.7
167
175
  signing_key:
168
176
  specification_version: 4
169
177
  summary: Zendesk REST API Client