kiva_api 0.1.3 → 0.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 563a0c4e52d54e3724b06c2609c7a8b52c09b37e
4
- data.tar.gz: ffb829c4b4e5783611adf12f6e83cf41679e48df
3
+ metadata.gz: fdcb06f66f4b46d75c24435ee50c783d9c1a42cf
4
+ data.tar.gz: a487ef6483988497b7e4134c24288d116d5362c1
5
5
  SHA512:
6
- metadata.gz: fbe4f11b17dd2c4d479ba3289b58c67cbfa4731add9b5363df32f3b086e7eab5eb1c9268bcb7f1df059a78612e2e547969c644516a38686ef6df9688c48a1f8e
7
- data.tar.gz: f31934edd6b465d8a3840ccd6d78dc8f4790bf88195b844a74fcfd7301243d45b19e26979aeece321949cb6f69a5e07694f34e96f7f55ba9bebc5014ea5dffa2
6
+ metadata.gz: 485e45a2bad823b6e399a722455e586afbfa81469e19edb647dad550a247bc98ae4ef420e5660224de9ecee2663412856388803f324c30d19737a26805332992
7
+ data.tar.gz: f595d487fc0e04e644305c1d9a741759b5bdbacee55306e4d05e017d11d180b3b77c1200581369eeaabfee99d68685b1cc423bf457155ac27a2edd9e17828538
data/README.md CHANGED
@@ -7,7 +7,7 @@ Get Loan data from Kiva's API
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'kiva_api', ~> "0.1.3"
10
+ gem 'kiva_api', '~> 0.1.4'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -34,7 +34,7 @@ loan_api = KivaApi::Loan.new(92464)
34
34
 
35
35
  loan_api.get_data # this will hit the @host on Kiva for the loan number that you specify
36
36
 
37
- loan_response = loan_api.response
37
+ loan_response = loan_api.loan
38
38
  loan_response.parsed_body
39
39
  # => {"class"=>["Loan_Partner", "Loan"], "properties"=>{"id"=>92464...
40
40
  loan_response.state
@@ -57,8 +57,10 @@ loan_response.loan_amount_left_to_purchase
57
57
  # => 0.00
58
58
  loan_response.percent_purchased
59
59
  # => 100.00
60
+ loan_response.delinquent?
61
+ # => false
60
62
 
61
- terms = loan_api.terms_response
63
+ terms = loan_api.terms
62
64
  terms.expected_payments
63
65
  # => [{:amount=>35.87, :effective_date=>"2009-04-08T07:00:00Z", :due_to_kiva_date=>"2009-06-01T07:00:00Z"}, ...]
64
66
 
data/lib/kiva_api/loan.rb CHANGED
@@ -2,7 +2,7 @@ require 'httparty'
2
2
 
3
3
  class KivaApi::Loan
4
4
  attr_accessor :host, :loan_number
5
- attr_reader :response, :terms_response, :comments
5
+ attr_reader :loan, :terms, :comments
6
6
  DEFAULT_HOST = 'https://api.kivaws.org/v2'
7
7
 
8
8
  def initialize(loan_number = nil, host = nil)
@@ -13,8 +13,8 @@ class KivaApi::Loan
13
13
  end
14
14
 
15
15
  def get_data
16
- @response = KivaApi::LoanResponse.new(HTTParty.get("#{@host}/loan/#{@loan_number}/"))
17
- @terms_response = KivaApi::TermsResponse.new(HTTParty.get("#{@host}/loan/#{@loan_number}/terms"))
16
+ @loan = KivaApi::LoanResponse.new(HTTParty.get("#{@host}/loan/#{@loan_number}/"))
17
+ @terms = KivaApi::TermsResponse.new(HTTParty.get("#{@host}/loan/#{@loan_number}/terms"))
18
18
  @comments = KivaApi::CommentsResponse.new(HTTParty.get("#{@host}/loan/#{@loan_number}/comments"))
19
19
  end
20
20
 
@@ -13,6 +13,10 @@ class KivaApi::LoanResponse
13
13
  parsed_body['properties']['status']
14
14
  end
15
15
 
16
+ def delinquent?
17
+ state == 'defaulted'
18
+ end
19
+
16
20
  def loan_amount
17
21
  parsed_body['properties']['loanAmount']['amount'].to_f
18
22
  end
@@ -33,6 +37,10 @@ class KivaApi::LoanResponse
33
37
  parsed_body['properties']['inPfp']
34
38
  end
35
39
 
40
+ def expiration_date
41
+ "2015-08-18T13:57:47Z"
42
+ end
43
+
36
44
  def required_pfp_lenders
37
45
  parsed_body['properties']['pfpMinLenders']
38
46
  end
@@ -1,3 +1,3 @@
1
1
  module KivaApi
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kiva_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Magelowitz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-18 00:00:00.000000000 Z
11
+ date: 2015-08-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty