corepro_fvr 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +15 -0
  4. data/LICENSE +21 -0
  5. data/README.md +47 -0
  6. data/Rakefile +2 -0
  7. data/config-sample.yml +5 -0
  8. data/corepro_fvr.gemspec +25 -0
  9. data/lib/corepro.rb +15 -0
  10. data/lib/corepro/account.rb +111 -0
  11. data/lib/corepro/account_close.rb +21 -0
  12. data/lib/corepro/bank_document.rb +42 -0
  13. data/lib/corepro/card.rb +90 -0
  14. data/lib/corepro/connection.rb +90 -0
  15. data/lib/corepro/core_pro_api_exception.rb +26 -0
  16. data/lib/corepro/customer.rb +140 -0
  17. data/lib/corepro/customer_beneficiary.rb +42 -0
  18. data/lib/corepro/customer_document.rb +22 -0
  19. data/lib/corepro/external_account.rb +84 -0
  20. data/lib/corepro/external_account_document.rb +34 -0
  21. data/lib/corepro/models/account_access.rb +25 -0
  22. data/lib/corepro/models/account_id_only.rb +9 -0
  23. data/lib/corepro/models/api_error.rb +14 -0
  24. data/lib/corepro/models/customer_address.rb +17 -0
  25. data/lib/corepro/models/customer_answer.rb +9 -0
  26. data/lib/corepro/models/customer_beneficiary_id_only.rb +8 -0
  27. data/lib/corepro/models/customer_id_only.rb +8 -0
  28. data/lib/corepro/models/customer_message.rb +10 -0
  29. data/lib/corepro/models/customer_phone.rb +11 -0
  30. data/lib/corepro/models/customer_question.rb +21 -0
  31. data/lib/corepro/models/customer_response.rb +28 -0
  32. data/lib/corepro/models/customer_verify_request.rb +28 -0
  33. data/lib/corepro/models/envelope.rb +37 -0
  34. data/lib/corepro/models/external_account_id_only.rb +8 -0
  35. data/lib/corepro/models/external_account_verify.rb +13 -0
  36. data/lib/corepro/models/file_content.rb +10 -0
  37. data/lib/corepro/models/json_base.rb +93 -0
  38. data/lib/corepro/models/model_base.rb +26 -0
  39. data/lib/corepro/models/program_account.rb +20 -0
  40. data/lib/corepro/models/program_checking.rb +38 -0
  41. data/lib/corepro/models/program_e_code.rb +31 -0
  42. data/lib/corepro/models/program_external_account.rb +21 -0
  43. data/lib/corepro/models/program_interest_rate.rb +18 -0
  44. data/lib/corepro/models/program_limit.rb +12 -0
  45. data/lib/corepro/models/program_prepaid.rb +37 -0
  46. data/lib/corepro/models/program_savings.rb +36 -0
  47. data/lib/corepro/program.rb +74 -0
  48. data/lib/corepro/statement.rb +25 -0
  49. data/lib/corepro/transaction.rb +53 -0
  50. data/lib/corepro/transfer.rb +42 -0
  51. data/lib/corepro/utils/logger.rb +9 -0
  52. data/lib/corepro/utils/requestor.rb +120 -0
  53. data/lib/corepro/version.rb +4 -0
  54. data/q2labs_public.pem +9 -0
  55. data/test.pdf +0 -0
  56. data/test/a_program_test.rb +12 -0
  57. data/test/aa_customer_test.rb +78 -0
  58. data/test/ab_account_test.rb +45 -0
  59. data/test/ac_external_account_test.rb +39 -0
  60. data/test/ad_customer_beneficiary_test.rb +43 -0
  61. data/test/ae_customer_document_test.rb +16 -0
  62. data/test/af_bankdocument_test.rb +20 -0
  63. data/test/ag_external_account_document_test.rb +18 -0
  64. data/test/ai_statement_test.rb +23 -0
  65. data/test/aj_transfer_test.rb +53 -0
  66. data/test/ak_transaction_test.rb +19 -0
  67. data/test/al_card_test.rb +51 -0
  68. data/test/core_pro_test_base.rb +30 -0
  69. metadata +170 -0
@@ -0,0 +1,12 @@
1
+ require_relative 'json_base'
2
+ module CorePro
3
+ module Models
4
+ class ProgramLimit < JsonBase
5
+ attr_accessor :minimumAmount
6
+ attr_accessor :maximumAmount
7
+ def to_s
8
+ return "min: #{@minimumAmount}, max: #{@maximumAmount}"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,37 @@
1
+ require_relative 'json_base'
2
+ require_relative 'program_interest_rate'
3
+ require_relative 'program_limit'
4
+ module CorePro
5
+ module Models
6
+ class ProgramPrepaid < JsonBase
7
+ def is_hash?
8
+ true
9
+ end
10
+ attr_accessor :category
11
+ attr_accessor :type
12
+ attr_accessor :balanceLimit
13
+ attr_accessor :interestRates
14
+ attr_accessor :isImmediateLoadFromLinkedAccountEnabled
15
+ attr_accessor :isExternalWithdrawEnabled
16
+ attr_accessor :isInterestEnabled
17
+ attr_accessor :isRecurringContributionEnabled
18
+ attr_accessor :perTransactionDepositLimit
19
+ attr_accessor :perTransactionWithdrawLimit
20
+
21
+ def initialize
22
+ super
23
+ @interestRates = []
24
+ end
25
+
26
+ def from_json! json, classDefs
27
+ classDefs = classDefs || {}
28
+ classDefs['balanceLimit'] = CorePro::Models::ProgramLimit
29
+ classDefs['interestRates'] = CorePro::Models::ProgramInterestRate
30
+ classDefs['perTransactionDepositLimit'] = CorePro::Models::ProgramLimit
31
+ classDefs['perTransactionWithdrawLimit'] = CorePro::Models::ProgramLimit
32
+
33
+ super json, classDefs
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,36 @@
1
+ require_relative 'json_base'
2
+ require_relative 'program_interest_rate'
3
+ require_relative 'program_limit'
4
+ module CorePro
5
+ module Models
6
+ class ProgramSavings < JsonBase
7
+ def is_hash?
8
+ true
9
+ end
10
+ attr_accessor :category
11
+ attr_accessor :type
12
+ attr_accessor :balanceLimit
13
+ attr_accessor :interestRates
14
+ attr_accessor :isExternalWithdrawEnabled
15
+ attr_accessor :isInterestEnabled
16
+ attr_accessor :isRecurringContributionEnabled
17
+ attr_accessor :perTransactionDepositLimit
18
+ attr_accessor :perTransactionWithdrawLimit
19
+
20
+ def initialize
21
+ @interestRates = []
22
+ super
23
+ end
24
+
25
+ def from_json! json, classDefs
26
+ classDefs = classDefs || {}
27
+ classDefs['balanceLimit'] = CorePro::Models::ProgramLimit
28
+ classDefs['interestRates'] = CorePro::Models::ProgramInterestRate
29
+ classDefs['perTransactionDepositLimit'] = CorePro::Models::ProgramLimit
30
+ classDefs['perTransactionWithdrawLimit'] = CorePro::Models::ProgramLimit
31
+
32
+ super json, classDefs
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,74 @@
1
+ require_relative 'models/model_base'
2
+ require_relative 'utils/requestor'
3
+ require_relative 'models/program_account'
4
+ require_relative 'models/program_checking'
5
+ require_relative 'models/program_e_code'
6
+ require_relative 'models/program_external_account'
7
+ require_relative 'models/program_interest_rate'
8
+ require_relative 'models/program_savings'
9
+ require_relative 'models/program_prepaid'
10
+ require_relative 'models/program_limit'
11
+
12
+ module CorePro
13
+ class Program < Models::ModelBase
14
+
15
+ attr_accessor :name
16
+ attr_accessor :verificationType
17
+ attr_accessor :timeZone
18
+ attr_accessor :perUserDailyWithdrawLimit
19
+ attr_accessor :perUserMonthlyWithdrawLimit
20
+ attr_accessor :perProgramDailyWithdrawLimit
21
+ attr_accessor :perUserDailyDepositLimit
22
+ attr_accessor :perUserMonthlyDepositLimit
23
+ attr_accessor :perProgramDailyDepositLimit
24
+ attr_accessor :website
25
+ attr_accessor :isInternalToInternalTransferEnabled
26
+ attr_accessor :decimalCount
27
+ attr_accessor :validAccountTypes
28
+ attr_accessor :filledDate
29
+ attr_accessor :externalAccountCountMax
30
+ attr_accessor :accountCountMax
31
+ attr_accessor :checkingProducts
32
+ attr_accessor :eCodeProducts
33
+ attr_accessor :savingsProducts
34
+ attr_accessor :prepaidProducts
35
+ attr_accessor :accounts
36
+ attr_accessor :externalAccounts
37
+
38
+ def initialize
39
+ super
40
+ @checkingProducts = {}
41
+ @eCodeProducts = {}
42
+ @savingsProducts = {}
43
+ @prepaidProducts = {}
44
+ @accounts = {}
45
+ @externalAccounts = {}
46
+ end
47
+
48
+ def from_json! json, classDefs
49
+ classDefs = classDefs || {}
50
+ classDefs['perUserDailyWithdrawLimit'] = CorePro::Models::ProgramLimit
51
+ classDefs['perUserMonthlyWithdrawLimit'] = CorePro::Models::ProgramLimit
52
+ classDefs['perProgramDailyWithdrawLimit'] = CorePro::Models::ProgramLimit
53
+
54
+ classDefs['perUserDailyDepositLimit'] = CorePro::Models::ProgramLimit
55
+ classDefs['perUserMonthlyDepositLimit'] = CorePro::Models::ProgramLimit
56
+ classDefs['perProgramDailyDepositLimit'] = CorePro::Models::ProgramLimit
57
+
58
+ classDefs['checkingProducts'] = CorePro::Models::ProgramChecking
59
+ classDefs['eCodeProducts'] = CorePro::Models::ProgramECode
60
+ classDefs['savingsProducts'] = CorePro::Models::ProgramSavings
61
+ classDefs['prepaidProducts'] = CorePro::Models::ProgramPrepaid
62
+
63
+ classDefs['accounts'] = CorePro::Models::ProgramAccount
64
+ classDefs['externalAccounts'] = CorePro::Models::ProgramExternalAccount
65
+
66
+ super json, classDefs
67
+ end
68
+
69
+ def self.get(connection = nil, loggingObject = nil)
70
+ CorePro::Utils::Requestor.get("/program/get", Program, connection, loggingObject)
71
+ end
72
+
73
+ end
74
+ end
@@ -0,0 +1,25 @@
1
+ require_relative 'models/model_base'
2
+ require_relative 'utils/requestor'
3
+ require_relative 'models/file_content'
4
+
5
+ module CorePro
6
+ class Statement < Models::ModelBase
7
+ attr_accessor :statementId
8
+ attr_accessor :customerId
9
+ attr_accessor :type
10
+ attr_accessor :month
11
+ attr_accessor :year
12
+
13
+ def self.list(customerId, connection = nil, loggingObject = nil)
14
+ CorePro::Utils::Requestor.get("/statement/list/#{customerId}", Statement, connection, loggingObject)
15
+ end
16
+
17
+ def self.get(customerId, statementId, connection = nil, loggingObject = nil)
18
+ CorePro::Utils::Requestor.get("/statement/get/#{customerId}/#{statementId}", Statement, connection, loggingObject)
19
+ end
20
+
21
+ def self.download(customerId, statementId, connection = nil, loggingObject = nil)
22
+ CorePro::Utils::Requestor.get("/statement/download/#{customerId}/#{statementId}", CorePro::Models::FileContent, connection, loggingObject)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,53 @@
1
+ require_relative 'models/model_base'
2
+ require_relative 'utils/requestor'
3
+
4
+ require 'date'
5
+ module CorePro
6
+ class Transaction < Models::ModelBase
7
+ attr_accessor :transactionCount
8
+ attr_accessor :customerId
9
+ attr_accessor :transactionId
10
+ attr_accessor :tag
11
+ attr_accessor :createdDate
12
+ attr_accessor :type
13
+ attr_accessor :typeCode
14
+ attr_accessor :status
15
+ attr_accessor :amount
16
+ attr_accessor :settledDate
17
+ attr_accessor :voidedDate
18
+ attr_accessor :nachaDescription
19
+ attr_accessor :friendlyDescription
20
+ attr_accessor :availableDate
21
+ attr_accessor :returnCode
22
+ attr_accessor :isCredit
23
+
24
+ def self.list(customerId, accountId, status = nil, beginDate = nil, endDate = nil, pageNumber = 0, pageSize = 200, connection = nil, loggingObject = nil)
25
+ t = Transaction.new
26
+ t.customerId = customerId
27
+ t.list accountId, status, beginDate, endDate, pageNumber, pageSize, connection, loggingObject
28
+ end
29
+
30
+ def list(accountId = nil, status = nil, beginDate = nil, endDate =nil, pageNumber =0, pageSize = 200, connection = nil, loggingObject = nil)
31
+ start = beginDate.kind_of?(Date) ? beginDate.strftime('%Y-%m-%d') : (beginDate.kind_of?(String) ? beginDate[0..9] : nil)
32
+ finish = endDate.kind_of?(Date) ? endDate.strftime('%Y-%m-%d') : (endDate.kind_of?(String) ? endDate[0..9] : nil)
33
+
34
+ start ||= ''
35
+ finish ||= ''
36
+
37
+ if finish != '' && start == ''
38
+ start = '1900-01-01'
39
+ end
40
+
41
+ CorePro::Utils::Requestor.get("/transaction/list/#{self.customerId}/#{accountId}/#{Transaction.escape(status)}/#{start}/#{finish}?pageNumber=#{pageNumber}&pageSize=#{pageSize}", Transaction, connection, loggingObject)
42
+ end
43
+
44
+ def self.get(customerId, transactionId, connection = nil, loggingObject = nil)
45
+ CorePro::Utils::Requestor.get("/transaction/get/#{customerId}/#{transactionId}", Transaction, connection, loggingObject)
46
+ end
47
+
48
+ def self.getByTag(customerId, tag, connection = nil, loggingObject = nil)
49
+ CorePro::Utils::Requestor.get("/transaction/getByTag/#{customerId}/#{Transaction.escape(tag)}", Transaction, connection, loggingObject)
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,42 @@
1
+ require_relative 'models/model_base'
2
+ require_relative 'utils/requestor'
3
+
4
+ module CorePro
5
+ class Transfer < Models::ModelBase
6
+
7
+ attr_accessor :customerId
8
+ attr_accessor :fromId
9
+ attr_accessor :toId
10
+ attr_accessor :amount
11
+ attr_accessor :tag
12
+ attr_accessor :transactionId
13
+ attr_accessor :description
14
+
15
+ def self.create(customerId, fromId, toId, amount, tag, description, connection = nil, loggingObject = nil)
16
+ t = Transfer.new
17
+ t.customerId = customerId
18
+ t.fromId = fromId
19
+ t.toId = toId
20
+ t.amount = amount
21
+ t.tag = tag
22
+ t.description = description
23
+ t.create connection, loggingObject
24
+ end
25
+
26
+ def create(connection = nil, loggingObject = nil)
27
+ CorePro::Utils::Requestor.post('/transfer/create', Transfer, self, connection, loggingObject)
28
+ end
29
+
30
+ def self.void(customerId, transactionId, tag, connection = nil, loggingObject = nil)
31
+ t = Transfer.new
32
+ t.customerId = customerId
33
+ t.transactionId = transactionId
34
+ t.tag = tag
35
+ t.void connection, loggingObject
36
+ end
37
+
38
+ def void(connection = nil, loggingObject = nil)
39
+ CorePro::Utils::Requestor.post('/transfer/void', Transfer, self, connection, loggingObject)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,9 @@
1
+ module CorePro
2
+ module Utils
3
+ class Logger
4
+ def write(body, loggingObject)
5
+ # TODO: write to log file / registered callback class
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,120 @@
1
+ require_relative '../version'
2
+ require_relative 'logger'
3
+ require_relative '../models/envelope'
4
+ require_relative '../core_pro_api_exception'
5
+ require_relative '../connection'
6
+
7
+ require 'openssl'
8
+ require 'base64'
9
+ require 'net/https'
10
+ require 'uri'
11
+ require 'json'
12
+
13
+ module CorePro
14
+ module Utils
15
+ class Requestor
16
+
17
+ SDK_USER_AGENT = "CorePro Ruby SDK v #{CorePro::VERSION}"
18
+
19
+ @@config = begin
20
+ if File.exists?('config.yml')
21
+ YAML.load(File.open('config.yml'))
22
+ else
23
+ {}
24
+ end
25
+ rescue ArgumentError => e
26
+ puts "Could not parse YAML: #{e.message}"
27
+ end
28
+
29
+
30
+ def self.get(relativeUrl, classDef, connection, loggingObject)
31
+ connection ||= Connection.createFromConfig()
32
+ if connection.headerValue.to_s.empty? || connection.domainName.to_s.empty?
33
+ raise ArgumentError, 'A valid connection with apiKey, apiSecret, and domainName must be specified.'
34
+ end
35
+ uri = URI.parse("https://#{connection.domainName}#{relativeUrl}")
36
+ if connection.proxyServerName != nil && connection.proxyPort != nil
37
+ proxy = Net::HTTP::Proxy(connection.proxyServerName, connection.proxyPort, connection.proxyUser, connection.proxyPassword)
38
+ http = proxy.new(uri.host, uri.port)
39
+ else
40
+ http = Net::HTTP.new(uri.host, uri.port)
41
+ end
42
+ http.use_ssl = true
43
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
44
+ headers = { 'User-Agent' => SDK_USER_AGENT,
45
+ 'Content-Type' => 'application/json; charset=utf-8',
46
+ 'Accept' => 'application/json; charset=utf-8',
47
+ 'Authorization' => connection.headerValue,
48
+ 'Host' => connection.domainName}
49
+ request = Net::HTTP::Get.new(uri.request_uri, headers)
50
+
51
+ response = http.request(request)
52
+
53
+ #Logger.write("hi mom", loggingObject)
54
+ parseResponse(request, response, classDef, connection, loggingObject)
55
+
56
+ end
57
+
58
+ def self.post(relativeUrl, classDef, toPost, connection, loggingObject)
59
+ connection ||= Connection.createFromConfig()
60
+ if connection.headerValue.to_s.empty? || connection.domainName.to_s.empty?
61
+ raise ArgumentError, 'A valid connection with apiKey, apiSecret, and domainName must be specified.'
62
+ end
63
+
64
+ uri = URI.parse("https://#{connection.domainName}#{relativeUrl}")
65
+ if connection.proxyServerName != nil && connection.proxyPort != nil
66
+ proxy = Net::HTTP::Proxy(connection.proxyServerName, connection.proxyPort, connection.proxyUser, connection.proxyPassword)
67
+ http = proxy.new(uri.host, uri.port)
68
+ else
69
+ http = Net::HTTP.new(uri.host, uri.port)
70
+ end
71
+ http.use_ssl = true
72
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
73
+ headers = { 'User-Agent' => SDK_USER_AGENT,
74
+ 'Content-Type' => 'application/json; charset=utf-8',
75
+ 'Accept' => 'application/json; charset=utf-8',
76
+ 'Authorization' => connection.headerValue,
77
+ 'Host' => connection.domainName}
78
+ request = Net::HTTP::Post.new(uri.request_uri, headers)
79
+ request.body = toPost.to_json
80
+ response = http.request(request)
81
+
82
+ #Logger.write("hi mom", loggingObject)
83
+ parseResponse(request, response, classDef, connection, loggingObject)
84
+
85
+ end
86
+
87
+ def self.parseResponse(req, resp, classDef, conn, loggingObject)
88
+ case resp.code
89
+ when '501'
90
+ raise 501
91
+ when '502'
92
+ raise 502
93
+ when '503'
94
+ raise 503
95
+ when '504'
96
+ raise 504
97
+ when '505'
98
+ raise 505
99
+ else
100
+ envelope = CorePro::Models::Envelope.new
101
+ envelope.rawRequestBody = req.body
102
+ envelope.rawResponseBody = resp.body
103
+ parsedJson = JSON.parse(resp.body)
104
+ envelope.from_json! parsedJson, { 'data' => classDef }
105
+ if envelope.errors.length > 0
106
+ raise CorePro::CoreProApiException.new(envelope.errors)
107
+ else
108
+ if classDef == nil
109
+ # no class definition given, return raw envelope
110
+ envelope
111
+ else
112
+ # class definition given, return just that data
113
+ envelope.data
114
+ end
115
+ end
116
+ end
117
+ end
118
+ end
119
+ end
120
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/ruby -w
2
+ module CorePro
3
+ VERSION = '1.0.9'
4
+ end
data/q2labs_public.pem ADDED
@@ -0,0 +1,9 @@
1
+ -----BEGIN PUBLIC KEY-----
2
+ MIIBIDANBgkqhkiG9w0BAQEFAAOCAQ0AMIIBCAKCAQEAvWp5DhHGFUQnMl7elQ2T
3
+ TQ+grCpsmo+ZsKE7K+FDqaCs0dxge0Sepju5wbusXCgPv1c0297foYLqfF7zHxIY
4
+ k5T/O8jsgt26iHAjUIOJx+qsMnWUR3/RUMscH4Ft8GVCWrJL+dRUM6rUFPDDwmbp
5
+ aQuVgvm/a0igDFZLykuBDTDaSTul35dPrRWsi+f8bQ3g+VdDQqB0A/eup2UxByts
6
+ zDf65xDIG8oC6C2Mf2Ws6i6zb69Su24a6jxwKDvglIlCDFxgGNDvZ2pyv8ifIgds
7
+ YPKw4UYnffRTJlRphrv/KiUIp8TluB0NPYQfJnGAcsheGjYuHCHkig0WEQ69GBRx
8
+ 0QIBJQ==
9
+ -----END PUBLIC KEY-----
data/test.pdf ADDED
Binary file
@@ -0,0 +1,12 @@
1
+ require_relative 'core_pro_test_base'
2
+ require_relative '../lib/corepro/program'
3
+
4
+ class AProgramTest < CoreProTestBase
5
+ def test_get
6
+ p = CorePro::Program.get @@exampleConn, nil
7
+ pa = p.accounts.select {|e| e.type == 'ProgramReserve'}
8
+ @@exampleProgramReserveAccountId = pa[0].programAccountId
9
+ puts "Program Reserve AccountId=#{@@exampleProgramReserveAccountId}"
10
+ assert_equal 'Example1', p.name
11
+ end
12
+ end