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.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +20 -0
  3. data/.gitignore +13 -0
  4. data/.rubocop.yml +44 -0
  5. data/Gemfile +5 -0
  6. data/LICENSE +21 -0
  7. data/README.md +60 -0
  8. data/Rakefile +11 -0
  9. data/lib/mx-platform-ruby.rb +44 -0
  10. data/lib/mx-platform-ruby/account.rb +107 -0
  11. data/lib/mx-platform-ruby/account_number.rb +57 -0
  12. data/lib/mx-platform-ruby/account_owner.rb +42 -0
  13. data/lib/mx-platform-ruby/category.rb +127 -0
  14. data/lib/mx-platform-ruby/challenge.rb +37 -0
  15. data/lib/mx-platform-ruby/client.rb +59 -0
  16. data/lib/mx-platform-ruby/connect_widget.rb +43 -0
  17. data/lib/mx-platform-ruby/credential.rb +54 -0
  18. data/lib/mx-platform-ruby/enhanced_transaction.rb +44 -0
  19. data/lib/mx-platform-ruby/error.rb +6 -0
  20. data/lib/mx-platform-ruby/holding.rb +87 -0
  21. data/lib/mx-platform-ruby/institution.rb +78 -0
  22. data/lib/mx-platform-ruby/member.rb +242 -0
  23. data/lib/mx-platform-ruby/member_status.rb +35 -0
  24. data/lib/mx-platform-ruby/merchant.rb +52 -0
  25. data/lib/mx-platform-ruby/oauth_window.rb +32 -0
  26. data/lib/mx-platform-ruby/pageable.rb +29 -0
  27. data/lib/mx-platform-ruby/statement.rb +70 -0
  28. data/lib/mx-platform-ruby/tag.rb +104 -0
  29. data/lib/mx-platform-ruby/tagging.rb +107 -0
  30. data/lib/mx-platform-ruby/transaction.rb +162 -0
  31. data/lib/mx-platform-ruby/transaction_rule.rb +112 -0
  32. data/lib/mx-platform-ruby/user.rb +112 -0
  33. data/lib/mx-platform-ruby/version.rb +5 -0
  34. data/lib/mx-platform-ruby/widget.rb +49 -0
  35. data/mx-platform-ruby.gemspec +31 -0
  36. data/spec/lib/mx-platform-ruby/account_number_spec.rb +100 -0
  37. data/spec/lib/mx-platform-ruby/account_owner_spec.rb +71 -0
  38. data/spec/lib/mx-platform-ruby/account_spec.rb +267 -0
  39. data/spec/lib/mx-platform-ruby/category_spec.rb +244 -0
  40. data/spec/lib/mx-platform-ruby/challenge_spec.rb +72 -0
  41. data/spec/lib/mx-platform-ruby/client_spec.rb +101 -0
  42. data/spec/lib/mx-platform-ruby/connect_widget_spec.rb +66 -0
  43. data/spec/lib/mx-platform-ruby/credential_spec.rb +90 -0
  44. data/spec/lib/mx-platform-ruby/enhanced_transaction_spec.rb +89 -0
  45. data/spec/lib/mx-platform-ruby/holding_spec.rb +178 -0
  46. data/spec/lib/mx-platform-ruby/institution_spec.rb +141 -0
  47. data/spec/lib/mx-platform-ruby/member_spec.rb +557 -0
  48. data/spec/lib/mx-platform-ruby/member_status_spec.rb +76 -0
  49. data/spec/lib/mx-platform-ruby/merchant_spec.rb +89 -0
  50. data/spec/lib/mx-platform-ruby/oauth_window_spec.rb +47 -0
  51. data/spec/lib/mx-platform-ruby/pageable_spec.rb +75 -0
  52. data/spec/lib/mx-platform-ruby/statement_spec.rb +130 -0
  53. data/spec/lib/mx-platform-ruby/tag_spec.rb +179 -0
  54. data/spec/lib/mx-platform-ruby/tagging_spec.rb +191 -0
  55. data/spec/lib/mx-platform-ruby/transaction_rule_spec.rb +207 -0
  56. data/spec/lib/mx-platform-ruby/transaction_spec.rb +449 -0
  57. data/spec/lib/mx-platform-ruby/user_spec.rb +196 -0
  58. data/spec/lib/mx-platform-ruby/widget_spec.rb +76 -0
  59. data/spec/lib/mx-platform-ruby_spec.rb +15 -0
  60. data/spec/sample.pdf +0 -0
  61. data/spec/spec_helper.rb +24 -0
  62. metadata +63 -3
@@ -0,0 +1,196 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ::MXPlatformRuby::User do
6
+ let(:user_attributes) do
7
+ {
8
+ email: 'email@provider.com',
9
+ guid: 'USR-d74cb14f-fd0a-449f-991b-e0362a63d9c6',
10
+ id: 'My-Unique-ID',
11
+ is_disabled: false,
12
+ metadata: '{\"first_name\": \"Steven\", \"last_name\": \"Universe\"}'
13
+ }
14
+ end
15
+ let(:create_user_options) do
16
+ {
17
+ email: 'email@provider.com',
18
+ id: 'My-Unique-ID',
19
+ is_disabled: false,
20
+ metadata: '{\"first_name\": \"Steven\", \"last_name\": \"Universe\"}'
21
+ }
22
+ end
23
+ let(:delete_user_options) do
24
+ {
25
+ user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
26
+ }
27
+ end
28
+ let(:list_users_options) do
29
+ {
30
+ page: 1,
31
+ records_per_page: 10
32
+ }
33
+ end
34
+ let(:read_user_options) do
35
+ {
36
+ user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54'
37
+ }
38
+ end
39
+ let(:update_user_options) do
40
+ {
41
+ email: 'email@provider.com',
42
+ id: 'My-Unique-ID',
43
+ is_disabled: false,
44
+ metadata: '{\"first_name\": \"Steven\", \"last_name\": \"Universe\"}',
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_user' do
58
+ let(:create_user_response) { { 'user' => user_attributes } }
59
+ before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(create_user_response) }
60
+
61
+ it 'returns user' do
62
+ response = described_class.create_user
63
+
64
+ expect(response).to be_kind_of(::MXPlatformRuby::User)
65
+ expect(response.email).to eq(user_attributes[:email])
66
+ expect(response.guid).to eq(user_attributes[:guid])
67
+ expect(response.id).to eq(user_attributes[:id])
68
+ expect(response.is_disabled).to eq(user_attributes[:is_disabled])
69
+ expect(response.metadata).to eq(user_attributes[:metadata])
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',
76
+ http_method: :post,
77
+ request_body: {
78
+ user: {
79
+ email: 'email@provider.com',
80
+ id: 'My-Unique-ID',
81
+ is_disabled: false,
82
+ metadata: '{\"first_name\": \"Steven\", \"last_name\": \"Universe\"}'
83
+ }
84
+ }
85
+ }
86
+ )
87
+ described_class.create_user(create_user_options)
88
+ end
89
+ end
90
+
91
+ describe 'delete_user' do
92
+ before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(nil) }
93
+
94
+ it 'returns nil' do
95
+ response = described_class.delete_user
96
+
97
+ expect(response).to be(nil)
98
+ end
99
+
100
+ it 'makes a client request with the expected params' do
101
+ expect(::MXPlatformRuby.client).to receive(:make_request).with(
102
+ {
103
+ endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54',
104
+ http_method: :delete
105
+ }
106
+ )
107
+ described_class.delete_user(delete_user_options)
108
+ end
109
+ end
110
+
111
+ context 'list_users endpoints' do
112
+ let(:list_users_response) do
113
+ {
114
+ 'users' => [user_attributes],
115
+ 'pagination' => pagination_attributes
116
+ }
117
+ end
118
+
119
+ before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(list_users_response) }
120
+
121
+ describe 'list_users' do
122
+ it 'returns a list of users' do
123
+ response = described_class.list_users
124
+
125
+ expect(response).to be_kind_of(::MXPlatformRuby::Page)
126
+ expect(response.first).to be_kind_of(::MXPlatformRuby::User)
127
+ expect(response.first.email).to eq(user_attributes[:email])
128
+ expect(response.first.guid).to eq(user_attributes[:guid])
129
+ expect(response.first.id).to eq(user_attributes[:id])
130
+ expect(response.first.is_disabled).to eq(user_attributes[:is_disabled])
131
+ expect(response.first.metadata).to eq(user_attributes[:metadata])
132
+ expect(response.length).to eq(1)
133
+ end
134
+ end
135
+ end
136
+
137
+ describe 'read_user' do
138
+ let(:read_user_response) { { 'user' => user_attributes } }
139
+ before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(read_user_response) }
140
+
141
+ it 'returns user' do
142
+ response = described_class.read_user
143
+
144
+ expect(response).to be_kind_of(::MXPlatformRuby::User)
145
+ expect(response.email).to eq(user_attributes[:email])
146
+ expect(response.guid).to eq(user_attributes[:guid])
147
+ expect(response.id).to eq(user_attributes[:id])
148
+ expect(response.is_disabled).to eq(user_attributes[:is_disabled])
149
+ expect(response.metadata).to eq(user_attributes[:metadata])
150
+ end
151
+
152
+ it 'makes a client request with the expected params' do
153
+ expect(::MXPlatformRuby.client).to receive(:make_request).with(
154
+ {
155
+ endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54',
156
+ http_method: :get
157
+ }
158
+ )
159
+ described_class.read_user(read_user_options)
160
+ end
161
+ end
162
+
163
+ describe 'update_user' do
164
+ let(:update_user_response) { { 'user' => user_attributes } }
165
+ before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(update_user_response) }
166
+
167
+ it 'returns user' do
168
+ response = described_class.update_user
169
+
170
+ expect(response).to be_kind_of(::MXPlatformRuby::User)
171
+ expect(response.email).to eq(user_attributes[:email])
172
+ expect(response.guid).to eq(user_attributes[:guid])
173
+ expect(response.id).to eq(user_attributes[:id])
174
+ expect(response.is_disabled).to eq(user_attributes[:is_disabled])
175
+ expect(response.metadata).to eq(user_attributes[:metadata])
176
+ end
177
+
178
+ it 'makes a client request with the expected params' do
179
+ expect(::MXPlatformRuby.client).to receive(:make_request).with(
180
+ {
181
+ endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54',
182
+ http_method: :put,
183
+ request_body: {
184
+ user: {
185
+ email: 'email@provider.com',
186
+ id: 'My-Unique-ID',
187
+ is_disabled: false,
188
+ metadata: '{\"first_name\": \"Steven\", \"last_name\": \"Universe\"}'
189
+ }
190
+ }
191
+ }
192
+ )
193
+ described_class.update_user(update_user_options)
194
+ end
195
+ end
196
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ::MXPlatformRuby::Widget do
6
+ let(:widget_attributes) do
7
+ {
8
+ type: 'connect_widget',
9
+ url: 'https://int-widgets.moneydesktop.com/md/connect/yxcdk7f1nb99jwApp34lA24m0AZ8rzprgmw17gm8z8h2AzjyAnd1rj42qfv42r3xnn07Amfwlg3j09hwp8bkq8tc5z21j33xjggmp2qtlpkz2v4gywfhfn31l44tx2w91bfc2thc58j4syqp0hgxcyvA4g7754hk7gjc56kt7tc36s45mmkdz2jqqqydspytmtr3dAb9jh6fkb24f3zkfpdjj0v77f0vmrtzvzxkmxz7dklsq8gd0gstkbhlw5bgpgc3m9mAtpAcr2w15gwy5xc4blgxppl42Avnm63291z3cyp0wm3lqgmvgzdAddct423gAdqxdlfx5d4mvc0ck2gt7ktqgks4vxq1pAy5',
10
+ user_id: 'U-jeff-201709221210'
11
+ }
12
+ end
13
+ let(:request_widget_url_options) do
14
+ {
15
+ accept_language: 'en-US',
16
+ color_scheme: 'light',
17
+ current_institution_code: 'chase',
18
+ current_institution_guid: 'INS-f1a3285d-e855-b61f-6aa7-8ae575c0e0e9',
19
+ current_member_guid: 'MBR-7c6f361b-e582-15b6-60c0-358f12466b4b',
20
+ disable_institution_search: false,
21
+ include_transactions: true,
22
+ is_mobile_webview: true,
23
+ mode: 'aggregation',
24
+ ui_message_version: 4,
25
+ ui_message_webview_url_scheme: 'mx',
26
+ update_credentials: false,
27
+ user_guid: 'USR-fa7537f3-48aa-a683-a02a-b18940482f54',
28
+ wait_for_full_aggregation: false,
29
+ widget_type: 'connect_widget'
30
+ }
31
+ end
32
+
33
+ describe 'request_widget_url' do
34
+ let(:request_widget_url_response) { { 'widget_url' => widget_attributes } }
35
+ before { allow(::MXPlatformRuby.client).to receive(:make_request).and_return(request_widget_url_response) }
36
+
37
+ it 'returns widget' do
38
+ response = described_class.request_widget_url
39
+
40
+ expect(response).to be_kind_of(::MXPlatformRuby::Widget)
41
+ expect(response.type).to eq(widget_attributes[:type])
42
+ expect(response.url).to eq(widget_attributes[:url])
43
+ expect(response.user_id).to eq(widget_attributes[:user_id])
44
+ end
45
+
46
+ it 'makes a client request with the expected params' do
47
+ expect(::MXPlatformRuby.client).to receive(:make_request).with(
48
+ {
49
+ endpoint: '/users/USR-fa7537f3-48aa-a683-a02a-b18940482f54/widget_urls',
50
+ headers: {
51
+ 'Accept-Language': 'en-US'
52
+ },
53
+ http_method: :post,
54
+ request_body: {
55
+ widget_url: {
56
+ color_scheme: 'light',
57
+ current_institution_code: 'chase',
58
+ current_institution_guid: 'INS-f1a3285d-e855-b61f-6aa7-8ae575c0e0e9',
59
+ current_member_guid: 'MBR-7c6f361b-e582-15b6-60c0-358f12466b4b',
60
+ disable_institution_search: false,
61
+ include_transactions: true,
62
+ is_mobile_webview: true,
63
+ mode: 'aggregation',
64
+ ui_message_version: 4,
65
+ ui_message_webview_url_scheme: 'mx',
66
+ update_credentials: false,
67
+ wait_for_full_aggregation: false,
68
+ widget_type: 'connect_widget'
69
+ }
70
+ }
71
+ }
72
+ )
73
+ described_class.request_widget_url(request_widget_url_options)
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe ::MXPlatformRuby do
6
+ it 'has a client' do
7
+ expect(described_class).to respond_to(:client)
8
+ end
9
+
10
+ describe '.configure' do
11
+ it 'yields a ::MXPlatformRuby::Client' do
12
+ expect { |block| described_class.configure(&block) }.to yield_with_args(::MXPlatformRuby::Client)
13
+ end
14
+ end
15
+ end
data/spec/sample.pdf ADDED
Binary file
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'simplecov'
4
+ require 'pry'
5
+
6
+ SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
7
+ SimpleCov.start do
8
+ add_filter '/spec/'
9
+ end
10
+
11
+ require 'mx-platform-ruby'
12
+
13
+ RSpec.configure do |config|
14
+ # Disable RSpec exposing methods globally on `Module` and `main`
15
+ config.disable_monkey_patching!
16
+
17
+ config.expect_with :rspec do |c|
18
+ c.syntax = :expect
19
+ end
20
+
21
+ config.mock_with :rspec do |mocks|
22
+ mocks.allow_message_expectations_on_nil = true
23
+ end
24
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mx-platform-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - MX
@@ -124,11 +124,71 @@ dependencies:
124
124
  version: '0'
125
125
  description: A Ruby library for the MX Platform API.
126
126
  email:
127
- - dev@mx.com
127
+ - devexperience@mx.com
128
128
  executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
131
- files: []
131
+ files:
132
+ - ".github/workflows/test.yml"
133
+ - ".gitignore"
134
+ - ".rubocop.yml"
135
+ - Gemfile
136
+ - LICENSE
137
+ - README.md
138
+ - Rakefile
139
+ - lib/mx-platform-ruby.rb
140
+ - lib/mx-platform-ruby/account.rb
141
+ - lib/mx-platform-ruby/account_number.rb
142
+ - lib/mx-platform-ruby/account_owner.rb
143
+ - lib/mx-platform-ruby/category.rb
144
+ - lib/mx-platform-ruby/challenge.rb
145
+ - lib/mx-platform-ruby/client.rb
146
+ - lib/mx-platform-ruby/connect_widget.rb
147
+ - lib/mx-platform-ruby/credential.rb
148
+ - lib/mx-platform-ruby/enhanced_transaction.rb
149
+ - lib/mx-platform-ruby/error.rb
150
+ - lib/mx-platform-ruby/holding.rb
151
+ - lib/mx-platform-ruby/institution.rb
152
+ - lib/mx-platform-ruby/member.rb
153
+ - lib/mx-platform-ruby/member_status.rb
154
+ - lib/mx-platform-ruby/merchant.rb
155
+ - lib/mx-platform-ruby/oauth_window.rb
156
+ - lib/mx-platform-ruby/pageable.rb
157
+ - lib/mx-platform-ruby/statement.rb
158
+ - lib/mx-platform-ruby/tag.rb
159
+ - lib/mx-platform-ruby/tagging.rb
160
+ - lib/mx-platform-ruby/transaction.rb
161
+ - lib/mx-platform-ruby/transaction_rule.rb
162
+ - lib/mx-platform-ruby/user.rb
163
+ - lib/mx-platform-ruby/version.rb
164
+ - lib/mx-platform-ruby/widget.rb
165
+ - mx-platform-ruby.gemspec
166
+ - spec/lib/mx-platform-ruby/account_number_spec.rb
167
+ - spec/lib/mx-platform-ruby/account_owner_spec.rb
168
+ - spec/lib/mx-platform-ruby/account_spec.rb
169
+ - spec/lib/mx-platform-ruby/category_spec.rb
170
+ - spec/lib/mx-platform-ruby/challenge_spec.rb
171
+ - spec/lib/mx-platform-ruby/client_spec.rb
172
+ - spec/lib/mx-platform-ruby/connect_widget_spec.rb
173
+ - spec/lib/mx-platform-ruby/credential_spec.rb
174
+ - spec/lib/mx-platform-ruby/enhanced_transaction_spec.rb
175
+ - spec/lib/mx-platform-ruby/holding_spec.rb
176
+ - spec/lib/mx-platform-ruby/institution_spec.rb
177
+ - spec/lib/mx-platform-ruby/member_spec.rb
178
+ - spec/lib/mx-platform-ruby/member_status_spec.rb
179
+ - spec/lib/mx-platform-ruby/merchant_spec.rb
180
+ - spec/lib/mx-platform-ruby/oauth_window_spec.rb
181
+ - spec/lib/mx-platform-ruby/pageable_spec.rb
182
+ - spec/lib/mx-platform-ruby/statement_spec.rb
183
+ - spec/lib/mx-platform-ruby/tag_spec.rb
184
+ - spec/lib/mx-platform-ruby/tagging_spec.rb
185
+ - spec/lib/mx-platform-ruby/transaction_rule_spec.rb
186
+ - spec/lib/mx-platform-ruby/transaction_spec.rb
187
+ - spec/lib/mx-platform-ruby/user_spec.rb
188
+ - spec/lib/mx-platform-ruby/widget_spec.rb
189
+ - spec/lib/mx-platform-ruby_spec.rb
190
+ - spec/sample.pdf
191
+ - spec/spec_helper.rb
132
192
  homepage: https://www.mx.com/products/platform-api
133
193
  licenses:
134
194
  - MIT