coyodlee 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -1
- data/examples/demo.rb +1 -0
- data/lib/coyodlee/connection.rb +30 -4
- data/lib/coyodlee/messages.rb +25 -0
- data/lib/coyodlee/session.rb +7 -13
- data/lib/coyodlee/session_authorization.rb +18 -15
- data/lib/coyodlee/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd36bfbc92332a3061593e8f97ff36ae8e500e6cff0a0408645944f5deb66444
|
4
|
+
data.tar.gz: 0c89b4b5f778bcad7bf9bd718ffbcc76a89a83254e79416461c35c3c0a13253f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz: '
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '02364475824bf945d1dbbd627b5c12eaa0595995df949373ec022c7d8721d5f386238f235ce85087bba80770a587120f83c9b17f50e3c0966da875f3d9282044'
|
7
|
+
data.tar.gz: c3483ffd64ee816641ca8ae38433488672d2dccd5006020b70d09d927e2f40a82be9b91d79c5b5e435bac7fa5e3b54354d3bb02d647ad257bc34c00fdd753fda
|
data/README.md
CHANGED
@@ -5,6 +5,10 @@
|
|
5
5
|
[![Maintainability](https://api.codeclimate.com/v1/badges/f36b069069540b196fbd/maintainability)](https://codeclimate.com/github/pennymac/coyodlee/maintainability)
|
6
6
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/f36b069069540b196fbd/test_coverage)](https://codeclimate.com/github/pennymac/coyodlee/test_coverage)
|
7
7
|
|
8
|
+
## Documentation
|
9
|
+
|
10
|
+
Check out the API documentation for the latest stable release at [RubyDoc](https://www.rubydoc.info/gems/coyodlee/0.2.3).
|
11
|
+
|
8
12
|
## Status
|
9
13
|
|
10
14
|
The software in this repository is in an early alpha state. This repository is currently not accepting pull requests or responding to issues. If there is a bug in the code or a feature you'd like to have, feel free to fork the repository.
|
@@ -90,7 +94,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
90
94
|
|
91
95
|
## Contributing
|
92
96
|
|
93
|
-
|
97
|
+
This repository contains alpha software and is currently not open to pull requests. If you'd like to modify the code in this repository, feel free to fork it.
|
94
98
|
|
95
99
|
## License
|
96
100
|
|
data/examples/demo.rb
CHANGED
data/lib/coyodlee/connection.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require_relative 'uri_builder'
|
2
2
|
require_relative 'facades'
|
3
|
+
require_relative 'session_tokens'
|
4
|
+
require_relative 'session_authorization'
|
3
5
|
require 'forwardable'
|
4
6
|
require 'net/http'
|
5
7
|
|
@@ -7,15 +9,23 @@ module Coyodlee
|
|
7
9
|
class RequestBuilder
|
8
10
|
extend Forwardable
|
9
11
|
|
12
|
+
attr_reader :session_authorization
|
13
|
+
|
10
14
|
def initialize(uri_builder)
|
11
15
|
@uri_builder = uri_builder
|
12
|
-
@session_authorization =
|
16
|
+
@session_authorization = SessionAuthorization.create
|
13
17
|
end
|
14
18
|
|
15
19
|
def_delegators :@uri_builder, :host
|
16
20
|
|
17
|
-
def
|
18
|
-
|
21
|
+
def authorize_user(user_session_token)
|
22
|
+
token = SessionToken.new user_session_token
|
23
|
+
@session_authorization.user_session_token = token
|
24
|
+
end
|
25
|
+
|
26
|
+
def authorize_cobrand(cobrand_session_token)
|
27
|
+
token = SessionToken.new cobrand_session_token
|
28
|
+
@session_authorization.cobrand_session_token = token
|
19
29
|
end
|
20
30
|
|
21
31
|
def build(method, resource_path, headers: {}, params: {}, body: nil)
|
@@ -78,16 +88,32 @@ module Coyodlee
|
|
78
88
|
@provider_accounts_facade = ProviderAccountsFacade.new(self)
|
79
89
|
end
|
80
90
|
|
81
|
-
def_delegators :@request_builder, :
|
91
|
+
def_delegators :@request_builder, :build, :authorize_cobrand, :authorize_user, :session_authorization
|
82
92
|
|
93
|
+
# @!method login_user
|
94
|
+
# @see UserFacade#login
|
83
95
|
def_delegator :@user_facade, :login, :login_user
|
96
|
+
# @!method logout_user
|
97
|
+
# @see UserFacade#logout
|
84
98
|
def_delegator :@user_facade, :logout, :logout_user
|
99
|
+
# @!method user_access_tokens
|
100
|
+
# @see UserFacade#access_tokens
|
85
101
|
def_delegator :@user_facade, :access_tokens, :user_access_tokens
|
102
|
+
# @!method register_user
|
103
|
+
# @see UserFacade#register
|
86
104
|
def_delegator :@user_facade, :register, :register_user
|
105
|
+
# @!method unregister_user
|
106
|
+
# @see UserFacade#unregister
|
87
107
|
def_delegator :@user_facade, :unregister, :unregister_user
|
88
108
|
|
109
|
+
# @!method login_cobrand
|
110
|
+
# @see CobrandFacade#login
|
89
111
|
def_delegator :@cobrand_facade, :login, :login_cobrand
|
112
|
+
# @!method logout_cobrand
|
113
|
+
# @see CobrandFacade#logout
|
90
114
|
def_delegator :@cobrand_facade, :logout, :logout_cobrand
|
115
|
+
# @!method cobrand_public_key
|
116
|
+
# @see CobrandFacade#public_key
|
91
117
|
def_delegator :@cobrand_facade, :public_key, :cobrand_public_key
|
92
118
|
|
93
119
|
def_delegator :@accounts_facade, :all, :accounts
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Coyodlee
|
4
|
+
class JsonMessage
|
5
|
+
def initialize(message = '{}')
|
6
|
+
@json = JSON.parse(message)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class UserLoginMessage < JsonMessage
|
11
|
+
def initialize(message = '{}')
|
12
|
+
super(message)
|
13
|
+
end
|
14
|
+
|
15
|
+
def session_token
|
16
|
+
@json.dig('user', 'session', 'userSession')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class CobrandLoginMessage < JsonMessage
|
21
|
+
def session_token
|
22
|
+
@json.dig('session', 'cobSession')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/coyodlee/session.rb
CHANGED
@@ -1,43 +1,37 @@
|
|
1
1
|
require_relative 'session_authorization'
|
2
2
|
require_relative 'session_tokens'
|
3
|
+
require_relative 'messages'
|
3
4
|
require 'json'
|
4
5
|
|
5
6
|
module Coyodlee
|
6
7
|
class Session
|
7
|
-
attr_reader :authorization
|
8
8
|
attr_writer :session_token_klass
|
9
9
|
|
10
10
|
class << self
|
11
11
|
def create(request_facade)
|
12
|
-
new(request_facade
|
13
|
-
session_authorization: SessionAuthorization.new).tap do |session|
|
12
|
+
new(request_facade).tap do |session|
|
14
13
|
session.session_token_klass = SessionToken
|
15
14
|
end
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
19
|
-
def initialize(request_facade
|
18
|
+
def initialize(request_facade)
|
20
19
|
@api = request_facade
|
21
|
-
@authorization = session_authorization
|
22
20
|
end
|
23
21
|
|
24
22
|
def login_cobrand(login_name:, password:)
|
25
23
|
@api.login_cobrand(login_name: login_name,
|
26
24
|
password: password).tap do |res|
|
27
|
-
|
28
|
-
|
29
|
-
@authorization.authorize_cobrand(@session_token_klass.new(token))
|
30
|
-
@api.authorize(@authorization)
|
25
|
+
msg = CobrandLoginMessage.new(res.body)
|
26
|
+
@api.authorize_cobrand(msg.session_token)
|
31
27
|
end
|
32
28
|
end
|
33
29
|
|
34
30
|
def login_user(login_name:, password:)
|
35
31
|
@api.login_user(login_name: login_name,
|
36
32
|
password: password).tap do |res|
|
37
|
-
|
38
|
-
|
39
|
-
@authorization.authorize_user(@session_token_klass.new(token))
|
40
|
-
@api.authorize(@authorization)
|
33
|
+
msg = UserLoginMessage.new(res.body)
|
34
|
+
@api.authorize_user(msg.session_token)
|
41
35
|
end
|
42
36
|
end
|
43
37
|
end
|
@@ -6,26 +6,19 @@ module Coyodlee
|
|
6
6
|
# authenticated requests to the Yodlee API
|
7
7
|
class SessionAuthorization
|
8
8
|
# @return [SessionToken] the cobrand session token
|
9
|
-
|
9
|
+
attr_accessor :cobrand_session_token
|
10
10
|
# @return [SessionToken] the user session token
|
11
|
-
|
11
|
+
attr_accessor :user_session_token
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
class << self
|
14
|
+
def create(authorization=NullSessionAuthorization.new)
|
15
|
+
new(cobrand_session_token: authorization.cobrand_session_token,
|
16
|
+
user_session_token: authorization.user_session_token)
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
|
-
|
19
|
-
# @param cobrand_session_token [SessionToken] the cobrand session token
|
20
|
-
# @return [SessionToken] the cobrand session token
|
21
|
-
def authorize_cobrand(cobrand_session_token)
|
20
|
+
def initialize(cobrand_session_token: NullSessionToken.new, user_session_token: NullSessionToken.new)
|
22
21
|
@cobrand_session_token = cobrand_session_token
|
23
|
-
end
|
24
|
-
|
25
|
-
# Sets the user session token
|
26
|
-
# @param user_session_token [SessionToken] the user session token
|
27
|
-
# @return [SessionToken] the user session token
|
28
|
-
def authorize_user(user_session_token)
|
29
22
|
@user_session_token = user_session_token
|
30
23
|
end
|
31
24
|
|
@@ -39,4 +32,14 @@ module Coyodlee
|
|
39
32
|
.join(',')
|
40
33
|
end
|
41
34
|
end
|
35
|
+
|
36
|
+
class NullSessionAuthorization
|
37
|
+
def cobrand_session_token
|
38
|
+
@cobrand_session_token ||= NullSessionToken.new
|
39
|
+
end
|
40
|
+
|
41
|
+
def user_session_token
|
42
|
+
@user_session_token ||= NullSessionToken.new
|
43
|
+
end
|
44
|
+
end
|
42
45
|
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.
|
4
|
+
version: 0.3.0
|
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-
|
11
|
+
date: 2018-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yajl-ruby
|
@@ -222,6 +222,7 @@ files:
|
|
222
222
|
- lib/coyodlee/facades/provider_accounts_facade.rb
|
223
223
|
- lib/coyodlee/facades/transactions_facade.rb
|
224
224
|
- lib/coyodlee/facades/user_facade.rb
|
225
|
+
- lib/coyodlee/messages.rb
|
225
226
|
- lib/coyodlee/session.rb
|
226
227
|
- lib/coyodlee/session_authorization.rb
|
227
228
|
- lib/coyodlee/session_tokens.rb
|