coyodlee 0.2.2 → 0.2.3

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: f4fdc7642da9a5d21ad077a91f6942cbc3f50f174185dabaeaba8b2e796fb174
4
- data.tar.gz: 84dbc8104d3e036db7aa47b2083c47dc0757da2ac9376a3c409c580e1321498e
3
+ metadata.gz: cca7c2abe3c6f2441a80d23cf3f80d93934b5f3a3333ffc8d236b7548d281e7b
4
+ data.tar.gz: 900e9c0969c2184075500d93b848c9533fe89edad67325409dba3aeb20c2c354
5
5
  SHA512:
6
- metadata.gz: f3d80dcda2c275403e1c351b2750d7f4950b1d65c9cf84fd70b3907db4f85c9348440c9173e9a1a3f74c2ad28cf599dd75fca924c3b141a17d3aca872f64fb39
7
- data.tar.gz: 217a9afd7b0fdd9d579f4798efae931276e3729d995716970ce1f3bfb2944a7b88f859c6c6d28fb78ee5887ae8b742dfd99320ac4d58339bf3ec2d88807be631
6
+ metadata.gz: '08b0c6e9d606047140708beeed6d4e7050f5561fa5654221249da1ef8aab962ef029439c097f2b4a18e57adb01d083b76097c8bff00fc525da7866034dce4a17'
7
+ data.tar.gz: 294c168e8f0fdf04e018490d80ea87abbce3325a4d0a8942caf165fa6d2630b8b1225dc096beca0adf71c43fcb916991d509db8de22e3988d305ec69d6862256
@@ -5,15 +5,13 @@ require 'json'
5
5
  module Coyodlee
6
6
  class Session
7
7
  attr_reader :authorization
8
- attr_writer :cobrand_session_token_klass
9
- attr_writer :user_session_token_klass
8
+ attr_writer :session_token_klass
10
9
 
11
10
  class << self
12
11
  def create(request_facade)
13
12
  new(request_facade: request_facade,
14
13
  session_authorization: SessionAuthorization.new).tap do |session|
15
- session.cobrand_session_token_klass = CobrandSessionToken
16
- session.user_session_token_klass = UserSessionToken
14
+ session.session_token_klass = SessionToken
17
15
  end
18
16
  end
19
17
  end
@@ -28,7 +26,7 @@ module Coyodlee
28
26
  password: password).tap do |res|
29
27
  body = JSON.parse(res.body)
30
28
  token = body.dig('session', 'cobSession')
31
- @authorization.authorize_cobrand(@cobrand_session_token_klass.new(token))
29
+ @authorization.authorize_cobrand(@session_token_klass.new(token))
32
30
  @api.authorize(@authorization)
33
31
  end
34
32
  end
@@ -38,7 +36,7 @@ module Coyodlee
38
36
  password: password).tap do |res|
39
37
  body = JSON.parse(res.body)
40
38
  token = body.dig('user', 'session', 'userSession')
41
- @authorization.authorize_user(@user_session_token_klass.new(token))
39
+ @authorization.authorize_user(@session_token_klass.new(token))
42
40
  @api.authorize(@authorization)
43
41
  end
44
42
  end
@@ -1,24 +1,41 @@
1
1
  require_relative 'session_tokens'
2
2
 
3
3
  module Coyodlee
4
+ # SessionAuthorization stores cobrand and user session tokens. Its purpose is to
5
+ # make it easy to recreate the Authentication header that must be included in
6
+ # authenticated requests to the Yodlee API
4
7
  class SessionAuthorization
8
+ # @return [SessionToken] the cobrand session token
9
+ attr_reader :cobrand_session_token
10
+ # @return [SessionToken] the user session token
11
+ attr_reader :user_session_token
12
+
5
13
  def initialize(cobrand_session_token: NullSessionToken.new, user_session_token: NullSessionToken.new)
6
14
  @cobrand_session_token = cobrand_session_token
7
15
  @user_session_token = user_session_token
8
16
  end
9
17
 
18
+ # Sets the cobrand session token
19
+ # @param cobrand_session_token [SessionToken] the cobrand session token
20
+ # @return [SessionToken] the cobrand session token
10
21
  def authorize_cobrand(cobrand_session_token)
11
22
  @cobrand_session_token = cobrand_session_token
12
23
  end
13
24
 
25
+ # Sets the user session token
26
+ # @param user_session_token [SessionToken] the user session token
27
+ # @return [SessionToken] the user session token
14
28
  def authorize_user(user_session_token)
15
29
  @user_session_token = user_session_token
16
30
  end
17
31
 
32
+ # @return [String] Returns the cobrand (and user) session as a string to be used in the Authentication header
18
33
  def to_s
19
- [@cobrand_session_token, @user_session_token]
20
- .select { |t| t.present? }
21
- .map(&:to_s)
34
+ ['cobSession', 'userSession']
35
+ .zip([@cobrand_session_token, @user_session_token])
36
+ .select { |_, token| token.present? }
37
+ .map { |k, token| [k, token.to_s] }
38
+ .map { |arr| arr.join('=') }
22
39
  .join(',')
23
40
  end
24
41
  end
@@ -1,39 +1,29 @@
1
1
  module Coyodlee
2
2
  class NullSessionToken
3
+ # @return [Boolean] false
3
4
  def present?
4
5
  false
5
6
  end
6
7
 
8
+ # @return [String] the empty string
7
9
  def to_s
8
10
  ''
9
11
  end
10
12
  end
11
13
 
12
- class UserSessionToken
14
+ class SessionToken
13
15
  def initialize(token='')
14
16
  @token = token
15
17
  end
16
18
 
19
+ # @return [Boolean] Returns true if the token is not empty; false otherwise
17
20
  def present?
18
21
  !@token.empty?
19
22
  end
20
23
 
24
+ # @return [String] Returns the string value of the token
21
25
  def to_s
22
- @token.empty? ? '' : "userSession=#{@token}"
23
- end
24
- end
25
-
26
- class CobrandSessionToken
27
- def initialize(token='')
28
- @token = token
29
- end
30
-
31
- def present?
32
- !@token.empty?
33
- end
34
-
35
- def to_s
36
- @token.empty? ? '' : "cobSession=#{@token}"
26
+ @token
37
27
  end
38
28
  end
39
29
  end
@@ -1,3 +1,3 @@
1
1
  module Coyodlee
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coyodlee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Dyba
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-14 00:00:00.000000000 Z
11
+ date: 2018-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yajl-ruby