mambu 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ef8c8bfcc89f6f6ce62610fb1e3ca88e1311fb5
4
- data.tar.gz: 70039eadb60d97207143f07ee21743e3d8b19bd6
3
+ metadata.gz: 84ec325824eea5bcf97d9222a4e5f93b92a73f9b
4
+ data.tar.gz: 41a71d849874b15a694c41adc5a9ac4a66db504a
5
5
  SHA512:
6
- metadata.gz: 64cd021596e615694145643fc617f59bcdc58a3cc7a4d35b2f6300307f817ab6009c61147aa5e8c55b42937c0b228e39845b99937641d224e3dc63c5242677b9
7
- data.tar.gz: 8770dfad2124c7856cf76f6a0bef33fb7d93294014dccee20fbf24cb4e9e50c0f4c4edd14be21b766e68953fd6539b2982c5af664f040b6a35991e785762f003
6
+ metadata.gz: 37763bd4eda479ec69b94fe383dd80f0fc9b78ba1d73993892384e5c5bc4cfe99c23ac17aeb663272483669b25da62eae54051d265b9b20d17c25fb8200b513b
7
+ data.tar.gz: 0e5585eca2faf06064f6134e107d343e27bfdd32572202f6385885e34f91021ca8ed2eb59e889858e440f9bfcb234d5a2687d5e2bd4c3041058c38f38b96f393
data/README.md CHANGED
@@ -23,7 +23,8 @@ Or install it yourself as:
23
23
  ## Usage
24
24
  # create api connection
25
25
  connection = Mambu::Connection.new('username', 'password', 'tenant.sandbox')
26
- ### API models
26
+
27
+ ### API models finders
27
28
  ##### #find_all
28
29
  Mambu::LoanProduct.find_all(connection)
29
30
  # or
@@ -33,8 +34,22 @@ Or install it yourself as:
33
34
  # or
34
35
  connection.loan_product.find('product_id')
35
36
 
37
+ ### Loan schedule
38
+ options = {
39
+ loan_amount: '10000',
40
+ first_repayment_date: '2015-06-15',
41
+ anticipated_disbursement: '2015-06-15',
42
+ interest_rate: '15',
43
+ repayment_installments: '12',
44
+ repayment_period_unit: 'MONTHS',
45
+ repayment_period_count: '1',
46
+ principal_repayment_interval: '1'
47
+ }
48
+ Mambu::Schedule.find(loan_product, options, connection)
49
+
36
50
  #### Implemented models:
37
51
  Mambu::LoanProduct https://developer.mambu.com/customer/portal/articles/1616164-loan-products-api
52
+ Mambu::LoanSchedule https://developer.mambu.com/customer/portal/articles/1616164-loan-products-api
38
53
 
39
54
 
40
55
  ## Development
@@ -0,0 +1,18 @@
1
+ module Mambu
2
+ module Helpers
3
+ def handle_error(response)
4
+ return if response.success?
5
+ error = response.error
6
+ if error.status == 'INTERNAL_SERVER_ERROR'
7
+ error = Mambu::Error.new(
8
+ 'Known mambu issue. Please grant administrator permissions to api user.'
9
+ )
10
+ end
11
+ fail error
12
+ end
13
+
14
+ def camelize_hash(options)
15
+ Hash[options.map { |k, v| [k.to_s.camelize(:lower).to_sym, v] }]
16
+ end
17
+ end
18
+ end
@@ -1,6 +1,7 @@
1
1
  module Mambu
2
2
  class LoanSchedule < ApiModel
3
3
  attr_accessor :repayments
4
+ extend Mambu::Helpers
4
5
 
5
6
  def repayments=(data)
6
7
  @repayments = data.map { |hash_fee| Mambu::Repayment.new(hash_fee) }
@@ -18,20 +19,5 @@ module Mambu
18
19
  def self.api_uri
19
20
  Mambu::LoanProduct.api_uri
20
21
  end
21
-
22
- def self.handle_error(response)
23
- return if response.success?
24
- error = response.error
25
- if error.status == 'INTERNAL_SERVER_ERROR'
26
- error = Mambu::Error.new(
27
- 'Known mambu issue. Please grant administrator permissions to api user.'
28
- )
29
- end
30
- fail error
31
- end
32
-
33
- def self.camelize_hash(options)
34
- Hash[options.map { |k, v| [k.to_s.camelize(:lower).to_sym, v] }]
35
- end
36
22
  end
37
23
  end
@@ -1,4 +1,7 @@
1
1
  module Mambu
2
2
  class Repayment < ApiModel
3
+ def payment_due
4
+ principal_due + interest_due + fees_due
5
+ end
3
6
  end
4
7
  end
@@ -0,0 +1,14 @@
1
+ module Mambu
2
+ class Savings < ApiModel
3
+ extend Mambu::Helpers
4
+
5
+ def self.create_deposit(account_id, connection, data)
6
+ response = connection.post(
7
+ "#{endpoint(connection)}/#{account_id}/transactions",
8
+ camelize_hash(data)
9
+ )
10
+ handle_error(response)
11
+ new(response.body)
12
+ end
13
+ end
14
+ end
data/lib/mambu/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mambu
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/mambu.rb CHANGED
@@ -4,6 +4,7 @@ require "json"
4
4
  require "mambu/version"
5
5
  require "mambu/finders"
6
6
  require "mambu/error"
7
+ require "mambu/helpers"
7
8
  require "mambu/response"
8
9
  require "mambu/connection"
9
10
  require "mambu/api_model"
@@ -11,6 +12,8 @@ require "mambu/loan_product"
11
12
  require "mambu/loan_fee"
12
13
  require "mambu/loan_schedule"
13
14
  require "mambu/repayment"
15
+ require "mambu/savings"
16
+
14
17
  begin
15
18
  require "pry"
16
19
  rescue LoadError
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mambu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Netguru
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-26 00:00:00.000000000 Z
11
+ date: 2015-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -173,11 +173,13 @@ files:
173
173
  - lib/mambu/connection.rb
174
174
  - lib/mambu/error.rb
175
175
  - lib/mambu/finders.rb
176
+ - lib/mambu/helpers.rb
176
177
  - lib/mambu/loan_fee.rb
177
178
  - lib/mambu/loan_product.rb
178
179
  - lib/mambu/loan_schedule.rb
179
180
  - lib/mambu/repayment.rb
180
181
  - lib/mambu/response.rb
182
+ - lib/mambu/savings.rb
181
183
  - lib/mambu/version.rb
182
184
  - mambu.gemspec
183
185
  homepage: http://github.com/netguru/mambu-api-ruby