checkify 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1fb398a2b3bac9a1ef8b2093c1fe8122611de7d42ba9d53c0b05d2e65ef13129
4
- data.tar.gz: 054d9fad13402d278031a748842987984164f46f3cb52a71c76c3868cde1d624
3
+ metadata.gz: 57474e58be9780c71d786e3ae001a38e14b5320fa83bbdae395a7b23272aef10
4
+ data.tar.gz: bddf837200c5e0cb2eec5aa99ba409b67d9c7e802974e5dc7df0e9046f23c670
5
5
  SHA512:
6
- metadata.gz: 6e43d7f516b7a591419dbdb834302c8a20f20842d423e659cfa9348f7271df494d0640ce863eb36c7fd1f33e40145dfc0cfbee2430539499760998bb643cb48a
7
- data.tar.gz: 7559c9c422bb50c8ed3c4d7e4792b95cf1a5bd52ec5b6427147663823e064e7d219d665777c0b996473522d67cc0b25f325bd03c1059fbad62acdd136a2fedba
6
+ metadata.gz: 882f84f2d61afdd65c10be77f6644515941876578a73fda196dd4497e923054d869122b19b95c7d8782a95a1354832d5e51d4cca05d2e6d711f1b1cd29498df6
7
+ data.tar.gz: 2c5a1b32f471902158efbdb0b52a41e38cfe85c78545c03c269bbd88ad353a09f51e6987b355e799a1d0038f8dfbbefa4848ae38cbff74ffbddf088a699f587e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.0 (2026-10-06)
4
+
5
+ - Replace Typhoeus with Faraday 2, using Faraday's default adapter and removing the libcurl/FFI dependency.
6
+ - Keep the per-client API, VCR recordings, multipart uploads, redirect opt-out, streamed CSV downloads, and Checkify error handling.
7
+ - Advanced transport configuration and timeout semantics now follow Faraday; see the README migration notes.
8
+
3
9
  ## 0.1.0 (2026-09-05)
4
10
 
5
11
  - Initial Ruby client for Checkify's address, business, identity, communication, account, and bulk APIs.
data/README.md CHANGED
@@ -4,12 +4,12 @@ Unofficial Ruby client for the [Checkify API](https://checkify.com.au/developers
4
4
 
5
5
  ## Installation
6
6
 
7
- Requires Ruby 3.3 or later and libcurl (normally included with macOS and Linux).
7
+ Requires Ruby 3.3 or later. HTTP requests use Faraday and its default adapter; no libcurl installation is needed.
8
8
 
9
9
  Add to your Gemfile:
10
10
 
11
11
  ```ruby
12
- gem "checkify", "~> 0.1.0"
12
+ gem "checkify", "~> 0.2.0"
13
13
  ```
14
14
 
15
15
  Then run `bundle install`.
@@ -22,8 +22,9 @@ require "checkify"
22
22
  client = Checkify::Client.new(api_key: ENV.fetch("CHECKIFY_API_KEY"))
23
23
  ```
24
24
 
25
- Each client has its own credentials and configuration. Requests time out after 30
26
- seconds by default; pass `timeout: 60` to change this (or `timeout: 0` to disable it).
25
+ Each client has its own credentials and configuration. The default Faraday timeout
26
+ is 30 seconds; pass `timeout: 60` to change it. The selected adapter determines how
27
+ timeouts apply (Net::HTTP applies separate open, read, and write limits).
27
28
  For advanced configuration, pass a block:
28
29
 
29
30
  ```ruby
@@ -147,6 +148,39 @@ account.units_remaining # => 48760
147
148
  account.usage # => { "autocomplete" => 520, "abn" => 295, ... }
148
149
  ```
149
150
 
151
+ ## Upgrading from 0.1
152
+
153
+ Version 0.2 replaces Typhoeus with Faraday 2. `Checkify::Client`, endpoint methods,
154
+ response models, and `Checkify::ApiError` remain available. Advanced transport
155
+ configuration changes:
156
+
157
+ | Version 0.1 | Version 0.2 |
158
+ |---|---|
159
+ | `verify_ssl` | `ssl_verify` |
160
+ | `ssl_ca_cert` | `ssl_ca_file` |
161
+ | `cert_file` / `key_file` (file paths) | `ssl_client_cert` / `ssl_client_key` (OpenSSL objects) |
162
+ | `params_encoding` | `params_encoder` (Faraday encoder) |
163
+ | `ApiClient#build_request` returns a Typhoeus request | Returns a Faraday request |
164
+
165
+ Timeouts now follow the selected Faraday adapter, rather than libcurl's total
166
+ request deadline. `timeout: 0` no longer means an unlimited timeout with the default
167
+ Net::HTTP adapter; use a suitable positive timeout. TLS hostname verification uses
168
+ the adapter's default; the old `verify_ssl_host` option is removed.
169
+
170
+ The gem leaves adapter selection to Faraday. Applications can set
171
+ `Faraday.default_adapter` before creating clients, or configure a single client:
172
+
173
+ ```ruby
174
+ client = Checkify::Client.new(api_key: ENV.fetch("CHECKIFY_API_KEY")) do |config|
175
+ config.configure_faraday_connection do |connection|
176
+ # Configure middleware or an adapter here after requiring its gem.
177
+ end
178
+ end
179
+ ```
180
+
181
+ CSV downloads stream to temporary files with adapters that support Faraday's
182
+ streaming callback. Other adapters fall back to their buffered response.
183
+
150
184
  ## Bulk processing
151
185
 
152
186
  Bulk processing requires an eligible Checkify subscription. JSON input accepts strings for
@@ -248,7 +282,7 @@ responses. Business fixtures use [Bunnings Group Limited (ABN 26 008 672 179)](h
248
282
  Other examples use public addresses, Checkify's documented sample identifiers, and
249
283
  `person@example.com`. Bulk tests use explicitly simulated responses because the
250
284
  recording account does not have a bulk subscription; the multipart test verifies
251
- libcurl's actual HTTP upload against a local test server.
285
+ Faraday's actual HTTP upload against a local test server.
252
286
 
253
287
  ### Recording against production
254
288
 
@@ -288,8 +322,8 @@ bundle exec rake generate
288
322
  bundle exec rake
289
323
  ```
290
324
 
291
- `script/generate` uses `generator/config.yaml`, applies the multipart, redirect,
292
- and timeout fixes to the upstream Ruby templates, regenerates the generated files
325
+ `script/generate` uses `generator/config.yaml` and the Faraday transport template
326
+ in `generator/templates/`, applies the shared template fixes, regenerates the generated files
293
327
  in `lib/` and `docs/`, and applies the project's lint rules. The handwritten
294
328
  `lib/checkify/client.rb`, tests, gemspec, README, and CI are preserved.
295
329
  Change the input spec or generator customization before regenerating; do not patch
@@ -15,7 +15,11 @@ require 'json'
15
15
  require 'logger'
16
16
  require 'tempfile'
17
17
  require 'time'
18
- require 'typhoeus'
18
+ require 'faraday'
19
+ require 'faraday/follow_redirects'
20
+ require 'timeout'
21
+ require 'faraday/multipart' if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
22
+ require 'marcel'
19
23
 
20
24
 
21
25
  module Checkify
@@ -43,165 +47,133 @@ module Checkify
43
47
  @@default ||= ApiClient.new
44
48
  end
45
49
 
46
- # Call an API with given options.
47
- #
48
- # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
49
- # the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
50
+ # Faraday transport. Keep downloads on disk and preserve Checkify::ApiError.
50
51
  def call_api(http_method, path, opts = {})
51
- request = build_request(http_method, path, opts)
52
- tempfile = nil
53
- (download_file(request) { tempfile = _1 }) if opts[:return_type] == 'File'
54
- response = request.run
55
-
56
- if @config.debugging
57
- @config.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
52
+ file = nil
53
+ result = nil
54
+ error_body = +''
55
+ download = ['File', 'Binary'].include?(opts[:return_type])
56
+ response = connection(opts).run_request(http_method.to_s.downcase.to_sym, nil, nil, nil) do |request|
57
+ build_request(http_method, path, opts, request)
58
+ if download
59
+ request.options.on_data = proc do |chunk, received, env|
60
+ if (200...300).cover?(env.status)
61
+ file ||= download_file(env.response_headers)
62
+ file.write(chunk)
63
+ else
64
+ error_body.clear if received == chunk.bytesize
65
+ error_body << chunk
66
+ end
67
+ end
68
+ end
58
69
  end
59
70
 
60
71
  unless response.success?
61
- if response.timed_out?
62
- fail ApiError.new('Connection timed out')
63
- elsif response.code == 0
64
- # Errors from libcurl will be made visible here
65
- fail ApiError.new(:code => 0,
66
- :message => response.return_message)
67
- else
68
- fail ApiError.new(:code => response.code,
69
- :response_headers => response.headers,
70
- :response_body => response.body),
71
- response.status_message
72
- end
72
+ fail ApiError.new(code: response.status, response_headers: response.headers,
73
+ response_body: download && !error_body.empty? ? error_body : response.body), response.reason_phrase
73
74
  end
74
75
 
75
- if opts[:return_type] == 'File'
76
- data = tempfile
76
+ if download
77
+ # Adapters without streaming support may return the body normally.
78
+ unless file
79
+ file = download_file(response.headers)
80
+ file.write(response.body.to_s)
81
+ end
82
+ file.close
83
+ result = config.return_binary_data ? File.binread(file.path) : file
77
84
  elsif opts[:return_type]
78
- data = deserialize(response, opts[:return_type])
79
- else
80
- data = nil
85
+ config.logger.debug "HTTP response body: #{response.body}" if config.debugging
86
+ result = deserialize(response, opts[:return_type])
81
87
  end
82
- return data, response.code, response.headers
88
+ return result, response.status, response.headers
89
+ rescue Faraday::TimeoutError
90
+ fail ApiError.new('Connection timed out')
91
+ rescue Faraday::Error => error
92
+ message = error.cause.is_a?(Timeout::Error) ? 'Connection timed out' : error.message
93
+ fail ApiError.new(code: 0, message: message)
94
+ ensure
95
+ file&.close! unless result.equal?(file)
83
96
  end
84
97
 
85
- # Builds the HTTP request
86
- #
87
- # @param [String] http_method HTTP method/verb (e.g. POST)
88
- # @param [String] path URL path (e.g. /account/new)
89
- # @option opts [Hash] :header_params Header parameters
90
- # @option opts [Hash] :query_params Query parameters
91
- # @option opts [Hash] :form_params Query parameters
92
- # @option opts [Object] :body HTTP body (JSON/XML)
93
- # @return [Typhoeus::Request] A Typhoeus Request
94
- def build_request(http_method, path, opts = {})
95
- url = build_request_url(path, opts)
96
- http_method = http_method.to_sym.downcase
97
-
98
+ # Build a request without sending it. The optional request is supplied by Faraday.
99
+ def build_request(http_method, path, opts = {}, request = Faraday::Request.new)
98
100
  header_params = @default_headers.merge(opts[:header_params] || {})
99
- query_params = opts[:query_params] || {}
100
- form_params = opts[:form_params] || {}
101
- follow_location = opts.fetch(:follow_location, true)
102
-
101
+ query_params = (opts[:query_params] || {}).dup
103
102
  update_params_for_auth! header_params, query_params, opts[:auth_names]
104
-
105
- # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
106
- _verify_ssl_host = @config.verify_ssl_host ? 2 : 0
107
-
108
- req_opts = {
109
- :method => http_method,
110
- :headers => header_params,
111
- :params => query_params,
112
- :params_encoding => @config.params_encoding,
113
- :timeout => @config.timeout,
114
- :ssl_verifypeer => @config.verify_ssl,
115
- :ssl_verifyhost => _verify_ssl_host,
116
- :sslcert => @config.cert_file,
117
- :sslkey => @config.key_file,
118
- :verbose => @config.debugging,
119
- :followlocation => follow_location
120
- }
121
-
122
- # set custom cert, if provided
123
- req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
124
-
125
- if [:post, :patch, :put, :delete].include?(http_method)
126
- req_body = build_request_body(header_params, form_params, opts[:body])
127
- req_opts.update :body => req_body
128
- if @config.debugging
129
- @config.logger.debug "HTTP request body param ~BEGIN~\n#{req_body}\n~END~\n"
130
- end
103
+ request.http_method = http_method.to_s.downcase.to_sym
104
+ request.headers = header_params
105
+ if [:post, :patch, :put, :delete].include?(request.http_method)
106
+ request.body = build_request_body(header_params, opts[:form_params] || {}, opts[:body])
131
107
  end
132
-
133
- Typhoeus::Request.new(url, req_opts)
108
+ request.options = Faraday::RequestOptions.new unless request.options
109
+ request.options.params_encoder = config.params_encoder
110
+ request.options.timeout = config.timeout
111
+ request.params = Faraday::Utils::ParamsHash.new.merge(query_params)
112
+ request.url build_request_url(path, opts)
113
+ request
134
114
  end
135
115
 
136
- # Builds the HTTP request body
137
- #
138
- # @param [Hash] header_params Header parameters
139
- # @param [Hash] form_params Query parameters
140
- # @param [Object] body HTTP body (JSON/XML)
141
- # @return [String] HTTP body data in the form of string
142
116
  def build_request_body(header_params, form_params, body)
143
- # http form
144
- if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
145
- header_params['Content-Type'] == 'multipart/form-data'
146
- data = {}
147
- form_params.each do |key, value|
117
+ case header_params['Content-Type']
118
+ when 'application/x-www-form-urlencoded'
119
+ URI.encode_www_form(form_params)
120
+ when 'multipart/form-data'
121
+ form_params.transform_values do |value|
148
122
  case value
149
- when ::File, ::Array, nil
150
- # let typhoeus handle File, Array and nil parameters
151
- data[key] = value
123
+ when ::File, ::Tempfile
124
+ Faraday::Multipart::FilePart.new(value, Marcel::MimeType.for(Pathname.new(value.path)), File.basename(value.path))
125
+ when ::Array, nil
126
+ value
152
127
  else
153
- data[key] = value.to_s
128
+ value.to_s
154
129
  end
155
130
  end
156
- elsif body
157
- data = body.is_a?(String) ? body : body.to_json
158
131
  else
159
- data = nil
132
+ body.is_a?(String) ? body : body&.to_json
160
133
  end
161
- data
162
134
  end
163
135
 
164
- # Save response body into a file in (the defined) temporary folder, using the filename
165
- # from the "Content-Disposition" header if provided, otherwise a random filename.
166
- # The response body is written to the file in chunks in order to handle files which
167
- # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
168
- # process can use.
169
- #
170
- # @see Configuration#temp_folder_path
171
- #
172
- # @return [Tempfile] the tempfile generated
173
- def download_file(request)
174
- tempfile = nil
175
- encoding = nil
176
- request.on_headers do |response|
177
- content_disposition = response.headers['Content-Disposition']
178
- if content_disposition && content_disposition =~ /filename=/i
179
- filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
180
- prefix = sanitize_filename(filename)
181
- else
182
- prefix = 'download-'
183
- end
184
- prefix = prefix + '-' unless prefix.end_with?('-')
185
- encoding = response.body.encoding
186
- tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
187
- end
188
- request.on_body do |chunk|
189
- chunk.force_encoding(encoding)
190
- tempfile.write(chunk)
191
- end
192
- request.on_complete do
193
- if !tempfile
194
- fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{request.inspect}")
136
+ def download_file(headers)
137
+ disposition = headers['Content-Disposition'].to_s
138
+ filename = disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
139
+ prefix = filename ? sanitize_filename(filename) : 'download'
140
+ Tempfile.new("#{prefix}-", config.temp_folder_path, binmode: true)
141
+ end
142
+
143
+ def connection(opts = {})
144
+ multipart = opts.fetch(:header_params, {})['Content-Type'] == 'multipart/form-data'
145
+ follow_location = opts.fetch(:follow_location, true)
146
+ @connections ||= {}
147
+ @connections[[multipart, follow_location]] ||= build_connection(multipart: multipart, follow_location: follow_location)
148
+ end
149
+
150
+ def build_connection(multipart: false, follow_location: true)
151
+ Faraday.new(url: config.base_url, ssl: ssl_options, proxy: config.proxy) do |conn|
152
+ if follow_location
153
+ # Also cover scheme-relative URLs, which the middleware treats as local paths.
154
+ conn.response :follow_redirects, callback: lambda { |from, to|
155
+ if [from.url.scheme, from.url.host, from.url.port] != [to.url.scheme, to.url.host, to.url.port]
156
+ to.request_headers.delete('Authorization')
157
+ end
158
+ }
195
159
  end
196
- tempfile.close
197
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
198
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
199
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
200
- "explicitly with `tempfile.delete`"
201
- yield tempfile if block_given?
160
+ conn.request :multipart if multipart
161
+ config.configure_middleware(conn)
162
+ config.configure_connection(conn)
163
+ # Faraday installs its default adapter if the application did not choose one.
202
164
  end
203
165
  end
204
166
 
167
+ def ssl_options
168
+ {
169
+ ca_file: config.ssl_ca_file,
170
+ verify: config.ssl_verify,
171
+ verify_mode: config.ssl_verify_mode,
172
+ client_cert: config.ssl_client_cert,
173
+ client_key: config.ssl_client_key
174
+ }
175
+ end
176
+
205
177
  # Check if the given MIME is a JSON MIME.
206
178
  # JSON MIME examples:
207
179
  # application/json
@@ -387,7 +359,7 @@ module Checkify
387
359
  when :pipes
388
360
  param.join('|')
389
361
  when :multi
390
- # return the array directly as typhoeus will handle it as expected
362
+ # return the array directly for the configured parameters encoder
391
363
  param
392
364
  else
393
365
  fail "unknown collection format: #{collection_format.inspect}"
@@ -101,7 +101,7 @@ module Checkify
101
101
  attr_accessor :temp_folder_path
102
102
 
103
103
  # The time limit for HTTP request in seconds.
104
- # Default to 30 seconds; set to 0 to disable the timeout.
104
+ # Default to 30 seconds. Timeout behavior follows the selected Faraday adapter.
105
105
  attr_accessor :timeout
106
106
 
107
107
  # Set this to false to skip client side validation in the operation.
@@ -116,40 +116,39 @@ module Checkify
116
116
  # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
117
117
  #
118
118
  # @return [true, false]
119
- attr_accessor :verify_ssl
119
+ attr_accessor :ssl_verify
120
120
 
121
121
  ### TLS/SSL setting
122
- # Set this to false to skip verifying SSL host name
123
- # Default to true.
122
+ # Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)
124
123
  #
125
124
  # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
126
125
  #
127
- # @return [true, false]
128
- attr_accessor :verify_ssl_host
126
+ attr_accessor :ssl_verify_mode
129
127
 
130
128
  ### TLS/SSL setting
131
129
  # Set this to customize the certificate file to verify the peer.
132
130
  #
133
131
  # @return [String] the path to the certificate file
134
- #
135
- # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
136
- # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
137
- attr_accessor :ssl_ca_cert
132
+ attr_accessor :ssl_ca_file
138
133
 
139
134
  ### TLS/SSL setting
140
135
  # Client certificate file (for client certificate)
141
- attr_accessor :cert_file
136
+ attr_accessor :ssl_client_cert
142
137
 
143
138
  ### TLS/SSL setting
144
139
  # Client private key file (for client certificate)
145
- attr_accessor :key_file
140
+ attr_accessor :ssl_client_key
146
141
 
147
- # Set this to customize parameters encoding of array parameter with multi collectionFormat.
148
- # Default to nil.
142
+ ### Proxy setting
143
+ # HTTP Proxy settings
144
+ attr_accessor :proxy
145
+
146
+ # Set this to customize parameters encoder of array parameter.
147
+ # Default to nil. Faraday uses NestedParamsEncoder when nil.
149
148
  #
150
- # @see The params_encoding option of Ethon. Related source code:
151
- # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
152
- attr_accessor :params_encoding
149
+ # @see The params_encoder option of Faraday. Related source code:
150
+ # https://github.com/lostisland/faraday/tree/main/lib/faraday/encoders
151
+ attr_accessor :params_encoder
153
152
 
154
153
 
155
154
  attr_accessor :inject_format
@@ -167,12 +166,17 @@ module Checkify
167
166
  @api_key = {}
168
167
  @api_key_prefix = {}
169
168
  @client_side_validation = true
170
- @verify_ssl = true
171
- @verify_ssl_host = true
172
- @cert_file = nil
173
- @key_file = nil
169
+ @ssl_verify = true
170
+ @ssl_verify_mode = nil
171
+ @ssl_ca_file = nil
172
+ @ssl_client_cert = nil
173
+ @ssl_client_key = nil
174
+ @middlewares = Hash.new { |h, k| h[k] = [] }
175
+ @configure_connection_blocks = []
174
176
  @timeout = 30
175
- @params_encoding = nil
177
+ # return data as binary instead of file
178
+ @return_binary_data = false
179
+ @params_encoder = nil
176
180
  @debugging = false
177
181
  @ignore_operation_servers = false
178
182
  @inject_format = false
@@ -301,5 +305,86 @@ module Checkify
301
305
 
302
306
  url
303
307
  end
308
+
309
+ # Configure Faraday connection directly.
310
+ #
311
+ # ```
312
+ # c.configure_faraday_connection do |conn|
313
+ # conn.use Faraday::HttpCache, shared_cache: false, logger: logger
314
+ # conn.response :logger, nil, headers: true, bodies: true, log_level: :debug do |logger|
315
+ # logger.filter(/(Authorization: )(.*)/, '\1[REDACTED]')
316
+ # end
317
+ # end
318
+ #
319
+ # c.configure_faraday_connection do |conn|
320
+ # conn.adapter Faraday.default_adapter
321
+ # end
322
+ # ```
323
+ #
324
+ # @param block [Proc] `#call`able object that takes one arg, the connection
325
+ def configure_faraday_connection(&block)
326
+ @configure_connection_blocks << block
327
+ end
328
+
329
+ def configure_connection(conn)
330
+ @configure_connection_blocks.each do |block|
331
+ block.call(conn)
332
+ end
333
+ end
334
+
335
+ # Adds middleware to the stack
336
+ def use(*middleware)
337
+ set_faraday_middleware(:use, *middleware)
338
+ end
339
+
340
+ # Adds request middleware to the stack
341
+ def request(*middleware)
342
+ set_faraday_middleware(:request, *middleware)
343
+ end
344
+
345
+ # Adds response middleware to the stack
346
+ def response(*middleware)
347
+ set_faraday_middleware(:response, *middleware)
348
+ end
349
+
350
+ # Adds Faraday middleware setting information to the stack
351
+ #
352
+ # @example Use the `set_faraday_middleware` method to set middleware information
353
+ # config.set_faraday_middleware(:request, :retry, max: 3, methods: [:get, :post], retry_statuses: [503])
354
+ # config.set_faraday_middleware(:response, :logger, nil, { bodies: true, log_level: :debug })
355
+ # config.set_faraday_middleware(:use, Faraday::HttpCache, store: Rails.cache, shared_cache: false)
356
+ # config.set_faraday_middleware(:insert, 0, FaradayMiddleware::FollowRedirects, { standards_compliant: true, limit: 1 })
357
+ # config.set_faraday_middleware(:swap, 0, Faraday::Response::Logger)
358
+ # config.set_faraday_middleware(:delete, Faraday::Multipart::Middleware)
359
+ #
360
+ # @see https://github.com/lostisland/faraday/blob/v2.3.0/lib/faraday/rack_builder.rb#L92-L143
361
+ def set_faraday_middleware(operation, key, *args, &block)
362
+ unless [:request, :response, :use, :insert, :insert_before, :insert_after, :swap, :delete].include?(operation)
363
+ fail ArgumentError, "Invalid faraday middleware operation #{operation}. Must be" \
364
+ " :request, :response, :use, :insert, :insert_before, :insert_after, :swap or :delete."
365
+ end
366
+
367
+ @middlewares[operation] << [key, args, block]
368
+ end
369
+ ruby2_keywords(:set_faraday_middleware) if respond_to?(:ruby2_keywords, true)
370
+
371
+ # Set up middleware on the connection
372
+ def configure_middleware(connection)
373
+ return if @middlewares.empty?
374
+
375
+ [:request, :response, :use, :insert, :insert_before, :insert_after, :swap].each do |operation|
376
+ next unless @middlewares.key?(operation)
377
+
378
+ @middlewares[operation].each do |key, args, block|
379
+ connection.builder.send(operation, key, *args, &block)
380
+ end
381
+ end
382
+
383
+ if @middlewares.key?(:delete)
384
+ @middlewares[:delete].each do |key, _args, _block|
385
+ connection.builder.delete(key)
386
+ end
387
+ end
388
+ end
304
389
  end
305
390
  end
@@ -11,5 +11,5 @@ Generator version: 7.21.0
11
11
  =end
12
12
 
13
13
  module Checkify
14
- VERSION = '0.1.0'
14
+ VERSION = '0.2.0'
15
15
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checkify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Caldwell
@@ -24,25 +24,61 @@ dependencies:
24
24
  - !ruby/object:Gem::Version
25
25
  version: '1.6'
26
26
  - !ruby/object:Gem::Dependency
27
- name: typhoeus
27
+ name: faraday
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: '1.0'
33
- - - ">="
32
+ version: '2.14'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.14'
40
+ - !ruby/object:Gem::Dependency
41
+ name: faraday-multipart
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
34
45
  - !ruby/object:Gem::Version
35
- version: 1.0.1
46
+ version: '1.2'
36
47
  type: :runtime
37
48
  prerelease: false
38
49
  version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.2'
54
+ - !ruby/object:Gem::Dependency
55
+ name: faraday-follow_redirects
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0.5'
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '0.5'
68
+ - !ruby/object:Gem::Dependency
69
+ name: marcel
70
+ requirement: !ruby/object:Gem::Requirement
39
71
  requirements:
40
72
  - - "~>"
41
73
  - !ruby/object:Gem::Version
42
74
  version: '1.0'
43
- - - ">="
75
+ type: :runtime
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
44
80
  - !ruby/object:Gem::Version
45
- version: 1.0.1
81
+ version: '1.0'
46
82
  - !ruby/object:Gem::Dependency
47
83
  name: rspec
48
84
  requirement: !ruby/object:Gem::Requirement