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,191 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe ::MXPlatformRuby::Tagging do
|
6
|
+
let(:tagging_attributes) do
|
7
|
+
{
|
8
|
+
guid: 'TGN-007f5486-17e1-45fc-8b87-8f03984430fe',
|
9
|
+
member_is_managed_by_user: false,
|
10
|
+
tag_guid: 'TAG-40faf068-abb4-405c-8f6a-e883ed541fff',
|
11
|
+
transaction_guid: 'TRN-810828b0-5210-4878-9bd3-f4ce514f90c4',
|
12
|
+
user_guid: 'USR-11141024-90b3-1bce-cac9-c06ced52ab4c'
|
13
|
+
}
|
14
|
+
end
|
15
|
+
let(:create_tagging_options) do
|
16
|
+
{
|
17
|
+
tag_guid: 'TAG-40faf068-abb4-405c-8f6a-e883ed541fff',
|
18
|
+
transaction_guid: 'TRN-810828b0-5210-4878-9bd3-f4ce514f90c4',
|
19
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
20
|
+
}
|
21
|
+
end
|
22
|
+
let(:delete_tagging_options) do
|
23
|
+
{
|
24
|
+
tagging_guid: 'TGN-007f5486-17e1-45fc-8b87-8f03984430fe',
|
25
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
26
|
+
}
|
27
|
+
end
|
28
|
+
let(:list_taggings_options) do
|
29
|
+
{
|
30
|
+
page: 1,
|
31
|
+
records_per_page: 10,
|
32
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
let(:read_tagging_options) do
|
36
|
+
{
|
37
|
+
tagging_guid: 'TGN-007f5486-17e1-45fc-8b87-8f03984430fe',
|
38
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
39
|
+
}
|
40
|
+
end
|
41
|
+
let(:update_tagging_options) do
|
42
|
+
{
|
43
|
+
tag_guid: 'TAG-40faf068-abb4-405c-8f6a-e883ed541fff',
|
44
|
+
tagging_guid: 'TGN-007f5486-17e1-45fc-8b87-8f03984430fe',
|
45
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
let(:pagination_attributes) do
|
49
|
+
{
|
50
|
+
'current_page' => 1,
|
51
|
+
'per_page' => 25,
|
52
|
+
'total_pages' => 1,
|
53
|
+
'total_entries' => 1
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'create_tagging' do
|
58
|
+
let(:create_tagging_response) { { 'tagging' => tagging_attributes } }
|
59
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(create_tagging_response) }
|
60
|
+
|
61
|
+
it 'returns tagging' do
|
62
|
+
response = described_class.create_tagging
|
63
|
+
|
64
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Tagging)
|
65
|
+
expect(response.guid).to eq(tagging_attributes[:guid])
|
66
|
+
expect(response.member_is_managed_by_user).to eq(tagging_attributes[:member_is_managed_by_user])
|
67
|
+
expect(response.tag_guid).to eq(tagging_attributes[:tag_guid])
|
68
|
+
expect(response.transaction_guid).to eq(tagging_attributes[:transaction_guid])
|
69
|
+
expect(response.user_guid).to eq(tagging_attributes[:user_guid])
|
70
|
+
end
|
71
|
+
|
72
|
+
it 'makes a client request with the expected params' do
|
73
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
74
|
+
{
|
75
|
+
endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/taggings',
|
76
|
+
http_method: :post,
|
77
|
+
request_body: {
|
78
|
+
tagging: {
|
79
|
+
tag_guid: 'TAG-40faf068-abb4-405c-8f6a-e883ed541fff',
|
80
|
+
transaction_guid: 'TRN-810828b0-5210-4878-9bd3-f4ce514f90c4'
|
81
|
+
}
|
82
|
+
}
|
83
|
+
}
|
84
|
+
)
|
85
|
+
described_class.create_tagging(create_tagging_options)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe 'delete_tagging' do
|
90
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(nil) }
|
91
|
+
|
92
|
+
it 'returns nil' do
|
93
|
+
response = described_class.delete_tagging
|
94
|
+
|
95
|
+
expect(response).to be(nil)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'makes a client request with the expected params' do
|
99
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
100
|
+
{
|
101
|
+
endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/taggings/TGN-007f5486-17e1-45fc-8b87-8f03984430fe',
|
102
|
+
http_method: :delete
|
103
|
+
}
|
104
|
+
)
|
105
|
+
described_class.delete_tagging(delete_tagging_options)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'list_taggings endpoints' do
|
110
|
+
let(:list_taggings_response) do
|
111
|
+
{
|
112
|
+
'taggings' => [tagging_attributes],
|
113
|
+
'pagination' => pagination_attributes
|
114
|
+
}
|
115
|
+
end
|
116
|
+
|
117
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(list_taggings_response) }
|
118
|
+
|
119
|
+
describe 'list_taggings' do
|
120
|
+
it 'returns a list of taggings' do
|
121
|
+
response = described_class.list_taggings
|
122
|
+
|
123
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Page)
|
124
|
+
expect(response.first).to be_kind_of(::MXPlatformRuby::Tagging)
|
125
|
+
expect(response.first.guid).to eq(tagging_attributes[:guid])
|
126
|
+
expect(response.first.member_is_managed_by_user).to eq(tagging_attributes[:member_is_managed_by_user])
|
127
|
+
expect(response.first.tag_guid).to eq(tagging_attributes[:tag_guid])
|
128
|
+
expect(response.first.transaction_guid).to eq(tagging_attributes[:transaction_guid])
|
129
|
+
expect(response.first.user_guid).to eq(tagging_attributes[:user_guid])
|
130
|
+
expect(response.length).to eq(1)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe 'read_tagging' do
|
136
|
+
let(:read_tagging_response) { { 'tagging' => tagging_attributes } }
|
137
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(read_tagging_response) }
|
138
|
+
|
139
|
+
it 'returns tagging' do
|
140
|
+
response = described_class.read_tagging
|
141
|
+
|
142
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Tagging)
|
143
|
+
expect(response.guid).to eq(tagging_attributes[:guid])
|
144
|
+
expect(response.member_is_managed_by_user).to eq(tagging_attributes[:member_is_managed_by_user])
|
145
|
+
expect(response.tag_guid).to eq(tagging_attributes[:tag_guid])
|
146
|
+
expect(response.transaction_guid).to eq(tagging_attributes[:transaction_guid])
|
147
|
+
expect(response.user_guid).to eq(tagging_attributes[:user_guid])
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'makes a client request with the expected params' do
|
151
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
152
|
+
{
|
153
|
+
endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/taggings/TGN-007f5486-17e1-45fc-8b87-8f03984430fe',
|
154
|
+
http_method: :get
|
155
|
+
}
|
156
|
+
)
|
157
|
+
described_class.read_tagging(read_tagging_options)
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe 'update_tagging' do
|
162
|
+
let(:update_tagging_response) { { 'tagging' => tagging_attributes } }
|
163
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(update_tagging_response) }
|
164
|
+
|
165
|
+
it 'returns tagging' do
|
166
|
+
response = described_class.update_tagging
|
167
|
+
|
168
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Tagging)
|
169
|
+
expect(response.guid).to eq(tagging_attributes[:guid])
|
170
|
+
expect(response.member_is_managed_by_user).to eq(tagging_attributes[:member_is_managed_by_user])
|
171
|
+
expect(response.tag_guid).to eq(tagging_attributes[:tag_guid])
|
172
|
+
expect(response.transaction_guid).to eq(tagging_attributes[:transaction_guid])
|
173
|
+
expect(response.user_guid).to eq(tagging_attributes[:user_guid])
|
174
|
+
end
|
175
|
+
|
176
|
+
it 'makes a client request with the expected params' do
|
177
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
178
|
+
{
|
179
|
+
endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/taggings/TGN-007f5486-17e1-45fc-8b87-8f03984430fe',
|
180
|
+
http_method: :put,
|
181
|
+
request_body: {
|
182
|
+
tagging: {
|
183
|
+
tag_guid: 'TAG-40faf068-abb4-405c-8f6a-e883ed541fff'
|
184
|
+
}
|
185
|
+
}
|
186
|
+
}
|
187
|
+
)
|
188
|
+
described_class.update_tagging(update_tagging_options)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
@@ -0,0 +1,207 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe ::MXPlatformRuby::TransactionRule do
|
6
|
+
let(:transaction_rule_attributes) do
|
7
|
+
{
|
8
|
+
category_guid: 'CAT-b1de2a04-db08-b6ed-f6fe-ca2f5b11c2d0',
|
9
|
+
created_at: '2018-10-02T22:00:50+00:00',
|
10
|
+
description: 'Wal-mart food storage',
|
11
|
+
guid: 'TXR-a080e0f9-a2d4-4d6f-9e03-672cc357a4d3',
|
12
|
+
match_description: 'Wal-mart',
|
13
|
+
updated_at: '2018-10-02T23:54:40+00:00',
|
14
|
+
user_guid: 'USR-22fc3203-b3e6-8340-43db-8e50b2f56995'
|
15
|
+
}
|
16
|
+
end
|
17
|
+
let(:create_transaction_rule_options) do
|
18
|
+
{
|
19
|
+
category_guid: 'CAT-b1de2a04-db08-b6ed-f6fe-ca2f5b11c2d0',
|
20
|
+
description: 'Wal-mart food storage',
|
21
|
+
match_description: 'Wal-mart',
|
22
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
23
|
+
}
|
24
|
+
end
|
25
|
+
let(:delete_transaction_rule_options) do
|
26
|
+
{
|
27
|
+
transaction_rule_guid: 'TXR-a080e0f9-a2d4-4d6f-9e03-672cc357a4d3',
|
28
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
29
|
+
}
|
30
|
+
end
|
31
|
+
let(:list_transaction_rules_by_user_options) do
|
32
|
+
{
|
33
|
+
page: 1,
|
34
|
+
records_per_page: 10,
|
35
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
let(:read_transaction_rule_options) do
|
39
|
+
{
|
40
|
+
transaction_rule_guid: 'TXR-a080e0f9-a2d4-4d6f-9e03-672cc357a4d3',
|
41
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
let(:update_transaction_rule_options) do
|
45
|
+
{
|
46
|
+
category_guid: 'CAT-b1de2a04-db08-b6ed-f6fe-ca2f5b11c2d0',
|
47
|
+
description: 'Wal-mart food storage',
|
48
|
+
match_description: 'Wal-mart',
|
49
|
+
transaction_rule_guid: 'TXR-a080e0f9-a2d4-4d6f-9e03-672cc357a4d3',
|
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
|
+
describe 'create_transaction_rule' do
|
63
|
+
let(:create_transaction_rule_response) { { 'transaction_rule' => transaction_rule_attributes } }
|
64
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(create_transaction_rule_response) }
|
65
|
+
|
66
|
+
it 'returns transaction_rule' do
|
67
|
+
response = described_class.create_transaction_rule
|
68
|
+
|
69
|
+
expect(response).to be_kind_of(::MXPlatformRuby::TransactionRule)
|
70
|
+
expect(response.category_guid).to eq(transaction_rule_attributes[:category_guid])
|
71
|
+
expect(response.created_at).to eq(transaction_rule_attributes[:created_at])
|
72
|
+
expect(response.description).to eq(transaction_rule_attributes[:description])
|
73
|
+
expect(response.guid).to eq(transaction_rule_attributes[:guid])
|
74
|
+
expect(response.match_description).to eq(transaction_rule_attributes[:match_description])
|
75
|
+
expect(response.updated_at).to eq(transaction_rule_attributes[:updated_at])
|
76
|
+
expect(response.user_guid).to eq(transaction_rule_attributes[:user_guid])
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'makes a client request with the expected params' do
|
80
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
81
|
+
{
|
82
|
+
endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/transaction_rules',
|
83
|
+
http_method: :post,
|
84
|
+
request_body: {
|
85
|
+
transaction_rule: {
|
86
|
+
category_guid: 'CAT-b1de2a04-db08-b6ed-f6fe-ca2f5b11c2d0',
|
87
|
+
description: 'Wal-mart food storage',
|
88
|
+
match_description: 'Wal-mart'
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
)
|
93
|
+
described_class.create_transaction_rule(create_transaction_rule_options)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe 'delete_transaction_rule' do
|
98
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(nil) }
|
99
|
+
|
100
|
+
it 'returns nil' do
|
101
|
+
response = described_class.delete_transaction_rule
|
102
|
+
|
103
|
+
expect(response).to be(nil)
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'makes a client request with the expected params' do
|
107
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
108
|
+
{
|
109
|
+
endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/transaction_rules/TXR-a080e0f9-a2d4-4d6f-9e03-672cc357a4d3',
|
110
|
+
http_method: :delete
|
111
|
+
}
|
112
|
+
)
|
113
|
+
described_class.delete_transaction_rule(delete_transaction_rule_options)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'list_transaction_rules_by_user endpoints' do
|
118
|
+
let(:list_transaction_rules_by_user_response) do
|
119
|
+
{
|
120
|
+
'transaction_rules' => [transaction_rule_attributes],
|
121
|
+
'pagination' => pagination_attributes
|
122
|
+
}
|
123
|
+
end
|
124
|
+
|
125
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(list_transaction_rules_by_user_response) }
|
126
|
+
|
127
|
+
describe 'list_transaction_rules_by_user' do
|
128
|
+
it 'returns a list of transaction_rules' do
|
129
|
+
response = described_class.list_transaction_rules_by_user
|
130
|
+
|
131
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Page)
|
132
|
+
expect(response.first).to be_kind_of(::MXPlatformRuby::TransactionRule)
|
133
|
+
expect(response.first.category_guid).to eq(transaction_rule_attributes[:category_guid])
|
134
|
+
expect(response.first.created_at).to eq(transaction_rule_attributes[:created_at])
|
135
|
+
expect(response.first.description).to eq(transaction_rule_attributes[:description])
|
136
|
+
expect(response.first.guid).to eq(transaction_rule_attributes[:guid])
|
137
|
+
expect(response.first.match_description).to eq(transaction_rule_attributes[:match_description])
|
138
|
+
expect(response.first.updated_at).to eq(transaction_rule_attributes[:updated_at])
|
139
|
+
expect(response.first.user_guid).to eq(transaction_rule_attributes[:user_guid])
|
140
|
+
expect(response.length).to eq(1)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
describe 'read_transaction_rule' do
|
146
|
+
let(:read_transaction_rule_response) { { 'transaction_rule' => transaction_rule_attributes } }
|
147
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(read_transaction_rule_response) }
|
148
|
+
|
149
|
+
it 'returns transaction_rule' do
|
150
|
+
response = described_class.read_transaction_rule
|
151
|
+
|
152
|
+
expect(response).to be_kind_of(::MXPlatformRuby::TransactionRule)
|
153
|
+
expect(response.category_guid).to eq(transaction_rule_attributes[:category_guid])
|
154
|
+
expect(response.created_at).to eq(transaction_rule_attributes[:created_at])
|
155
|
+
expect(response.description).to eq(transaction_rule_attributes[:description])
|
156
|
+
expect(response.guid).to eq(transaction_rule_attributes[:guid])
|
157
|
+
expect(response.match_description).to eq(transaction_rule_attributes[:match_description])
|
158
|
+
expect(response.updated_at).to eq(transaction_rule_attributes[:updated_at])
|
159
|
+
expect(response.user_guid).to eq(transaction_rule_attributes[:user_guid])
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'makes a client request with the expected params' do
|
163
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
164
|
+
{
|
165
|
+
endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/transaction_rules/TXR-a080e0f9-a2d4-4d6f-9e03-672cc357a4d3',
|
166
|
+
http_method: :get
|
167
|
+
}
|
168
|
+
)
|
169
|
+
described_class.read_transaction_rule(read_transaction_rule_options)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe 'update_transaction_rule' do
|
174
|
+
let(:update_transaction_rule_response) { { 'transaction_rule' => transaction_rule_attributes } }
|
175
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(update_transaction_rule_response) }
|
176
|
+
|
177
|
+
it 'returns transaction_rule' do
|
178
|
+
response = described_class.update_transaction_rule
|
179
|
+
|
180
|
+
expect(response).to be_kind_of(::MXPlatformRuby::TransactionRule)
|
181
|
+
expect(response.category_guid).to eq(transaction_rule_attributes[:category_guid])
|
182
|
+
expect(response.created_at).to eq(transaction_rule_attributes[:created_at])
|
183
|
+
expect(response.description).to eq(transaction_rule_attributes[:description])
|
184
|
+
expect(response.guid).to eq(transaction_rule_attributes[:guid])
|
185
|
+
expect(response.match_description).to eq(transaction_rule_attributes[:match_description])
|
186
|
+
expect(response.updated_at).to eq(transaction_rule_attributes[:updated_at])
|
187
|
+
expect(response.user_guid).to eq(transaction_rule_attributes[:user_guid])
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'makes a client request with the expected params' do
|
191
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
192
|
+
{
|
193
|
+
endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/transaction_rules/TXR-a080e0f9-a2d4-4d6f-9e03-672cc357a4d3',
|
194
|
+
http_method: :put,
|
195
|
+
request_body: {
|
196
|
+
transaction_rule: {
|
197
|
+
category_guid: 'CAT-b1de2a04-db08-b6ed-f6fe-ca2f5b11c2d0',
|
198
|
+
description: 'Wal-mart food storage',
|
199
|
+
match_description: 'Wal-mart'
|
200
|
+
}
|
201
|
+
}
|
202
|
+
}
|
203
|
+
)
|
204
|
+
described_class.update_transaction_rule(update_transaction_rule_options)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
@@ -0,0 +1,449 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe ::MXPlatformRuby::Transaction do
|
6
|
+
let(:transaction_attributes) do
|
7
|
+
{
|
8
|
+
account_guid: 'ACT-06d7f44b-caae-0f6e-1384-01f52e75dcb1',
|
9
|
+
amount: 61.11,
|
10
|
+
category: 'Groceries',
|
11
|
+
check_number_string: '6812',
|
12
|
+
created_at: '2016-10-06T09:43:42.000Z',
|
13
|
+
currency_code: 'USD',
|
14
|
+
date: '2013-09-23T00:00:00.000Z',
|
15
|
+
description: 'Whole foods',
|
16
|
+
guid: 'TRN-265abee9-889b-af6a-c69b-25157db2bdd9',
|
17
|
+
id: 'transaction-265abee9-889b-af6a-c69b-25157db2bdd9',
|
18
|
+
is_bill_pay: false,
|
19
|
+
is_direct_deposit: false,
|
20
|
+
is_expense: true,
|
21
|
+
is_fee: false,
|
22
|
+
is_income: false,
|
23
|
+
is_international: false,
|
24
|
+
is_overdraft_fee: false,
|
25
|
+
is_payroll_advance: false,
|
26
|
+
is_recurring: false,
|
27
|
+
is_subscription: false,
|
28
|
+
latitude: -43.2075,
|
29
|
+
localized_description: 'This is a localized_description',
|
30
|
+
localized_memo: 'This is a localized_memo',
|
31
|
+
longitude: 139.691706,
|
32
|
+
member_guid: 'MBR-7c6f361b-e582-15b6-60c0-358f12466b4b',
|
33
|
+
memo: 'This is a memo',
|
34
|
+
merchant_category_code: 5411,
|
35
|
+
merchant_guid: 'MCH-7ed79542-884d-2b1b-dd74-501c5cc9d25b',
|
36
|
+
original_description: 'WHOLEFDS TSQ 102',
|
37
|
+
posted_at: '2016-10-07T06:00:00.000Z',
|
38
|
+
status: 'POSTED',
|
39
|
+
top_level_category: 'Food & Dining',
|
40
|
+
transacted_at: '2016-10-06T13:00:00.000Z',
|
41
|
+
type: 'DEBIT',
|
42
|
+
updated_at: '2016-10-07T05:49:12.000Z',
|
43
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
44
|
+
}
|
45
|
+
end
|
46
|
+
let(:list_transactions_by_account_options) do
|
47
|
+
{
|
48
|
+
account_guid: 'ACT-06d7f44b-caae-0f6e-1384-01f52e75dcb1',
|
49
|
+
from_date: '2015-09-20',
|
50
|
+
page: 1,
|
51
|
+
records_per_page: 10,
|
52
|
+
to_date: '2019-10-20',
|
53
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
54
|
+
}
|
55
|
+
end
|
56
|
+
let(:list_transactions_by_member_options) do
|
57
|
+
{
|
58
|
+
from_date: '2015-09-20',
|
59
|
+
member_guid: 'MBR-7c6f361b-e582-15b6-60c0-358f12466b4b',
|
60
|
+
page: 1,
|
61
|
+
records_per_page: 10,
|
62
|
+
to_date: '2019-10-20',
|
63
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
64
|
+
}
|
65
|
+
end
|
66
|
+
let(:list_transactions_by_tag_options) do
|
67
|
+
{
|
68
|
+
tag_guid: 'TAG-aef36e72-6294-4c38-844d-e573e80aed52',
|
69
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
70
|
+
}
|
71
|
+
end
|
72
|
+
let(:list_transactions_by_user_options) do
|
73
|
+
{
|
74
|
+
from_date: '2015-09-20',
|
75
|
+
page: 1,
|
76
|
+
records_per_page: 10,
|
77
|
+
to_date: '2019-10-20',
|
78
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
79
|
+
}
|
80
|
+
end
|
81
|
+
let(:read_transaction_options) do
|
82
|
+
{
|
83
|
+
transaction_guid: 'TRN-810828b0-5210-4878-9bd3-f4ce514f90c4',
|
84
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
85
|
+
}
|
86
|
+
end
|
87
|
+
let(:update_transaction_options) do
|
88
|
+
{
|
89
|
+
description: 'new description',
|
90
|
+
transaction_guid: 'TRN-810828b0-5210-4878-9bd3-f4ce514f90c4',
|
91
|
+
user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
|
92
|
+
}
|
93
|
+
end
|
94
|
+
let(:pagination_attributes) do
|
95
|
+
{
|
96
|
+
'current_page' => 1,
|
97
|
+
'per_page' => 25,
|
98
|
+
'total_pages' => 1,
|
99
|
+
'total_entries' => 1
|
100
|
+
}
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'list_transactions_by_account endpoints' do
|
104
|
+
let(:list_transactions_by_account_response) do
|
105
|
+
{
|
106
|
+
'transactions' => [transaction_attributes],
|
107
|
+
'pagination' => pagination_attributes
|
108
|
+
}
|
109
|
+
end
|
110
|
+
|
111
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(list_transactions_by_account_response) }
|
112
|
+
|
113
|
+
describe 'list_transactions_by_account' do
|
114
|
+
it 'returns a list of transactions' do
|
115
|
+
response = described_class.list_transactions_by_account
|
116
|
+
|
117
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Page)
|
118
|
+
expect(response.first).to be_kind_of(::MXPlatformRuby::Transaction)
|
119
|
+
expect(response.first.account_guid).to eq(transaction_attributes[:account_guid])
|
120
|
+
expect(response.first.amount).to eq(transaction_attributes[:amount])
|
121
|
+
expect(response.first.category).to eq(transaction_attributes[:category])
|
122
|
+
expect(response.first.check_number_string).to eq(transaction_attributes[:check_number_string])
|
123
|
+
expect(response.first.created_at).to eq(transaction_attributes[:created_at])
|
124
|
+
expect(response.first.currency_code).to eq(transaction_attributes[:currency_code])
|
125
|
+
expect(response.first.date).to eq(transaction_attributes[:date])
|
126
|
+
expect(response.first.description).to eq(transaction_attributes[:description])
|
127
|
+
expect(response.first.guid).to eq(transaction_attributes[:guid])
|
128
|
+
expect(response.first.id).to eq(transaction_attributes[:id])
|
129
|
+
expect(response.first.is_bill_pay).to eq(transaction_attributes[:is_bill_pay])
|
130
|
+
expect(response.first.is_direct_deposit).to eq(transaction_attributes[:is_direct_deposit])
|
131
|
+
expect(response.first.is_expense).to eq(transaction_attributes[:is_expense])
|
132
|
+
expect(response.first.is_fee).to eq(transaction_attributes[:is_fee])
|
133
|
+
expect(response.first.is_income).to eq(transaction_attributes[:is_income])
|
134
|
+
expect(response.first.is_international).to eq(transaction_attributes[:is_international])
|
135
|
+
expect(response.first.is_overdraft_fee).to eq(transaction_attributes[:is_overdraft_fee])
|
136
|
+
expect(response.first.is_payroll_advance).to eq(transaction_attributes[:is_payroll_advance])
|
137
|
+
expect(response.first.is_recurring).to eq(transaction_attributes[:is_recurring])
|
138
|
+
expect(response.first.is_subscription).to eq(transaction_attributes[:is_subscription])
|
139
|
+
expect(response.first.latitude).to eq(transaction_attributes[:latitude])
|
140
|
+
expect(response.first.localized_description).to eq(transaction_attributes[:localized_description])
|
141
|
+
expect(response.first.localized_memo).to eq(transaction_attributes[:localized_memo])
|
142
|
+
expect(response.first.longitude).to eq(transaction_attributes[:longitude])
|
143
|
+
expect(response.first.member_guid).to eq(transaction_attributes[:member_guid])
|
144
|
+
expect(response.first.memo).to eq(transaction_attributes[:memo])
|
145
|
+
expect(response.first.merchant_category_code).to eq(transaction_attributes[:merchant_category_code])
|
146
|
+
expect(response.first.merchant_guid).to eq(transaction_attributes[:merchant_guid])
|
147
|
+
expect(response.first.original_description).to eq(transaction_attributes[:original_description])
|
148
|
+
expect(response.first.posted_at).to eq(transaction_attributes[:posted_at])
|
149
|
+
expect(response.first.status).to eq(transaction_attributes[:status])
|
150
|
+
expect(response.first.top_level_category).to eq(transaction_attributes[:top_level_category])
|
151
|
+
expect(response.first.transacted_at).to eq(transaction_attributes[:transacted_at])
|
152
|
+
expect(response.first.type).to eq(transaction_attributes[:type])
|
153
|
+
expect(response.first.updated_at).to eq(transaction_attributes[:updated_at])
|
154
|
+
expect(response.first.user_guid).to eq(transaction_attributes[:user_guid])
|
155
|
+
expect(response.length).to eq(1)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
context 'list_transactions_by_member endpoints' do
|
161
|
+
let(:list_transactions_by_member_response) do
|
162
|
+
{
|
163
|
+
'transactions' => [transaction_attributes],
|
164
|
+
'pagination' => pagination_attributes
|
165
|
+
}
|
166
|
+
end
|
167
|
+
|
168
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(list_transactions_by_member_response) }
|
169
|
+
|
170
|
+
describe 'list_transactions_by_member' do
|
171
|
+
it 'returns a list of transactions' do
|
172
|
+
response = described_class.list_transactions_by_member
|
173
|
+
|
174
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Page)
|
175
|
+
expect(response.first).to be_kind_of(::MXPlatformRuby::Transaction)
|
176
|
+
expect(response.first.account_guid).to eq(transaction_attributes[:account_guid])
|
177
|
+
expect(response.first.amount).to eq(transaction_attributes[:amount])
|
178
|
+
expect(response.first.category).to eq(transaction_attributes[:category])
|
179
|
+
expect(response.first.check_number_string).to eq(transaction_attributes[:check_number_string])
|
180
|
+
expect(response.first.created_at).to eq(transaction_attributes[:created_at])
|
181
|
+
expect(response.first.currency_code).to eq(transaction_attributes[:currency_code])
|
182
|
+
expect(response.first.date).to eq(transaction_attributes[:date])
|
183
|
+
expect(response.first.description).to eq(transaction_attributes[:description])
|
184
|
+
expect(response.first.guid).to eq(transaction_attributes[:guid])
|
185
|
+
expect(response.first.id).to eq(transaction_attributes[:id])
|
186
|
+
expect(response.first.is_bill_pay).to eq(transaction_attributes[:is_bill_pay])
|
187
|
+
expect(response.first.is_direct_deposit).to eq(transaction_attributes[:is_direct_deposit])
|
188
|
+
expect(response.first.is_expense).to eq(transaction_attributes[:is_expense])
|
189
|
+
expect(response.first.is_fee).to eq(transaction_attributes[:is_fee])
|
190
|
+
expect(response.first.is_income).to eq(transaction_attributes[:is_income])
|
191
|
+
expect(response.first.is_international).to eq(transaction_attributes[:is_international])
|
192
|
+
expect(response.first.is_overdraft_fee).to eq(transaction_attributes[:is_overdraft_fee])
|
193
|
+
expect(response.first.is_payroll_advance).to eq(transaction_attributes[:is_payroll_advance])
|
194
|
+
expect(response.first.is_recurring).to eq(transaction_attributes[:is_recurring])
|
195
|
+
expect(response.first.is_subscription).to eq(transaction_attributes[:is_subscription])
|
196
|
+
expect(response.first.latitude).to eq(transaction_attributes[:latitude])
|
197
|
+
expect(response.first.localized_description).to eq(transaction_attributes[:localized_description])
|
198
|
+
expect(response.first.localized_memo).to eq(transaction_attributes[:localized_memo])
|
199
|
+
expect(response.first.longitude).to eq(transaction_attributes[:longitude])
|
200
|
+
expect(response.first.member_guid).to eq(transaction_attributes[:member_guid])
|
201
|
+
expect(response.first.memo).to eq(transaction_attributes[:memo])
|
202
|
+
expect(response.first.merchant_category_code).to eq(transaction_attributes[:merchant_category_code])
|
203
|
+
expect(response.first.merchant_guid).to eq(transaction_attributes[:merchant_guid])
|
204
|
+
expect(response.first.original_description).to eq(transaction_attributes[:original_description])
|
205
|
+
expect(response.first.posted_at).to eq(transaction_attributes[:posted_at])
|
206
|
+
expect(response.first.status).to eq(transaction_attributes[:status])
|
207
|
+
expect(response.first.top_level_category).to eq(transaction_attributes[:top_level_category])
|
208
|
+
expect(response.first.transacted_at).to eq(transaction_attributes[:transacted_at])
|
209
|
+
expect(response.first.type).to eq(transaction_attributes[:type])
|
210
|
+
expect(response.first.updated_at).to eq(transaction_attributes[:updated_at])
|
211
|
+
expect(response.first.user_guid).to eq(transaction_attributes[:user_guid])
|
212
|
+
expect(response.length).to eq(1)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
context 'list_transactions_by_tag endpoints' do
|
218
|
+
let(:list_transactions_by_tag_response) do
|
219
|
+
{
|
220
|
+
'transactions' => [transaction_attributes],
|
221
|
+
'pagination' => pagination_attributes
|
222
|
+
}
|
223
|
+
end
|
224
|
+
|
225
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(list_transactions_by_tag_response) }
|
226
|
+
|
227
|
+
describe 'list_transactions_by_tag' do
|
228
|
+
it 'returns a list of transactions' do
|
229
|
+
response = described_class.list_transactions_by_tag
|
230
|
+
|
231
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Page)
|
232
|
+
expect(response.first).to be_kind_of(::MXPlatformRuby::Transaction)
|
233
|
+
expect(response.first.account_guid).to eq(transaction_attributes[:account_guid])
|
234
|
+
expect(response.first.amount).to eq(transaction_attributes[:amount])
|
235
|
+
expect(response.first.category).to eq(transaction_attributes[:category])
|
236
|
+
expect(response.first.check_number_string).to eq(transaction_attributes[:check_number_string])
|
237
|
+
expect(response.first.created_at).to eq(transaction_attributes[:created_at])
|
238
|
+
expect(response.first.currency_code).to eq(transaction_attributes[:currency_code])
|
239
|
+
expect(response.first.date).to eq(transaction_attributes[:date])
|
240
|
+
expect(response.first.description).to eq(transaction_attributes[:description])
|
241
|
+
expect(response.first.guid).to eq(transaction_attributes[:guid])
|
242
|
+
expect(response.first.id).to eq(transaction_attributes[:id])
|
243
|
+
expect(response.first.is_bill_pay).to eq(transaction_attributes[:is_bill_pay])
|
244
|
+
expect(response.first.is_direct_deposit).to eq(transaction_attributes[:is_direct_deposit])
|
245
|
+
expect(response.first.is_expense).to eq(transaction_attributes[:is_expense])
|
246
|
+
expect(response.first.is_fee).to eq(transaction_attributes[:is_fee])
|
247
|
+
expect(response.first.is_income).to eq(transaction_attributes[:is_income])
|
248
|
+
expect(response.first.is_international).to eq(transaction_attributes[:is_international])
|
249
|
+
expect(response.first.is_overdraft_fee).to eq(transaction_attributes[:is_overdraft_fee])
|
250
|
+
expect(response.first.is_payroll_advance).to eq(transaction_attributes[:is_payroll_advance])
|
251
|
+
expect(response.first.is_recurring).to eq(transaction_attributes[:is_recurring])
|
252
|
+
expect(response.first.is_subscription).to eq(transaction_attributes[:is_subscription])
|
253
|
+
expect(response.first.latitude).to eq(transaction_attributes[:latitude])
|
254
|
+
expect(response.first.localized_description).to eq(transaction_attributes[:localized_description])
|
255
|
+
expect(response.first.localized_memo).to eq(transaction_attributes[:localized_memo])
|
256
|
+
expect(response.first.longitude).to eq(transaction_attributes[:longitude])
|
257
|
+
expect(response.first.member_guid).to eq(transaction_attributes[:member_guid])
|
258
|
+
expect(response.first.memo).to eq(transaction_attributes[:memo])
|
259
|
+
expect(response.first.merchant_category_code).to eq(transaction_attributes[:merchant_category_code])
|
260
|
+
expect(response.first.merchant_guid).to eq(transaction_attributes[:merchant_guid])
|
261
|
+
expect(response.first.original_description).to eq(transaction_attributes[:original_description])
|
262
|
+
expect(response.first.posted_at).to eq(transaction_attributes[:posted_at])
|
263
|
+
expect(response.first.status).to eq(transaction_attributes[:status])
|
264
|
+
expect(response.first.top_level_category).to eq(transaction_attributes[:top_level_category])
|
265
|
+
expect(response.first.transacted_at).to eq(transaction_attributes[:transacted_at])
|
266
|
+
expect(response.first.type).to eq(transaction_attributes[:type])
|
267
|
+
expect(response.first.updated_at).to eq(transaction_attributes[:updated_at])
|
268
|
+
expect(response.first.user_guid).to eq(transaction_attributes[:user_guid])
|
269
|
+
expect(response.length).to eq(1)
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
context 'list_transactions_by_user endpoints' do
|
275
|
+
let(:list_transactions_by_user_response) do
|
276
|
+
{
|
277
|
+
'transactions' => [transaction_attributes],
|
278
|
+
'pagination' => pagination_attributes
|
279
|
+
}
|
280
|
+
end
|
281
|
+
|
282
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(list_transactions_by_user_response) }
|
283
|
+
|
284
|
+
describe 'list_transactions_by_user' do
|
285
|
+
it 'returns a list of transactions' do
|
286
|
+
response = described_class.list_transactions_by_user
|
287
|
+
|
288
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Page)
|
289
|
+
expect(response.first).to be_kind_of(::MXPlatformRuby::Transaction)
|
290
|
+
expect(response.first.account_guid).to eq(transaction_attributes[:account_guid])
|
291
|
+
expect(response.first.amount).to eq(transaction_attributes[:amount])
|
292
|
+
expect(response.first.category).to eq(transaction_attributes[:category])
|
293
|
+
expect(response.first.check_number_string).to eq(transaction_attributes[:check_number_string])
|
294
|
+
expect(response.first.created_at).to eq(transaction_attributes[:created_at])
|
295
|
+
expect(response.first.currency_code).to eq(transaction_attributes[:currency_code])
|
296
|
+
expect(response.first.date).to eq(transaction_attributes[:date])
|
297
|
+
expect(response.first.description).to eq(transaction_attributes[:description])
|
298
|
+
expect(response.first.guid).to eq(transaction_attributes[:guid])
|
299
|
+
expect(response.first.id).to eq(transaction_attributes[:id])
|
300
|
+
expect(response.first.is_bill_pay).to eq(transaction_attributes[:is_bill_pay])
|
301
|
+
expect(response.first.is_direct_deposit).to eq(transaction_attributes[:is_direct_deposit])
|
302
|
+
expect(response.first.is_expense).to eq(transaction_attributes[:is_expense])
|
303
|
+
expect(response.first.is_fee).to eq(transaction_attributes[:is_fee])
|
304
|
+
expect(response.first.is_income).to eq(transaction_attributes[:is_income])
|
305
|
+
expect(response.first.is_international).to eq(transaction_attributes[:is_international])
|
306
|
+
expect(response.first.is_overdraft_fee).to eq(transaction_attributes[:is_overdraft_fee])
|
307
|
+
expect(response.first.is_payroll_advance).to eq(transaction_attributes[:is_payroll_advance])
|
308
|
+
expect(response.first.is_recurring).to eq(transaction_attributes[:is_recurring])
|
309
|
+
expect(response.first.is_subscription).to eq(transaction_attributes[:is_subscription])
|
310
|
+
expect(response.first.latitude).to eq(transaction_attributes[:latitude])
|
311
|
+
expect(response.first.localized_description).to eq(transaction_attributes[:localized_description])
|
312
|
+
expect(response.first.localized_memo).to eq(transaction_attributes[:localized_memo])
|
313
|
+
expect(response.first.longitude).to eq(transaction_attributes[:longitude])
|
314
|
+
expect(response.first.member_guid).to eq(transaction_attributes[:member_guid])
|
315
|
+
expect(response.first.memo).to eq(transaction_attributes[:memo])
|
316
|
+
expect(response.first.merchant_category_code).to eq(transaction_attributes[:merchant_category_code])
|
317
|
+
expect(response.first.merchant_guid).to eq(transaction_attributes[:merchant_guid])
|
318
|
+
expect(response.first.original_description).to eq(transaction_attributes[:original_description])
|
319
|
+
expect(response.first.posted_at).to eq(transaction_attributes[:posted_at])
|
320
|
+
expect(response.first.status).to eq(transaction_attributes[:status])
|
321
|
+
expect(response.first.top_level_category).to eq(transaction_attributes[:top_level_category])
|
322
|
+
expect(response.first.transacted_at).to eq(transaction_attributes[:transacted_at])
|
323
|
+
expect(response.first.type).to eq(transaction_attributes[:type])
|
324
|
+
expect(response.first.updated_at).to eq(transaction_attributes[:updated_at])
|
325
|
+
expect(response.first.user_guid).to eq(transaction_attributes[:user_guid])
|
326
|
+
expect(response.length).to eq(1)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
describe 'read_transaction' do
|
332
|
+
let(:read_transaction_response) { { 'transaction' => transaction_attributes } }
|
333
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(read_transaction_response) }
|
334
|
+
|
335
|
+
it 'returns transaction' do
|
336
|
+
response = described_class.read_transaction
|
337
|
+
|
338
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Transaction)
|
339
|
+
expect(response.account_guid).to eq(transaction_attributes[:account_guid])
|
340
|
+
expect(response.amount).to eq(transaction_attributes[:amount])
|
341
|
+
expect(response.category).to eq(transaction_attributes[:category])
|
342
|
+
expect(response.check_number_string).to eq(transaction_attributes[:check_number_string])
|
343
|
+
expect(response.created_at).to eq(transaction_attributes[:created_at])
|
344
|
+
expect(response.currency_code).to eq(transaction_attributes[:currency_code])
|
345
|
+
expect(response.date).to eq(transaction_attributes[:date])
|
346
|
+
expect(response.description).to eq(transaction_attributes[:description])
|
347
|
+
expect(response.guid).to eq(transaction_attributes[:guid])
|
348
|
+
expect(response.id).to eq(transaction_attributes[:id])
|
349
|
+
expect(response.is_bill_pay).to eq(transaction_attributes[:is_bill_pay])
|
350
|
+
expect(response.is_direct_deposit).to eq(transaction_attributes[:is_direct_deposit])
|
351
|
+
expect(response.is_expense).to eq(transaction_attributes[:is_expense])
|
352
|
+
expect(response.is_fee).to eq(transaction_attributes[:is_fee])
|
353
|
+
expect(response.is_income).to eq(transaction_attributes[:is_income])
|
354
|
+
expect(response.is_international).to eq(transaction_attributes[:is_international])
|
355
|
+
expect(response.is_overdraft_fee).to eq(transaction_attributes[:is_overdraft_fee])
|
356
|
+
expect(response.is_payroll_advance).to eq(transaction_attributes[:is_payroll_advance])
|
357
|
+
expect(response.is_recurring).to eq(transaction_attributes[:is_recurring])
|
358
|
+
expect(response.is_subscription).to eq(transaction_attributes[:is_subscription])
|
359
|
+
expect(response.latitude).to eq(transaction_attributes[:latitude])
|
360
|
+
expect(response.localized_description).to eq(transaction_attributes[:localized_description])
|
361
|
+
expect(response.localized_memo).to eq(transaction_attributes[:localized_memo])
|
362
|
+
expect(response.longitude).to eq(transaction_attributes[:longitude])
|
363
|
+
expect(response.member_guid).to eq(transaction_attributes[:member_guid])
|
364
|
+
expect(response.memo).to eq(transaction_attributes[:memo])
|
365
|
+
expect(response.merchant_category_code).to eq(transaction_attributes[:merchant_category_code])
|
366
|
+
expect(response.merchant_guid).to eq(transaction_attributes[:merchant_guid])
|
367
|
+
expect(response.original_description).to eq(transaction_attributes[:original_description])
|
368
|
+
expect(response.posted_at).to eq(transaction_attributes[:posted_at])
|
369
|
+
expect(response.status).to eq(transaction_attributes[:status])
|
370
|
+
expect(response.top_level_category).to eq(transaction_attributes[:top_level_category])
|
371
|
+
expect(response.transacted_at).to eq(transaction_attributes[:transacted_at])
|
372
|
+
expect(response.type).to eq(transaction_attributes[:type])
|
373
|
+
expect(response.updated_at).to eq(transaction_attributes[:updated_at])
|
374
|
+
expect(response.user_guid).to eq(transaction_attributes[:user_guid])
|
375
|
+
end
|
376
|
+
|
377
|
+
it 'makes a client request with the expected params' do
|
378
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
379
|
+
{
|
380
|
+
endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/transactions/TRN-810828b0-5210-4878-9bd3-f4ce514f90c4',
|
381
|
+
http_method: :get
|
382
|
+
}
|
383
|
+
)
|
384
|
+
described_class.read_transaction(read_transaction_options)
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
describe 'update_transaction' do
|
389
|
+
let(:update_transaction_response) { { 'transaction' => transaction_attributes } }
|
390
|
+
before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(update_transaction_response) }
|
391
|
+
|
392
|
+
it 'returns transaction' do
|
393
|
+
response = described_class.update_transaction
|
394
|
+
|
395
|
+
expect(response).to be_kind_of(::MXPlatformRuby::Transaction)
|
396
|
+
expect(response.account_guid).to eq(transaction_attributes[:account_guid])
|
397
|
+
expect(response.amount).to eq(transaction_attributes[:amount])
|
398
|
+
expect(response.category).to eq(transaction_attributes[:category])
|
399
|
+
expect(response.check_number_string).to eq(transaction_attributes[:check_number_string])
|
400
|
+
expect(response.created_at).to eq(transaction_attributes[:created_at])
|
401
|
+
expect(response.currency_code).to eq(transaction_attributes[:currency_code])
|
402
|
+
expect(response.date).to eq(transaction_attributes[:date])
|
403
|
+
expect(response.description).to eq(transaction_attributes[:description])
|
404
|
+
expect(response.guid).to eq(transaction_attributes[:guid])
|
405
|
+
expect(response.id).to eq(transaction_attributes[:id])
|
406
|
+
expect(response.is_bill_pay).to eq(transaction_attributes[:is_bill_pay])
|
407
|
+
expect(response.is_direct_deposit).to eq(transaction_attributes[:is_direct_deposit])
|
408
|
+
expect(response.is_expense).to eq(transaction_attributes[:is_expense])
|
409
|
+
expect(response.is_fee).to eq(transaction_attributes[:is_fee])
|
410
|
+
expect(response.is_income).to eq(transaction_attributes[:is_income])
|
411
|
+
expect(response.is_international).to eq(transaction_attributes[:is_international])
|
412
|
+
expect(response.is_overdraft_fee).to eq(transaction_attributes[:is_overdraft_fee])
|
413
|
+
expect(response.is_payroll_advance).to eq(transaction_attributes[:is_payroll_advance])
|
414
|
+
expect(response.is_recurring).to eq(transaction_attributes[:is_recurring])
|
415
|
+
expect(response.is_subscription).to eq(transaction_attributes[:is_subscription])
|
416
|
+
expect(response.latitude).to eq(transaction_attributes[:latitude])
|
417
|
+
expect(response.localized_description).to eq(transaction_attributes[:localized_description])
|
418
|
+
expect(response.localized_memo).to eq(transaction_attributes[:localized_memo])
|
419
|
+
expect(response.longitude).to eq(transaction_attributes[:longitude])
|
420
|
+
expect(response.member_guid).to eq(transaction_attributes[:member_guid])
|
421
|
+
expect(response.memo).to eq(transaction_attributes[:memo])
|
422
|
+
expect(response.merchant_category_code).to eq(transaction_attributes[:merchant_category_code])
|
423
|
+
expect(response.merchant_guid).to eq(transaction_attributes[:merchant_guid])
|
424
|
+
expect(response.original_description).to eq(transaction_attributes[:original_description])
|
425
|
+
expect(response.posted_at).to eq(transaction_attributes[:posted_at])
|
426
|
+
expect(response.status).to eq(transaction_attributes[:status])
|
427
|
+
expect(response.top_level_category).to eq(transaction_attributes[:top_level_category])
|
428
|
+
expect(response.transacted_at).to eq(transaction_attributes[:transacted_at])
|
429
|
+
expect(response.type).to eq(transaction_attributes[:type])
|
430
|
+
expect(response.updated_at).to eq(transaction_attributes[:updated_at])
|
431
|
+
expect(response.user_guid).to eq(transaction_attributes[:user_guid])
|
432
|
+
end
|
433
|
+
|
434
|
+
it 'makes a client request with the expected params' do
|
435
|
+
expect(::MXPlatformRuby.client).to receive(:make_request).with(
|
436
|
+
{
|
437
|
+
endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/transactions/TRN-810828b0-5210-4878-9bd3-f4ce514f90c4',
|
438
|
+
http_method: :put,
|
439
|
+
request_body: {
|
440
|
+
transaction: {
|
441
|
+
description: 'new description'
|
442
|
+
}
|
443
|
+
}
|
444
|
+
}
|
445
|
+
)
|
446
|
+
described_class.update_transaction(update_transaction_options)
|
447
|
+
end
|
448
|
+
end
|
449
|
+
end
|