kiva_api 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 +4 -4
- data/README.md +17 -7
- data/lib/kiva_api/loan_response.rb +7 -23
- data/lib/kiva_api/terms_response.rb +1 -1
- 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: 05a82aaa587d1ae16dcaea94230a200a3b5fd8f8
|
4
|
+
data.tar.gz: f18e6f91f74c1e137e69420aa391a7064e948e56
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 857fb6ebf965b96388c5436902547ea68c53870f84190e72810d87fb49c4d634f76f590b1f1e6a865ec83c77ec374b9995ae1de8aa18f0437fa5771baf5b39ae
|
7
|
+
data.tar.gz: 901a759e117cd5ebc7f3af8e88b6f4138487b4a0a40016c01976ec44ac2a35ebaa963b71a347f4ec3875299b3057bc113cf872b6fb144efc19db1a5016d68ff0
|
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'
|
10
|
+
gem 'kiva_api', ~> "0.1.2"
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
@@ -38,19 +38,29 @@ loan_response = loan_api.response
|
|
38
38
|
loan_response.parsed_body
|
39
39
|
# => {"class"=>["Loan_Partner", "Loan"], "properties"=>{"id"=>92464...
|
40
40
|
loan_response.state
|
41
|
-
# =>
|
41
|
+
# => "ended"
|
42
42
|
loan_response.loan_amount
|
43
|
-
# =>
|
43
|
+
# => 825.00
|
44
44
|
loan_response.funded_amount
|
45
|
-
# =>
|
45
|
+
# => 825.00
|
46
46
|
loan_response.basket_amount
|
47
|
-
# =>
|
47
|
+
# => 0.00
|
48
48
|
loan_response.paid_amount
|
49
|
-
# =>
|
49
|
+
# => 825.00
|
50
|
+
loan_response.privately_fundraising?
|
51
|
+
# => false
|
50
52
|
|
51
53
|
terms = loan_api.terms_response
|
52
54
|
terms.expected_payments
|
53
|
-
# => [{:amount=>
|
55
|
+
# => [{:amount=>35.87, :effective_date=>"2009-04-08T07:00:00Z", :due_to_kiva_date=>"2009-06-01T07:00:00Z"}, ...]
|
56
|
+
|
57
|
+
comments = loan_api.comments
|
58
|
+
comments.comment_count
|
59
|
+
# => 0
|
60
|
+
|
61
|
+
# If there are comments this would be the comments response
|
62
|
+
comments.comments
|
63
|
+
# => [{body: "Comment body", author: "Steve", date: "2012-09-19T18:55:20Z"}, ...]
|
54
64
|
```
|
55
65
|
|
56
66
|
### Bad Responses
|
@@ -1,21 +1,6 @@
|
|
1
1
|
class KivaApi::LoanResponse
|
2
2
|
attr_reader :response
|
3
3
|
|
4
|
-
STATES = {
|
5
|
-
'deleted' => 'deleted',
|
6
|
-
'refunded' => 'refunded',
|
7
|
-
'inactive' => 'hidden',
|
8
|
-
'inactive_expired' => 'hidden',
|
9
|
-
'fundRaising' => 'fundraising',
|
10
|
-
'expired' => 'expired',
|
11
|
-
'raised' => 'raised',
|
12
|
-
'payingBack' => 'paying_back',
|
13
|
-
'ended' => 'ended',
|
14
|
-
'reviewed' => 'review',
|
15
|
-
'issue' => 'review',
|
16
|
-
'defaulted' => 'paying_back_defaulted'
|
17
|
-
}
|
18
|
-
|
19
4
|
def initialize(response)
|
20
5
|
@response = response
|
21
6
|
end
|
@@ -25,27 +10,26 @@ class KivaApi::LoanResponse
|
|
25
10
|
end
|
26
11
|
|
27
12
|
def state
|
28
|
-
|
13
|
+
parsed_body['properties']['status']
|
29
14
|
end
|
30
15
|
|
31
16
|
def loan_amount
|
32
|
-
parsed_body['properties']['loanAmount']['amount']
|
17
|
+
parsed_body['properties']['loanAmount']['amount'].to_f
|
33
18
|
end
|
34
19
|
|
35
20
|
def funded_amount
|
36
|
-
parsed_body['properties']['fundedAmount']['amount']
|
21
|
+
parsed_body['properties']['fundedAmount']['amount'].to_f
|
37
22
|
end
|
38
23
|
|
39
24
|
def basket_amount
|
40
|
-
parsed_body['properties']['basketAmount']['amount']
|
25
|
+
parsed_body['properties']['basketAmount']['amount'].to_f
|
41
26
|
end
|
42
27
|
|
43
28
|
def paid_amount
|
44
|
-
parsed_body['properties']['paidAmount']['amount']
|
29
|
+
parsed_body['properties']['paidAmount']['amount'].to_f
|
45
30
|
end
|
46
31
|
|
47
|
-
|
48
|
-
|
49
|
-
STATES[state].to_sym
|
32
|
+
def privately_fundraising?
|
33
|
+
parsed_body['properties']['inPfp']
|
50
34
|
end
|
51
35
|
end
|
@@ -9,7 +9,7 @@ class KivaApi::TermsResponse
|
|
9
9
|
payments = []
|
10
10
|
response['properties']['expectedPayments'].each do |payment|
|
11
11
|
payments << {
|
12
|
-
amount: payment['amount']['amount'],
|
12
|
+
amount: payment['amount']['amount'].to_f,
|
13
13
|
effective_date: payment['effectiveDate'],
|
14
14
|
due_to_kiva_date: payment['dueToKivaDate']
|
15
15
|
}
|
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.2
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|