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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c37bb296e94c8e9931a9446fb80593f48d9e7b87ac3fb71d1d29cebb58c8723
|
4
|
+
data.tar.gz: 5d60ba2b693ffeecdd49348c0a0a444f1e202367a263f4385f3a61ab1e34fafd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a245730b4ba64a0a5bc1d21a25b1834ed18951371fb4bcef008e5a8c84a5f78351b82f4ceab2cff914249d5cf4ed1e80f4ff06e36dcacecfc706b490cb818ff
|
7
|
+
data.tar.gz: ec13d47c295fff12ec888c527f3e4dfc81a401bb10c0169fb31bcdfd826b2f18d7d8091d40cd0fbefbe348dda13047b98e055ee4f3c153f89c4c2e270a86338e
|
@@ -0,0 +1,20 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
Test:
|
7
|
+
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
|
10
|
+
steps:
|
11
|
+
- uses: actions/checkout@v2
|
12
|
+
- name: Set up Ruby
|
13
|
+
uses: ruby/setup-ruby@v1
|
14
|
+
with:
|
15
|
+
bundler-cache: true
|
16
|
+
ruby-version: 2.6
|
17
|
+
- name: Install dependencies
|
18
|
+
run: bundle install
|
19
|
+
- name: Run RuboCop and RSpec
|
20
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
AllCops:
|
2
|
+
NewCops: disable # Disabling pending cops
|
3
|
+
SuggestExtensions: false # Disabling extension suggestions
|
4
|
+
TargetRubyVersion: 2.6
|
5
|
+
|
6
|
+
Layout/LineLength:
|
7
|
+
Description: Checks the length of lines in the source code
|
8
|
+
Exclude:
|
9
|
+
- 'spec/lib/**/*.rb' # Excluding to avoid multiline expect statements
|
10
|
+
IgnoredPatterns: ['^ endpoint: ".*'] # Excluding since the endpoints may require longer lines
|
11
|
+
Max: 120
|
12
|
+
|
13
|
+
Metrics/AbcSize:
|
14
|
+
Description: Checks that the ABC size of methods is not higher than the configured maximum
|
15
|
+
Exclude:
|
16
|
+
- 'lib/mx-platform-ruby/pageable.rb' # Disabling because clarity > brevity
|
17
|
+
|
18
|
+
Metrics/BlockLength:
|
19
|
+
Description: Checks if the length of a block exceeds some maximum value
|
20
|
+
Exclude:
|
21
|
+
- 'spec/**/*' # Excluding to allow rspec tests to grow with number of attributes
|
22
|
+
|
23
|
+
Metrics/ClassLength:
|
24
|
+
Description: Checks if the length a class exceeds some maximum value
|
25
|
+
Enabled: false # Disabling because clarity > brevity
|
26
|
+
|
27
|
+
Metrics/MethodLength:
|
28
|
+
Description: Checks if the length a method exceeds some maximum value
|
29
|
+
Enabled: false # Disabling to allow class methods to grow with number of attributes
|
30
|
+
|
31
|
+
Naming/FileName:
|
32
|
+
Description: Checks that Ruby source files have snake_case names
|
33
|
+
Exclude:
|
34
|
+
- 'spec/lib/mx-platform-ruby_spec.rb' # Excluding since gems may have `-` in their name
|
35
|
+
- 'lib/mx-platform-ruby.rb' # Excluding since gems may have `-` in their name
|
36
|
+
|
37
|
+
Style/Documentation:
|
38
|
+
Description: Checks for missing top-level documentation of classes and modules
|
39
|
+
Enabled: false # Disabling because Rails models should be self-explanatory
|
40
|
+
|
41
|
+
Style/SignalException:
|
42
|
+
Description: Checks for uses of fail and raise
|
43
|
+
Exclude:
|
44
|
+
- 'lib/mx-platform-ruby/pageable.rb' # Allow fail if block isn't provided
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 MX
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
*This project is currently in **Beta**. Please open up an issue [here](https://github.com/mxenabled/mx-platform-ruby/issues) to report issues using the MX Platform API Ruby Library.*
|
2
|
+
|
3
|
+
# MX Platform API Ruby Library
|
4
|
+
#### Version 0.1.1
|
5
|
+
|
6
|
+
A Ruby library for the [MX Platform API](https://www.mx.com/products/platform-api).
|
7
|
+
|
8
|
+
## Documentation
|
9
|
+
|
10
|
+
See the [MX Platform API docs](https://docs.mx.com/api).
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'mx-platform-ruby'
|
18
|
+
```
|
19
|
+
|
20
|
+
And then execute:
|
21
|
+
```shell
|
22
|
+
$ bundle
|
23
|
+
```
|
24
|
+
Or install it yourself with:
|
25
|
+
```shell
|
26
|
+
$ gem install mx-platform-ruby
|
27
|
+
```
|
28
|
+
|
29
|
+
## Configuration
|
30
|
+
|
31
|
+
In order to make API requests, you will need to [sign up for the MX Platform API](https://dashboard.mx.com/sign_up) and get a `Client ID` and `API Key`.
|
32
|
+
```ruby
|
33
|
+
::MXPlatformRuby.configure do |config|
|
34
|
+
config.username = 'Client ID'
|
35
|
+
config.password = 'API Key'
|
36
|
+
config.base_url = 'https://int-api.mx.com' # in production, use 'https://api.mx.com'
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
40
|
+
## Paginated endpoints
|
41
|
+
|
42
|
+
For paginated endpoints, the pagination values can be accessed through the returned `::MXPlatformRuby::Page` array as follows
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
institutions = ::MXPlatformRuby::Institution.list_institutions(options)
|
46
|
+
|
47
|
+
puts "Current page: #{institutions.current_page}"
|
48
|
+
puts "Per page: #{institutions.per_page}"
|
49
|
+
puts "Total entries: #{institutions.total_entries}"
|
50
|
+
puts "Total pages: #{institutions.total_pages}"
|
51
|
+
|
52
|
+
institutions.each do |institution|
|
53
|
+
p institution
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
|
58
|
+
## Contributing
|
59
|
+
|
60
|
+
Bug reports and pull requests are welcome on [GitHub](https://github.com/mxenabled/mx-platform-ruby).
|
data/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
6
|
+
|
7
|
+
::RSpec::Core::RakeTask.new(:spec)
|
8
|
+
::RuboCop::RakeTask.new(:rubocop)
|
9
|
+
|
10
|
+
desc 'Run RuboCop and RSpec'
|
11
|
+
task default: %i[rubocop spec]
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_attr'
|
4
|
+
require 'base64'
|
5
|
+
require 'httpclient'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
require 'mx-platform-ruby/client'
|
9
|
+
require 'mx-platform-ruby/error'
|
10
|
+
require 'mx-platform-ruby/pageable'
|
11
|
+
require 'mx-platform-ruby/version'
|
12
|
+
|
13
|
+
require 'mx-platform-ruby/account'
|
14
|
+
require 'mx-platform-ruby/account_number'
|
15
|
+
require 'mx-platform-ruby/account_owner'
|
16
|
+
require 'mx-platform-ruby/category'
|
17
|
+
require 'mx-platform-ruby/challenge'
|
18
|
+
require 'mx-platform-ruby/connect_widget'
|
19
|
+
require 'mx-platform-ruby/credential'
|
20
|
+
require 'mx-platform-ruby/enhanced_transaction'
|
21
|
+
require 'mx-platform-ruby/holding'
|
22
|
+
require 'mx-platform-ruby/institution'
|
23
|
+
require 'mx-platform-ruby/member'
|
24
|
+
require 'mx-platform-ruby/member_status'
|
25
|
+
require 'mx-platform-ruby/merchant'
|
26
|
+
require 'mx-platform-ruby/oauth_window'
|
27
|
+
require 'mx-platform-ruby/statement'
|
28
|
+
require 'mx-platform-ruby/tag'
|
29
|
+
require 'mx-platform-ruby/tagging'
|
30
|
+
require 'mx-platform-ruby/transaction'
|
31
|
+
require 'mx-platform-ruby/transaction_rule'
|
32
|
+
require 'mx-platform-ruby/user'
|
33
|
+
require 'mx-platform-ruby/widget'
|
34
|
+
|
35
|
+
module MXPlatformRuby
|
36
|
+
class << self
|
37
|
+
attr_reader :client
|
38
|
+
|
39
|
+
def configure
|
40
|
+
@client = ::MXPlatformRuby::Client.new
|
41
|
+
yield @client
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MXPlatformRuby
|
4
|
+
class Account
|
5
|
+
extend ::MXPlatformRuby::Pageable
|
6
|
+
include ::ActiveAttr::Model
|
7
|
+
|
8
|
+
attribute :account_number
|
9
|
+
attribute :apr
|
10
|
+
attribute :apy
|
11
|
+
attribute :available_balance
|
12
|
+
attribute :available_credit
|
13
|
+
attribute :balance
|
14
|
+
attribute :cash_balance
|
15
|
+
attribute :cash_surrender_value
|
16
|
+
attribute :created_at
|
17
|
+
attribute :credit_limit
|
18
|
+
attribute :currency_code
|
19
|
+
attribute :day_payment_is_due
|
20
|
+
attribute :death_benefit
|
21
|
+
attribute :guid
|
22
|
+
attribute :holdings_value
|
23
|
+
attribute :id
|
24
|
+
attribute :institution_code
|
25
|
+
attribute :insured_name
|
26
|
+
attribute :interest_rate
|
27
|
+
attribute :is_closed
|
28
|
+
attribute :is_hidden
|
29
|
+
attribute :last_payment
|
30
|
+
attribute :last_payment_at
|
31
|
+
attribute :loan_amount
|
32
|
+
attribute :matures_on
|
33
|
+
attribute :member_guid
|
34
|
+
attribute :minimum_balance
|
35
|
+
attribute :minimum_payment
|
36
|
+
attribute :name
|
37
|
+
attribute :original_balance
|
38
|
+
attribute :pay_out_amount
|
39
|
+
attribute :payment_due_at
|
40
|
+
attribute :payoff_balance
|
41
|
+
attribute :premium_amount
|
42
|
+
attribute :started_on
|
43
|
+
attribute :subtype
|
44
|
+
attribute :total_account_value
|
45
|
+
attribute :type
|
46
|
+
attribute :updated_at
|
47
|
+
attribute :user_guid
|
48
|
+
|
49
|
+
def self.list_user_accounts(options = {})
|
50
|
+
options = list_user_accounts_options(options)
|
51
|
+
|
52
|
+
paginate(options)
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.read_account(options = {})
|
56
|
+
read_account_options = read_account_options(options)
|
57
|
+
response = ::MXPlatformRuby.client.make_request(read_account_options)
|
58
|
+
|
59
|
+
account_params = response['account']
|
60
|
+
::MXPlatformRuby::Account.new(account_params)
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.update_account(options = {})
|
64
|
+
update_account_options = update_account_options(options)
|
65
|
+
response = ::MXPlatformRuby.client.make_request(update_account_options)
|
66
|
+
|
67
|
+
account_params = response['account']
|
68
|
+
::MXPlatformRuby::Account.new(account_params)
|
69
|
+
end
|
70
|
+
|
71
|
+
# Private class methods
|
72
|
+
|
73
|
+
def self.list_user_accounts_options(options)
|
74
|
+
{
|
75
|
+
endpoint: "/users/#{options[:user_guid]}/accounts",
|
76
|
+
http_method: :get,
|
77
|
+
query_params: {
|
78
|
+
page: options[:page],
|
79
|
+
records_per_page: options[:records_per_page]
|
80
|
+
}.compact,
|
81
|
+
resource: 'accounts'
|
82
|
+
}
|
83
|
+
end
|
84
|
+
private_class_method :list_user_accounts_options
|
85
|
+
|
86
|
+
def self.read_account_options(options)
|
87
|
+
{
|
88
|
+
endpoint: "/users/#{options[:user_guid]}/accounts/#{options[:account_guid]}",
|
89
|
+
http_method: :get
|
90
|
+
}
|
91
|
+
end
|
92
|
+
private_class_method :read_account_options
|
93
|
+
|
94
|
+
def self.update_account_options(options)
|
95
|
+
{
|
96
|
+
endpoint: "/users/#{options[:user_guid]}/members/#{options[:member_guid]}/accounts/#{options[:account_guid]}",
|
97
|
+
http_method: :put,
|
98
|
+
request_body: {
|
99
|
+
account: {
|
100
|
+
is_hidden: options[:is_hidden]
|
101
|
+
}.compact
|
102
|
+
}
|
103
|
+
}
|
104
|
+
end
|
105
|
+
private_class_method :update_account_options
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MXPlatformRuby
|
4
|
+
class AccountNumber
|
5
|
+
extend ::MXPlatformRuby::Pageable
|
6
|
+
include ::ActiveAttr::Model
|
7
|
+
|
8
|
+
attribute :account_guid
|
9
|
+
attribute :account_number
|
10
|
+
attribute :guid
|
11
|
+
attribute :institution_number
|
12
|
+
attribute :member_guid
|
13
|
+
attribute :routing_number
|
14
|
+
attribute :transit_number
|
15
|
+
attribute :user_guid
|
16
|
+
|
17
|
+
def self.list_account_numbers_by_account(options = {})
|
18
|
+
options = list_account_numbers_by_account_options(options)
|
19
|
+
|
20
|
+
paginate(options)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.list_account_numbers_by_member(options = {})
|
24
|
+
options = list_account_numbers_by_member_options(options)
|
25
|
+
|
26
|
+
paginate(options)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Private class methods
|
30
|
+
|
31
|
+
def self.list_account_numbers_by_account_options(options)
|
32
|
+
{
|
33
|
+
endpoint: "/users/#{options[:user_guid]}/accounts/#{options[:account_guid]}/account_numbers",
|
34
|
+
http_method: :get,
|
35
|
+
query_params: {
|
36
|
+
page: options[:page],
|
37
|
+
records_per_page: options[:records_per_page]
|
38
|
+
}.compact,
|
39
|
+
resource: 'account_numbers'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
private_class_method :list_account_numbers_by_account_options
|
43
|
+
|
44
|
+
def self.list_account_numbers_by_member_options(options)
|
45
|
+
{
|
46
|
+
endpoint: "/users/#{options[:user_guid]}/members/#{options[:member_guid]}/account_numbers",
|
47
|
+
http_method: :get,
|
48
|
+
query_params: {
|
49
|
+
page: options[:page],
|
50
|
+
records_per_page: options[:records_per_page]
|
51
|
+
}.compact,
|
52
|
+
resource: 'account_numbers'
|
53
|
+
}
|
54
|
+
end
|
55
|
+
private_class_method :list_account_numbers_by_member_options
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module MXPlatformRuby
|
4
|
+
class AccountOwner
|
5
|
+
extend ::MXPlatformRuby::Pageable
|
6
|
+
include ::ActiveAttr::Model
|
7
|
+
|
8
|
+
attribute :account_guid
|
9
|
+
attribute :address
|
10
|
+
attribute :city
|
11
|
+
attribute :country
|
12
|
+
attribute :email
|
13
|
+
attribute :guid
|
14
|
+
attribute :member_guid
|
15
|
+
attribute :owner_name
|
16
|
+
attribute :phone
|
17
|
+
attribute :postal_code
|
18
|
+
attribute :state
|
19
|
+
attribute :user_guid
|
20
|
+
|
21
|
+
def self.list_account_owners(options = {})
|
22
|
+
options = list_account_owners_options(options)
|
23
|
+
|
24
|
+
paginate(options)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Private class methods
|
28
|
+
|
29
|
+
def self.list_account_owners_options(options)
|
30
|
+
{
|
31
|
+
endpoint: "/users/#{options[:user_guid]}/members/#{options[:member_guid]}/account_owners",
|
32
|
+
http_method: :get,
|
33
|
+
query_params: {
|
34
|
+
page: options[:page],
|
35
|
+
records_per_page: options[:records_per_page]
|
36
|
+
}.compact,
|
37
|
+
resource: 'account_owners'
|
38
|
+
}
|
39
|
+
end
|
40
|
+
private_class_method :list_account_owners_options
|
41
|
+
end
|
42
|
+
end
|