IBMhifive 0.0.01

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4025359f98283885b1057f0c249994cbe1cc418c
4
+ data.tar.gz: 0a4e2c48ccacc6a90176d5c9562a93cf7535b3ea
5
+ SHA512:
6
+ metadata.gz: fc61c61dd0dccee892cc05e10f2c34f10d9202a62b2f74ba1f69cfe38515281211e2dab1122cfeb1205bebc17c12785072cdd6938e0f18ec54a83d4d317b1535
7
+ data.tar.gz: c41f683bd2da902c6785902c7706c11540f40aaeaa760b00679e691644f6960c74e24d2b3ee576f8d165e06867d7a1a934e7b954fd071f4e0912faa25fd4d780
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /lib/IBMhifive/support/fake_ibm_hifive/**/*.json
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.2
@@ -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
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in IBMhifive.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,42 @@
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
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ guard :minitest do
19
+ # with Minitest::Unit
20
+ watch(%r{^test/(.*)\/?(.*)_test\.rb$})
21
+ watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}#{m[2]}_test.rb" }
22
+ watch(%r{^test/test_helper\.rb$}) { 'test' }
23
+
24
+ # with Minitest::Spec
25
+ # watch(%r{^spec/(.*)_spec\.rb$})
26
+ # watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
27
+ # watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
28
+
29
+ # Rails 4
30
+ # watch(%r{^app/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
31
+ # watch(%r{^app/controllers/application_controller\.rb$}) { 'test/controllers' }
32
+ # watch(%r{^app/controllers/(.+)_controller\.rb$}) { |m| "test/integration/#{m[1]}_test.rb" }
33
+ # watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
34
+ # watch(%r{^lib/(.+)\.rb$}) { |m| "test/lib/#{m[1]}_test.rb" }
35
+ # watch(%r{^test/.+_test\.rb$})
36
+ # watch(%r{^test/test_helper\.rb$}) { 'test' }
37
+
38
+ # Rails < 4
39
+ # watch(%r{^app/controllers/(.*)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
40
+ # watch(%r{^app/helpers/(.*)\.rb$}) { |m| "test/helpers/#{m[1]}_test.rb" }
41
+ # watch(%r{^app/models/(.*)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
42
+ end
data/IBMhifive.gemspec ADDED
@@ -0,0 +1,48 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'IBMhifive/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "IBMhifive"
8
+ spec.version = IBMhifive::VERSION
9
+ spec.authors = ["Kariuki Gathitu"]
10
+ spec.email = ["kgathi2@gmail.com"]
11
+
12
+ spec.summary = %q{Integration module for the IBMSocial Recomemdation system}
13
+ spec.description = %q{Integrates to the System that sits between PZ and IBM}
14
+ spec.homepage = "https://bitbucket.org/kgathi2/ibmhifive"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+ spec.required_ruby_version = '~> 2.0'
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.9"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ spec.add_development_dependency "guard", "~> 2.12"
34
+ spec.add_development_dependency "minitest", "~> 5.6"
35
+ spec.add_development_dependency "guard-minitest", "~> 2.4"
36
+ spec.add_development_dependency "minitest-reporters", "~> 1.0"
37
+ spec.add_development_dependency "pry", "~> 0.10"
38
+ spec.add_development_dependency "pry-nav", "~> 0.2"
39
+ spec.add_development_dependency "pry-alias", "~> 0.0"
40
+ spec.add_development_dependency "coveralls", '~> 0'
41
+ spec.add_development_dependency "webmock", '~> 1.21'
42
+ spec.add_development_dependency "sinatra", '~> 1.4'
43
+ spec.add_development_dependency "faker", '~> 1.4'
44
+
45
+ spec.add_dependency 'activesupport', "~> 4.2"
46
+ spec.add_dependency 'httparty', "~> 0.13"
47
+ spec.add_dependency 'hashie', "~> 3.4"
48
+ 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
+ # IBMhifive
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/IBMhifive`. 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 'IBMhifive'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install IBMhifive
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]/IBMhifive/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 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "IBMhifive"
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/lib/IBMhifive.rb ADDED
@@ -0,0 +1,34 @@
1
+ require "active_support/time"
2
+ require "httparty"
3
+ require "hashie"
4
+ require "IBMhifive/version"
5
+ require "IBMhifive/configuration"
6
+ require "IBMhifive/fetch"
7
+ require "IBMhifive/endpoints/_endpoint"
8
+ require "IBMhifive/endpoints/loan"
9
+ # require "IBMhifive/endpoints/transaction"
10
+ # require "IBMhifive/endpoints/recommenders"
11
+
12
+ begin
13
+ require "pry"
14
+ require "pry-alias"
15
+ rescue LoadError
16
+ end
17
+
18
+ module IBMhifive
19
+ class << self
20
+ attr_writer :configuration
21
+
22
+ def configuration
23
+ @configuration ||= Configuration.new
24
+ end
25
+
26
+ def reset
27
+ @configuration = Configuration.new
28
+ end
29
+
30
+ def setup
31
+ yield(configuration)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,34 @@
1
+ module IBMhifive
2
+ class Configuration
3
+ attr_accessor :username, :password, :base_url, :time_zone
4
+
5
+ def initialize(username:nil,password:nil,time_zone:nil,base_url:'http://nairobidigest.co.ke/pesazetu/rest2/api')
6
+ @base_url ||= base_url
7
+ @username ||= username
8
+ @password ||= password
9
+ @time_zone ||= time_zone
10
+ set_time_zone
11
+ end
12
+
13
+ def time_zone=(value)
14
+ set_time_zone(value)
15
+ @time_zone = value
16
+ end
17
+
18
+ def basic_auth
19
+ {username: username, password: password}
20
+ end
21
+
22
+ def header
23
+ {'Content-Type'=> 'application/json', 'Accept' => 'application/json'}
24
+ end
25
+
26
+ private
27
+
28
+ def set_time_zone(tz = nil)
29
+ time_zone = tz || @time_zone || Time.zone || 'UTC'
30
+ Time.zone = time_zone unless time_zone.nil?
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,90 @@
1
+ module IBMhifive
2
+ class Endpoint
3
+ attr_accessor :config, :response, :pagination, :endpoint, :attributes
4
+ attr_accessor :id
5
+
6
+ # IBMhifive::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
+ def id=(value)
19
+ raise Exception, "IBMhifive Object ID cannot be nil" if value.nil? and attributes.deleting.nil?
20
+ @id = value
21
+ end
22
+
23
+ def success?
24
+ !response.code.to_s.match(/\A2\d+/).to_s.empty? rescue false
25
+ end
26
+
27
+ protected
28
+
29
+ def kill
30
+ instance_variables.each{|var| instance_variable_set(var,nil)}
31
+ freeze
32
+ end
33
+
34
+ # after_initialize{ @endpoint = 'clients'}
35
+ # class << self
36
+ # # Used to instantiate new objects instead of using def initialize
37
+ # def after_initialize#(&block)
38
+ # # block.call
39
+ # # yield if block_given?
40
+ # yield
41
+ # end
42
+ # end
43
+
44
+ def after_initialize
45
+
46
+ end
47
+
48
+ # Use this methon in the association reader method witht the same name
49
+ def find_all(page:1,per_page:100,**options)
50
+ # gets caller methods as association
51
+ association = caller_locations(1,1)[0].label
52
+ url = assoc_link(association.to_sym,options)
53
+ if self.pagination[association]=={per_page:per_page,page:page}
54
+ self.send("#{association}=", IBMhifive::Fetch.get(url,query:{page:page,per_page:per_page}) ) if instance_variable_get("@#{association}").nil?
55
+ else
56
+ self.send("#{association}=", IBMhifive::Fetch.get(url,query:{page:page,per_page:per_page}) )
57
+ end
58
+ self.pagination.merge!({"#{association}":{page:page,per_page:per_page}})
59
+ return instance_variable_get("@#{association}")
60
+ end
61
+
62
+ def assoc_link(association,**options)
63
+ case association
64
+ when :transactions
65
+ raise ArgumentError if options[:account_id].nil?
66
+ "/#{self.endpoint}/#{self.id}/accounts/#{options[:account_id]}/#{association}"
67
+ else # :accounts, :payables, :members
68
+ "/#{self.endpoint}/#{self.id}/#{association}"
69
+ end
70
+ end
71
+
72
+ def set_config(configuration)
73
+ config = IBMhifive.configuration.clone
74
+ unless configuration.nil?
75
+ config.username = configuration[:username]
76
+ config.password = configuration[:password]
77
+ end
78
+ config
79
+ end
80
+
81
+ def method_missing(m, *args, &block)
82
+ if @response.is_a?(Hash)
83
+ @response.keys.include?(m.to_s) ? @response.send(m) : super
84
+ else
85
+ super
86
+ end
87
+ end
88
+
89
+ end
90
+ end
@@ -0,0 +1,74 @@
1
+ module IBMhifive
2
+ class Loan < IBMhifive::Endpoint
3
+ # attr_writer :accounts, :account, :payables, :transactions
4
+
5
+ class << self
6
+
7
+ # # IBMhifive::Loan.all
8
+ # def all(page:1,per_page:100)
9
+ # url = "/loans/all_loans"
10
+ # IBMhifive::Fetch.get(url,query:{page:page,per_page:per_page})
11
+ # end
12
+
13
+ # IBMhifive::Loan.find(id)
14
+ def find(loan_id,fetch: true)
15
+ url = "/loans/#{loan_id}"
16
+ response = IBMhifive::Fetch.get(url) if fetch
17
+ loan = new(id:loan_id,response:response)
18
+ end
19
+
20
+ # loan_attributes = {loan: { loan_name: "Kiki Lolo", loan_birthday: Time.zone.now.iso8601, loan_type: "ext", ac_type: "cu",loan_mobile: '073373932', loan_email: 'lolo@kiki.com',currency: "kes", mandate:"s", sub_type: "od" }}
21
+ # IBMhifive::Loan.create(loan_attributes)
22
+ def create(options={})
23
+ url = "/loans"
24
+ # bp
25
+ response = IBMhifive::Fetch.post(url,options.to_json)
26
+ loan = new(options.merge!(id:response.loan_id ,response:response)) rescue response
27
+ end
28
+
29
+ end
30
+
31
+ # options = transaction = {amount_paid: "5000", balance: "25000", pay_date: "2015-10-07 14:52:57"}
32
+ # IBMhifive::Loan.find(20284).create_transaction(options)
33
+ def create_transaction(options={})
34
+ url = "/loans/#{self.id}/transactions"
35
+ @transaction = IBMhifive::Fetch.post(url,options.to_json)
36
+ end
37
+
38
+ # # IBMhifive::Loan.find(id:20284).account(accountsid)
39
+ # def account(account_id=nil,loan_id=id)
40
+ # account_id ||= @account.id rescue nil
41
+ # raise "Arguments missing: account_id or loan_id" if loan_id.nil? or account_id.nil?
42
+ # url = "/loans/#{loan_id}/accounts/#{account_id}"
43
+ # if (@account.id == account_id rescue false)
44
+ # @account ||= IBMhifive::Fetch.get(url)
45
+ # else
46
+ # @account = IBMhifive::Fetch.get(url)
47
+ # end
48
+ # end
49
+
50
+
51
+ # # IBMhifive::Loan.find(26, fetch:false).accounts(page:1,per_page:100)
52
+ # def accounts(page:1,per_page:100)
53
+ # find_all(page:page,per_page:per_page)
54
+ # end
55
+
56
+ # # IBMhifive::Loan.find(26, fetch:false).payables(page:1,per_page:100)
57
+ # def payables(page:1,per_page:100)
58
+ # find_all(page:page,per_page:per_page)
59
+ # end
60
+
61
+ # # IBMhifive::Loan.find(26, fetch:false).transactions(account_id, page:1,per_page:100)
62
+ # def transactions(account_id,page:1,per_page:100)
63
+ # find_all(page:page,per_page:per_page,account_id:account_id)
64
+ # end
65
+
66
+ protected
67
+
68
+ def after_initialize
69
+ @endpoint = 'loans'
70
+ end
71
+
72
+
73
+ end
74
+ end
@@ -0,0 +1,48 @@
1
+ module IBMhifive
2
+ class Fetch
3
+ include HTTParty
4
+
5
+ # base_uri 'http://nairobidigest.co.ke/pesazetu/rest2/api/'
6
+ parser proc {|data| Hashie::Mash.new(response: (JSON.parse(data) rescue {data:data}.to_json) ).response}
7
+ format :json
8
+ headers
9
+
10
+ class << self
11
+ def headers
12
+ IBMhifive.configuration.header.merge!(super)
13
+ end
14
+
15
+ %w(get put post delete).each do |m|
16
+ define_method m do |path, options={}, &block|
17
+ # options = {basic_auth: IBMhifive.configuration.basic_auth,base_uri: IBMhifive.configuration.base_url}
18
+ options = {body: options, base_uri: IBMhifive.configuration.base_url, basic_auth: IBMhifive.configuration.basic_auth}
19
+ res = perform_request Net::HTTP::Put, path, options, &block if m == 'put'
20
+ res = perform_request Net::HTTP::Post, path, options, &block if m == 'post'
21
+ res = perform_request Net::HTTP::Get, path, options, &block if m == 'get'
22
+ res = perform_request Net::HTTP::Delete, path, options, &block if m == 'delete'
23
+ save_json(res) if load_json?
24
+ res.data rescue res
25
+ end
26
+ end
27
+
28
+ def save_json(response)
29
+ request_method = response.request.http_method.name.split('::').last.upcase
30
+ file_path = response.request.path.to_s
31
+ slash,model,*file_name = file_path.split('?')[0].split(/\/|\?/)
32
+ file_location = "lib/IBMhifive/support/fake_ibm_hifive/#{model}/#{request_method}_#{file_name.join('_')}.json"
33
+ File.write(file_location, response.body)
34
+ end
35
+
36
+ def load_json?
37
+ # load JSON if WebMock is off while testing and only in local env with load IBMhifive turned on
38
+ defined?(WebMock).nil? and ENV['CI_TEST'].nil? and defined?(Minitest) and ENV['LOAD_IBMHIFIVE'] == "true"
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+ end
45
+
46
+ # response = HTTParty.get('http://nairobidigest.co.ke/pesazetu/rest2/api/loans/12345')
47
+ # puts response.body, response.code, response.message, response.headers.inspect
48
+
@@ -0,0 +1,26 @@
1
+ require 'sinatra/base'
2
+ require 'tilt/erb'
3
+
4
+ class FakeIBMhifive < Sinatra::Base
5
+ set :dump_errors, false
6
+
7
+ [ :get, :post, :put, :delete ].each do |method|
8
+ send method, /.*/ do
9
+ # if (request.env['HTTP_X_WSSE'].empty? rescue true)
10
+ # [200, {}, [{base:["Authentication Failed"]}.to_json]]
11
+ # else
12
+ slash,pesazetu,rest,api,model,*path = request.path_info.split('?')[0].split(/\/|\?/)
13
+ json_response 200, "#{model}/#{request.request_method}_#{path.join('_')}.json"
14
+ # end
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def json_response(response_code, file_name)
21
+ content_type :json
22
+ status response_code
23
+ headers "content-type"=>["application/json; charset=utf-8"]
24
+ erb File.open(File.dirname(__FILE__) + '/fake_ibm_hifive/' + file_name, 'rb').read
25
+ end
26
+ end
@@ -0,0 +1,104 @@
1
+ module IBMhifive::TestHelper
2
+ def create_ibm_hifive_loan
3
+ loan_attributes = {
4
+ loan_id: rand(10000).to_s,
5
+ loan_amount: "5000",
6
+ interest_rate: "0.1",
7
+ balance: "0",
8
+ loan_request_date: Date.yesterday.to_s,
9
+ loan_disbursal_date: Date.today.to_s,
10
+ loan_due_date: [(Date.today + 7.days).to_s, (Date.today + 14.days).to_s, (Date.today + 21.days).to_s, (Date.today + 28.days).to_s],
11
+ loan_status: "accepted",
12
+ pz_credit_score: "0.6",
13
+ borrower_id: rand(10000).to_s,
14
+ borrower_name: Faker::Name.name,
15
+ borrower_phone: Faker::Number.number(10),
16
+ gender: "female",
17
+ borrower_address: Faker::Address.city,
18
+ borrower_location: Faker::Address.city,
19
+ survey_id: rand(10000).to_s
20
+ }
21
+ @@create_ibm_hifive_loan ||= IBMhifive::Loan.create(loan_attributes)
22
+ end
23
+
24
+ def create_ibm_hifive_transaction
25
+ transaction = {
26
+ amount_paid: "5000",
27
+ balance: "25000",
28
+ pay_date: "2015-10-07 14:52:57"
29
+ }
30
+
31
+ loan = create_ibm_hifive_loan
32
+ @@create_ibm_hifive_transaction ||= IBMhifive::Loan.find(loan.id,fetch:false).create_transaction(transaction)
33
+ # loan.create_transaction(transaction)
34
+ end
35
+
36
+ # def create_ibm_hifive_account
37
+ # client = create_ibm_hifive_client
38
+ # account_options = {
39
+ # account:{
40
+ # name: "#{client.fname} #{client.lname}",
41
+ # ac_type: 'cu',
42
+ # sub_type: 'od',
43
+ # mandate: 's',
44
+ # aliases_attributes: [{org_id:ibm_hifive_login.org_no ,alias_key:'telephone', alias_value:"#{client.fname}#{SecureRandom.uuid.gsub('-','')}"}]
45
+ # # tags_attributes:@tags,
46
+ # # infos_attributes:@infos
47
+ # }
48
+ # }
49
+ # @@create_ibm_hifive_account ||= client.create_account(account_options)
50
+ # @@account ||= IBMhifive::Client.find(client.id,fetch:false).account(@@create_ibm_hifive_account.id)
51
+ # @@create_ibm_hifive_account
52
+ # end
53
+
54
+ # def create_ibm_hifive_payable
55
+ # account = create_ibm_hifive_account
56
+ # payable_items = []
57
+ # [*0..5].each do |n|
58
+ # payable_items << {
59
+ # payment_party: account.acid ,
60
+ # terminal_ac: account.acid ,
61
+ # details: Faker::Lorem.sentence ,
62
+ # amount: 10,
63
+ # price: 10,
64
+ # unit_measure: 1.0
65
+ # }
66
+ # end
67
+
68
+ # options = {
69
+ # payment: {
70
+ # payable_no: SecureRandom.uuid,
71
+ # note: Faker::Lorem.sentence ,
72
+ # ref_id: SecureRandom.uuid,
73
+ # # client_id: client_id,
74
+ # # status: @model.status,
75
+ # # payable_type: @model.payable_type,
76
+ # due_date: Time.zone.now+(86400*31),
77
+ # pay: payable_items
78
+ # # tags:@tags,
79
+ # # flags:@flags,
80
+ # # infos:@infos ,
81
+ # # sync_lag:@sync_lag
82
+ # }
83
+ # }
84
+ # @@create_ibm_hifive_payable ||= IBMhifive::Payable.create(options)
85
+ # @@search_payable ||= IBMhifive::Payable.where(ref_id:@@create_ibm_hifive_payable.ref_id)
86
+ # @@create_ibm_hifive_payable
87
+ # end
88
+
89
+ # def get_ibm_hifive_accounts
90
+ # @@get_ibm_hifive_accounts ||= IBMhifive::Account.all
91
+ # end
92
+
93
+ # def get_ibm_hifive_account
94
+ # first_account = get_ibm_hifive_accounts.first
95
+ # @@get_ibm_hifive_account ||= IBMhifive::Account.find(first_account.id)
96
+ # end
97
+
98
+
99
+
100
+ # def get_ibm_hifive_transactions
101
+ # @@get_ibm_hifive_transactions ||= IBMhifive::Transaction.all(from: Time.zone.now - (86400*400))
102
+ # @@get_ibm_hifive_transactions.any? ? @@get_ibm_hifive_transactions : [create_ibm_hifive_transaction]
103
+ # end
104
+ end
@@ -0,0 +1,3 @@
1
+ module IBMhifive
2
+ VERSION = "0.0.01"
3
+ end
metadata ADDED
@@ -0,0 +1,288 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: IBMhifive
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.01
5
+ platform: ruby
6
+ authors:
7
+ - Kariuki Gathitu
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-11-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: guard
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.6'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.4'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: minitest-reporters
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.10'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.10'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry-nav
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.2'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.2'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry-alias
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: coveralls
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: webmock
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.21'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '1.21'
167
+ - !ruby/object:Gem::Dependency
168
+ name: sinatra
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '1.4'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '1.4'
181
+ - !ruby/object:Gem::Dependency
182
+ name: faker
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '1.4'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '1.4'
195
+ - !ruby/object:Gem::Dependency
196
+ name: activesupport
197
+ requirement: !ruby/object:Gem::Requirement
198
+ requirements:
199
+ - - "~>"
200
+ - !ruby/object:Gem::Version
201
+ version: '4.2'
202
+ type: :runtime
203
+ prerelease: false
204
+ version_requirements: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - "~>"
207
+ - !ruby/object:Gem::Version
208
+ version: '4.2'
209
+ - !ruby/object:Gem::Dependency
210
+ name: httparty
211
+ requirement: !ruby/object:Gem::Requirement
212
+ requirements:
213
+ - - "~>"
214
+ - !ruby/object:Gem::Version
215
+ version: '0.13'
216
+ type: :runtime
217
+ prerelease: false
218
+ version_requirements: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - "~>"
221
+ - !ruby/object:Gem::Version
222
+ version: '0.13'
223
+ - !ruby/object:Gem::Dependency
224
+ name: hashie
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - "~>"
228
+ - !ruby/object:Gem::Version
229
+ version: '3.4'
230
+ type: :runtime
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: '3.4'
237
+ description: Integrates to the System that sits between PZ and IBM
238
+ email:
239
+ - kgathi2@gmail.com
240
+ executables: []
241
+ extensions: []
242
+ extra_rdoc_files: []
243
+ files:
244
+ - ".gitignore"
245
+ - ".travis.yml"
246
+ - CODE_OF_CONDUCT.md
247
+ - Gemfile
248
+ - Guardfile
249
+ - IBMhifive.gemspec
250
+ - LICENSE.txt
251
+ - README.md
252
+ - Rakefile
253
+ - bin/console
254
+ - bin/setup
255
+ - lib/IBMhifive.rb
256
+ - lib/IBMhifive/configuration.rb
257
+ - lib/IBMhifive/endpoints/_endpoint.rb
258
+ - lib/IBMhifive/endpoints/loan.rb
259
+ - lib/IBMhifive/fetch.rb
260
+ - lib/IBMhifive/support/fake_ibm_hifive.rb
261
+ - lib/IBMhifive/support/test_helper.rb
262
+ - lib/IBMhifive/version.rb
263
+ homepage: https://bitbucket.org/kgathi2/ibmhifive
264
+ licenses:
265
+ - MIT
266
+ metadata: {}
267
+ post_install_message:
268
+ rdoc_options: []
269
+ require_paths:
270
+ - lib
271
+ required_ruby_version: !ruby/object:Gem::Requirement
272
+ requirements:
273
+ - - "~>"
274
+ - !ruby/object:Gem::Version
275
+ version: '2.0'
276
+ required_rubygems_version: !ruby/object:Gem::Requirement
277
+ requirements:
278
+ - - ">="
279
+ - !ruby/object:Gem::Version
280
+ version: '0'
281
+ requirements: []
282
+ rubyforge_project:
283
+ rubygems_version: 2.4.5
284
+ signing_key:
285
+ specification_version: 4
286
+ summary: Integration module for the IBMSocial Recomemdation system
287
+ test_files: []
288
+ has_rdoc: