corepro 0.0.4

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 (55) hide show
  1. data/.gitignore +16 -0
  2. data/.idea/.name +1 -0
  3. data/.idea/.rakeTasks +7 -0
  4. data/.idea/corepro-sdk-ruby.iml +67 -0
  5. data/.idea/encodings.xml +5 -0
  6. data/.idea/misc.xml +5 -0
  7. data/.idea/modules.xml +9 -0
  8. data/.idea/scopes/scope_settings.xml +5 -0
  9. data/.idea/vcs.xml +7 -0
  10. data/CorePro.gemspec +23 -0
  11. data/Gemfile +15 -0
  12. data/LICENSE +21 -0
  13. data/README.md +47 -0
  14. data/Rakefile +2 -0
  15. data/config-sample.yml +3 -0
  16. data/lib/CorePro/Models/account_id_only.rb +8 -0
  17. data/lib/CorePro/Models/api_error.rb +14 -0
  18. data/lib/CorePro/Models/customer_address.rb +17 -0
  19. data/lib/CorePro/Models/customer_answer.rb +9 -0
  20. data/lib/CorePro/Models/customer_id_only.rb +8 -0
  21. data/lib/CorePro/Models/customer_message.rb +10 -0
  22. data/lib/CorePro/Models/customer_phone.rb +11 -0
  23. data/lib/CorePro/Models/customer_question.rb +21 -0
  24. data/lib/CorePro/Models/customer_response.rb +27 -0
  25. data/lib/CorePro/Models/customer_verify_request.rb +29 -0
  26. data/lib/CorePro/Models/envelope.rb +37 -0
  27. data/lib/CorePro/Models/external_account_id_only.rb +8 -0
  28. data/lib/CorePro/Models/external_account_verify.rb +13 -0
  29. data/lib/CorePro/Models/file_content.rb +10 -0
  30. data/lib/CorePro/Models/json_base.rb +81 -0
  31. data/lib/CorePro/Models/model_base.rb +16 -0
  32. data/lib/CorePro/Models/program_interest_rate.rb +13 -0
  33. data/lib/CorePro/Models/program_limit.rb +12 -0
  34. data/lib/CorePro/Utils/logger.rb +9 -0
  35. data/lib/CorePro/Utils/requestor.rb +89 -0
  36. data/lib/CorePro/account.rb +74 -0
  37. data/lib/CorePro/account_close.rb +22 -0
  38. data/lib/CorePro/connection.rb +68 -0
  39. data/lib/CorePro/core_pro_api_exception.rb +21 -0
  40. data/lib/CorePro/customer.rb +150 -0
  41. data/lib/CorePro/customer_beneficiary.rb +55 -0
  42. data/lib/CorePro/customer_document.rb +34 -0
  43. data/lib/CorePro/document.rb +23 -0
  44. data/lib/CorePro/external_account.rb +86 -0
  45. data/lib/CorePro/external_account_document.rb +36 -0
  46. data/lib/CorePro/program.rb +58 -0
  47. data/lib/CorePro/statement.rb +28 -0
  48. data/lib/CorePro/transaction.rb +40 -0
  49. data/lib/CorePro/transfer.rb +42 -0
  50. data/lib/CorePro/version.rb +4 -0
  51. data/lib/CorePro.rb +14 -0
  52. data/test/account_test.rb +37 -0
  53. data/test/core_pro_test_base.rb +10 -0
  54. data/test/customer_test.rb +46 -0
  55. metadata +135 -0
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+
16
+ config.yml
data/.idea/.name ADDED
@@ -0,0 +1 @@
1
+ corepro-sdk-ruby
data/.idea/.rakeTasks ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build CorePro-0.0.1.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Build and install CorePro-0.0.1.gem into system gems" fullCmd="install" taksId="install" /><RakeTask description="Create tag v0.0.1 and build and push CorePro-0.0.1.gem to Rubygems" fullCmd="release" taksId="release" /></RakeGroup></Settings>
@@ -0,0 +1,67 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="CompassSettings">
4
+ <option name="compassSupportEnabled" value="true" />
5
+ </component>
6
+ <component name="FacetManager">
7
+ <facet type="gem" name="Ruby Gem">
8
+ <configuration>
9
+ <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
10
+ <option name="GEM_APP_TEST_PATH" value="$MODULE_DIR$/test" />
11
+ <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
12
+ </configuration>
13
+ </facet>
14
+ </component>
15
+ <component name="ModuleRunConfigurationManager">
16
+ <configuration default="false" name="All tests in corepro-sdk-ruby: corepro-sdk-ruby" type="TestUnitRunConfigurationType" factoryName="Test::Unit/Shoulda/Minitest" temporary="true">
17
+ <predefined_log_file id="RUBY_TESTUNIT" enabled="true" />
18
+ <module name="corepro-sdk-ruby" />
19
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
20
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
21
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
22
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
23
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
24
+ <envs>
25
+ <env name="JRUBY_OPTS" value="-X+O" />
26
+ </envs>
27
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
28
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
29
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov" />
30
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
31
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="$MODULE_DIR$" />
32
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="" />
33
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/{*_test,test_*}.rb" />
34
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_METHOD_NAME" VALUE="" />
35
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="ALL_IN_FOLDER" />
36
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
37
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
38
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="SPRING" VALUE="false" />
39
+ <RTEST_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_OPTIONS" VALUE="" />
40
+ <RunnerSettings RunnerId="RubyCover" />
41
+ <RunnerSettings RunnerId="RubyDebugRunner" />
42
+ <RunnerSettings RunnerId="RubyRunner" />
43
+ <ConfigurationWrapper RunnerId="RubyCover" />
44
+ <ConfigurationWrapper RunnerId="RubyDebugRunner" />
45
+ <ConfigurationWrapper RunnerId="RubyRunner" />
46
+ <method />
47
+ </configuration>
48
+ </component>
49
+ <component name="NewModuleRootManager">
50
+ <content url="file://$MODULE_DIR$">
51
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
52
+ </content>
53
+ <orderEntry type="inheritedJdk" />
54
+ <orderEntry type="sourceFolder" forTests="false" />
55
+ <orderEntry type="library" scope="PROVIDED" name="ansi (v1.4.3, ruby-1.9.3-p484) [gem]" level="application" />
56
+ <orderEntry type="library" scope="PROVIDED" name="builder (v3.2.2, ruby-1.9.3-p484) [gem]" level="application" />
57
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v1.7.0, ruby-1.9.3-p484) [gem]" level="application" />
58
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.4.0, ruby-1.9.3-p484) [gem]" level="application" />
59
+ <orderEntry type="library" scope="PROVIDED" name="minitest-reporters (v1.0.5, ruby-1.9.3-p484) [gem]" level="application" />
60
+ <orderEntry type="library" scope="PROVIDED" name="power_assert (v0.1.3, ruby-1.9.3-p484) [gem]" level="application" />
61
+ <orderEntry type="library" scope="PROVIDED" name="rake (v10.3.2, ruby-1.9.3-p484) [gem]" level="application" />
62
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.5.1, ruby-1.9.3-p484) [gem]" level="application" />
63
+ <orderEntry type="library" scope="PROVIDED" name="test-unit (v3.0.1, ruby-1.9.3-p484) [gem]" level="application" />
64
+ <orderEntry type="library" scope="PROVIDED" name="win32console (v1.3.0, ruby-1.9.3-p484) [gem]" level="application" />
65
+ </component>
66
+ </module>
67
+
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
4
+ </project>
5
+
data/.idea/misc.xml ADDED
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="ruby-1.9.3-p484" project-jdk-type="RUBY_SDK" />
4
+ </project>
5
+
data/.idea/modules.xml ADDED
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/corepro-sdk-ruby.iml" filepath="$PROJECT_DIR$/.idea/corepro-sdk-ruby.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
9
+
@@ -0,0 +1,5 @@
1
+ <component name="DependencyValidationManager">
2
+ <state>
3
+ <option name="SKIP_IMPORT_STATEMENTS" value="false" />
4
+ </state>
5
+ </component>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
7
+
data/CorePro.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'corepro/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'corepro'
8
+ spec.version = CorePro::VERSION
9
+ spec.authors = ['devsupport']
10
+ spec.email = ['devsupport@socialmoney.com']
11
+ spec.summary = %q{A Ruby SDK for consuming the corepro API.}
12
+ spec.description = %q{See http://docs.corepro.io for more detail.}
13
+ spec.homepage = 'https://github.com/socialmoney/corepro-sdk-ruby'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.6'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ end
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in corepro.gemspec
4
+ gemspec
5
+
6
+ # gem 'corepro'
7
+
8
+ group :test do
9
+ if RUBY_PLATFORM =~ /(win32|w32)/
10
+ gem "win32console", '1.3.0'
11
+ end
12
+ gem "minitest"
13
+ gem 'minitest-reporters', '>= 0.5.0'
14
+ gem 'test-unit'
15
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 socialmoney.com
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,47 @@
1
+ # corepro-sdk-ruby
2
+
3
+ A Ruby SDK for consuming the CorePro API
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'corepro'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install corepro
20
+
21
+ ## Usage
22
+
23
+ Use this object hierarchy as a simple entry point into CorePro. Details of the CorePro API itself are available at
24
+ https://docs.corepro.io/api. To see all available SDKs, visit https://docs.corepro.io/sdk.
25
+
26
+ ```ruby
27
+ require 'corepro'
28
+
29
+ # create a connection
30
+ # (typical use case is to pull connection info from config.yml, this is for example only)
31
+ conn = CorePro::Connection.new 'your-api-key-here', 'your-api-secret-here', 'api.corepro.io'
32
+
33
+ # retrieve a customer by a known tag (pass conn as nil if connection info is in config.yml)
34
+ cust = CorePro::Customer.getByTag 'bweaver', conn
35
+
36
+ # retrieve most recent transactions for that customer's primary account
37
+ trans = CorePro::Transaction.list cust.customerId, cust.accounts[0].accountId
38
+
39
+ ```
40
+
41
+ ## Contributing
42
+
43
+ 1. Fork it ( https://github.com/socialmoney/corepro-sdk-ruby/fork )
44
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
45
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
46
+ 4. Push to the branch (`git push origin my-new-feature`)
47
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/config-sample.yml ADDED
@@ -0,0 +1,3 @@
1
+ CoreProApiKey: your-api-key-here
2
+ CoreProApiSecret: your-secret-here
3
+ CoreProDomainName: sandbox-api.corepro.io
@@ -0,0 +1,8 @@
1
+ require_relative 'model_base'
2
+ module CorePro
3
+ module Models
4
+ class AccountIdOnly < ModelBase
5
+ attr_accessor :accountId
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ require_relative 'json_base'
2
+
3
+ module CorePro
4
+ module Models
5
+ class ApiError < JsonBase
6
+ attr_accessor :code
7
+ attr_accessor :message
8
+
9
+ def to_s
10
+ "code: #{@code}, message: #{@message}"
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ require_relative 'json_base'
2
+ module CorePro
3
+ module Models
4
+ class CustomerAddress < JsonBase
5
+ attr_accessor :addressType
6
+ attr_accessor :addressLine1
7
+ attr_accessor :addressLine2
8
+ attr_accessor :addressLine3
9
+ attr_accessor :addressLine4
10
+ attr_accessor :city
11
+ attr_accessor :state
12
+ attr_accessor :postalCode
13
+ attr_accessor :country
14
+ attr_accessor :isActive
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ require_relative 'json_base'
2
+ module CorePro
3
+ module Models
4
+ class CustomerAnswer < JsonBase
5
+ attr_accessor :questionType
6
+ attr_accessor :questionAnswer
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ require_relative 'model_base'
2
+ module CorePro
3
+ module Models
4
+ class CustomerIdOnly < ModelBase
5
+ attr_accessor :customerId
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ require_relative 'json_base'
2
+
3
+ module CorePro
4
+ module Models
5
+ class CustomerMessage < JsonBase
6
+ attr_accessor :verificationId
7
+ attr_accessor :verificationMessage
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,11 @@
1
+ require_relative 'json_base'
2
+
3
+ module CorePro
4
+ module Models
5
+ class CustomerPhone < JsonBase
6
+ attr_accessor :phoneType
7
+ attr_accessor :number
8
+ attr_accessor :isActive
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ require_relative 'json_base'
2
+ require_relative 'customer_answer'
3
+ module CorePro
4
+ module Models
5
+ class CustomerQuestion < JsonBase
6
+ attr_accessor :answers
7
+ attr_accessor :prompt
8
+ attr_accessor :type
9
+
10
+ def from_json! json, classDefs
11
+ classDefs = classDefs || {}
12
+ classDefs['answers'] = CustomerAnswer
13
+ super json, classDefs
14
+ end
15
+
16
+ def initialize
17
+ @answers = []
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ require_relative 'model_base'
2
+ require_relative 'customer_message'
3
+ require_relative 'customer_question'
4
+
5
+ module CorePro
6
+ module Models
7
+ class CustomerResponse < ModelBase
8
+ attr_accessor :customerId
9
+ attr_accessor :messages
10
+ attr_accessor :questions
11
+ attr_accessor :verificationId
12
+ attr_accessor :verificationStatus
13
+
14
+ def from_json! json, classDefs
15
+ classDefs = classDefs || {}
16
+ classDefs['messages'] = CustomerMessage
17
+ classDefs['questions'] = CustomerQuestion
18
+ super json, classDefs
19
+ end
20
+
21
+ def initialize
22
+ @messages = []
23
+ @questions = []
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,29 @@
1
+ require_relative 'model_base'
2
+ require_relative '../utils/requestor'
3
+ require_relative 'customer_response'
4
+ require_relative 'customer_answer'
5
+
6
+ module CorePro
7
+ module Models
8
+ class CustomerVerifyRequest < ModelBase
9
+ attr_accessor :customerId
10
+ attr_accessor :verificationId
11
+ attr_accessor :answers
12
+
13
+ def from_json! json, classDefs
14
+ classDefs = classDefs || {}
15
+ classDefs['answers'] = CustomerAnswer
16
+ super json, classDefs
17
+ end
18
+
19
+ def initialize
20
+ @answers = []
21
+ end
22
+
23
+ def verify(connection = NIL, loggingObject = NIL)
24
+ connection = connection || Connection.createFromConfig()
25
+ CorePro::Utils::Requestor.post('/customer/verify', CustomerResponse, self, connection, loggingObject)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,37 @@
1
+ require_relative 'model_base'
2
+ require_relative 'api_error'
3
+
4
+ module CorePro
5
+ module Models
6
+ class Envelope < ModelBase
7
+ attr_accessor :data
8
+ attr_accessor :errors
9
+ attr_accessor :status
10
+ attr_accessor :rawRequestBody
11
+ attr_accessor :rawResponseBody
12
+
13
+ def from_json! json, classDefs = {}
14
+ classDefs = classDefs || {}
15
+ classDefs['errors'] = ApiError
16
+ super json, classDefs
17
+
18
+ if classDefs.has_key?('data')
19
+ if @data.kind_of?(Array)
20
+ @data.each {|item|
21
+ if item.instance_variable_defined?('@requestId')
22
+ item.requestId = @requestId
23
+ end
24
+ }
25
+ else
26
+ if @data.instance_variable_defined?('@requestId')
27
+ @data.requestId = @requestId
28
+ end
29
+ end
30
+ end
31
+
32
+ self
33
+
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,8 @@
1
+ require_relative 'model_base'
2
+ module CorePro
3
+ module Models
4
+ class ExternalAccountIdOnly < ModelBase
5
+ attr_accessor :externalAccountId
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,13 @@
1
+ require_relative 'model_base'
2
+
3
+ module CorePro
4
+ module Models
5
+ class ExternalAccountVerify < ModelBase
6
+
7
+ attr_accessor :customerId
8
+ attr_accessor :externalAccountId
9
+ attr_accessor :amount1
10
+ attr_accessor :amount2
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ require_relative 'model_base'
2
+ module CorePro
3
+ module Models
4
+ class FileContent < ModelBase
5
+ attr_accessor :content
6
+ attr_accessor :contentType
7
+ attr_accessor :contentLength
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,81 @@
1
+ require 'json'
2
+
3
+ module CorePro
4
+ module Models
5
+ class JsonBase
6
+
7
+ def to_hash
8
+ hash = {}
9
+ self.instance_variables.each do |var|
10
+ val = self.instance_variable_get var
11
+ if val != nil
12
+ if val.instance_of?(Array)
13
+ arr = []
14
+ val.each do |x|
15
+ arr.push(x.to_hash)
16
+ end
17
+ hash[var.to_s.delete('@')] = arr
18
+ else
19
+ hash[var.to_s.delete('@')] = val
20
+ end
21
+ end
22
+ end
23
+
24
+ hash
25
+ end
26
+
27
+ def to_json
28
+ hash = {}
29
+ self.instance_variables.each do |var|
30
+ val = self.instance_variable_get var
31
+ if val != nil
32
+ if val.instance_of?(String)
33
+ hash[var.to_s.delete('@')] = val
34
+ elsif val.instance_of?(Array)
35
+ # do not serialize empty arrays. no point.
36
+ if val.length > 0
37
+ arr = []
38
+ val.each do |x|
39
+ h = x.to_hash
40
+ arr.push h
41
+ end
42
+ hash[var.to_s.delete('@')] = arr
43
+ end
44
+ else
45
+ hash[var.to_s.delete('@')] = val.to_json
46
+ end
47
+ end
48
+ end
49
+ hash.to_json
50
+ end
51
+
52
+
53
+
54
+ def from_json! json, classDefs = nil
55
+ classDefs = classDefs || {}
56
+ json.each do |var, val|
57
+ # if self.instance_variable_defined?("@#{var}")
58
+ cd = nil
59
+ cd = classDefs[var] if classDefs.has_key? var
60
+ if cd == nil
61
+ self.instance_variable_set "@#{var}", val
62
+ else
63
+ if val.kind_of?(Array)
64
+ arr = []
65
+ val.each do |x|
66
+ item = cd.new
67
+ item.from_json! x, nil
68
+ arr.push item
69
+ end
70
+ self.instance_variable_set "@#{var}", arr
71
+ else
72
+ item = cd.new
73
+ item.from_json! val, nil
74
+ self.instance_variable_set "@#{var}", item
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'json_base'
2
+ module CorePro
3
+ module Models
4
+ class ModelBase < JsonBase
5
+ attr_accessor :requestId
6
+
7
+ def to_s
8
+ vars = self.instance_variables.map{|v|
9
+ "#{v}=#{instance_variable_get(v).inspect}"
10
+ }.join(", ")
11
+ "<#{self.class}: #{vars}>"
12
+ end
13
+
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ require_relative 'json_base'
2
+ module CorePro
3
+ module Models
4
+ class ProgramInterestRate < JsonBase
5
+ attr_accessor :tier
6
+ attr_accessor :apy
7
+ attr_accessor :apr
8
+ attr_accessor :minimumAmount
9
+ attr_accessor :maximumAmount
10
+
11
+ end
12
+ end
13
+ end
@@ -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,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