increase 0.3.0 → 0.3.1
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 +4 -4
- data/CHANGELOG.md +90 -0
- data/README.md +2 -2
- data/lib/increase/client.rb +11 -6
- data/lib/increase/file_upload.rb +17 -10
- data/lib/increase/middleware/encode_json.rb +57 -0
- data/lib/increase/middleware/parse_json.rb +42 -0
- data/lib/increase/middleware/raise_api_error.rb +13 -0
- data/lib/increase/resource.rb +1 -1
- data/lib/increase/response_array.rb +1 -1
- data/lib/increase/version.rb +1 -1
- metadata +19 -10
- data/lib/faraday/raise_increase_api_error.rb +0 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9520a7eb024d05477e162e1158a07f54167a6a89297f44d3a71caa01a40599cf
|
|
4
|
+
data.tar.gz: 273bb964f85fb97660212f6a2046a58caf4e7302d07859fe3d562afe8269922d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d4b399cda4f620ca00549831546a4992069eb17cb84f08ce9aa0039744e7d3ea4868dd3498ee593c001678633bf708a6e8257ee093f75922996c0f1012f9aa6d
|
|
7
|
+
data.tar.gz: bfd03c310aaf256d89228e6bcd0da10e3505004ab958c10c30baa51dd6df1c22d09ca974bcd61def524888dc9203a00fef78a51082991d2dd3aa8701f6060294
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.3.1] - 2023-03-23
|
|
4
|
+
|
|
5
|
+
### Enhancements
|
|
6
|
+
|
|
7
|
+
- Support Faraday >= 1.0.1 (https://github.com/garyhtou/increase-ruby/pull/8)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## [0.3.0] - 2023-03-23
|
|
11
|
+
|
|
12
|
+
### Enhancements
|
|
13
|
+
|
|
14
|
+
- Better developer experience for file uploads (9fc40df62a537ed3402a0c0deb5bee908d84b671)
|
|
15
|
+
|
|
16
|
+
### Documentation
|
|
17
|
+
|
|
18
|
+
- Pin gem version in install command (2127f5a04be8832ba5c5c42476e2844fb6ca9c24)
|
|
19
|
+
- Update README to reflect new file upload DX (9fc40df62a537ed3402a0c0deb5bee908d84b671)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
## [0.2.0] - 2023-03-21
|
|
23
|
+
|
|
24
|
+
### Enhancements
|
|
25
|
+
|
|
26
|
+
- Made webhook verification `verify` raise an error, but `verify?` return a bool (58d462fc648cafdcfdb7b8d2c0e0ec1f45362984)
|
|
27
|
+
- Wrote a generator to generate API resource classes from the OpenAPI spec (8eedc2d4a5daecd97c156546c649f27376eb9762)
|
|
28
|
+
- Added all API resources (2a04096dea06a34ba8ff1d5061475ed1a2354ac2)
|
|
29
|
+
- Supported getting response from `list` operation (a2141f034a4f29cfee0222a4fac32949581adbc6)
|
|
30
|
+
|
|
31
|
+
### Fixes
|
|
32
|
+
|
|
33
|
+
- Use `ArgumentError` when unknown config passed to `Configuration` (cdd0703febd6f9dec0ecd4ac34fe465697edbf08)
|
|
34
|
+
- File uploads! Increase::Files.create now works (236cad5011b996b40793abe85698ba47fa1ba3f8)
|
|
35
|
+
|
|
36
|
+
### Documentation
|
|
37
|
+
|
|
38
|
+
- Updated error handling example to be more clear (85d8d6ff102a8ef502040322537b79085f89779d)
|
|
39
|
+
- Fixed idempotency example (343ae6d4cb1b8216192e2f820836ca87cc3a9a36)
|
|
40
|
+
- Added example for passing hash to `with_config` (b82fac134c813d03a31466e83341acc891c1deb6)
|
|
41
|
+
- Updated Rails config example to use Rails credentials (2b4fec9c1d52d04e42760a9889ba1cb313b5bd18)
|
|
42
|
+
- Added list filtering example (6333f982062b2527f676a6aade4e5abf01a7816b)
|
|
43
|
+
- Added table of contents (88e9b6ae05aaa62974514a6c318f35e708e49fb5)
|
|
44
|
+
- Added full example for Idempotency keys (6d5ce8bdd3d4baf13c4d0800a159c784bc1bdc78)
|
|
45
|
+
- Added manual pagination example using `next_cursor` (57157e2965904c9150676696e8567b5518892945)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
## [0.1.3] - 2023-03-20
|
|
49
|
+
|
|
50
|
+
### Enhancements
|
|
51
|
+
|
|
52
|
+
- Added `Limits` resource (98654433812b202ecfd31ba35d520981529f2e2b)
|
|
53
|
+
- Added `CheckTransfers` resource (a899c9ca6206af78df23ba8b62c8dfc88b7fc22d)
|
|
54
|
+
- Added `RoutingNumbers` resource (209e7f279a1ff648142ac6aca6cfe946fc653845)
|
|
55
|
+
|
|
56
|
+
### Documentation
|
|
57
|
+
|
|
58
|
+
- Added section about webhook signature verification (650aed416ab820ed55f0ed8936f201274964fc37)
|
|
59
|
+
- Added section about Rails configuration (650aed416ab820ed55f0ed8936f201274964fc37)
|
|
60
|
+
|
|
61
|
+
## [0.1.2] - 2023-03-20
|
|
62
|
+
|
|
63
|
+
### Enhancements
|
|
64
|
+
|
|
65
|
+
- Added webhook verification support (ce193fb8888d497817ab5551bf8e9096c5bf7e26)
|
|
66
|
+
- Added user agent to requests (ce44249ead32ba4055b13ba576f0b91f20493cfc)
|
|
67
|
+
- Update supported Ruby version to >= 2.7.4 (c404f8ddc4762615bac660edabf0385716b4bd74)
|
|
68
|
+
|
|
69
|
+
### Fixes
|
|
70
|
+
|
|
71
|
+
- Always apply default configuration options (079f0ca603a80dd2c9523df23244b64e2e0a5772)
|
|
72
|
+
|
|
73
|
+
### Documentation
|
|
74
|
+
|
|
75
|
+
- Wrote the README! (aa7c778834cd268ab1318e44fceea0b062a5c5df)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
## [0.1.1] - 2023-03-19
|
|
79
|
+
|
|
80
|
+
### Enhancements
|
|
81
|
+
- Added client-wide configuration options (c47e32c93371b43f2e0a3ac49525e46fbe9ef326)
|
|
82
|
+
- Load `INCREASE_API_KEY` and `INCREASE_BASE_URL` from environment variables (2e6cbe21a2b37c230dc3f2382613b98ffc3ea4d8, 24cea582c03b64018ed2f0997f99f4bae581a1fa, 4a80e4263c7917bbfa1371c70752476d7f7f0695)
|
|
83
|
+
- Added the following API resources:
|
|
84
|
+
- `AccountNumbers` (209b155c0fa3977c2c19602a2239c8b27001935e)
|
|
85
|
+
- `AccountTransfers` (6065a932522bd582aa4f177037a5eca8e5d1647d)
|
|
86
|
+
- `AchTransfers` (caef61c36bfffc780016880959f067b59bfa288e)
|
|
87
|
+
- `Cards` (b58bccc8aab00fd2ee69f2973898e6a13c1b2544)
|
|
88
|
+
- `Events` (dd3312638227be47f04c8bd740c3dd25104959e7)
|
|
89
|
+
- `PendingTransactions` (b6f4b2c02a9108603b4d1feee9a39c1a7f1086ef)
|
|
90
|
+
- `Transaction` (b6f4b2c02a9108603b4d1feee9a39c1a7f1086ef)
|
data/README.md
CHANGED
|
@@ -19,14 +19,14 @@ Bare-Metal Banking APIs!
|
|
|
19
19
|
Install the gem and add to the application's Gemfile by executing:
|
|
20
20
|
|
|
21
21
|
```sh
|
|
22
|
-
$ bundle add increase -v 0.3.
|
|
22
|
+
$ bundle add increase -v 0.3.1
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
If bundler is not being used to manage dependencies, install the gem by
|
|
26
26
|
executing:
|
|
27
27
|
|
|
28
28
|
```sh
|
|
29
|
-
$ gem install increase -v 0.3.
|
|
29
|
+
$ gem install increase -v 0.3.1
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
## Usage
|
data/lib/increase/client.rb
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require "increase/configuration"
|
|
4
|
+
require "increase/middleware/raise_api_error"
|
|
4
5
|
|
|
5
6
|
require "faraday"
|
|
6
|
-
require "faraday/follow_redirects"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
require "faraday/follow_redirects" # Supports both Faraday 1.0 and 2.0
|
|
8
|
+
if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new("2.0")
|
|
9
|
+
# In Faraday 2.0, multipart support is no longer included by default
|
|
10
|
+
require "faraday/multipart"
|
|
11
|
+
else
|
|
12
|
+
# In Faraday 1.0, the JSON middleware is not included by default
|
|
13
|
+
require "increase/middleware/encode_json"
|
|
14
|
+
require "increase/middleware/parse_json"
|
|
15
|
+
end
|
|
11
16
|
|
|
12
17
|
module Increase
|
|
13
18
|
class Client
|
|
@@ -38,7 +43,7 @@ module Increase
|
|
|
38
43
|
if @configuration.raise_api_errors
|
|
39
44
|
# This custom middleware for raising Increase API errors must be
|
|
40
45
|
# located before the JSON response middleware.
|
|
41
|
-
f.use
|
|
46
|
+
f.use Increase::Middleware::RaiseApiError
|
|
42
47
|
end
|
|
43
48
|
|
|
44
49
|
f.response :json
|
data/lib/increase/file_upload.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
3
|
+
require "tempfile"
|
|
4
|
+
require "marcel"
|
|
5
|
+
require "faraday"
|
|
6
|
+
require "pathname"
|
|
7
7
|
|
|
8
8
|
module Increase
|
|
9
9
|
class FileUpload
|
|
@@ -33,11 +33,19 @@ module Increase
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def file_part
|
|
36
|
-
Faraday::
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new("2.0")
|
|
37
|
+
Faraday::Multipart::FilePart.new(
|
|
38
|
+
@file,
|
|
39
|
+
@content_type,
|
|
40
|
+
@filename
|
|
41
|
+
)
|
|
42
|
+
else
|
|
43
|
+
Faraday::FilePart.new(
|
|
44
|
+
@file,
|
|
45
|
+
@content_type,
|
|
46
|
+
@filename
|
|
47
|
+
)
|
|
48
|
+
end
|
|
41
49
|
end
|
|
42
50
|
|
|
43
51
|
private
|
|
@@ -45,6 +53,5 @@ module Increase
|
|
|
45
53
|
def default_filename
|
|
46
54
|
"file upload #{Time.now}"
|
|
47
55
|
end
|
|
48
|
-
|
|
49
56
|
end
|
|
50
57
|
end
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "faraday"
|
|
4
|
+
|
|
5
|
+
module Increase
|
|
6
|
+
module Middleware
|
|
7
|
+
# JSON request middleware for Faraday 1.0
|
|
8
|
+
# In Faraday 2.0, the JSON middleware is bundled with the Faraday gem itself
|
|
9
|
+
#
|
|
10
|
+
# This middleware is from
|
|
11
|
+
# https://github.com/lostisland/faraday_middleware/blob/main/lib/faraday_middleware/request/encode_json.rb
|
|
12
|
+
class EncodeJson < Faraday::Middleware
|
|
13
|
+
CONTENT_TYPE = "Content-Type"
|
|
14
|
+
MIME_TYPE = "application/json"
|
|
15
|
+
MIME_TYPE_REGEX = %r{^application/(vnd\..+\+)?json$}.freeze
|
|
16
|
+
|
|
17
|
+
dependency do
|
|
18
|
+
require "json" unless defined?(::JSON)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def call(env)
|
|
22
|
+
match_content_type(env) do |data|
|
|
23
|
+
env[:body] = encode data
|
|
24
|
+
end
|
|
25
|
+
@app.call env
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def encode(data)
|
|
29
|
+
::JSON.generate data
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def match_content_type(env)
|
|
33
|
+
return unless process_request?(env)
|
|
34
|
+
|
|
35
|
+
env[:request_headers][CONTENT_TYPE] ||= MIME_TYPE
|
|
36
|
+
yield env[:body] unless env[:body].respond_to?(:to_str)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def process_request?(env)
|
|
40
|
+
type = request_type(env)
|
|
41
|
+
has_body?(env) && (type.empty? || MIME_TYPE_REGEX =~ type)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def has_body?(env)
|
|
45
|
+
(body = env[:body]) && !(body.respond_to?(:to_str) && body.empty?)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def request_type(env)
|
|
49
|
+
type = env[:request_headers][CONTENT_TYPE].to_s
|
|
50
|
+
type = type.split(";", 2).first if type.index(";")
|
|
51
|
+
type
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
Faraday::Request.register_middleware(json: Increase::Middleware::EncodeJson)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "faraday"
|
|
4
|
+
require "json"
|
|
5
|
+
|
|
6
|
+
module Increase
|
|
7
|
+
module Middleware
|
|
8
|
+
# JSON response middleware for Faraday 1.0
|
|
9
|
+
# In Faraday 2.0, the JSON middleware is bundled with the Faraday gem itself
|
|
10
|
+
#
|
|
11
|
+
# This middleware is from
|
|
12
|
+
# https://github.com/jsmestad/jsonapi-consumer/blob/7d9721ea7feb888ea1e43edb9f1c0c38334762ed/lib/jsonapi/consumer/middleware/parse_json.rb
|
|
13
|
+
class ParseJson < Faraday::Middleware
|
|
14
|
+
def call(environment)
|
|
15
|
+
@app.call(environment).on_complete do |env|
|
|
16
|
+
if process_response_type?(response_type(env))
|
|
17
|
+
env[:raw_body] = env[:body]
|
|
18
|
+
env[:body] = parse(env[:body])
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def parse(body)
|
|
26
|
+
::JSON.parse(body) unless body.strip.empty?
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def response_type(env)
|
|
30
|
+
type = env[:response_headers]["Content-Type"].to_s
|
|
31
|
+
type = type.split(";", 2).first if type.index(";")
|
|
32
|
+
type
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def process_response_type?(type)
|
|
36
|
+
!!type.match(/\bjson$/)
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
Faraday::Response.register_middleware(json: Increase::Middleware::ParseJson)
|
data/lib/increase/resource.rb
CHANGED
|
@@ -29,7 +29,7 @@ module Increase
|
|
|
29
29
|
with = [with].flatten.compact
|
|
30
30
|
|
|
31
31
|
# TODO: This doesn't support multiple path params
|
|
32
|
-
is_id = ->(path_segment) { path_segment.is_a?(Symbol) && path_segment.to_s.end_with?(
|
|
32
|
+
is_id = ->(path_segment) { path_segment.is_a?(Symbol) && path_segment.to_s.end_with?("id") }
|
|
33
33
|
has_id = path.any? is_id
|
|
34
34
|
|
|
35
35
|
request_method = :request
|
data/lib/increase/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: increase
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gary Tou
|
|
@@ -14,30 +14,36 @@ dependencies:
|
|
|
14
14
|
name: faraday
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 1.0.1
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: '2.0'
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
24
|
-
- - "
|
|
27
|
+
- - ">="
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: 1.0.1
|
|
30
|
+
- - "<"
|
|
25
31
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '2.
|
|
32
|
+
version: '2.0'
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: faraday-follow_redirects
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
30
36
|
requirements:
|
|
31
|
-
- -
|
|
37
|
+
- - "~>"
|
|
32
38
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: 0.3
|
|
39
|
+
version: '0.3'
|
|
34
40
|
type: :runtime
|
|
35
41
|
prerelease: false
|
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
43
|
requirements:
|
|
38
|
-
- -
|
|
44
|
+
- - "~>"
|
|
39
45
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: 0.3
|
|
46
|
+
version: '0.3'
|
|
41
47
|
- !ruby/object:Gem::Dependency
|
|
42
48
|
name: faraday-multipart
|
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -159,6 +165,7 @@ extra_rdoc_files: []
|
|
|
159
165
|
files:
|
|
160
166
|
- ".rspec"
|
|
161
167
|
- ".standard.yml"
|
|
168
|
+
- CHANGELOG.md
|
|
162
169
|
- Gemfile
|
|
163
170
|
- LICENSE.txt
|
|
164
171
|
- OPENAPI_VERSION
|
|
@@ -167,12 +174,14 @@ files:
|
|
|
167
174
|
- bin/generate
|
|
168
175
|
- bin/setup
|
|
169
176
|
- generate/resource.rb.erb
|
|
170
|
-
- lib/faraday/raise_increase_api_error.rb
|
|
171
177
|
- lib/increase.rb
|
|
172
178
|
- lib/increase/client.rb
|
|
173
179
|
- lib/increase/configuration.rb
|
|
174
180
|
- lib/increase/errors.rb
|
|
175
181
|
- lib/increase/file_upload.rb
|
|
182
|
+
- lib/increase/middleware/encode_json.rb
|
|
183
|
+
- lib/increase/middleware/parse_json.rb
|
|
184
|
+
- lib/increase/middleware/raise_api_error.rb
|
|
176
185
|
- lib/increase/resource.rb
|
|
177
186
|
- lib/increase/resources.rb
|
|
178
187
|
- lib/increase/resources/account_numbers.rb
|