setsuzoku 0.14.1 → 0.14.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 323e5a4555c1f507e09e4c37a03c17dd0d8be3a9178a103a63472e6a4b5182f7
4
- data.tar.gz: f70654328bbe20500bdc1c4f59e5077633fcaf353e8726d84e9d2918cdf1aef2
3
+ metadata.gz: a87d8bf5c78f062059a7ee3ab3c442784730d9f9718cfe2b3e08da5800f0515c
4
+ data.tar.gz: '09e0c378a4ac21c06115b6f6212440a6aaece5fb26e842092eee65055d5d1dfe'
5
5
  SHA512:
6
- metadata.gz: 57c8ceaf5f4d4cfdb202126038cfc7e2095d251d5d68bf765663500ac3780b2611295a2df27d970e605cf2aa522de5bd58c5e116d59a3a66369f699f5825fd68
7
- data.tar.gz: e81190b2aca16f38d15002c7d52ceff0541d2a81ca25eb31b8fd497b814db479a81ef71e997515a5358c7907f1ba74b132e0af688fcf2b4e8d6565420ec0ebac
6
+ metadata.gz: 0e4a1acc8ef9b62d9c6bdba0bcf2ef608827570f1391027dd465cbb58edad33b5b1b26d8240d616c850c6e76336b20c93c6f16345a45e53ea5cd7326883f1f79
7
+ data.tar.gz: e6871ad32ff6a26ea65fd17f59503b325775d2d09933e8abf7dbd4957b3cd1f64ba5bb69ca9a5cd5bf828a8e3b99f94aa04fbc9cbf122bbe895b68a2070d6808
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- setsuzoku (0.14.0)
4
+ setsuzoku (0.14.5)
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.4)
13
+ activesupport (6.1.4.1)
14
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
15
  i18n (>= 1.6, < 2)
16
16
  minitest (>= 5.1)
@@ -27,11 +27,11 @@ GEM
27
27
  hashdiff (1.0.1)
28
28
  i18n (1.8.10)
29
29
  concurrent-ruby (~> 1.0)
30
- mini_portile2 (2.5.3)
30
+ mini_portile2 (2.6.1)
31
31
  minitest (5.14.4)
32
32
  multipart-post (2.1.1)
33
- nokogiri (1.11.7)
34
- mini_portile2 (~> 2.5.0)
33
+ nokogiri (1.12.5)
34
+ mini_portile2 (~> 2.6.1)
35
35
  racc (~> 1.4)
36
36
  public_suffix (4.0.5)
37
37
  racc (1.5.2)
@@ -52,7 +52,7 @@ GEM
52
52
  safe_yaml (1.0.5)
53
53
  sorbet (0.5.5675)
54
54
  sorbet-static (= 0.5.5675)
55
- sorbet-runtime (0.5.6466)
55
+ sorbet-runtime (0.5.9174)
56
56
  sorbet-static (0.5.5675-universal-darwin-14)
57
57
  tzinfo (2.0.4)
58
58
  concurrent-ruby (~> 1.0)
@@ -122,9 +122,12 @@ module Setsuzoku
122
122
  def formulate_request(request_properties = {}, request_options = {})
123
123
  request_format = request_properties.dig(:request_format).to_s
124
124
  params = request_properties[:req_params].merge(request_options.except(:headers))
125
-
126
- if request_properties[:request_method] == :get || request_properties[:req_params].empty?
127
- params
125
+ if request_properties[:req_params].empty?
126
+ if request_properties[:request_method] == :get
127
+ params
128
+ else
129
+ params.to_json
130
+ end
128
131
  else
129
132
  # if the header or request format include urlencoded return the body as a hash
130
133
  if request_format.include?('urlencoded')
@@ -81,7 +81,8 @@ module Setsuzoku
81
81
  def parse_response(response:, **options)
82
82
  case options[:response_type]
83
83
  when :json
84
- JSON.parse(response.body).deep_symbolize_keys
84
+ resp = JSON.parse(response.body)
85
+ resp.is_a?(Hash) ? resp.deep_symbolize_keys : resp
85
86
  when :xml
86
87
  convert_xml_to_hash(response.body)
87
88
  when :html
@@ -97,7 +98,8 @@ module Setsuzoku
97
98
  # t.rewind
98
99
  # t
99
100
  else
100
- JSON.parse(response.body).deep_symbolize_keys
101
+ resp = JSON.parse(response.body)
102
+ resp.is_a?(Hash) ? resp.deep_symbolize_keys : resp
101
103
  end
102
104
  end
103
105
 
@@ -146,18 +146,6 @@ module Setsuzoku
146
146
 
147
147
  self.credential.set_token!(resp)
148
148
  end
149
-
150
- #
151
- # set_token!
152
- sig { abstract.params(resp: Setsuzoku::ApiResponse, attrs: T::Hash[Symbol, T.untyped]).void }
153
- #
154
- # Persist relevant token and response data after authentication.
155
- #
156
- # @param resp [Setsuzoku::ApiResponse] the successful response for an authentication token.
157
- # @param attrs [Hash] additional attrs that can be set by a specific credential implementation.
158
- #
159
- # @return [void]
160
- def set_token!(resp, attrs = {}); end
161
149
  end
162
150
  end
163
151
  end
@@ -53,14 +53,14 @@ module Setsuzoku
53
53
  sig{ abstract.params(val: DateTime).returns(T.nilable(DateTime)) }
54
54
  def expires_on=(val); end
55
55
 
56
- # Alternatively, a credential can manually handle what to do with a token response.
57
- # For instance, storing multiple tokens as sub-resources
56
+ # All credentials must have some implementation of storing their token details.
58
57
  #
59
- # @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.
60
60
  #
61
61
  # @return [Hash] the attributes to assign to the credential.
62
- sig{ abstract.params(resp: T::Hash[Symbol, T.untyped]).void }
63
- def set_token!; end
62
+ sig { abstract.params(resp: Setsuzoku::ApiResponse, attrs: T.nilable(T::Hash[Symbol, T.untyped])).void }
63
+ def set_token!(resp, attrs); 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.14.1'
5
+ VERSION = '0.14.5'
6
6
  end
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.14.1
4
+ version: 0.14.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luke Stadtler
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-06-30 00:00:00.000000000 Z
11
+ date: 2021-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler