mx-platform-ruby 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +20 -0
- data/.gitignore +13 -0
- data/.rubocop.yml +44 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/README.md +60 -0
- data/Rakefile +11 -0
- data/lib/mx-platform-ruby.rb +44 -0
- data/lib/mx-platform-ruby/account.rb +107 -0
- data/lib/mx-platform-ruby/account_number.rb +57 -0
- data/lib/mx-platform-ruby/account_owner.rb +42 -0
- data/lib/mx-platform-ruby/category.rb +127 -0
- data/lib/mx-platform-ruby/challenge.rb +37 -0
- data/lib/mx-platform-ruby/client.rb +59 -0
- data/lib/mx-platform-ruby/connect_widget.rb +43 -0
- data/lib/mx-platform-ruby/credential.rb +54 -0
- data/lib/mx-platform-ruby/enhanced_transaction.rb +44 -0
- data/lib/mx-platform-ruby/error.rb +6 -0
- data/lib/mx-platform-ruby/holding.rb +87 -0
- data/lib/mx-platform-ruby/institution.rb +78 -0
- data/lib/mx-platform-ruby/member.rb +242 -0
- data/lib/mx-platform-ruby/member_status.rb +35 -0
- data/lib/mx-platform-ruby/merchant.rb +52 -0
- data/lib/mx-platform-ruby/oauth_window.rb +32 -0
- data/lib/mx-platform-ruby/pageable.rb +29 -0
- data/lib/mx-platform-ruby/statement.rb +70 -0
- data/lib/mx-platform-ruby/tag.rb +104 -0
- data/lib/mx-platform-ruby/tagging.rb +107 -0
- data/lib/mx-platform-ruby/transaction.rb +162 -0
- data/lib/mx-platform-ruby/transaction_rule.rb +112 -0
- data/lib/mx-platform-ruby/user.rb +112 -0
- data/lib/mx-platform-ruby/version.rb +5 -0
- data/lib/mx-platform-ruby/widget.rb +49 -0
- data/mx-platform-ruby.gemspec +31 -0
- data/spec/lib/mx-platform-ruby/account_number_spec.rb +100 -0
- data/spec/lib/mx-platform-ruby/account_owner_spec.rb +71 -0
- data/spec/lib/mx-platform-ruby/account_spec.rb +267 -0
- data/spec/lib/mx-platform-ruby/category_spec.rb +244 -0
- data/spec/lib/mx-platform-ruby/challenge_spec.rb +72 -0
- data/spec/lib/mx-platform-ruby/client_spec.rb +101 -0
- data/spec/lib/mx-platform-ruby/connect_widget_spec.rb +66 -0
- data/spec/lib/mx-platform-ruby/credential_spec.rb +90 -0
- data/spec/lib/mx-platform-ruby/enhanced_transaction_spec.rb +89 -0
- data/spec/lib/mx-platform-ruby/holding_spec.rb +178 -0
- data/spec/lib/mx-platform-ruby/institution_spec.rb +141 -0
- data/spec/lib/mx-platform-ruby/member_spec.rb +557 -0
- data/spec/lib/mx-platform-ruby/member_status_spec.rb +76 -0
- data/spec/lib/mx-platform-ruby/merchant_spec.rb +89 -0
- data/spec/lib/mx-platform-ruby/oauth_window_spec.rb +47 -0
- data/spec/lib/mx-platform-ruby/pageable_spec.rb +75 -0
- data/spec/lib/mx-platform-ruby/statement_spec.rb +130 -0
- data/spec/lib/mx-platform-ruby/tag_spec.rb +179 -0
- data/spec/lib/mx-platform-ruby/tagging_spec.rb +191 -0
- data/spec/lib/mx-platform-ruby/transaction_rule_spec.rb +207 -0
- data/spec/lib/mx-platform-ruby/transaction_spec.rb +449 -0
- data/spec/lib/mx-platform-ruby/user_spec.rb +196 -0
- data/spec/lib/mx-platform-ruby/widget_spec.rb +76 -0
- data/spec/lib/mx-platform-ruby_spec.rb +15 -0
- data/spec/sample.pdf +0 -0
- data/spec/spec_helper.rb +24 -0
- metadata +63 -3
@@ -0,0 +1,90 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe ::MXPlatformRuby::Credential do
|
6
|
+
let(:credential_attributes) do
|
7
|
+
{
|
8
|
+
display_order: 1,
|
9
|
+
field_name: 'LOGIN',
|
10
|
+
field_type: 'TEXT',
|
11
|
+
guid: 'CRD-1ec152cd-e628-e81a-e852-d1e7104624da',
|
12
|
+
label: 'Username'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
let(:list_institution_required_credentials_options) do
|
16
|
+
{
|
17
|
+
institution_code: 'chase',
|
18
|
+
page: 1,
|
19
|
+
records_per_page: 10
|
20
|
+
}
|
21
|
+
end
|
22
|
+
let(:list_member_credentials_options) do
|
23
|
+
{
|
24
|
+
member_guid: 'MBR-7c6f361b-e582-15b6-60c0-358f12466b4b',
|
25
|
+
page: 1,
|
26
|
+
records_per_page: 10,
|
27
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
28
|
+
}
|
29
|
+
end
|
30
|
+
let(:pagination_attributes) do
|
31
|
+
{
|
32
|
+
'current_page' => 1,
|
33
|
+
'per_page' => 25,
|
34
|
+
'total_pages' => 1,
|
35
|
+
'total_entries' => 1
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'list_institution_required_credentials endpoints' do
|
40
|
+
let(:list_institution_required_credentials_response) do
|
41
|
+
{
|
42
|
+
'credentials' => [credential_attributes],
|
43
|
+
'pagination' => pagination_attributes
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(list_institution_required_credentials_response) }
|
48
|
+
|
49
|
+
describe 'list_institution_required_credentials' do
|
50
|
+
it 'returns a list of credentials' do
|
51
|
+
response = described_class.list_institution_required_credentials
|
52
|
+
|
53
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Page)
|
54
|
+
expect(response.first).to be_kind_of(::MXPlatformRuby::Credential)
|
55
|
+
expect(response.first.display_order).to eq(credential_attributes[:display_order])
|
56
|
+
expect(response.first.field_name).to eq(credential_attributes[:field_name])
|
57
|
+
expect(response.first.field_type).to eq(credential_attributes[:field_type])
|
58
|
+
expect(response.first.guid).to eq(credential_attributes[:guid])
|
59
|
+
expect(response.first.label).to eq(credential_attributes[:label])
|
60
|
+
expect(response.length).to eq(1)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'list_member_credentials endpoints' do
|
66
|
+
let(:list_member_credentials_response) do
|
67
|
+
{
|
68
|
+
'credentials' => [credential_attributes],
|
69
|
+
'pagination' => pagination_attributes
|
70
|
+
}
|
71
|
+
end
|
72
|
+
|
73
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(list_member_credentials_response) }
|
74
|
+
|
75
|
+
describe 'list_member_credentials' do
|
76
|
+
it 'returns a list of credentials' do
|
77
|
+
response = described_class.list_member_credentials
|
78
|
+
|
79
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Page)
|
80
|
+
expect(response.first).to be_kind_of(::MXPlatformRuby::Credential)
|
81
|
+
expect(response.first.display_order).to eq(credential_attributes[:display_order])
|
82
|
+
expect(response.first.field_name).to eq(credential_attributes[:field_name])
|
83
|
+
expect(response.first.field_type).to eq(credential_attributes[:field_type])
|
84
|
+
expect(response.first.guid).to eq(credential_attributes[:guid])
|
85
|
+
expect(response.first.label).to eq(credential_attributes[:label])
|
86
|
+
expect(response.length).to eq(1)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe ::MXPlatformRuby::EnhancedTransaction do
|
6
|
+
let(:enhanced_transaction_attributes) do
|
7
|
+
{
|
8
|
+
amount: 21.33,
|
9
|
+
category: 'Fast Food',
|
10
|
+
description: 'IN-N-OUT BURGER',
|
11
|
+
id: 'ID-123',
|
12
|
+
is_bill_pay: false,
|
13
|
+
is_direct_deposit: false,
|
14
|
+
is_expense: false,
|
15
|
+
is_fee: false,
|
16
|
+
is_income: false,
|
17
|
+
is_international: false,
|
18
|
+
is_overdraft_fee: false,
|
19
|
+
is_payroll_advance: false,
|
20
|
+
merchant_category_code: 5411,
|
21
|
+
merchant_guid: 'MCH-7ed79542-884d-2b1b-dd74-501c5cc9d25b',
|
22
|
+
original_description: 'IN-N-OUT BURGER',
|
23
|
+
type: 'DEBIT'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
let(:enhance_transactions_options) do
|
27
|
+
{
|
28
|
+
transactions: [
|
29
|
+
{
|
30
|
+
amount: 21.33,
|
31
|
+
description: 'IN-N-OUT BURGER',
|
32
|
+
id: 'ID-123',
|
33
|
+
merchant_category_code: 123,
|
34
|
+
type: 'DEBIT'
|
35
|
+
}
|
36
|
+
]
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
describe 'enhance_transactions' do
|
41
|
+
let(:enhance_transactions_response) { { 'transactions' => [enhanced_transaction_attributes] } }
|
42
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(enhance_transactions_response) }
|
43
|
+
|
44
|
+
it 'returns an array of enhanced_transactions' do
|
45
|
+
response = described_class.enhance_transactions
|
46
|
+
|
47
|
+
expect(response).to be_kind_of(::Array)
|
48
|
+
expect(response.first).to be_kind_of(::MXPlatformRuby::EnhancedTransaction)
|
49
|
+
expect(response.first.amount).to eq(enhanced_transaction_attributes[:amount])
|
50
|
+
expect(response.first.category).to eq(enhanced_transaction_attributes[:category])
|
51
|
+
expect(response.first.description).to eq(enhanced_transaction_attributes[:description])
|
52
|
+
expect(response.first.id).to eq(enhanced_transaction_attributes[:id])
|
53
|
+
expect(response.first.is_bill_pay).to eq(enhanced_transaction_attributes[:is_bill_pay])
|
54
|
+
expect(response.first.is_direct_deposit).to eq(enhanced_transaction_attributes[:is_direct_deposit])
|
55
|
+
expect(response.first.is_expense).to eq(enhanced_transaction_attributes[:is_expense])
|
56
|
+
expect(response.first.is_fee).to eq(enhanced_transaction_attributes[:is_fee])
|
57
|
+
expect(response.first.is_income).to eq(enhanced_transaction_attributes[:is_income])
|
58
|
+
expect(response.first.is_international).to eq(enhanced_transaction_attributes[:is_international])
|
59
|
+
expect(response.first.is_overdraft_fee).to eq(enhanced_transaction_attributes[:is_overdraft_fee])
|
60
|
+
expect(response.first.is_payroll_advance).to eq(enhanced_transaction_attributes[:is_payroll_advance])
|
61
|
+
expect(response.first.merchant_category_code).to eq(enhanced_transaction_attributes[:merchant_category_code])
|
62
|
+
expect(response.first.merchant_guid).to eq(enhanced_transaction_attributes[:merchant_guid])
|
63
|
+
expect(response.first.original_description).to eq(enhanced_transaction_attributes[:original_description])
|
64
|
+
expect(response.first.type).to eq(enhanced_transaction_attributes[:type])
|
65
|
+
expect(response.length).to eq(1)
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'makes a client request with the expected params' do
|
69
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
70
|
+
{
|
71
|
+
endpoint: '/transactions/enhance',
|
72
|
+
http_method: :post,
|
73
|
+
request_body: {
|
74
|
+
transactions: [
|
75
|
+
{
|
76
|
+
amount: 21.33,
|
77
|
+
description: 'IN-N-OUT BURGER',
|
78
|
+
id: 'ID-123',
|
79
|
+
merchant_category_code: 123,
|
80
|
+
type: 'DEBIT'
|
81
|
+
}
|
82
|
+
]
|
83
|
+
}
|
84
|
+
}
|
85
|
+
)
|
86
|
+
described_class.enhance_transactions(enhance_transactions_options)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,178 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe ::MXPlatformRuby::Holding do
|
6
|
+
let(:holding_attributes) do
|
7
|
+
{
|
8
|
+
account_guid: 'HOL-d65683e8-9eab-26bb-bcfd-ced159c9abe2',
|
9
|
+
cost_basis: 827.0,
|
10
|
+
created_at: '2015-04-13T18:01:23.000Z',
|
11
|
+
currency_code: 'USD',
|
12
|
+
cusip: '18383M878',
|
13
|
+
daily_change: 2.5,
|
14
|
+
description: 'Guggenheim Defensive Equity ETF',
|
15
|
+
guid: 'HOL-d65683e8-9eab-26bb-bcfd-ced159c9abe2',
|
16
|
+
holding_type: 'MONEY_MARKET',
|
17
|
+
id: 'ID-123',
|
18
|
+
market_value: 989.5,
|
19
|
+
member_guid: 'MBR-d65683e8-9eab-26bb-bcfd-ced159c9abe',
|
20
|
+
metadata: 'metadata',
|
21
|
+
purchase_price: 26.3,
|
22
|
+
shares: 6.0,
|
23
|
+
symbol: 'DEF',
|
24
|
+
updated_at: '2015-04-13T18:01:23.000Z',
|
25
|
+
user_guid: 'USR-743e5d7f-1116-28fa-5de1-d3ba02e41d8d'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
let(:list_holdings_by_member_options) do
|
29
|
+
{
|
30
|
+
from_date: '2015-09-20',
|
31
|
+
member_guid: 'MBR-7c6f361b-e582-15b6-60c0-358f12466b4b',
|
32
|
+
page: 1,
|
33
|
+
records_per_page: 10,
|
34
|
+
to_date: '2019-10-20',
|
35
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
let(:list_holdings_by_user_options) do
|
39
|
+
{
|
40
|
+
from_date: '2015-09-20',
|
41
|
+
page: 1,
|
42
|
+
records_per_page: 10,
|
43
|
+
to_date: '2019-10-20',
|
44
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
45
|
+
}
|
46
|
+
end
|
47
|
+
let(:read_holding_options) do
|
48
|
+
{
|
49
|
+
holding_guid: 'HOL-d65683e8-9eab-26bb-bcfd-ced159c9abe2',
|
50
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
51
|
+
}
|
52
|
+
end
|
53
|
+
let(:pagination_attributes) do
|
54
|
+
{
|
55
|
+
'current_page' => 1,
|
56
|
+
'per_page' => 25,
|
57
|
+
'total_pages' => 1,
|
58
|
+
'total_entries' => 1
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'list_holdings_by_member endpoints' do
|
63
|
+
let(:list_holdings_by_member_response) do
|
64
|
+
{
|
65
|
+
'holdings' => [holding_attributes],
|
66
|
+
'pagination' => pagination_attributes
|
67
|
+
}
|
68
|
+
end
|
69
|
+
|
70
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(list_holdings_by_member_response) }
|
71
|
+
|
72
|
+
describe 'list_holdings_by_member' do
|
73
|
+
it 'returns a list of holdings' do
|
74
|
+
response = described_class.list_holdings_by_member
|
75
|
+
|
76
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Page)
|
77
|
+
expect(response.first).to be_kind_of(::MXPlatformRuby::Holding)
|
78
|
+
expect(response.first.account_guid).to eq(holding_attributes[:account_guid])
|
79
|
+
expect(response.first.cost_basis).to eq(holding_attributes[:cost_basis])
|
80
|
+
expect(response.first.created_at).to eq(holding_attributes[:created_at])
|
81
|
+
expect(response.first.currency_code).to eq(holding_attributes[:currency_code])
|
82
|
+
expect(response.first.cusip).to eq(holding_attributes[:cusip])
|
83
|
+
expect(response.first.daily_change).to eq(holding_attributes[:daily_change])
|
84
|
+
expect(response.first.description).to eq(holding_attributes[:description])
|
85
|
+
expect(response.first.guid).to eq(holding_attributes[:guid])
|
86
|
+
expect(response.first.holding_type).to eq(holding_attributes[:holding_type])
|
87
|
+
expect(response.first.id).to eq(holding_attributes[:id])
|
88
|
+
expect(response.first.market_value).to eq(holding_attributes[:market_value])
|
89
|
+
expect(response.first.member_guid).to eq(holding_attributes[:member_guid])
|
90
|
+
expect(response.first.metadata).to eq(holding_attributes[:metadata])
|
91
|
+
expect(response.first.purchase_price).to eq(holding_attributes[:purchase_price])
|
92
|
+
expect(response.first.shares).to eq(holding_attributes[:shares])
|
93
|
+
expect(response.first.symbol).to eq(holding_attributes[:symbol])
|
94
|
+
expect(response.first.updated_at).to eq(holding_attributes[:updated_at])
|
95
|
+
expect(response.first.user_guid).to eq(holding_attributes[:user_guid])
|
96
|
+
expect(response.length).to eq(1)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'list_holdings_by_user endpoints' do
|
102
|
+
let(:list_holdings_by_user_response) do
|
103
|
+
{
|
104
|
+
'holdings' => [holding_attributes],
|
105
|
+
'pagination' => pagination_attributes
|
106
|
+
}
|
107
|
+
end
|
108
|
+
|
109
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(list_holdings_by_user_response) }
|
110
|
+
|
111
|
+
describe 'list_holdings_by_user' do
|
112
|
+
it 'returns a list of holdings' do
|
113
|
+
response = described_class.list_holdings_by_user
|
114
|
+
|
115
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Page)
|
116
|
+
expect(response.first).to be_kind_of(::MXPlatformRuby::Holding)
|
117
|
+
expect(response.first.account_guid).to eq(holding_attributes[:account_guid])
|
118
|
+
expect(response.first.cost_basis).to eq(holding_attributes[:cost_basis])
|
119
|
+
expect(response.first.created_at).to eq(holding_attributes[:created_at])
|
120
|
+
expect(response.first.currency_code).to eq(holding_attributes[:currency_code])
|
121
|
+
expect(response.first.cusip).to eq(holding_attributes[:cusip])
|
122
|
+
expect(response.first.daily_change).to eq(holding_attributes[:daily_change])
|
123
|
+
expect(response.first.description).to eq(holding_attributes[:description])
|
124
|
+
expect(response.first.guid).to eq(holding_attributes[:guid])
|
125
|
+
expect(response.first.holding_type).to eq(holding_attributes[:holding_type])
|
126
|
+
expect(response.first.id).to eq(holding_attributes[:id])
|
127
|
+
expect(response.first.market_value).to eq(holding_attributes[:market_value])
|
128
|
+
expect(response.first.member_guid).to eq(holding_attributes[:member_guid])
|
129
|
+
expect(response.first.metadata).to eq(holding_attributes[:metadata])
|
130
|
+
expect(response.first.purchase_price).to eq(holding_attributes[:purchase_price])
|
131
|
+
expect(response.first.shares).to eq(holding_attributes[:shares])
|
132
|
+
expect(response.first.symbol).to eq(holding_attributes[:symbol])
|
133
|
+
expect(response.first.updated_at).to eq(holding_attributes[:updated_at])
|
134
|
+
expect(response.first.user_guid).to eq(holding_attributes[:user_guid])
|
135
|
+
expect(response.length).to eq(1)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
describe 'read_holding' do
|
141
|
+
let(:read_holding_response) { { 'holding' => holding_attributes } }
|
142
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(read_holding_response) }
|
143
|
+
|
144
|
+
it 'returns holding' do
|
145
|
+
response = described_class.read_holding
|
146
|
+
|
147
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Holding)
|
148
|
+
expect(response.account_guid).to eq(holding_attributes[:account_guid])
|
149
|
+
expect(response.cost_basis).to eq(holding_attributes[:cost_basis])
|
150
|
+
expect(response.created_at).to eq(holding_attributes[:created_at])
|
151
|
+
expect(response.currency_code).to eq(holding_attributes[:currency_code])
|
152
|
+
expect(response.cusip).to eq(holding_attributes[:cusip])
|
153
|
+
expect(response.daily_change).to eq(holding_attributes[:daily_change])
|
154
|
+
expect(response.description).to eq(holding_attributes[:description])
|
155
|
+
expect(response.guid).to eq(holding_attributes[:guid])
|
156
|
+
expect(response.holding_type).to eq(holding_attributes[:holding_type])
|
157
|
+
expect(response.id).to eq(holding_attributes[:id])
|
158
|
+
expect(response.market_value).to eq(holding_attributes[:market_value])
|
159
|
+
expect(response.member_guid).to eq(holding_attributes[:member_guid])
|
160
|
+
expect(response.metadata).to eq(holding_attributes[:metadata])
|
161
|
+
expect(response.purchase_price).to eq(holding_attributes[:purchase_price])
|
162
|
+
expect(response.shares).to eq(holding_attributes[:shares])
|
163
|
+
expect(response.symbol).to eq(holding_attributes[:symbol])
|
164
|
+
expect(response.updated_at).to eq(holding_attributes[:updated_at])
|
165
|
+
expect(response.user_guid).to eq(holding_attributes[:user_guid])
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'makes a client request with the expected params' do
|
169
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
170
|
+
{
|
171
|
+
endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/holdings/HOL-d65683e8-9eab-26bb-bcfd-ced159c9abe2',
|
172
|
+
http_method: :get
|
173
|
+
}
|
174
|
+
)
|
175
|
+
described_class.read_holding(read_holding_options)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe ::MXPlatformRuby::Institution do
|
6
|
+
let(:institution_attributes) do
|
7
|
+
{
|
8
|
+
code: 'chase',
|
9
|
+
medium_logo_url: 'https://content.moneydesktop.com/storage/MD_Assets/Ipad%20Logos/100x100/default_100x100.png',
|
10
|
+
name: 'Chase Bank',
|
11
|
+
small_logo_url: 'https://content.moneydesktop.com/storage/MD_Assets/Ipad%20Logos/50x50/default_50x50.png',
|
12
|
+
supports_account_identification: true,
|
13
|
+
supports_account_statement: true,
|
14
|
+
supports_account_verification: true,
|
15
|
+
supports_oauth: true,
|
16
|
+
supports_transaction_history: true,
|
17
|
+
url: 'https://www.chase.com'
|
18
|
+
}
|
19
|
+
end
|
20
|
+
let(:list_favorites_options) do
|
21
|
+
{
|
22
|
+
page: 1,
|
23
|
+
records_per_page: 10
|
24
|
+
}
|
25
|
+
end
|
26
|
+
let(:list_institutions_options) do
|
27
|
+
{
|
28
|
+
name: 'chase',
|
29
|
+
supports_account_identification: true,
|
30
|
+
supports_account_statement: true,
|
31
|
+
supports_account_verification: true,
|
32
|
+
supports_transaction_history: true
|
33
|
+
}
|
34
|
+
end
|
35
|
+
let(:read_institution_options) do
|
36
|
+
{
|
37
|
+
institution_code: 'chase'
|
38
|
+
}
|
39
|
+
end
|
40
|
+
let(:pagination_attributes) do
|
41
|
+
{
|
42
|
+
'current_page' => 1,
|
43
|
+
'per_page' => 25,
|
44
|
+
'total_pages' => 1,
|
45
|
+
'total_entries' => 1
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'list_favorites endpoints' do
|
50
|
+
let(:list_favorites_response) do
|
51
|
+
{
|
52
|
+
'institutions' => [institution_attributes],
|
53
|
+
'pagination' => pagination_attributes
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(list_favorites_response) }
|
58
|
+
|
59
|
+
describe 'list_favorites' do
|
60
|
+
it 'returns a list of institutions' do
|
61
|
+
response = described_class.list_favorites
|
62
|
+
|
63
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Page)
|
64
|
+
expect(response.first).to be_kind_of(::MXPlatformRuby::Institution)
|
65
|
+
expect(response.first.code).to eq(institution_attributes[:code])
|
66
|
+
expect(response.first.medium_logo_url).to eq(institution_attributes[:medium_logo_url])
|
67
|
+
expect(response.first.name).to eq(institution_attributes[:name])
|
68
|
+
expect(response.first.small_logo_url).to eq(institution_attributes[:small_logo_url])
|
69
|
+
expect(response.first.supports_account_identification).to eq(institution_attributes[:supports_account_identification])
|
70
|
+
expect(response.first.supports_account_statement).to eq(institution_attributes[:supports_account_statement])
|
71
|
+
expect(response.first.supports_account_verification).to eq(institution_attributes[:supports_account_verification])
|
72
|
+
expect(response.first.supports_oauth).to eq(institution_attributes[:supports_oauth])
|
73
|
+
expect(response.first.supports_transaction_history).to eq(institution_attributes[:supports_transaction_history])
|
74
|
+
expect(response.first.url).to eq(institution_attributes[:url])
|
75
|
+
expect(response.length).to eq(1)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'list_institutions endpoints' do
|
81
|
+
let(:list_institutions_response) do
|
82
|
+
{
|
83
|
+
'institutions' => [institution_attributes],
|
84
|
+
'pagination' => pagination_attributes
|
85
|
+
}
|
86
|
+
end
|
87
|
+
|
88
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(list_institutions_response) }
|
89
|
+
|
90
|
+
describe 'list_institutions' do
|
91
|
+
it 'returns a list of institutions' do
|
92
|
+
response = described_class.list_institutions
|
93
|
+
|
94
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Page)
|
95
|
+
expect(response.first).to be_kind_of(::MXPlatformRuby::Institution)
|
96
|
+
expect(response.first.code).to eq(institution_attributes[:code])
|
97
|
+
expect(response.first.medium_logo_url).to eq(institution_attributes[:medium_logo_url])
|
98
|
+
expect(response.first.name).to eq(institution_attributes[:name])
|
99
|
+
expect(response.first.small_logo_url).to eq(institution_attributes[:small_logo_url])
|
100
|
+
expect(response.first.supports_account_identification).to eq(institution_attributes[:supports_account_identification])
|
101
|
+
expect(response.first.supports_account_statement).to eq(institution_attributes[:supports_account_statement])
|
102
|
+
expect(response.first.supports_account_verification).to eq(institution_attributes[:supports_account_verification])
|
103
|
+
expect(response.first.supports_oauth).to eq(institution_attributes[:supports_oauth])
|
104
|
+
expect(response.first.supports_transaction_history).to eq(institution_attributes[:supports_transaction_history])
|
105
|
+
expect(response.first.url).to eq(institution_attributes[:url])
|
106
|
+
expect(response.length).to eq(1)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
describe 'read_institution' do
|
112
|
+
let(:read_institution_response) { { 'institution' => institution_attributes } }
|
113
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(read_institution_response) }
|
114
|
+
|
115
|
+
it 'returns institution' do
|
116
|
+
response = described_class.read_institution
|
117
|
+
|
118
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Institution)
|
119
|
+
expect(response.code).to eq(institution_attributes[:code])
|
120
|
+
expect(response.medium_logo_url).to eq(institution_attributes[:medium_logo_url])
|
121
|
+
expect(response.name).to eq(institution_attributes[:name])
|
122
|
+
expect(response.small_logo_url).to eq(institution_attributes[:small_logo_url])
|
123
|
+
expect(response.supports_account_identification).to eq(institution_attributes[:supports_account_identification])
|
124
|
+
expect(response.supports_account_statement).to eq(institution_attributes[:supports_account_statement])
|
125
|
+
expect(response.supports_account_verification).to eq(institution_attributes[:supports_account_verification])
|
126
|
+
expect(response.supports_oauth).to eq(institution_attributes[:supports_oauth])
|
127
|
+
expect(response.supports_transaction_history).to eq(institution_attributes[:supports_transaction_history])
|
128
|
+
expect(response.url).to eq(institution_attributes[:url])
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'makes a client request with the expected params' do
|
132
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
133
|
+
{
|
134
|
+
endpoint: '/institutions/chase',
|
135
|
+
http_method: :get
|
136
|
+
}
|
137
|
+
)
|
138
|
+
described_class.read_institution(read_institution_options)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|