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 +4 -4
- data/README.md +3 -1
- data/lib/kiva_api/loan.rb +7 -4
- data/lib/kiva_api/loan_response.rb +12 -8
- data/lib/kiva_api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84d8caaaf090e6f1d6814580bb402803d86535eb
|
4
|
+
data.tar.gz: 087f1b3e4fe27f5f53b1dac1376554a723822acf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
-
|
17
|
-
@
|
18
|
-
|
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
|
-
|
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
|
-
|
25
|
+
properties['loanAmount']['amount'].to_f
|
22
26
|
end
|
23
27
|
|
24
28
|
def funded_amount
|
25
|
-
|
29
|
+
properties['fundedAmount']['amount'].to_f
|
26
30
|
end
|
27
31
|
|
28
32
|
def basket_amount
|
29
|
-
|
33
|
+
properties['basketAmount']['amount'].to_f
|
30
34
|
end
|
31
35
|
|
32
36
|
def paid_amount
|
33
|
-
|
37
|
+
properties['paidAmount']['amount'].to_f
|
34
38
|
end
|
35
39
|
|
36
40
|
def privately_fundraising?
|
37
|
-
|
41
|
+
properties['inPfp']
|
38
42
|
end
|
39
43
|
|
40
44
|
def expiration_date
|
41
|
-
|
45
|
+
properties['plannedExpirationDate']
|
42
46
|
end
|
43
47
|
|
44
48
|
def required_pfp_lenders
|
45
|
-
|
49
|
+
properties['pfpMinLenders']
|
46
50
|
end
|
47
51
|
|
48
52
|
def loan_amount_left_to_purchase
|
data/lib/kiva_api/version.rb
CHANGED
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
|
+
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-
|
11
|
+
date: 2015-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|