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 +4 -4
 - data/lib/coyodlee/session.rb +4 -6
 - data/lib/coyodlee/session_authorization.rb +20 -3
 - data/lib/coyodlee/session_tokens.rb +6 -16
 - data/lib/coyodlee/version.rb +1 -1
 - metadata +2 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: cca7c2abe3c6f2441a80d23cf3f80d93934b5f3a3333ffc8d236b7548d281e7b
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 900e9c0969c2184075500d93b848c9533fe89edad67325409dba3aeb20c2c354
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: '08b0c6e9d606047140708beeed6d4e7050f5561fa5654221249da1ef8aab962ef029439c097f2b4a18e57adb01d083b76097c8bff00fc525da7866034dce4a17'
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 294c168e8f0fdf04e018490d80ea87abbce3325a4d0a8942caf165fa6d2630b8b1225dc096beca0adf71c43fcb916991d509db8de22e3988d305ec69d6862256
         
     | 
    
        data/lib/coyodlee/session.rb
    CHANGED
    
    | 
         @@ -5,15 +5,13 @@ require 'json' 
     | 
|
| 
       5 
5 
     | 
    
         
             
            module Coyodlee
         
     | 
| 
       6 
6 
     | 
    
         
             
              class Session
         
     | 
| 
       7 
7 
     | 
    
         
             
                attr_reader :authorization
         
     | 
| 
       8 
     | 
    
         
            -
                attr_writer : 
     | 
| 
       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. 
     | 
| 
       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(@ 
     | 
| 
      
 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(@ 
     | 
| 
      
 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 
     | 
    
         
            -
                  [ 
     | 
| 
       20 
     | 
    
         
            -
                    . 
     | 
| 
       21 
     | 
    
         
            -
                    . 
     | 
| 
      
 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  
     | 
| 
      
 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 
     | 
| 
       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
         
     | 
    
        data/lib/coyodlee/version.rb
    CHANGED
    
    
    
        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. 
     | 
| 
      
 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- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2018-05-15 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: yajl-ruby
         
     |