kiva_api 0.1.7 → 0.1.8

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: f086686258a2deef9d34babcefc1fc575b65350f
4
- data.tar.gz: 844cf648bbdb2907dffb9a9a96cc6c327615b86e
3
+ metadata.gz: fef42fc8b27b1d86c3b0c5f212643edbd9af0bcb
4
+ data.tar.gz: a2c5f6f1ace626df6c0480e634c1e92f297a24b8
5
5
  SHA512:
6
- metadata.gz: a39da4b3356b1919cb5ddd7686e1a4af38e60cd04710590ef51c4acc91d058bb0d0e69835146dfdb0da4baf55dbb6815a77aa72a2bc3eeea474f46e69cb32887
7
- data.tar.gz: c105c84cd2ef802f19427978d0427c7d3840d4588c445659953c52ed69921202ad95a7234e82738ad94f1103386b0c8104c9a45b2043e28e51710d3553fa7c80
6
+ metadata.gz: 5a3bac255308fbac5a5f321c4ff8b466b3934f055d571021fc1ea58e0c75b5758861c048d259e0114919d4fb4e5c07f6352394f3f2dc7070df280fb39560a7e3
7
+ data.tar.gz: f26b65e587cd514039d71327927ba5df6f1d039e07cdf5545ee7dcd7ee94b29908ea80ea3d0204526ffdf9470f1eb9696e185c4d3c0eac7cead62c58acbaec1b
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.7'
10
+ gem 'kiva_api', '~> 0.1.8'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -75,6 +75,10 @@ comments.comment_count
75
75
  # If there are comments this would be the comments response
76
76
  comments.comments
77
77
  # => [{body: "Comment body", author: "Steve", date: "2012-09-19T18:55:20Z"}, ...]
78
+
79
+ lenders = loan_api.lenders
80
+ lenders.lender_count
81
+ # => 6
78
82
  ```
79
83
 
80
84
  ### Bad Responses
@@ -0,0 +1,15 @@
1
+ class KivaApi::LendersResponse
2
+ attr_reader :response
3
+
4
+ def initialize(response)
5
+ @response = response.parsed_response
6
+ end
7
+
8
+ def lender_count
9
+ if @response["properties"].is_a?(Hash)
10
+ @response["properties"]["count"]
11
+ else
12
+ 0
13
+ end
14
+ end
15
+ end
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 :loan, :terms, :comments
5
+ attr_reader :loan, :terms, :comments, :lenders
6
6
  DEFAULT_HOST = 'https://api.kivaws.org/v2'
7
7
 
8
8
  def initialize(loan_number = nil, host = nil)
@@ -20,6 +20,8 @@ class KivaApi::Loan
20
20
  @terms = KivaApi::TermsResponse.new(terms_response)
21
21
  comments_response = HTTParty.get("#{@loan_root}/#{@loan_number}/comments", verify: verify)
22
22
  @comments = KivaApi::CommentsResponse.new(comments_response)
23
+ lenders_response = HTTParty.get("#{@loan_root}/#{@loan_number}/lenders", verify: verify)
24
+ @lenders = KivaApi::LendersResponse.new(lenders_response)
23
25
  end
24
26
 
25
27
  private
@@ -38,7 +38,7 @@ class KivaApi::LoanResponse
38
38
  end
39
39
 
40
40
  def privately_fundraising?
41
- properties['inPfp']
41
+ properties['inPfp'] || false
42
42
  end
43
43
 
44
44
  def expiration_date
@@ -46,11 +46,11 @@ class KivaApi::LoanResponse
46
46
  end
47
47
 
48
48
  def required_pfp_lenders
49
- properties['pfpMinLenders']
49
+ properties['pfpMinLenders'] || 0
50
50
  end
51
51
 
52
52
  def business_name
53
- properties['businessName']
53
+ properties['businessName'] || properties['partnerName']
54
54
  end
55
55
 
56
56
  def loan_amount_left_to_purchase
@@ -1,3 +1,3 @@
1
1
  module KivaApi
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
data/lib/kiva_api.rb CHANGED
@@ -3,6 +3,7 @@ require 'kiva_api/loan'
3
3
  require 'kiva_api/loan_response'
4
4
  require 'kiva_api/terms_response'
5
5
  require 'kiva_api/comments_response'
6
+ require 'kiva_api/lenders_response'
6
7
 
7
8
  module KivaApi
8
9
  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.7
4
+ version: 0.1.8
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-09-02 00:00:00.000000000 Z
11
+ date: 2015-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -114,6 +114,7 @@ files:
114
114
  - kiva_api.gemspec
115
115
  - lib/kiva_api.rb
116
116
  - lib/kiva_api/comments_response.rb
117
+ - lib/kiva_api/lenders_response.rb
117
118
  - lib/kiva_api/loan.rb
118
119
  - lib/kiva_api/loan_response.rb
119
120
  - lib/kiva_api/terms_response.rb