setsuzoku 0.12.56 → 0.13.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 +6 -4
- data/lib/setsuzoku/api_strategy.rb +1 -1
- data/lib/setsuzoku/service/web_service/api_strategies/rest_strategy.rb +2 -2
- data/lib/setsuzoku/service/web_service/api_strategy.rb +14 -2
- data/lib/setsuzoku/service/web_service/auth_strategies/strategy_can_use_tokens.rb +2 -1
- data/lib/setsuzoku/service/web_service/credentials/o_auth_credential.rb +1 -1
- data/lib/setsuzoku/version.rb +1 -1
- data/setsuzoku.gemspec +1 -1
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fc8faec9ca8af63095c8bcb40750b05286261e2d55c3e5b0e72716254de0d8d
|
4
|
+
data.tar.gz: e4f78c16811e13234dfccb2b60bf2158bcd25cf586e7c770b5c67643ec681344
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 280622a422f80f84bc13dd5b83e87be5b756d393645741d8b0b155b45713fad63bb55e62147cb2a4f34e963241c6f56ad66018c412141f927c5679f0ea514bd4
|
7
|
+
data.tar.gz: b106bffe570548d00faf98b7d19695b759bbeff0dd9c807848b5147a049ff2d5836688fb67d4a362398c1844eaaff648605f5775b660770453a287a662348433
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
setsuzoku (0.
|
5
|
-
activesupport (
|
4
|
+
setsuzoku (0.13.1)
|
5
|
+
activesupport (>= 5.0, < 7)
|
6
6
|
faraday (~> 0.11)
|
7
7
|
nokogiri (~> 1.10)
|
8
8
|
sorbet-runtime (~> 0.5)
|
@@ -10,11 +10,12 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activesupport (
|
13
|
+
activesupport (6.0.3.4)
|
14
14
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
15
|
i18n (>= 0.7, < 2)
|
16
16
|
minitest (~> 5.1)
|
17
17
|
tzinfo (~> 1.1)
|
18
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
18
19
|
addressable (2.7.0)
|
19
20
|
public_suffix (>= 2.0.2, < 5.0)
|
20
21
|
concurrent-ruby (1.1.7)
|
@@ -49,7 +50,7 @@ GEM
|
|
49
50
|
safe_yaml (1.0.5)
|
50
51
|
sorbet (0.5.5675)
|
51
52
|
sorbet-static (= 0.5.5675)
|
52
|
-
sorbet-runtime (0.5.
|
53
|
+
sorbet-runtime (0.5.5937)
|
53
54
|
sorbet-static (0.5.5675-universal-darwin-14)
|
54
55
|
thread_safe (0.3.6)
|
55
56
|
tzinfo (1.2.7)
|
@@ -58,6 +59,7 @@ GEM
|
|
58
59
|
addressable (>= 2.3.6)
|
59
60
|
crack (>= 0.3.2)
|
60
61
|
hashdiff (>= 0.4.0, < 2.0.0)
|
62
|
+
zeitwerk (2.4.0)
|
61
63
|
|
62
64
|
PLATFORMS
|
63
65
|
ruby
|
@@ -86,7 +86,7 @@ module Setsuzoku
|
|
86
86
|
raw_response = self.perform_external_call(request: request, action_details: action_details, **options)
|
87
87
|
formatted_response = self.parse_response(response: raw_response, response_type: action_details[:actions][request.action][:response_type])
|
88
88
|
success = true
|
89
|
-
rescue Exception => e
|
89
|
+
rescue ::Exception => e
|
90
90
|
exception = e
|
91
91
|
self.external_api_handler.call_external_api_exception(
|
92
92
|
plugin: self.plugin,
|
@@ -65,12 +65,12 @@ module Setsuzoku
|
|
65
65
|
image = open(url, 'rb')
|
66
66
|
Faraday::UploadIO.new(image, T.must(image).content_type, File.basename(url))
|
67
67
|
end
|
68
|
-
payload[options[:attachment_url_key]] = attachments
|
69
68
|
if request_properties[:request_format] == :json
|
70
69
|
payload[:json] = Faraday::UploadIO.new(StringIO.new(full_request), 'application/json')
|
71
70
|
else
|
72
71
|
payload.merge!(full_request)
|
73
72
|
end
|
73
|
+
payload[options[:attachment_url_key]] = attachments
|
74
74
|
req.body = payload
|
75
75
|
end
|
76
76
|
else
|
@@ -147,7 +147,7 @@ module Setsuzoku
|
|
147
147
|
.merge!(self.auth_strategy.get_from_context(:auth_headers).except(:authorization))
|
148
148
|
.merge!(self.get_from_context(:api_headers))
|
149
149
|
.merge!(action_details[:request_options] || {})
|
150
|
-
request_options[:authorization] = self.auth_strategy.get_from_context(:auth_headers)[:authorization]
|
150
|
+
request_options[:authorization] = action_details[:authorization] || self.auth_strategy.get_from_context(:auth_headers)[:authorization]
|
151
151
|
|
152
152
|
content_type = case request_format
|
153
153
|
when :json
|
@@ -86,6 +86,16 @@ module Setsuzoku
|
|
86
86
|
convert_xml_to_hash(response.body)
|
87
87
|
when :html
|
88
88
|
response.body
|
89
|
+
when :txt, :png, :jpg, :gif
|
90
|
+
# for now just return the file
|
91
|
+
response.body
|
92
|
+
# for now just put in tmp
|
93
|
+
# tmp_dir = "#{Dir.tmpdir}/setsuzoku/#{self.plugin.class.system_name.underscore}/#{self.plugin.name.underscore}"
|
94
|
+
# file_name = "#{self.plugin.class.system_name.underscore}_#{self.plugin.name.underscore}_#{Time.now.strftime("%Y_%m_%d_%T")}"
|
95
|
+
# t = Tempfile.new([file_name, ".#{options[:response_type]}"], encoding: 'ascii-8bit')
|
96
|
+
# t.write(response.body)
|
97
|
+
# t.rewind
|
98
|
+
# t
|
89
99
|
else
|
90
100
|
JSON.parse(response.body).deep_symbolize_keys
|
91
101
|
end
|
@@ -116,8 +126,10 @@ module Setsuzoku
|
|
116
126
|
def convert_xml_to_hash(xml)
|
117
127
|
begin
|
118
128
|
result = Nokogiri::XML(xml)
|
119
|
-
|
120
|
-
|
129
|
+
key = result.root.name.underscore.to_sym
|
130
|
+
val = xml_node_to_hash(result.root)
|
131
|
+
{ key => val }
|
132
|
+
rescue ::Exception => e
|
121
133
|
{}
|
122
134
|
end
|
123
135
|
end
|
@@ -137,7 +137,8 @@ module Setsuzoku
|
|
137
137
|
# @return void
|
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
|
+
request = self.api_strategy.request_class.new(action: action, body: body, without_headers: without_headers)
|
141
142
|
|
142
143
|
resp = self.api_strategy.call_external_api(request: request, strategy: :auth)
|
143
144
|
|
@@ -59,7 +59,7 @@ module Setsuzoku
|
|
59
59
|
# @param resp [Hash] the response hash from the external api call for a token.
|
60
60
|
#
|
61
61
|
# @return [Hash] the attributes to assign to the credential.
|
62
|
-
sig{
|
62
|
+
sig{ overridable.params(resp: Setsuzoku::ApiResponse).returns(T::Hash[Symbol, T.untyped]) }
|
63
63
|
def token_attributes_to_assign(resp)
|
64
64
|
attrs = {
|
65
65
|
token: resp.data[:access_token],
|
data/lib/setsuzoku/version.rb
CHANGED
data/setsuzoku.gemspec
CHANGED
@@ -40,7 +40,7 @@ Gem::Specification.new do |spec|
|
|
40
40
|
spec.add_development_dependency "rake", "~> 10.0"
|
41
41
|
spec.add_development_dependency "rspec", "3.8"
|
42
42
|
spec.add_development_dependency "webmock", "3.8"
|
43
|
-
spec.add_runtime_dependency "activesupport", "
|
43
|
+
spec.add_runtime_dependency "activesupport", ">= 5.0", '< 7'
|
44
44
|
spec.add_development_dependency "sorbet", "~> 0.5"
|
45
45
|
spec.add_runtime_dependency "sorbet-runtime", "~> 0.5"
|
46
46
|
#TODO: we should remove httparty if we can just use faraday
|
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.13.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: 2021-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,16 +70,22 @@ dependencies:
|
|
70
70
|
name: activesupport
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '5.0'
|
76
|
+
- - "<"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '7'
|
76
79
|
type: :runtime
|
77
80
|
prerelease: false
|
78
81
|
version_requirements: !ruby/object:Gem::Requirement
|
79
82
|
requirements:
|
80
|
-
- - "
|
83
|
+
- - ">="
|
81
84
|
- !ruby/object:Gem::Version
|
82
85
|
version: '5.0'
|
86
|
+
- - "<"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '7'
|
83
89
|
- !ruby/object:Gem::Dependency
|
84
90
|
name: sorbet
|
85
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -221,7 +227,7 @@ homepage: https://github.com/rocketreferrals/setsuzoku
|
|
221
227
|
licenses:
|
222
228
|
- MIT
|
223
229
|
metadata: {}
|
224
|
-
post_install_message:
|
230
|
+
post_install_message:
|
225
231
|
rdoc_options: []
|
226
232
|
require_paths:
|
227
233
|
- lib
|
@@ -237,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
237
243
|
version: '0'
|
238
244
|
requirements: []
|
239
245
|
rubygems_version: 3.0.1
|
240
|
-
signing_key:
|
246
|
+
signing_key:
|
241
247
|
specification_version: 4
|
242
248
|
summary: Extensible 3rd-party interface and functionality plugins
|
243
249
|
test_files: []
|