coyodlee 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +10 -1
- data/Gemfile +1 -0
- data/README.md +29 -30
- data/coyodlee.gemspec +5 -1
- data/examples/demo.rb +23 -0
- data/lib/coyodlee.rb +6 -5
- data/lib/coyodlee/connection.rb +207 -0
- data/lib/coyodlee/facades.rb +6 -0
- data/lib/coyodlee/facades/accounts_facade.rb +52 -0
- data/lib/coyodlee/facades/cobrand_facade.rb +32 -0
- data/lib/coyodlee/facades/holdings_facade.rb +33 -0
- data/lib/coyodlee/facades/provider_accounts_facade.rb +52 -0
- data/lib/coyodlee/facades/transactions_facade.rb +88 -0
- data/lib/coyodlee/facades/user_facade.rb +39 -0
- data/lib/coyodlee/session.rb +46 -0
- data/lib/coyodlee/session_authorization.rb +25 -0
- data/lib/coyodlee/session_tokens.rb +39 -0
- data/lib/coyodlee/uri_builder.rb +26 -0
- data/lib/coyodlee/version.rb +1 -1
- metadata +75 -12
- data/lib/coyodlee/client.rb +0 -550
- data/lib/coyodlee/http_wrapper.rb +0 -27
- data/lib/coyodlee/sessions.rb +0 -2
- data/lib/coyodlee/sessions/cobrand_session.rb +0 -50
- data/lib/coyodlee/sessions/user_session.rb +0 -60
- data/lib/coyodlee/utils.rb +0 -26
@@ -1,27 +0,0 @@
|
|
1
|
-
require "rest-client"
|
2
|
-
|
3
|
-
module Coyodlee
|
4
|
-
module HttpWrapper
|
5
|
-
class << self
|
6
|
-
def get(url:, params: {}, headers: {})
|
7
|
-
if params.empty?
|
8
|
-
RestClient.get(url, headers)
|
9
|
-
else
|
10
|
-
RestClient.get(url, { params: params }.merge(headers))
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def post(url:, body:, headers: {})
|
15
|
-
RestClient.post(url, body, headers)
|
16
|
-
end
|
17
|
-
|
18
|
-
def put(url:, body:, headers: {})
|
19
|
-
RestClient.put(url, body, headers)
|
20
|
-
end
|
21
|
-
|
22
|
-
def delete(url:, headers: {})
|
23
|
-
RestClient.delete(url, nil, headers)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/lib/coyodlee/sessions.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module Coyodlee
|
4
|
-
module Sessions
|
5
|
-
class CobrandSession
|
6
|
-
# Holds the cobrand session token
|
7
|
-
#
|
8
|
-
# @return [String] the cobrand session token
|
9
|
-
attr_reader :token
|
10
|
-
|
11
|
-
# Creates a new cobrand session
|
12
|
-
def initialize
|
13
|
-
@token = ''
|
14
|
-
end
|
15
|
-
|
16
|
-
# Initiates a cobrand session
|
17
|
-
#
|
18
|
-
# @return the underlying response object for the HTTP client you've selected, RestClient by default
|
19
|
-
def login(login_name:, password:)
|
20
|
-
HttpWrapper.post(
|
21
|
-
url: "#{::Coyodlee.base_url}/cobrand/login",
|
22
|
-
body: {
|
23
|
-
cobrand: {
|
24
|
-
cobrandLogin: login_name,
|
25
|
-
cobrandPassword: password,
|
26
|
-
locale: 'en_US'
|
27
|
-
}
|
28
|
-
}.to_json,
|
29
|
-
headers: { content_type: :json, accept: :json }
|
30
|
-
).tap { |response|
|
31
|
-
@token = JSON.parse(response.body)['session']['cobSession']
|
32
|
-
}
|
33
|
-
end
|
34
|
-
|
35
|
-
# Returns a string containing the cobrand session token which can be used as the value of the Authorization HTTP header
|
36
|
-
def auth_header
|
37
|
-
@token.empty? ? '' : "cobSession=#{@token}"
|
38
|
-
end
|
39
|
-
|
40
|
-
# Terminates the cobrand session
|
41
|
-
#
|
42
|
-
# @return the underlying response object for the HTTP client you've selected, RestClient by default
|
43
|
-
def logout
|
44
|
-
HttpWrapper.post(
|
45
|
-
url: "#{::Coyodlee.base_url}/cobrand/logout"
|
46
|
-
)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
module Coyodlee
|
4
|
-
module Sessions
|
5
|
-
class UserSession
|
6
|
-
# Holds the user session token
|
7
|
-
#
|
8
|
-
# @return [String] the user session token
|
9
|
-
attr_reader :token
|
10
|
-
|
11
|
-
# Creates a new user session
|
12
|
-
#
|
13
|
-
# @param cobrand_session [CobrandSession] the cobrand session
|
14
|
-
def initialize(cobrand_session:)
|
15
|
-
@token = ''
|
16
|
-
@cobrand_session = cobrand_session
|
17
|
-
end
|
18
|
-
|
19
|
-
# Initiates a user session. If the login is successful, the {#token} will be
|
20
|
-
# set
|
21
|
-
#
|
22
|
-
# @param login_name [String] the login name of the user
|
23
|
-
# @param password [String] the password of the user
|
24
|
-
# @return the underlying response object for the HTTP client you've selected, RestClient by default
|
25
|
-
def login(login_name:, password:)
|
26
|
-
HttpWrapper.post(
|
27
|
-
url: "#{::Coyodlee.base_url}/user/login",
|
28
|
-
body: {
|
29
|
-
user: {
|
30
|
-
loginName: login_name,
|
31
|
-
password: password,
|
32
|
-
locale: 'en_US'
|
33
|
-
}
|
34
|
-
}.to_json,
|
35
|
-
headers: {
|
36
|
-
content_type: :json,
|
37
|
-
accept: :json,
|
38
|
-
authorization: @cobrand_session.auth_header
|
39
|
-
}
|
40
|
-
).tap { |response|
|
41
|
-
@token = JSON.parse(response.body)['user']['session']['userSession']
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
# Returns a string containing the cobrand session token and the user session token which can be used as the value of the Authorization HTTP header
|
46
|
-
def auth_header
|
47
|
-
@token.empty? ? '' : "cobSession=#{@cobrand_session.token},userSession=#{@token}"
|
48
|
-
end
|
49
|
-
|
50
|
-
# Terminates the user session
|
51
|
-
#
|
52
|
-
# @return the underlying response object for the HTTP client you've selected, RestClient by default
|
53
|
-
def logout
|
54
|
-
HttpWrapper.post(
|
55
|
-
url: "#{::Coyodlee.base_url}/user/logout"
|
56
|
-
)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
data/lib/coyodlee/utils.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
module Coyodlee
|
2
|
-
module Utils
|
3
|
-
# Converts a string to camel-case with the first letter uncapitalized
|
4
|
-
# @param str [String] The string to modify
|
5
|
-
# @return [String] The string as camel-cased with the first letter uncapitalized
|
6
|
-
def uncapitalized_camelize(str)
|
7
|
-
str
|
8
|
-
.split('_')
|
9
|
-
.map { |w| w.capitalize }
|
10
|
-
.join
|
11
|
-
.tap { |w| w[0] = w[0].downcase }
|
12
|
-
end
|
13
|
-
|
14
|
-
def sub_underscore(str)
|
15
|
-
str.sub(/^_/, '')
|
16
|
-
end
|
17
|
-
|
18
|
-
def sub_double_underscore(str)
|
19
|
-
str.gsub(/__/, '.')
|
20
|
-
end
|
21
|
-
|
22
|
-
def build_url(path)
|
23
|
-
::Coyodlee.base_url.to_s + path
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|