setsuzoku 0.14.8 → 0.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +16 -14
- data/lib/setsuzoku/api_response.rb +5 -0
- data/lib/setsuzoku/api_strategy.rb +3 -2
- data/lib/setsuzoku/service/web_service/api_strategies/rest_strategy.rb +11 -5
- data/lib/setsuzoku/service/web_service/auth_strategies/strategy_can_use_tokens.rb +2 -0
- data/lib/setsuzoku/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33e2792dd95e82af3c6d7da592db91dfc6deb3231bba7408b02a5d0d400a06df
|
4
|
+
data.tar.gz: c3dd57468f5e8e1a8f948522f34a62231759c15b2778e3a591b414b6e208e6cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17824e32cc43b626875a9fb4bcfdae86b29a109b78f8c8aea01116734d72e4093ebfa1087e50b54ebcc65a1439b7002eb592057b9633596102f8590726e777ee
|
7
|
+
data.tar.gz: 7ad2426f1f7959301f1ec50ce45611363d79f433de59a0414226e8cd99f765a6bc68a6c2c9b391b84f1533aca6cbc07f8a46ff60b893d5af42241bd586c738a9
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
setsuzoku (0.
|
4
|
+
setsuzoku (0.15.1)
|
5
5
|
activesupport (>= 5.0, < 7)
|
6
6
|
faraday (~> 0.11)
|
7
7
|
nokogiri (~> 1.10)
|
@@ -10,7 +10,7 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activesupport (6.1.
|
13
|
+
activesupport (6.1.6)
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
15
|
i18n (>= 1.6, < 2)
|
16
16
|
minitest (>= 5.1)
|
@@ -18,21 +18,23 @@ GEM
|
|
18
18
|
zeitwerk (~> 2.3)
|
19
19
|
addressable (2.7.0)
|
20
20
|
public_suffix (>= 2.0.2, < 5.0)
|
21
|
-
concurrent-ruby (1.1.
|
21
|
+
concurrent-ruby (1.1.10)
|
22
22
|
crack (0.4.3)
|
23
23
|
safe_yaml (~> 1.0.0)
|
24
24
|
diff-lcs (1.4.2)
|
25
|
-
faraday (0.17.
|
25
|
+
faraday (0.17.5)
|
26
26
|
multipart-post (>= 1.2, < 3)
|
27
27
|
hashdiff (1.0.1)
|
28
|
-
i18n (1.
|
28
|
+
i18n (1.10.0)
|
29
29
|
concurrent-ruby (~> 1.0)
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
mini_portile2 (2.8.0)
|
31
|
+
minitest (5.16.1)
|
32
|
+
multipart-post (2.2.3)
|
33
|
+
nokogiri (1.13.6)
|
34
|
+
mini_portile2 (~> 2.8.0)
|
33
35
|
racc (~> 1.4)
|
34
36
|
public_suffix (4.0.5)
|
35
|
-
racc (1.
|
37
|
+
racc (1.6.0)
|
36
38
|
rake (10.5.0)
|
37
39
|
rspec (3.8.0)
|
38
40
|
rspec-core (~> 3.8.0)
|
@@ -48,17 +50,17 @@ GEM
|
|
48
50
|
rspec-support (~> 3.8.0)
|
49
51
|
rspec-support (3.8.3)
|
50
52
|
safe_yaml (1.0.5)
|
51
|
-
sorbet (0.5.
|
52
|
-
sorbet-static (= 0.5.
|
53
|
-
sorbet-runtime (0.5.
|
54
|
-
sorbet-static (0.5.
|
53
|
+
sorbet (0.5.10030)
|
54
|
+
sorbet-static (= 0.5.10030)
|
55
|
+
sorbet-runtime (0.5.10125)
|
56
|
+
sorbet-static (0.5.10030-universal-darwin-14)
|
55
57
|
tzinfo (2.0.4)
|
56
58
|
concurrent-ruby (~> 1.0)
|
57
59
|
webmock (3.8.0)
|
58
60
|
addressable (>= 2.3.6)
|
59
61
|
crack (>= 0.3.2)
|
60
62
|
hashdiff (>= 0.4.0, < 2.0.0)
|
61
|
-
zeitwerk (2.
|
63
|
+
zeitwerk (2.6.0)
|
62
64
|
|
63
65
|
PLATFORMS
|
64
66
|
ruby
|
@@ -4,8 +4,13 @@
|
|
4
4
|
module Setsuzoku
|
5
5
|
# The generic API response object that all API responses should return.
|
6
6
|
class ApiResponse < T::Struct
|
7
|
+
# the formatted response object for use in the application.
|
7
8
|
prop :data, T.nilable(T.untyped), default: {}
|
9
|
+
# whether the API request "succeeded" -- atm this is simply whether we hit the 3rd-party and received any kind of response.
|
8
10
|
prop :success, T::Boolean, default: false
|
11
|
+
# the error from the request -- this needs to manage codes and error messages in the future.
|
9
12
|
prop :error, T.nilable(String), default: nil
|
13
|
+
# the full object of the request/response. this is primarily for debugging purposes.
|
14
|
+
prop :full_object, T::Hash[T.untyped, T.untyped], default: {}
|
10
15
|
end
|
11
16
|
end
|
@@ -70,6 +70,7 @@ module Setsuzoku
|
|
70
70
|
self.current_action = request.action
|
71
71
|
formatted_response = T.let(nil, T.nilable(T::Hash[Symbol, T.untyped]))
|
72
72
|
success = T.let(false, T::Boolean)
|
73
|
+
full_object = {}
|
73
74
|
exception = T.let(nil, T.nilable(Setsuzoku::Exception))
|
74
75
|
action_details = case strategy
|
75
76
|
when :auth
|
@@ -99,7 +100,7 @@ module Setsuzoku
|
|
99
100
|
)
|
100
101
|
end
|
101
102
|
|
102
|
-
{
|
103
|
+
full_object = {
|
103
104
|
success: success,
|
104
105
|
plugin: self.plugin,
|
105
106
|
request: request,
|
@@ -110,7 +111,7 @@ module Setsuzoku
|
|
110
111
|
}
|
111
112
|
end
|
112
113
|
self.current_action = nil
|
113
|
-
ApiResponse.new(data: formatted_response, success: success)
|
114
|
+
ApiResponse.new(data: formatted_response, success: success, full_object: full_object)
|
114
115
|
end
|
115
116
|
|
116
117
|
# Parse the response from the API for the given request.
|
@@ -57,11 +57,13 @@ module Setsuzoku
|
|
57
57
|
end
|
58
58
|
faraday.adapter Faraday.default_adapter
|
59
59
|
end
|
60
|
-
|
61
|
-
if
|
60
|
+
attachment_urls = options[:attachment_url] || options[:attachment_urls]
|
61
|
+
if attachment_urls.present?
|
62
62
|
resp = @faraday.post do |req|
|
63
63
|
payload = {}
|
64
|
-
|
64
|
+
# create an array to just iterate over for 1 or many urls
|
65
|
+
attachment_urls = [attachment_urls] if options[:attachment_url]
|
66
|
+
attachments = attachment_urls.map do |url|
|
65
67
|
image = open(url, 'rb')
|
66
68
|
Faraday::UploadIO.new(image, T.must(image).content_type, File.basename(url))
|
67
69
|
end
|
@@ -70,7 +72,8 @@ module Setsuzoku
|
|
70
72
|
else
|
71
73
|
payload.merge!(full_request)
|
72
74
|
end
|
73
|
-
|
75
|
+
# if using the singular "attachment_url" key pull out the first item
|
76
|
+
payload[options[:attachment_url_key]] = options[:attachment_url] ? attachments.first : attachments
|
74
77
|
req.body = payload
|
75
78
|
end
|
76
79
|
else
|
@@ -126,7 +129,10 @@ module Setsuzoku
|
|
126
129
|
# Faraday expects get requests params to be a hash
|
127
130
|
params
|
128
131
|
elsif request_properties[:req_params].empty?
|
129
|
-
if
|
132
|
+
# if the header or request format include urlencoded return the body as a hash
|
133
|
+
if request_format.include?('urlencoded')
|
134
|
+
params
|
135
|
+
elsif %i[put patch post].include?(request_properties[:request_method])
|
130
136
|
params.to_json # Faraday doesn't support an empty hash for PUT/PATCH/POST requests
|
131
137
|
else
|
132
138
|
params # Faraday supports empty hashes for other request types...
|
@@ -138,6 +138,8 @@ module Setsuzoku
|
|
138
138
|
def get_token!(body, action)
|
139
139
|
success = false
|
140
140
|
without_headers = self.credential.auth_actions[action].has_key?(:without_headers) ? self.credential.auth_actions[action][:without_headers] : true
|
141
|
+
body.merge!(self.credential.auth_actions[action][:body]) if self.credential.auth_actions[action].has_key?(:body)
|
142
|
+
|
141
143
|
request = self.api_strategy.request_class.new(action: action, body: body, without_headers: without_headers)
|
142
144
|
|
143
145
|
resp = self.api_strategy.call_external_api(request: request, strategy: :auth)
|
data/lib/setsuzoku/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: setsuzoku
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luke Stadtler
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -227,7 +227,7 @@ homepage: https://github.com/rocketreferrals/setsuzoku
|
|
227
227
|
licenses:
|
228
228
|
- MIT
|
229
229
|
metadata: {}
|
230
|
-
post_install_message:
|
230
|
+
post_install_message:
|
231
231
|
rdoc_options: []
|
232
232
|
require_paths:
|
233
233
|
- lib
|
@@ -242,8 +242,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
242
242
|
- !ruby/object:Gem::Version
|
243
243
|
version: '0'
|
244
244
|
requirements: []
|
245
|
-
rubygems_version: 3.0.1
|
246
|
-
signing_key:
|
245
|
+
rubygems_version: 3.0.3.1
|
246
|
+
signing_key:
|
247
247
|
specification_version: 4
|
248
248
|
summary: Extensible 3rd-party interface and functionality plugins
|
249
249
|
test_files: []
|