musoni_ruby 0.0.01
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +10 -0
- data/.travis.yml +13 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/Guardfile +50 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +20 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/lib/musoni-ruby.rb +1 -0
- data/lib/musoni_ruby/configuration.rb +16 -0
- data/lib/musoni_ruby/endpoints/_endpoint.rb +101 -0
- data/lib/musoni_ruby/endpoints/client.rb +91 -0
- data/lib/musoni_ruby/endpoints/datatable.rb +77 -0
- data/lib/musoni_ruby/endpoints/loan.rb +78 -0
- data/lib/musoni_ruby/endpoints/run_report.rb +21 -0
- data/lib/musoni_ruby/endpoints/savings_account.rb +77 -0
- data/lib/musoni_ruby/fetch.rb +53 -0
- data/lib/musoni_ruby/support/fake_musoni/authentication/.keep +0 -0
- data/lib/musoni_ruby/support/fake_musoni/clients/.keep +0 -0
- data/lib/musoni_ruby/support/fake_musoni/datatables/.keep +0 -0
- data/lib/musoni_ruby/support/fake_musoni/loans/.keep +0 -0
- data/lib/musoni_ruby/support/fake_musoni/runreports/.keep +0 -0
- data/lib/musoni_ruby/support/fake_musoni/savingsaccounts/.keep +0 -0
- data/lib/musoni_ruby/support/fake_musoni.rb +25 -0
- data/lib/musoni_ruby/support/test_helper.rb +173 -0
- data/lib/musoni_ruby/version.rb +3 -0
- data/lib/musoni_ruby.rb +54 -0
- data/musoni_ruby.gemspec +47 -0
- metadata +285 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ac0fd2d663bf0b23d63c6299ef6014d09b4aefcf
|
4
|
+
data.tar.gz: b518d6c2ba1dbac1ee90725cdeab19a82b87b590
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7825b4299a4e84abf8f6c1b848fcd9a6512874d8bf0c214d11dd41f287aac36859d6ecdab6274f7cead78c498a727e0d28696847fc57b257565f1b05ebde69fd
|
7
|
+
data.tar.gz: 70dd3cd03e1bf00408e521b5528e39b2a0520d47d3a2fb6d0161cf228f523af5b3a61a8e06a049e9a0f36cb3978265c56f1d6fc7a2665eaeb85ea96f84665213
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features)
|
6
|
+
|
7
|
+
## Uncomment to clear the screen before every task
|
8
|
+
# clearing :on
|
9
|
+
|
10
|
+
## Guard internally checks for changes in the Guardfile and exits.
|
11
|
+
## If you want Guard to automatically start up again, run guard in a
|
12
|
+
## shell loop, e.g.:
|
13
|
+
##
|
14
|
+
## $ while bundle exec guard; do echo "Restarting Guard..."; done
|
15
|
+
##
|
16
|
+
## Note: if you are using the `directories` clause above and you are not
|
17
|
+
## watching the project directory ('.'), then you will want to move
|
18
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
19
|
+
#
|
20
|
+
# $ mkdir config
|
21
|
+
# $ mv Guardfile config/
|
22
|
+
# $ ln -s config/Guardfile .
|
23
|
+
#
|
24
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
25
|
+
|
26
|
+
guard :minitest do
|
27
|
+
# with Minitest::Unit
|
28
|
+
watch(%r{^test/(.*)\/?(.*)_test\.rb$})
|
29
|
+
watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
|
30
|
+
watch(%r{^test/test_helper\.rb$}) { 'test' }
|
31
|
+
|
32
|
+
# with Minitest::Spec
|
33
|
+
# watch(%r{^spec/(.*)_spec\.rb$})
|
34
|
+
# watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
35
|
+
# watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
|
36
|
+
|
37
|
+
# Rails 4
|
38
|
+
# watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
39
|
+
# watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
|
40
|
+
# watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
|
41
|
+
# watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
|
42
|
+
# watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
|
43
|
+
# watch(%r{^test/.+_test\.rb$})
|
44
|
+
# watch(%r{^test/test_helper\.rb$}) { 'test' }
|
45
|
+
|
46
|
+
# Rails < 4
|
47
|
+
# watch(%r{^app/controllers/(.*)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
|
48
|
+
# watch(%r{^app/helpers/(.*)\.rb$}) { |m| "test/helpers/#{m[1]}_test.rb" }
|
49
|
+
# watch(%r{^app/models/(.*)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
|
50
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Kariuki Gathitu
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Musoni
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/musoni_ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'musoni_ruby'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install musoni_ruby
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/musoni_ruby/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
Rake::TestTask.new do |task|
|
5
|
+
task.libs << %w(test lib)
|
6
|
+
task.pattern = 'test/**/*_test.rb'
|
7
|
+
end
|
8
|
+
|
9
|
+
namespace :load do
|
10
|
+
desc "Load Musoni to local from Test run for offline testing"
|
11
|
+
task :musoni do
|
12
|
+
# Delete current files first
|
13
|
+
File.delete(*Dir.glob('lib/musoni_ruby/support/**/*.json'))
|
14
|
+
ENV['LOAD_MUSONI'] = 'true'
|
15
|
+
Rake::Task["test"].invoke
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
task :default => :test
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "musoni_ruby"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/lib/musoni-ruby.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'musoni_ruby'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Musoni
|
2
|
+
class Configuration
|
3
|
+
attr_accessor :tenant, :token, :base_url
|
4
|
+
|
5
|
+
def initialize(tenant:nil,token:nil,base_url:'https://demo.musonisystem.com:8443/api/v1')
|
6
|
+
@base_url ||= base_url
|
7
|
+
@tenant ||= tenant
|
8
|
+
@token ||= token
|
9
|
+
end
|
10
|
+
|
11
|
+
def header
|
12
|
+
{'Content-Type'=> 'application/json', 'Accept' => 'application/json', 'X-Mifos-Platform-TenantId' => tenant.to_s, 'Authorization' => "Basic #{token}"}
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
module Musoni
|
2
|
+
class Endpoint
|
3
|
+
attr_accessor :config, :response, :pagination, :endpoint, :attributes
|
4
|
+
attr_accessor :id
|
5
|
+
|
6
|
+
# Musoni::Model.new(options={})
|
7
|
+
def initialize(config:nil,**keyword_args)
|
8
|
+
@attributes = Hashie::Mash.new(keyword_args)
|
9
|
+
keyword_args.each do |k,v|
|
10
|
+
self.send("#{k.to_s}=",v) rescue nil
|
11
|
+
end
|
12
|
+
@config = set_config(config)
|
13
|
+
# @is_new ||= true
|
14
|
+
@pagination ||= {}
|
15
|
+
after_initialize
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
|
20
|
+
def kill
|
21
|
+
instance_variables.each{|var| instance_variable_set(var,nil)}
|
22
|
+
freeze
|
23
|
+
end
|
24
|
+
|
25
|
+
# after_initialize{ @endpoint = 'clients'}
|
26
|
+
# class << self
|
27
|
+
# # Used to instantiate new objects instead of using def initialize
|
28
|
+
# def after_initialize#(&block)
|
29
|
+
# # block.call
|
30
|
+
# # yield if block_given?
|
31
|
+
# yield
|
32
|
+
# end
|
33
|
+
# end
|
34
|
+
|
35
|
+
def after_initialize
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
# Use this methon in the association reader method witht the same name
|
40
|
+
def find_all(offset:1,limit:100, **options)
|
41
|
+
# gets caller methods as association
|
42
|
+
association = caller_locations(1,1)[0].label
|
43
|
+
url = assoc_link(association.to_sym,options)
|
44
|
+
if self.pagination[association]=={limit:limit,offset:offset}
|
45
|
+
self.send("#{association}=", Musoni::Fetch.get(url,query:{offset:offset,limit:limit}) ) if instance_variable_get("@#{association}").nil?
|
46
|
+
else
|
47
|
+
self.send("#{association}=", Musoni::Fetch.get(url,query:{offset:offset,limit:limit}) )
|
48
|
+
end
|
49
|
+
self.pagination.merge!({"#{association}":{offset:offset,limit:limit}})
|
50
|
+
return instance_variable_get("@#{association}")
|
51
|
+
end
|
52
|
+
|
53
|
+
def assoc_link(association,**options)
|
54
|
+
query = options[:query].map{|k,v| "#{k}=#{v}" }.join('&') if options[:query]
|
55
|
+
extra_link = options[:link]
|
56
|
+
extra_link += '/' if options[:link]
|
57
|
+
extra_link += "?#{query}" if query
|
58
|
+
|
59
|
+
"/#{self.endpoint}/#{self.id}/#{association}/#{extra_link}"
|
60
|
+
|
61
|
+
# case association
|
62
|
+
# when :transactions
|
63
|
+
# raise ArgumentError if options[:account_id].nil?
|
64
|
+
# "/#{self.endpoint}/#{self.id}/accounts/#{options[:account_id]}/#{association}"
|
65
|
+
# else # :accounts, :payables, :members
|
66
|
+
# "/#{self.endpoint}/#{self.id}/#{association}"
|
67
|
+
# end
|
68
|
+
end
|
69
|
+
|
70
|
+
# def self.has_associations(*attr_names)
|
71
|
+
# attr_names.each do |attr_name|
|
72
|
+
# # writers
|
73
|
+
# define_method("#{attr_name}=") do |value|
|
74
|
+
# instance_variable_set("@"+attr_name.to_s, value)
|
75
|
+
# end
|
76
|
+
# #readers
|
77
|
+
# define_method(attr_name) do
|
78
|
+
# instance_variable_get("@"+attr_name.to_s)
|
79
|
+
# end
|
80
|
+
# end
|
81
|
+
# end
|
82
|
+
|
83
|
+
def set_config(configuration)
|
84
|
+
config = Musoni.configuration.clone
|
85
|
+
unless configuration.nil?
|
86
|
+
config.tenant = configuration[:tenant]
|
87
|
+
config.token = configuration[:token]
|
88
|
+
end
|
89
|
+
config
|
90
|
+
end
|
91
|
+
|
92
|
+
def method_missing(m, *args, &block)
|
93
|
+
if @response.is_a?(Hash)
|
94
|
+
@response.keys.include?(m.to_s) ? @response.send(m) : super
|
95
|
+
else
|
96
|
+
super
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
module Musoni
|
2
|
+
class Client < Musoni::Endpoint
|
3
|
+
attr_writer :accounts, :identifier, :identifiers#, :transactions
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
# Musoni::Client.all
|
8
|
+
def all(offset:1,limit:100)
|
9
|
+
url = "/clients"
|
10
|
+
clients = Musoni::Fetch.get(url,query:{offset:offset,limit:limit}).pageItems
|
11
|
+
end
|
12
|
+
|
13
|
+
# Musoni::Client.find(id)
|
14
|
+
def find(client_id,fetch: true)
|
15
|
+
url = "/clients/#{client_id}"
|
16
|
+
response = Musoni::Fetch.get(url) if fetch
|
17
|
+
client = new(id:client_id,response:response)
|
18
|
+
end
|
19
|
+
|
20
|
+
# client_attributes = {:officeId=>"2",:firstname=>"Firstname",:staffId=>"1",:lastname=>"Lastname",:middlename=>"MiddleName",:externalId=>rand(100000),:mobileNo=>"072345678",:submittedOnDate=>"11-05-2015",:active=>"true",:activationDate=>"12-05-2015"}
|
21
|
+
# Musoni::Client.create(client_attributes)
|
22
|
+
def create(options={})
|
23
|
+
url = "/clients"
|
24
|
+
response = Musoni::Fetch.post(url,options)
|
25
|
+
client = new(options.merge!(id:response.clientId ,response:response)) rescue response
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
# identifier={:documentTypeId=>"2",:documentKey=>"12441221412",:description=>"Kenya National ID"}
|
31
|
+
# client.create_identifier(identifier)
|
32
|
+
def create_identifier(options={})
|
33
|
+
url = "/clients/#{self.id}/identifiers"
|
34
|
+
@identifier = Musoni::Fetch.post(url,options)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
# [[193, "Passport No"],
|
40
|
+
# [194, "Service ID"],
|
41
|
+
# [195, "Alien ID"],
|
42
|
+
# [192, "National ID"],
|
43
|
+
# [196, "Tax ID"],
|
44
|
+
# [1, "Passport"],
|
45
|
+
# [2, "Id"],
|
46
|
+
# [3, "Drivers License"],
|
47
|
+
# [4, "Any Other Id Type"]]
|
48
|
+
|
49
|
+
# # Musoni::Client.find(id:20284).account(accountsid)
|
50
|
+
# def account(account_id=nil,client_id=id)
|
51
|
+
# account_id ||= @account.id rescue nil
|
52
|
+
# raise "Arguments missing: account_id or client_id" if client_id.nil? or account_id.nil?
|
53
|
+
# url = "/clients/#{client_id}/accounts/#{account_id}"
|
54
|
+
# if (@account.id == account_id rescue false)
|
55
|
+
# @account ||= Musoni::Fetch.get(url)
|
56
|
+
# else
|
57
|
+
# @account = Musoni::Fetch.get(url)
|
58
|
+
# end
|
59
|
+
# end
|
60
|
+
|
61
|
+
# # options = {account:{name: name, ac_type: ac_type, mandate: mandate, tags_attributes:@tags, infos_attributes:@infos}}
|
62
|
+
# # Musoni::Client.find(id:20284).create_account(options)
|
63
|
+
# def create_account(options={})
|
64
|
+
# url = "/clients/#{self.id}/accounts/new"
|
65
|
+
# @account = Musoni::Fetch.post(url,options)
|
66
|
+
# end
|
67
|
+
|
68
|
+
# Musoni::Client.find(26, fetch:false).identifiers(offset:1,limit:100)
|
69
|
+
# Musoni::Client.find(26, fetch:false).identifiers(link:tempalate,query:{})
|
70
|
+
def identifiers(offset:1,limit:100,link:nil)
|
71
|
+
find_all(offset:offset,limit:limit,link:link)
|
72
|
+
end
|
73
|
+
|
74
|
+
# Musoni::Client.find(26, fetch:false).accounts(offset:1,limit:100)
|
75
|
+
def accounts(offset:1,limit:100)
|
76
|
+
find_all(offset:offset,limit:limit)
|
77
|
+
end
|
78
|
+
|
79
|
+
# # Musoni::Client.find(26, fetch:false).transactions(account_id, offset:1,limit:100)
|
80
|
+
# def transactions(account_id,offset:1,limit:100)
|
81
|
+
# find_all(offset:offset,limit:limit,account_id:account_id)
|
82
|
+
# end
|
83
|
+
|
84
|
+
protected
|
85
|
+
|
86
|
+
def after_initialize
|
87
|
+
@endpoint = 'clients'
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
module Musoni
|
2
|
+
class Datatable < Musoni::Endpoint
|
3
|
+
attr_accessor :table_name
|
4
|
+
DATATABLES = [:ml_client_details, :cct_Borrower_Details, :cct_TransUnion, :cct_First_Access_Score]
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
# Musoni::Datatable.all(:ml_client_details)
|
9
|
+
def all(datatable, offset:1,limit:100)
|
10
|
+
url = "/datatables/#{datatable}"
|
11
|
+
datatables = Musoni::Fetch.get(url,query:{offset:offset,limit:limit})
|
12
|
+
end
|
13
|
+
|
14
|
+
# Musoni::Datatable.find(:ml_client_details,1)
|
15
|
+
def find(datatable, datatable_id,fetch: true)
|
16
|
+
url = "/datatables/#{datatable}/#{datatable_id}"
|
17
|
+
response = Musoni::Fetch.get(url) if fetch
|
18
|
+
datatable = new(id:datatable_id,response:response,table_name:datatable)
|
19
|
+
end
|
20
|
+
|
21
|
+
# datatable_attributes = {:MaritalStatus_cv_maritalStatus=>"Single",:dateOfBirth=>"01-01-1900",:Email=>"some@mailaddress.com",:Password=>"lajflkajsfldsjflk",:Client_Type=>"Borrower",:dateFormat=>"DD-MM-YYYY",:locale=>"en_GB"}
|
22
|
+
# Musoni::Datatable.create(:ml_client_details,1,datatable_attributes)
|
23
|
+
def create(datatable, datatable_id, options={})
|
24
|
+
url = "/datatables/#{datatable}/#{datatable_id}"
|
25
|
+
response = Musoni::Fetch.post(url,options)
|
26
|
+
datatable = new(id:datatable_id,response:response,table_name:datatable)
|
27
|
+
end
|
28
|
+
|
29
|
+
def add_client_info(client_id, options={})
|
30
|
+
Musoni::Datatable.create(:ml_client_details,client_id,options)
|
31
|
+
end
|
32
|
+
|
33
|
+
def add_borrower_info(client_id, options={})
|
34
|
+
Musoni::Datatable.create(:cct_Borrower_Details,client_id,options)
|
35
|
+
end
|
36
|
+
|
37
|
+
def find_client_info(client_id)
|
38
|
+
Musoni::Datatable.find(:ml_client_details,client_id)
|
39
|
+
end
|
40
|
+
|
41
|
+
def find_borrower_info(client_id)
|
42
|
+
Musoni::Datatable.find(:cct_Borrower_Details,client_id)
|
43
|
+
end
|
44
|
+
|
45
|
+
def find_credit_score(client_id)
|
46
|
+
Musoni::Datatable.find(:cct_First_Access_Score,client_id)
|
47
|
+
end
|
48
|
+
|
49
|
+
def find_credit_report(client_id)
|
50
|
+
Musoni::Datatable.find(:cct_TransUnion,client_id)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
# datatable_attributes = {:Email=>"new@email.com"}
|
56
|
+
# Musoni::Datatable.find(:ml_client_details,1).update(datatable_attributes)
|
57
|
+
def update(options)
|
58
|
+
url = "/datatables/#{self.table_name}/#{self.id}"
|
59
|
+
response = Musoni::Fetch.put(url,options)
|
60
|
+
self.response = response
|
61
|
+
end
|
62
|
+
|
63
|
+
# Musoni::Datatable.find(:ml_client_details,1).destroy
|
64
|
+
def destroy
|
65
|
+
url = "/datatables/#{self.table_name}/#{self.id}"
|
66
|
+
response = Musoni::Fetch.delete(url)
|
67
|
+
self.kill
|
68
|
+
end
|
69
|
+
|
70
|
+
protected
|
71
|
+
|
72
|
+
def after_initialize
|
73
|
+
@endpoint = 'datatables'
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module Musoni
|
2
|
+
class Loan < Musoni::Endpoint
|
3
|
+
attr_writer :transactions, :payable_items
|
4
|
+
|
5
|
+
class << self
|
6
|
+
|
7
|
+
# Musoni::Loan.all()
|
8
|
+
def all(offset:1,limit:100)
|
9
|
+
url = "/loans"
|
10
|
+
Musoni::Fetch.get(url,query:{offset:offset,limit:limit}).pageItems
|
11
|
+
end
|
12
|
+
|
13
|
+
# Musoni::Loan.find(loan_id)
|
14
|
+
def find(loan_id,fetch:true)
|
15
|
+
url = "/loans/#{loan_id}?associations=all"
|
16
|
+
response = Musoni::Fetch.get(url) if fetch
|
17
|
+
loan = new(id:loan_id,response:response)
|
18
|
+
end
|
19
|
+
|
20
|
+
# account_attributes = {:clientId=>"1",:productId=>"1",:submittedOnDate=>"13-05-2015",:fieldOfficerId=>"1",:charges=>[],:allowOverdraft=>false}
|
21
|
+
# Musoni::Loan.create(account_attributes)
|
22
|
+
def create(options={})
|
23
|
+
url = "/loans"
|
24
|
+
response = Musoni::Fetch.post(url,options)
|
25
|
+
new(options.merge!(id:response.loanId ,response:response)) rescue response
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
# # activation = {:approvedOnDate=>"13-05-2015",:note=>"Loan Funded"}
|
31
|
+
# # Musoni::Loan.find(loan.id, fetch:false).activate(activation)
|
32
|
+
%w{approve}.each do |m|
|
33
|
+
define_method m do |options={}|
|
34
|
+
options[:"#{m}dOnDate"] ||= Time.now.strftime("%d-%m-%Y")
|
35
|
+
url = "/loans/#{self.id}?command=#{m}"
|
36
|
+
response = Musoni::Fetch.post(url,options)
|
37
|
+
new(options.merge!(id:response.loanId ,response:response)) rescue response
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# disbursement = {:submittedOnDate=>"13-05-2015",:clientId=>"3",:productId=>"1",:loanOfficerId=>"1",:loanPurposeId=>"37",:principal=>"10,000.00",:loanTermFrequency=>"1",:loanTermFrequencyType=>"2",:numberOfRepayments=>"1",:repaymentEvery=>"1",:repaymentFrequencyType=>"2",:transactionProcessingStrategyId=>"1",:interestRatePerPeriod=>"5",:expectedDisbursementDate=>"13-05-2015",:amortizationType=>"1",:interestType=>"1",:interestCalculationPeriodType=>"1",:inArrearsTolerance=>"0",:interestChargedFromDate=>"13-05-2015",:repaymentsStartingFromDate=>"13-06-2015",:charges=>[],:loanType=>"individual",:linkAccountId=>"",:graceOnPrincipalPayment=>"0",:graceOnInterestCharged=>"0",:graceOnInterestPayment=>"0",:fundId=>"1",:createStandingInstructionAtDisbursement=>false}
|
42
|
+
# # Musoni::Loan.find(loan.id, fetch:false).disburse(disbursement)
|
43
|
+
%w{disburse}.each do |m|
|
44
|
+
define_method m do |options={}|
|
45
|
+
options[:actualDisbursementDate] ||= Time.now.strftime("%d-%m-%Y")
|
46
|
+
url = "/loans/#{self.id}?command=#{m}"
|
47
|
+
response = Musoni::Fetch.post(url,options)
|
48
|
+
new(options.merge!(id:response.loanId ,response:response)) rescue response
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# loan_options = {:interestCalculationPeriodType=>"1",:interestRatePerPeriod=>"7",:interestType=>"1",:loanTermFrequency=>"1",:loanTermFrequencyType=>"2",:numberOfRepayments=>"1",:principal=>"1000",:productId=>1,:repaymentEvery=>"1",:repaymentFrequencyType=>"2"}
|
53
|
+
# loan.update(loan_options)
|
54
|
+
def update(options)
|
55
|
+
url = "/loans/#{self.id}"
|
56
|
+
response = Musoni::Fetch.put(url,options)
|
57
|
+
self.response = response
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# # Musoni::Loan.find(26, fetch:false).transactions(offset:1,limit:100)
|
62
|
+
# def transactions(offset:1,limit:100)
|
63
|
+
# find_all(offset:offset,limit:limit)
|
64
|
+
# end
|
65
|
+
|
66
|
+
# # Musoni::Loan.find(26, fetch:false).payable_items(offset:1,limit:100)
|
67
|
+
# def payable_items(offset:1,limit:100)
|
68
|
+
# find_all(offset:offset,limit:limit)
|
69
|
+
# end
|
70
|
+
|
71
|
+
protected
|
72
|
+
|
73
|
+
def after_initialize
|
74
|
+
@endpoint = 'loans'
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Musoni
|
2
|
+
class RunReport < Musoni::Endpoint
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
# Musoni::RunReport.findSavingsAccount(mobile_no:'0974747474')
|
7
|
+
def findSavingsAccount(mobile_no:)
|
8
|
+
url = "/runreports/SearchSavingsAccountByMobile?R_phone_number=#{mobile_no}&genericResultSet=false"
|
9
|
+
response = Musoni::Fetch.get(url)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
def after_initialize
|
17
|
+
@endpoint = 'runreports'
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|