setsuzoku 0.12.59 → 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91e75181c6010018c0ccb02179d910c7105925bfa77be612655fd44f5990f74f
4
- data.tar.gz: d9f769db0a64eb941f0edb89820bf76000af714d95a06f7d7f8478cad40582e1
3
+ metadata.gz: 8112cbd43e8c0b19c96ed0197a6b91ca7df547c4e8ce58bcb40f531dae3eff2b
4
+ data.tar.gz: 80a90a90db0ad55bc69ec5fc087319261df453c5a247fd8e0772db674a34fd22
5
5
  SHA512:
6
- metadata.gz: de97461b4cfbd53e0066b11b237b676420895a9979184fcb922ad73c3016d55dd4eca505a6132b69f13746182955f4c7690fab264ac67300334d4465455c6996
7
- data.tar.gz: 6900195befc6a9f5e03e190913dee68197c1a632497d3ba3bc3a2d014e7f58fab3152e6f16de9b1a6aa70b0435e9e83d17804625fe7718a831af1963950aff36
6
+ metadata.gz: b4ee3cc74093cd713d6a0bec429a42639cfd5b552c2038100014ccf82b5f115e60e50096453cd6e0b1f3f99e426f01a2942bc095fd07f8b67538f2e23f5f2bf8
7
+ data.tar.gz: e03952368397f59b1ec4a8a425e1a96ea0c7f4cc5bec67477ba25e76981ffff13af2fc507e988c92a539f02e2b4b949308bd9f2b935704ff9bb44713854510cb
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- setsuzoku (0.12.59)
5
- activesupport (~> 5.0)
4
+ setsuzoku (0.14.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 (5.2.4.3)
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)
@@ -27,7 +28,7 @@ GEM
27
28
  i18n (1.8.5)
28
29
  concurrent-ruby (~> 1.0)
29
30
  mini_portile2 (2.4.0)
30
- minitest (5.14.1)
31
+ minitest (5.14.2)
31
32
  multipart-post (2.1.1)
32
33
  nokogiri (1.10.10)
33
34
  mini_portile2 (~> 2.4.0)
@@ -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.5935)
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
@@ -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
@@ -137,36 +137,14 @@ module Setsuzoku
137
137
  # @return void
138
138
  def get_token!(body, action)
139
139
  success = false
140
- request = self.api_strategy.request_class.new(action: action, body: body, without_headers: true)
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
 
144
145
  return false unless resp.success
145
146
 
146
- attrs = self.credential.token_attributes_to_assign(resp)
147
- attrs[:status] = if attrs[:token]
148
- 'active'
149
- else
150
- 'error'
151
- end
152
-
153
- # Assign any additional attributes the plugin's credential needs to know about.
154
- # E.g. the extension for a phone_number.
155
- plugin_attrs = self.credential.additional_attributes_to_assign(resp) if self.plugin.respond_to?(:credential_fields_to_update)
156
- attrs.merge!(plugin_attrs) if plugin_attrs
157
-
158
- # Only save Setsuzoku known fields, and any additional attributes the plugin specifies
159
- # in credential_fields_to_update.
160
- if self.credential.respond_to?(:"update_columns")
161
- # we issue an update_columns instead of a save/update_attributes
162
- # so as to only mutate these attributes
163
- # and not any other fields that may have been set for the credential
164
- save = self.credential.update_columns(attrs)
165
- self.credential.touch if save && self.credential.respond_to?(:"touch")
166
- save
167
- else
168
- true
169
- end
147
+ self.credential.set_token!(resp)
170
148
  end
171
149
  end
172
150
  end
@@ -54,26 +54,6 @@ module Setsuzoku
54
54
  sig { abstract.returns(T.nilable(String)) }
55
55
  def redirect_url; end
56
56
 
57
- # The token, refresh_token, and expires_at to assign for an OAuth token request.
58
- #
59
- # @param resp [Hash] the response hash from the external api call for a token.
60
- #
61
- # @return [Hash] the attributes to assign to the credential.
62
- sig{ override.params(resp: Setsuzoku::ApiResponse).returns(T::Hash[Symbol, T.untyped]) }
63
- def token_attributes_to_assign(resp)
64
- attrs = {
65
- token: resp.data[:access_token],
66
- refresh_token: resp.data[:refresh_token]
67
- }
68
-
69
- expires_in = resp.data[:expires_in]
70
- if expires_in && (expires_in.is_a?(Integer) || expires_in.match(/^\d+$/))
71
- attrs[:expires_on] = expires_in.to_i.seconds.from_now
72
- end
73
-
74
- attrs
75
- end
76
-
77
57
  # Stub an o_auth_credential-like instance.
78
58
  #
79
59
  # @return [Struct] a stubbed o_auth_credential-like struct.
@@ -51,16 +51,16 @@ module Setsuzoku
51
51
  #
52
52
  # @return [Datetime] the time to set for the current token's expiry.
53
53
  sig{ abstract.params(val: DateTime).returns(T.nilable(DateTime)) }
54
- def expires_on=(val);
54
+ def expires_on=(val); end
55
55
 
56
- # The token fields to bet set for the custom credential.
56
+ # All credentials must have some implementation of storing their token details.
57
57
  #
58
- # @param resp [Hash] the response hash from the external api call for a token.
58
+ # @param resp [Setsuzoku::ApiResponse] the response hash from the external api call for a token.
59
+ # @param attrs [Hash] additional attrs to be passed to super if desired.
59
60
  #
60
61
  # @return [Hash] the attributes to assign to the credential.
61
- sig{ abstract.params(resp: T::Hash[Symbol, T.untyped]).returns(T::Hash[Symbol, T.untyped]) }
62
- def token_attributes_to_assign(resp); end
63
- end
62
+ sig { abstract.params(resp: Setsuzoku::ApiResponse, attrs: T::Hash[Symbol, T.untyped]).void }
63
+ def set_token!; end
64
64
  end
65
65
  end
66
66
  end
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Setsuzoku
5
- VERSION = '0.12.59'
5
+ VERSION = '0.14.2'
6
6
  end
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", "~> 5.0"
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.12.59
4
+ version: 0.14.2
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: 2020-10-06 00:00:00.000000000 Z
11
+ date: 2021-06-30 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: []