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,244 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe ::MXPlatformRuby::Category do
|
6
|
+
let(:category_attributes) do
|
7
|
+
{
|
8
|
+
created_at: '2015-04-13T18:01:23.000Z',
|
9
|
+
guid: 'CAT-7829f71c-2e8c-afa5-2f55-fa3634b89874',
|
10
|
+
is_default: true,
|
11
|
+
is_income: false,
|
12
|
+
metadata: 'some metadata',
|
13
|
+
name: 'Auto Insurance',
|
14
|
+
parent_guid: 'CAT-7829f71c-2e8c-afa5-2f55-fa3634b89874',
|
15
|
+
updated_at: '2015-05-13T18:01:23.000Z'
|
16
|
+
}
|
17
|
+
end
|
18
|
+
let(:create_category_options) do
|
19
|
+
{
|
20
|
+
metadata: 'some metadata',
|
21
|
+
name: 'Online Shopping',
|
22
|
+
parent_guid: 'CAT-aad51b46-d6f7-3da5-fd6e-492328b3023f',
|
23
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
let(:delete_category_options) do
|
27
|
+
{
|
28
|
+
category_guid: 'CAT-7829f71c-2e8c-afa5-2f55-fa3634b89874',
|
29
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
let(:list_categories_options) do
|
33
|
+
{
|
34
|
+
page: 1,
|
35
|
+
records_per_page: 10,
|
36
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
37
|
+
}
|
38
|
+
end
|
39
|
+
let(:list_default_categories_options) do
|
40
|
+
{
|
41
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
let(:read_category_options) do
|
45
|
+
{
|
46
|
+
category_guid: 'CAT-7829f71c-2e8c-afa5-2f55-fa3634b89874',
|
47
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
48
|
+
}
|
49
|
+
end
|
50
|
+
let(:update_category_options) do
|
51
|
+
{
|
52
|
+
category_guid: 'CAT-7829f71c-2e8c-afa5-2f55-fa3634b89874',
|
53
|
+
metadata: 'some metadata',
|
54
|
+
name: 'Web shopping',
|
55
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
56
|
+
}
|
57
|
+
end
|
58
|
+
let(:pagination_attributes) do
|
59
|
+
{
|
60
|
+
'current_page' => 1,
|
61
|
+
'per_page' => 25,
|
62
|
+
'total_pages' => 1,
|
63
|
+
'total_entries' => 1
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
describe 'create_category' do
|
68
|
+
let(:create_category_response) { { 'category' => category_attributes } }
|
69
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(create_category_response) }
|
70
|
+
|
71
|
+
it 'returns category' do
|
72
|
+
response = described_class.create_category
|
73
|
+
|
74
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Category)
|
75
|
+
expect(response.created_at).to eq(category_attributes[:created_at])
|
76
|
+
expect(response.guid).to eq(category_attributes[:guid])
|
77
|
+
expect(response.is_default).to eq(category_attributes[:is_default])
|
78
|
+
expect(response.is_income).to eq(category_attributes[:is_income])
|
79
|
+
expect(response.metadata).to eq(category_attributes[:metadata])
|
80
|
+
expect(response.name).to eq(category_attributes[:name])
|
81
|
+
expect(response.parent_guid).to eq(category_attributes[:parent_guid])
|
82
|
+
expect(response.updated_at).to eq(category_attributes[:updated_at])
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'makes a client request with the expected params' do
|
86
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
87
|
+
{
|
88
|
+
endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/categories',
|
89
|
+
http_method: :post,
|
90
|
+
request_body: {
|
91
|
+
category: {
|
92
|
+
metadata: 'some metadata',
|
93
|
+
name: 'Online Shopping',
|
94
|
+
parent_guid: 'CAT-aad51b46-d6f7-3da5-fd6e-492328b3023f'
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
)
|
99
|
+
described_class.create_category(create_category_options)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe 'delete_category' do
|
104
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(nil) }
|
105
|
+
|
106
|
+
it 'returns nil' do
|
107
|
+
response = described_class.delete_category
|
108
|
+
|
109
|
+
expect(response).to be(nil)
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'makes a client request with the expected params' do
|
113
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
114
|
+
{
|
115
|
+
endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/categories/CAT-7829f71c-2e8c-afa5-2f55-fa3634b89874',
|
116
|
+
http_method: :delete
|
117
|
+
}
|
118
|
+
)
|
119
|
+
described_class.delete_category(delete_category_options)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
context 'list_categories endpoints' do
|
124
|
+
let(:list_categories_response) do
|
125
|
+
{
|
126
|
+
'categories' => [category_attributes],
|
127
|
+
'pagination' => pagination_attributes
|
128
|
+
}
|
129
|
+
end
|
130
|
+
|
131
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(list_categories_response) }
|
132
|
+
|
133
|
+
describe 'list_categories' do
|
134
|
+
it 'returns a list of categorys' do
|
135
|
+
response = described_class.list_categories
|
136
|
+
|
137
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Page)
|
138
|
+
expect(response.first).to be_kind_of(::MXPlatformRuby::Category)
|
139
|
+
expect(response.first.created_at).to eq(category_attributes[:created_at])
|
140
|
+
expect(response.first.guid).to eq(category_attributes[:guid])
|
141
|
+
expect(response.first.is_default).to eq(category_attributes[:is_default])
|
142
|
+
expect(response.first.is_income).to eq(category_attributes[:is_income])
|
143
|
+
expect(response.first.metadata).to eq(category_attributes[:metadata])
|
144
|
+
expect(response.first.name).to eq(category_attributes[:name])
|
145
|
+
expect(response.first.parent_guid).to eq(category_attributes[:parent_guid])
|
146
|
+
expect(response.first.updated_at).to eq(category_attributes[:updated_at])
|
147
|
+
expect(response.length).to eq(1)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
context 'list_default_categories endpoints' do
|
153
|
+
let(:list_default_categories_response) do
|
154
|
+
{
|
155
|
+
'categories' => [category_attributes],
|
156
|
+
'pagination' => pagination_attributes
|
157
|
+
}
|
158
|
+
end
|
159
|
+
|
160
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(list_default_categories_response) }
|
161
|
+
|
162
|
+
describe 'list_default_categories' do
|
163
|
+
it 'returns a list of categorys' do
|
164
|
+
response = described_class.list_default_categories
|
165
|
+
|
166
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Page)
|
167
|
+
expect(response.first).to be_kind_of(::MXPlatformRuby::Category)
|
168
|
+
expect(response.first.created_at).to eq(category_attributes[:created_at])
|
169
|
+
expect(response.first.guid).to eq(category_attributes[:guid])
|
170
|
+
expect(response.first.is_default).to eq(category_attributes[:is_default])
|
171
|
+
expect(response.first.is_income).to eq(category_attributes[:is_income])
|
172
|
+
expect(response.first.metadata).to eq(category_attributes[:metadata])
|
173
|
+
expect(response.first.name).to eq(category_attributes[:name])
|
174
|
+
expect(response.first.parent_guid).to eq(category_attributes[:parent_guid])
|
175
|
+
expect(response.first.updated_at).to eq(category_attributes[:updated_at])
|
176
|
+
expect(response.length).to eq(1)
|
177
|
+
end
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
181
|
+
describe 'read_category' do
|
182
|
+
let(:read_category_response) { { 'category' => category_attributes } }
|
183
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(read_category_response) }
|
184
|
+
|
185
|
+
it 'returns category' do
|
186
|
+
response = described_class.read_category
|
187
|
+
|
188
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Category)
|
189
|
+
expect(response.created_at).to eq(category_attributes[:created_at])
|
190
|
+
expect(response.guid).to eq(category_attributes[:guid])
|
191
|
+
expect(response.is_default).to eq(category_attributes[:is_default])
|
192
|
+
expect(response.is_income).to eq(category_attributes[:is_income])
|
193
|
+
expect(response.metadata).to eq(category_attributes[:metadata])
|
194
|
+
expect(response.name).to eq(category_attributes[:name])
|
195
|
+
expect(response.parent_guid).to eq(category_attributes[:parent_guid])
|
196
|
+
expect(response.updated_at).to eq(category_attributes[:updated_at])
|
197
|
+
end
|
198
|
+
|
199
|
+
it 'makes a client request with the expected params' do
|
200
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
201
|
+
{
|
202
|
+
endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/categories/CAT-7829f71c-2e8c-afa5-2f55-fa3634b89874',
|
203
|
+
http_method: :get
|
204
|
+
}
|
205
|
+
)
|
206
|
+
described_class.read_category(read_category_options)
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
describe 'update_category' do
|
211
|
+
let(:update_category_response) { { 'category' => category_attributes } }
|
212
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(update_category_response) }
|
213
|
+
|
214
|
+
it 'returns category' do
|
215
|
+
response = described_class.update_category
|
216
|
+
|
217
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Category)
|
218
|
+
expect(response.created_at).to eq(category_attributes[:created_at])
|
219
|
+
expect(response.guid).to eq(category_attributes[:guid])
|
220
|
+
expect(response.is_default).to eq(category_attributes[:is_default])
|
221
|
+
expect(response.is_income).to eq(category_attributes[:is_income])
|
222
|
+
expect(response.metadata).to eq(category_attributes[:metadata])
|
223
|
+
expect(response.name).to eq(category_attributes[:name])
|
224
|
+
expect(response.parent_guid).to eq(category_attributes[:parent_guid])
|
225
|
+
expect(response.updated_at).to eq(category_attributes[:updated_at])
|
226
|
+
end
|
227
|
+
|
228
|
+
it 'makes a client request with the expected params' do
|
229
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
230
|
+
{
|
231
|
+
endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/categories/CAT-7829f71c-2e8c-afa5-2f55-fa3634b89874',
|
232
|
+
http_method: :put,
|
233
|
+
request_body: {
|
234
|
+
category: {
|
235
|
+
metadata: 'some metadata',
|
236
|
+
name: 'Web shopping'
|
237
|
+
}
|
238
|
+
}
|
239
|
+
}
|
240
|
+
)
|
241
|
+
described_class.update_category(update_category_options)
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe ::MXPlatformRuby::Challenge do
|
6
|
+
let(:challenge_attributes) do
|
7
|
+
{
|
8
|
+
field_name: 'Who is this guy?',
|
9
|
+
guid: 'CRD-ce76d2e3-86bd-ec4a-ec52-eb53b5194bf5',
|
10
|
+
image_data: 'Who is this guy?',
|
11
|
+
image_options: [
|
12
|
+
{
|
13
|
+
data_uri: 'data:image/png;base64,iVBORw0KGgoAAAANSUh ... more image data ...',
|
14
|
+
label: 'IMAGE_1',
|
15
|
+
value: 'image_data'
|
16
|
+
}
|
17
|
+
],
|
18
|
+
label: 'Who is this guy?',
|
19
|
+
options: [
|
20
|
+
{
|
21
|
+
label: 'IMAGE_1',
|
22
|
+
value: 'image_data'
|
23
|
+
}
|
24
|
+
],
|
25
|
+
type: 'IMAGE_DATA'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
let(:list_member_challenges_options) do
|
29
|
+
{
|
30
|
+
member_guid: 'MBR-7c6f361b-e582-15b6-60c0-358f12466b4b',
|
31
|
+
page: 1,
|
32
|
+
records_per_page: 10,
|
33
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
34
|
+
}
|
35
|
+
end
|
36
|
+
let(:pagination_attributes) do
|
37
|
+
{
|
38
|
+
'current_page' => 1,
|
39
|
+
'per_page' => 25,
|
40
|
+
'total_pages' => 1,
|
41
|
+
'total_entries' => 1
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'list_member_challenges endpoints' do
|
46
|
+
let(:list_member_challenges_response) do
|
47
|
+
{
|
48
|
+
'challenges' => [challenge_attributes],
|
49
|
+
'pagination' => pagination_attributes
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(list_member_challenges_response) }
|
54
|
+
|
55
|
+
describe 'list_member_challenges' do
|
56
|
+
it 'returns a list of challenges' do
|
57
|
+
response = described_class.list_member_challenges
|
58
|
+
|
59
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Page)
|
60
|
+
expect(response.first).to be_kind_of(::MXPlatformRuby::Challenge)
|
61
|
+
expect(response.first.field_name).to eq(challenge_attributes[:field_name])
|
62
|
+
expect(response.first.guid).to eq(challenge_attributes[:guid])
|
63
|
+
expect(response.first.image_data).to eq(challenge_attributes[:image_data])
|
64
|
+
expect(response.first.image_options).to eq(challenge_attributes[:image_options])
|
65
|
+
expect(response.first.label).to eq(challenge_attributes[:label])
|
66
|
+
expect(response.first.options).to eq(challenge_attributes[:options])
|
67
|
+
expect(response.first.type).to eq(challenge_attributes[:type])
|
68
|
+
expect(response.length).to eq(1)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe ::MXPlatformRuby::Client do
|
6
|
+
let(:client_custom_params) { described_class.new('base_url', 'password', 'username') }
|
7
|
+
let(:client_default_params) { described_class.new }
|
8
|
+
let(:error_response) { ::OpenStruct.new('status' => 500, 'body' => 'error_message') }
|
9
|
+
let(:file_response) { ::OpenStruct.new('status' => 200, 'body' => sample_pdf_binary) }
|
10
|
+
let(:ok_response) { ::OpenStruct.new('status' => 200, 'body' => '{ "key": "value" }') }
|
11
|
+
let(:sample_pdf) { ::File.open('spec/sample.pdf') }
|
12
|
+
let(:sample_pdf_binary) { ::IO.binread(sample_pdf) }
|
13
|
+
|
14
|
+
describe '#http_client' do
|
15
|
+
it 'returns a HTTPClient' do
|
16
|
+
expect(client_custom_params.http_client).to be_a(::HTTPClient)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#initialize' do
|
21
|
+
context 'with default params' do
|
22
|
+
it 'sets password to param default' do
|
23
|
+
expect(client_default_params.password).to eq(nil)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'sets username to param default' do
|
27
|
+
expect(client_default_params.username).to eq(nil)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'sets base_url to param default' do
|
31
|
+
expect(client_default_params.base_url).to eq('https://int-api.mx.com')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'with params' do
|
36
|
+
it 'sets password to param' do
|
37
|
+
expect(client_custom_params.password).to eq('password')
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'sets username to param' do
|
41
|
+
expect(client_custom_params.username).to eq('username')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'sets base_url to param' do
|
45
|
+
expect(client_custom_params.base_url).to eq('base_url')
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#make_request' do
|
51
|
+
before do
|
52
|
+
allow(client_custom_params.http_client).to receive(:get).and_return(ok_response)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'builds the request url' do
|
56
|
+
expect(client_custom_params.http_client).to receive(:get).with('base_url/endpoint', any_args)
|
57
|
+
client_custom_params.make_request({ http_method: :get, endpoint: '/endpoint' })
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'sends authentication headers' do
|
61
|
+
expect(client_custom_params.http_client).to receive(:get).with(
|
62
|
+
anything,
|
63
|
+
anything,
|
64
|
+
hash_including(Authorization: 'Basic dXNlcm5hbWU6cGFzc3dvcmQ=')
|
65
|
+
)
|
66
|
+
client_custom_params.make_request({ http_method: :get, endpoint: '/endpoint' })
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'sends the body as json' do
|
70
|
+
expect(client_custom_params.http_client).to receive(:get).with(anything, '{"key":"value"}', any_args)
|
71
|
+
client_custom_params.make_request({ http_method: :get, endpoint: '/endpoint', request_body: { key: :value } })
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when the response is json' do
|
75
|
+
it 'parses the json response' do
|
76
|
+
allow(client_custom_params.http_client).to receive(:get).and_return(ok_response)
|
77
|
+
parsed_response = client_custom_params.make_request({ http_method: :get, endpoint: '/endpoint', request_body: { key: :value } })
|
78
|
+
expect(parsed_response['key']).to eq('value')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'when the response is not json' do
|
83
|
+
it 'formats the response as a ::TempFile' do
|
84
|
+
allow(client_custom_params.http_client).to receive(:get).and_return(file_response)
|
85
|
+
temp_file = client_custom_params.make_request({ http_method: :get, endpoint: '/endpoint', request_body: { key: :value } })
|
86
|
+
|
87
|
+
expect(temp_file).to be_kind_of(::Tempfile)
|
88
|
+
expect(::IO.read(temp_file)).to eq(::IO.read(sample_pdf))
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'with error' do
|
93
|
+
it 'raises a ::MXPlatformRuby::Error' do
|
94
|
+
allow(client_custom_params.http_client).to receive(:get).and_return(error_response)
|
95
|
+
expect { client_custom_params.make_request({ http_method: :get, endpoint: '/endpoint', request_body: { key: :value } }) }.to raise_error(
|
96
|
+
::MXPlatformRuby::Error
|
97
|
+
)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe ::MXPlatformRuby::ConnectWidget do
|
6
|
+
let(:connect_widget_attributes) do
|
7
|
+
{
|
8
|
+
connect_widget_url: 'https://int-widgets.moneydesktop.com/md/connect/jb1rA14m85tw2lyvpgfx4gc6d3Z8z8Ayb8',
|
9
|
+
guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
10
|
+
}
|
11
|
+
end
|
12
|
+
let(:request_connect_widget_url_options) do
|
13
|
+
{
|
14
|
+
color_scheme: 'light',
|
15
|
+
current_institution_code: 'chase',
|
16
|
+
current_member_guid: 'MBR-7c6f361b-e582-15b6-60c0-358f12466b4b',
|
17
|
+
disable_institution_search: false,
|
18
|
+
include_transactions: true,
|
19
|
+
is_mobile_webview: true,
|
20
|
+
mode: 'aggregation',
|
21
|
+
ui_message_version: 4,
|
22
|
+
ui_message_webview_url_scheme: 'mx',
|
23
|
+
update_credentials: false,
|
24
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54',
|
25
|
+
wait_for_full_aggregation: false
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
describe 'request_connect_widget_url' do
|
30
|
+
let(:request_connect_widget_url_response) { { 'user' => connect_widget_attributes } }
|
31
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(request_connect_widget_url_response) }
|
32
|
+
|
33
|
+
it 'returns connect_widget' do
|
34
|
+
response = described_class.request_connect_widget_url
|
35
|
+
|
36
|
+
expect(response).to be_kind_of(::MXPlatformRuby::ConnectWidget)
|
37
|
+
expect(response.connect_widget_url).to eq(connect_widget_attributes[:connect_widget_url])
|
38
|
+
expect(response.guid).to eq(connect_widget_attributes[:guid])
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'makes a client request with the expected params' do
|
42
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
43
|
+
{
|
44
|
+
endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/connect_widget_url',
|
45
|
+
http_method: :post,
|
46
|
+
request_body: {
|
47
|
+
config: {
|
48
|
+
color_scheme: 'light',
|
49
|
+
current_institution_code: 'chase',
|
50
|
+
current_member_guid: 'MBR-7c6f361b-e582-15b6-60c0-358f12466b4b',
|
51
|
+
disable_institution_search: false,
|
52
|
+
include_transactions: true,
|
53
|
+
is_mobile_webview: true,
|
54
|
+
mode: 'aggregation',
|
55
|
+
ui_message_version: 4,
|
56
|
+
ui_message_webview_url_scheme: 'mx',
|
57
|
+
update_credentials: false,
|
58
|
+
wait_for_full_aggregation: false
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
)
|
63
|
+
described_class.request_connect_widget_url(request_connect_widget_url_options)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|