kiva_api 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fdcb06f66f4b46d75c24435ee50c783d9c1a42cf
4
- data.tar.gz: a487ef6483988497b7e4134c24288d116d5362c1
3
+ metadata.gz: 84d8caaaf090e6f1d6814580bb402803d86535eb
4
+ data.tar.gz: 087f1b3e4fe27f5f53b1dac1376554a723822acf
5
5
  SHA512:
6
- metadata.gz: 485e45a2bad823b6e399a722455e586afbfa81469e19edb647dad550a247bc98ae4ef420e5660224de9ecee2663412856388803f324c30d19737a26805332992
7
- data.tar.gz: f595d487fc0e04e644305c1d9a741759b5bdbacee55306e4d05e017d11d180b3b77c1200581369eeaabfee99d68685b1cc423bf457155ac27a2edd9e17828538
6
+ metadata.gz: c6a058ba1958941e07cc95e2c7c6be5321eb1ac775f54564b166e2224bcb4e8ded6db59cc03b5938a274e921072ac01995d2c42f0aa29341d3b400723b09752d
7
+ data.tar.gz: 299e8f364aec62bc1f803064799c7819185d33baf34be8c9ed9a94bb8740cedc56916bcf83443ef08b00424ac17dfbfd3d1f911e6c7604330c860afe70a18e08
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.4'
10
+ gem 'kiva_api', '~> 0.1.5'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -59,6 +59,8 @@ loan_response.percent_purchased
59
59
  # => 100.00
60
60
  loan_response.delinquent?
61
61
  # => false
62
+ loan_response.expiration_date
63
+ # => "2015-09-15T16:47:02Z"
62
64
 
63
65
  terms = loan_api.terms
64
66
  terms.expected_payments
data/lib/kiva_api/loan.rb CHANGED
@@ -12,10 +12,13 @@ class KivaApi::Loan
12
12
  end
13
13
  end
14
14
 
15
- def get_data
16
- @loan = KivaApi::LoanResponse.new(HTTParty.get("#{@host}/loan/#{@loan_number}/"))
17
- @terms = KivaApi::TermsResponse.new(HTTParty.get("#{@host}/loan/#{@loan_number}/terms"))
18
- @comments = KivaApi::CommentsResponse.new(HTTParty.get("#{@host}/loan/#{@loan_number}/comments"))
15
+ def get_data(verify = true)
16
+ loan_response = HTTParty.get("#{@host}/loan/#{@loan_number}/", verify: verify)
17
+ @loan = KivaApi::LoanResponse.new(loan_response)
18
+ terms_response = HTTParty.get("#{@host}/loan/#{@loan_number}/terms", verify: verify)
19
+ @terms = KivaApi::TermsResponse.new(terms_response)
20
+ comments_response = HTTParty.get("#{@host}/loan/#{@loan_number}/comments", verify: verify)
21
+ @comments = KivaApi::CommentsResponse.new(comments_response)
19
22
  end
20
23
 
21
24
  private
@@ -9,8 +9,12 @@ class KivaApi::LoanResponse
9
9
  @response.parsed_response
10
10
  end
11
11
 
12
+ def properties
13
+ parsed_body['properties']
14
+ end
15
+
12
16
  def state
13
- parsed_body['properties']['status']
17
+ properties['status']
14
18
  end
15
19
 
16
20
  def delinquent?
@@ -18,31 +22,31 @@ class KivaApi::LoanResponse
18
22
  end
19
23
 
20
24
  def loan_amount
21
- parsed_body['properties']['loanAmount']['amount'].to_f
25
+ properties['loanAmount']['amount'].to_f
22
26
  end
23
27
 
24
28
  def funded_amount
25
- parsed_body['properties']['fundedAmount']['amount'].to_f
29
+ properties['fundedAmount']['amount'].to_f
26
30
  end
27
31
 
28
32
  def basket_amount
29
- parsed_body['properties']['basketAmount']['amount'].to_f
33
+ properties['basketAmount']['amount'].to_f
30
34
  end
31
35
 
32
36
  def paid_amount
33
- parsed_body['properties']['paidAmount']['amount'].to_f
37
+ properties['paidAmount']['amount'].to_f
34
38
  end
35
39
 
36
40
  def privately_fundraising?
37
- parsed_body['properties']['inPfp']
41
+ properties['inPfp']
38
42
  end
39
43
 
40
44
  def expiration_date
41
- "2015-08-18T13:57:47Z"
45
+ properties['plannedExpirationDate']
42
46
  end
43
47
 
44
48
  def required_pfp_lenders
45
- parsed_body['properties']['pfpMinLenders']
49
+ properties['pfpMinLenders']
46
50
  end
47
51
 
48
52
  def loan_amount_left_to_purchase
@@ -1,3 +1,3 @@
1
1
  module KivaApi
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
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.4
4
+ version: 0.1.5
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-21 00:00:00.000000000 Z
11
+ date: 2015-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty