api_client_base 1.5.0 → 1.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +37 -0
- data/.gitignore +2 -0
- data/Appraisals +7 -0
- data/CHANGELOG.md +21 -0
- data/Gemfile +1 -1
- data/README.md +4 -0
- data/api_client_base.gemspec +3 -2
- data/gemfiles/.bundle/config +2 -0
- data/gemfiles/dry_validation_0.x.gemfile +9 -0
- data/gemfiles/dry_validation_0.x.gemfile.lock +140 -0
- data/gemfiles/dry_validation_1.x.gemfile +9 -0
- data/gemfiles/dry_validation_1.x.gemfile.lock +145 -0
- data/lib/api_client_base.rb +1 -0
- data/lib/api_client_base/request.rb +22 -12
- data/lib/api_client_base/response.rb +5 -0
- data/lib/api_client_base/services/build_typhoeus_options.rb +13 -0
- data/lib/api_client_base/services/validate.rb +7 -2
- data/lib/api_client_base/version.rb +1 -1
- metadata +30 -10
- data/.travis.yml +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0d7688c1ef8b38a3f6dabd86884a22d199f06793b66ac821e83560bfb3c9a52
|
4
|
+
data.tar.gz: 3ff78a2323c040fbac2c5b59963910c291273c1d096074b36af32333d943a616
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32eefbc1cf3d275bf534fc68611baa123ef809da3d7fd90af4116beb4912e9fb1f57aaca902a41ef0509a82f27676d38f16f2ec2cd08b568efbf76ddbf0345a3
|
7
|
+
data.tar.gz: c1eb95b14c639e6a29e23eb8a779a522fa6f7462239b2e35e0893de7d6d85a292665258715b73d3aebd2418abcf1f8222db38cd857399e6e42bf1723f07da7c7
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ master ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ master ]
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
test:
|
18
|
+
|
19
|
+
runs-on: ubuntu-latest
|
20
|
+
strategy:
|
21
|
+
matrix:
|
22
|
+
ruby-version: ['2.6', '2.7']
|
23
|
+
|
24
|
+
steps:
|
25
|
+
- uses: actions/checkout@v2
|
26
|
+
- name: Set up Ruby
|
27
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
28
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
29
|
+
# uses: ruby/setup-ruby@v1
|
30
|
+
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby-version }}
|
33
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
34
|
+
- name: Install appraisal gems
|
35
|
+
run: bundle exec appraisal install
|
36
|
+
- name: Run tests
|
37
|
+
run: bundle exec appraisal rspec
|
data/Appraisals
ADDED
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,27 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
6
|
|
7
|
+
## [1.10.0] - 2021-06-15
|
8
|
+
### Added
|
9
|
+
- `dry-validation` 1.x support (0.x support has not been dropped)
|
10
|
+
|
11
|
+
## [1.9.0] - 2020-06-30
|
12
|
+
### Added
|
13
|
+
- Allow users to override typhoeus_options to pass any args that we haven't defined
|
14
|
+
|
15
|
+
## [1.8.0] - 2020-06-30
|
16
|
+
### Added
|
17
|
+
- Allow all Typhoeus options to be passed to BuildTyphoeusOptions. This is useful when overriding the method `typhoeus_options` in requests
|
18
|
+
|
19
|
+
## [1.7.0] - 2020-04-15
|
20
|
+
### Added
|
21
|
+
- Add `Response#body` which is `raw_response`'s `body`
|
22
|
+
|
23
|
+
## [1.6.0] - 2020-04-09
|
24
|
+
### Added
|
25
|
+
- Move http-related code to Request#run. This is the one that should be overridden, instead of call, since `#call` calls other methods like `before_call`
|
26
|
+
- Set `#proxy` attribute to requests. This is passed to Typhoeus if present
|
27
|
+
|
7
28
|
## [1.5.0] - 2019-04-03
|
8
29
|
### Added
|
9
30
|
- Allow developer to define `before_call` in requests to execute code
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -197,6 +197,9 @@ client = MyGem::Client.new #...
|
|
197
197
|
client.get_user(user_id: nil) # -> this raises an ArgumentError "[user_id: 'must be filled']"
|
198
198
|
```
|
199
199
|
|
200
|
+
##### Proxy
|
201
|
+
Requests automatically have `proxy`. If set and you are relying on using Typhoeus, proxy will be passed on and used by Typhoeus.
|
202
|
+
|
200
203
|
#### Responses
|
201
204
|
|
202
205
|
```ruby
|
@@ -206,6 +209,7 @@ module MyGem
|
|
206
209
|
# - has `#status` method that is delegated to `raw_response.status`
|
207
210
|
# - has `#code` method to get the response's code
|
208
211
|
# - has `#raw_response` which is a Typhoeus response object
|
212
|
+
# - has `#success` which is delegated to `raw_response.success?`. May be accessed via `#success?`
|
209
213
|
|
210
214
|
# You're encouraged to use Virtus attributes to extract information cleanly
|
211
215
|
attribute :id, Integer, lazy: true, default: :default_id
|
data/api_client_base.gemspec
CHANGED
@@ -34,11 +34,12 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_dependency "virtus", ">= 1.0"
|
35
35
|
spec.add_dependency "gem_config", ">= 0.3.1"
|
36
36
|
|
37
|
-
spec.add_development_dependency "bundler", "~> 1
|
37
|
+
spec.add_development_dependency "bundler", "~> 2.1"
|
38
38
|
spec.add_development_dependency "rake", "~> 10.0"
|
39
39
|
spec.add_development_dependency "rspec", "~> 3.0"
|
40
40
|
spec.add_development_dependency "virtus-matchers"
|
41
41
|
spec.add_development_dependency "vcr", "~> 3.0"
|
42
42
|
spec.add_development_dependency "webmock"
|
43
|
-
spec.add_development_dependency "dry-validation"
|
43
|
+
spec.add_development_dependency "dry-validation", "< 2.0"
|
44
|
+
spec.add_development_dependency "appraisal"
|
44
45
|
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
api_client_base (1.9.0)
|
5
|
+
activesupport (>= 3.0)
|
6
|
+
gem_config (>= 0.3.1)
|
7
|
+
virtus (>= 1.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (6.1.3.1)
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
+
i18n (>= 1.6, < 2)
|
15
|
+
minitest (>= 5.1)
|
16
|
+
tzinfo (~> 2.0)
|
17
|
+
zeitwerk (~> 2.3)
|
18
|
+
addressable (2.7.0)
|
19
|
+
public_suffix (>= 2.0.2, < 5.0)
|
20
|
+
appraisal (2.4.0)
|
21
|
+
bundler
|
22
|
+
rake
|
23
|
+
thor (>= 0.14.0)
|
24
|
+
axiom-types (0.1.1)
|
25
|
+
descendants_tracker (~> 0.0.4)
|
26
|
+
ice_nine (~> 0.11.0)
|
27
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
28
|
+
byebug (11.1.3)
|
29
|
+
coderay (1.1.3)
|
30
|
+
coercible (1.0.0)
|
31
|
+
descendants_tracker (~> 0.0.1)
|
32
|
+
concurrent-ruby (1.1.8)
|
33
|
+
crack (0.4.5)
|
34
|
+
rexml
|
35
|
+
descendants_tracker (0.0.4)
|
36
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
37
|
+
diff-lcs (1.4.4)
|
38
|
+
dry-configurable (0.11.5)
|
39
|
+
concurrent-ruby (~> 1.0)
|
40
|
+
dry-core (~> 0.4, >= 0.4.7)
|
41
|
+
dry-equalizer (~> 0.2)
|
42
|
+
dry-container (0.7.2)
|
43
|
+
concurrent-ruby (~> 1.0)
|
44
|
+
dry-configurable (~> 0.1, >= 0.1.3)
|
45
|
+
dry-core (0.4.9)
|
46
|
+
concurrent-ruby (~> 1.0)
|
47
|
+
dry-equalizer (0.3.0)
|
48
|
+
dry-inflector (0.2.0)
|
49
|
+
dry-logic (0.6.1)
|
50
|
+
concurrent-ruby (~> 1.0)
|
51
|
+
dry-core (~> 0.2)
|
52
|
+
dry-equalizer (~> 0.2)
|
53
|
+
dry-types (0.14.1)
|
54
|
+
concurrent-ruby (~> 1.0)
|
55
|
+
dry-container (~> 0.3)
|
56
|
+
dry-core (~> 0.4, >= 0.4.4)
|
57
|
+
dry-equalizer (~> 0.2)
|
58
|
+
dry-inflector (~> 0.1, >= 0.1.2)
|
59
|
+
dry-logic (~> 0.5, >= 0.5)
|
60
|
+
dry-validation (0.13.3)
|
61
|
+
concurrent-ruby (~> 1.0)
|
62
|
+
dry-configurable (~> 0.1, >= 0.1.3)
|
63
|
+
dry-core (~> 0.2, >= 0.2.1)
|
64
|
+
dry-equalizer (~> 0.2)
|
65
|
+
dry-logic (~> 0.5, >= 0.5.0)
|
66
|
+
dry-types (~> 0.14.0)
|
67
|
+
equalizer (0.0.11)
|
68
|
+
ethon (0.12.0)
|
69
|
+
ffi (>= 1.3.0)
|
70
|
+
ffi (1.15.0)
|
71
|
+
gem_config (0.3.2)
|
72
|
+
hashdiff (1.0.1)
|
73
|
+
i18n (1.8.10)
|
74
|
+
concurrent-ruby (~> 1.0)
|
75
|
+
ice_nine (0.11.2)
|
76
|
+
method_source (1.0.0)
|
77
|
+
minitest (5.14.4)
|
78
|
+
pry (0.13.1)
|
79
|
+
coderay (~> 1.1)
|
80
|
+
method_source (~> 1.0)
|
81
|
+
pry-byebug (3.9.0)
|
82
|
+
byebug (~> 11.0)
|
83
|
+
pry (~> 0.13.0)
|
84
|
+
public_suffix (4.0.6)
|
85
|
+
rake (10.5.0)
|
86
|
+
rexml (3.2.4)
|
87
|
+
rspec (3.10.0)
|
88
|
+
rspec-core (~> 3.10.0)
|
89
|
+
rspec-expectations (~> 3.10.0)
|
90
|
+
rspec-mocks (~> 3.10.0)
|
91
|
+
rspec-core (3.10.1)
|
92
|
+
rspec-support (~> 3.10.0)
|
93
|
+
rspec-expectations (3.10.1)
|
94
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
95
|
+
rspec-support (~> 3.10.0)
|
96
|
+
rspec-mocks (3.10.1)
|
97
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
98
|
+
rspec-support (~> 3.10.0)
|
99
|
+
rspec-support (3.10.1)
|
100
|
+
thor (1.1.0)
|
101
|
+
thread_safe (0.3.6)
|
102
|
+
typhoeus (1.4.0)
|
103
|
+
ethon (>= 0.9.0)
|
104
|
+
tzinfo (2.0.4)
|
105
|
+
concurrent-ruby (~> 1.0)
|
106
|
+
vcr (3.0.3)
|
107
|
+
virtus (1.0.5)
|
108
|
+
axiom-types (~> 0.1)
|
109
|
+
coercible (~> 1.0)
|
110
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
111
|
+
equalizer (~> 0.0, >= 0.0.9)
|
112
|
+
virtus-matchers (0.4.0)
|
113
|
+
virtus (~> 1.0.0)
|
114
|
+
webmock (3.11.1)
|
115
|
+
addressable (>= 2.3.6)
|
116
|
+
crack (>= 0.3.2)
|
117
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
118
|
+
zeitwerk (2.4.2)
|
119
|
+
|
120
|
+
PLATFORMS
|
121
|
+
ruby
|
122
|
+
|
123
|
+
DEPENDENCIES
|
124
|
+
api_client_base!
|
125
|
+
appraisal
|
126
|
+
bundler (~> 2.1)
|
127
|
+
dry-validation (~> 0.13)
|
128
|
+
pry-byebug (~> 3.9)
|
129
|
+
rake (~> 10.0)
|
130
|
+
rspec (~> 3.0)
|
131
|
+
typhoeus
|
132
|
+
vcr (~> 3.0)
|
133
|
+
virtus-matchers
|
134
|
+
webmock
|
135
|
+
|
136
|
+
RUBY VERSION
|
137
|
+
ruby 2.7.3p183
|
138
|
+
|
139
|
+
BUNDLED WITH
|
140
|
+
2.1.4
|
@@ -0,0 +1,145 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ..
|
3
|
+
specs:
|
4
|
+
api_client_base (1.9.0)
|
5
|
+
activesupport (>= 3.0)
|
6
|
+
gem_config (>= 0.3.1)
|
7
|
+
virtus (>= 1.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
activesupport (6.1.3.2)
|
13
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
14
|
+
i18n (>= 1.6, < 2)
|
15
|
+
minitest (>= 5.1)
|
16
|
+
tzinfo (~> 2.0)
|
17
|
+
zeitwerk (~> 2.3)
|
18
|
+
addressable (2.7.0)
|
19
|
+
public_suffix (>= 2.0.2, < 5.0)
|
20
|
+
appraisal (2.4.0)
|
21
|
+
bundler
|
22
|
+
rake
|
23
|
+
thor (>= 0.14.0)
|
24
|
+
axiom-types (0.1.1)
|
25
|
+
descendants_tracker (~> 0.0.4)
|
26
|
+
ice_nine (~> 0.11.0)
|
27
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
28
|
+
byebug (11.1.3)
|
29
|
+
coderay (1.1.3)
|
30
|
+
coercible (1.0.0)
|
31
|
+
descendants_tracker (~> 0.0.1)
|
32
|
+
concurrent-ruby (1.1.9)
|
33
|
+
crack (0.4.5)
|
34
|
+
rexml
|
35
|
+
descendants_tracker (0.0.4)
|
36
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
37
|
+
diff-lcs (1.4.4)
|
38
|
+
dry-configurable (0.12.1)
|
39
|
+
concurrent-ruby (~> 1.0)
|
40
|
+
dry-core (~> 0.5, >= 0.5.0)
|
41
|
+
dry-container (0.8.0)
|
42
|
+
concurrent-ruby (~> 1.0)
|
43
|
+
dry-configurable (~> 0.1, >= 0.1.3)
|
44
|
+
dry-core (0.6.0)
|
45
|
+
concurrent-ruby (~> 1.0)
|
46
|
+
dry-equalizer (0.3.0)
|
47
|
+
dry-inflector (0.2.0)
|
48
|
+
dry-initializer (3.0.4)
|
49
|
+
dry-logic (1.2.0)
|
50
|
+
concurrent-ruby (~> 1.0)
|
51
|
+
dry-core (~> 0.5, >= 0.5)
|
52
|
+
dry-schema (1.6.2)
|
53
|
+
concurrent-ruby (~> 1.0)
|
54
|
+
dry-configurable (~> 0.8, >= 0.8.3)
|
55
|
+
dry-core (~> 0.5, >= 0.5)
|
56
|
+
dry-initializer (~> 3.0)
|
57
|
+
dry-logic (~> 1.0)
|
58
|
+
dry-types (~> 1.5)
|
59
|
+
dry-types (1.5.1)
|
60
|
+
concurrent-ruby (~> 1.0)
|
61
|
+
dry-container (~> 0.3)
|
62
|
+
dry-core (~> 0.5, >= 0.5)
|
63
|
+
dry-inflector (~> 0.1, >= 0.1.2)
|
64
|
+
dry-logic (~> 1.0, >= 1.0.2)
|
65
|
+
dry-validation (1.6.0)
|
66
|
+
concurrent-ruby (~> 1.0)
|
67
|
+
dry-container (~> 0.7, >= 0.7.1)
|
68
|
+
dry-core (~> 0.4)
|
69
|
+
dry-equalizer (~> 0.2)
|
70
|
+
dry-initializer (~> 3.0)
|
71
|
+
dry-schema (~> 1.5, >= 1.5.2)
|
72
|
+
equalizer (0.0.11)
|
73
|
+
ethon (0.14.0)
|
74
|
+
ffi (>= 1.15.0)
|
75
|
+
ffi (1.15.1)
|
76
|
+
gem_config (0.3.2)
|
77
|
+
hashdiff (1.0.1)
|
78
|
+
i18n (1.8.10)
|
79
|
+
concurrent-ruby (~> 1.0)
|
80
|
+
ice_nine (0.11.2)
|
81
|
+
method_source (1.0.0)
|
82
|
+
minitest (5.14.4)
|
83
|
+
pry (0.13.1)
|
84
|
+
coderay (~> 1.1)
|
85
|
+
method_source (~> 1.0)
|
86
|
+
pry-byebug (3.9.0)
|
87
|
+
byebug (~> 11.0)
|
88
|
+
pry (~> 0.13.0)
|
89
|
+
public_suffix (4.0.6)
|
90
|
+
rake (10.5.0)
|
91
|
+
rexml (3.2.5)
|
92
|
+
rspec (3.10.0)
|
93
|
+
rspec-core (~> 3.10.0)
|
94
|
+
rspec-expectations (~> 3.10.0)
|
95
|
+
rspec-mocks (~> 3.10.0)
|
96
|
+
rspec-core (3.10.1)
|
97
|
+
rspec-support (~> 3.10.0)
|
98
|
+
rspec-expectations (3.10.1)
|
99
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
100
|
+
rspec-support (~> 3.10.0)
|
101
|
+
rspec-mocks (3.10.2)
|
102
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
103
|
+
rspec-support (~> 3.10.0)
|
104
|
+
rspec-support (3.10.2)
|
105
|
+
thor (1.1.0)
|
106
|
+
thread_safe (0.3.6)
|
107
|
+
typhoeus (1.4.0)
|
108
|
+
ethon (>= 0.9.0)
|
109
|
+
tzinfo (2.0.4)
|
110
|
+
concurrent-ruby (~> 1.0)
|
111
|
+
vcr (3.0.3)
|
112
|
+
virtus (1.0.5)
|
113
|
+
axiom-types (~> 0.1)
|
114
|
+
coercible (~> 1.0)
|
115
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
116
|
+
equalizer (~> 0.0, >= 0.0.9)
|
117
|
+
virtus-matchers (0.4.0)
|
118
|
+
virtus (~> 1.0.0)
|
119
|
+
webmock (3.13.0)
|
120
|
+
addressable (>= 2.3.6)
|
121
|
+
crack (>= 0.3.2)
|
122
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
123
|
+
zeitwerk (2.4.2)
|
124
|
+
|
125
|
+
PLATFORMS
|
126
|
+
ruby
|
127
|
+
|
128
|
+
DEPENDENCIES
|
129
|
+
api_client_base!
|
130
|
+
appraisal
|
131
|
+
bundler (~> 2.1)
|
132
|
+
dry-validation (~> 1.6)
|
133
|
+
pry-byebug (~> 3.9)
|
134
|
+
rake (~> 10.0)
|
135
|
+
rspec (~> 3.0)
|
136
|
+
typhoeus
|
137
|
+
vcr (~> 3.0)
|
138
|
+
virtus-matchers
|
139
|
+
webmock
|
140
|
+
|
141
|
+
RUBY VERSION
|
142
|
+
ruby 2.7.3p183
|
143
|
+
|
144
|
+
BUNDLED WITH
|
145
|
+
2.1.4
|
data/lib/api_client_base.rb
CHANGED
@@ -7,6 +7,7 @@ require "gem_config"
|
|
7
7
|
require "virtus"
|
8
8
|
require "api_client_base/version"
|
9
9
|
require "api_client_base/services/validate"
|
10
|
+
require "api_client_base/services/build_typhoeus_options"
|
10
11
|
require "api_client_base/base"
|
11
12
|
require "api_client_base/base/class_methods"
|
12
13
|
require "api_client_base/client"
|
@@ -29,29 +29,35 @@ module APIClientBase
|
|
29
29
|
lazy: true,
|
30
30
|
default: :default_api_client_base_path,
|
31
31
|
})
|
32
|
+
attribute :proxy, String
|
32
33
|
end
|
33
34
|
|
34
35
|
def call
|
35
36
|
before_call
|
37
|
+
run
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
36
41
|
|
42
|
+
def run
|
37
43
|
require "typhoeus"
|
38
44
|
if defined?(Typhoeus)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
+
opts = BuildTyphoeusOptions.(
|
46
|
+
{
|
47
|
+
method: action,
|
48
|
+
headers: headers,
|
49
|
+
body: body,
|
50
|
+
params: params,
|
51
|
+
proxy: proxy,
|
52
|
+
}.merge(typhoeus_options)
|
45
53
|
)
|
46
|
-
|
54
|
+
request = Typhoeus::Request.new(uri, opts)
|
47
55
|
request.run
|
48
56
|
else
|
49
|
-
fail "Either override #
|
57
|
+
fail "Either override #run or make sure Typhoeus is available for use."
|
50
58
|
end
|
51
59
|
end
|
52
60
|
|
53
|
-
private
|
54
|
-
|
55
61
|
def headers ; {} ; end
|
56
62
|
def body ; nil ; end
|
57
63
|
def params ; {} ; end
|
@@ -65,8 +71,8 @@ module APIClientBase
|
|
65
71
|
path = URI.parse(host).path
|
66
72
|
if path.present?
|
67
73
|
URI.join(
|
68
|
-
host,
|
69
|
-
[path, "/"].join,
|
74
|
+
host,
|
75
|
+
[path, "/"].join,
|
70
76
|
api_client_base_path[1..-1]
|
71
77
|
)
|
72
78
|
else
|
@@ -90,5 +96,9 @@ module APIClientBase
|
|
90
96
|
|
91
97
|
def before_call; end
|
92
98
|
|
99
|
+
def typhoeus_options
|
100
|
+
{}
|
101
|
+
end
|
102
|
+
|
93
103
|
end
|
94
104
|
end
|
@@ -25,6 +25,7 @@ module APIClientBase
|
|
25
25
|
attribute :raw_response, Object
|
26
26
|
attribute :success, self::Boolean, lazy: true, default: :default_success
|
27
27
|
attribute :code, Integer, lazy: true, default: :default_code
|
28
|
+
attribute :body, String, lazy: true, default: :default_body
|
28
29
|
end
|
29
30
|
|
30
31
|
def default_success
|
@@ -35,5 +36,9 @@ module APIClientBase
|
|
35
36
|
raw_response.code
|
36
37
|
end
|
37
38
|
|
39
|
+
def default_body
|
40
|
+
raw_response.body
|
41
|
+
end
|
42
|
+
|
38
43
|
end
|
39
44
|
end
|
@@ -11,11 +11,16 @@ module APIClientBase
|
|
11
11
|
def self.errors_of(klass, attrs)
|
12
12
|
schema = schema_of(klass)
|
13
13
|
return [] if schema.nil?
|
14
|
-
|
14
|
+
|
15
|
+
schema.(attrs).errors.to_h
|
15
16
|
end
|
16
17
|
|
17
18
|
def self.schema_of(klass)
|
18
|
-
"#{klass.name}Schema".constantize
|
19
|
+
contract_class = "#{klass.name}Schema".constantize
|
20
|
+
|
21
|
+
return contract_class if Dry::Validation.const_defined?("Schema")
|
22
|
+
|
23
|
+
contract_class.new
|
19
24
|
rescue NameError
|
20
25
|
end
|
21
26
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_client_base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ramon Tayag
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1
|
61
|
+
version: '2.1'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1
|
68
|
+
version: '2.1'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -138,6 +138,20 @@ dependencies:
|
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: dry-validation
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "<"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '2.0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "<"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '2.0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: appraisal
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
142
156
|
requirements:
|
143
157
|
- - ">="
|
@@ -157,9 +171,10 @@ executables: []
|
|
157
171
|
extensions: []
|
158
172
|
extra_rdoc_files: []
|
159
173
|
files:
|
174
|
+
- ".github/workflows/ruby.yml"
|
160
175
|
- ".gitignore"
|
161
176
|
- ".rspec"
|
162
|
-
-
|
177
|
+
- Appraisals
|
163
178
|
- CHANGELOG.md
|
164
179
|
- CODE_OF_CONDUCT.md
|
165
180
|
- Gemfile
|
@@ -169,6 +184,11 @@ files:
|
|
169
184
|
- api_client_base.gemspec
|
170
185
|
- bin/console
|
171
186
|
- bin/setup
|
187
|
+
- gemfiles/.bundle/config
|
188
|
+
- gemfiles/dry_validation_0.x.gemfile
|
189
|
+
- gemfiles/dry_validation_0.x.gemfile.lock
|
190
|
+
- gemfiles/dry_validation_1.x.gemfile
|
191
|
+
- gemfiles/dry_validation_1.x.gemfile.lock
|
172
192
|
- lib/api_client_base.rb
|
173
193
|
- lib/api_client_base/base.rb
|
174
194
|
- lib/api_client_base/base/class_methods.rb
|
@@ -177,6 +197,7 @@ files:
|
|
177
197
|
- lib/api_client_base/client/class_methods.rb
|
178
198
|
- lib/api_client_base/request.rb
|
179
199
|
- lib/api_client_base/response.rb
|
200
|
+
- lib/api_client_base/services/build_typhoeus_options.rb
|
180
201
|
- lib/api_client_base/services/validate.rb
|
181
202
|
- lib/api_client_base/version.rb
|
182
203
|
homepage: https://github.com/imacchiato/api_client-ruby
|
@@ -184,7 +205,7 @@ licenses:
|
|
184
205
|
- MIT
|
185
206
|
metadata:
|
186
207
|
allowed_push_host: https://rubygems.org
|
187
|
-
post_install_message:
|
208
|
+
post_install_message:
|
188
209
|
rdoc_options: []
|
189
210
|
require_paths:
|
190
211
|
- lib
|
@@ -199,9 +220,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
220
|
- !ruby/object:Gem::Version
|
200
221
|
version: '0'
|
201
222
|
requirements: []
|
202
|
-
|
203
|
-
|
204
|
-
signing_key:
|
223
|
+
rubygems_version: 3.1.6
|
224
|
+
signing_key:
|
205
225
|
specification_version: 4
|
206
226
|
summary: Abstractions to help author API wrappers in Ruby.
|
207
227
|
test_files: []
|