kiva_api 0.1.0 → 0.1.1
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/lib/kiva_api/comments_response.rb +31 -0
- data/lib/kiva_api/loan.rb +3 -2
- data/lib/kiva_api/version.rb +1 -1
- data/lib/kiva_api.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 245421fc53b4e783d890b0da38d26b885b0cf500
|
4
|
+
data.tar.gz: bed30fd8a7c2e5f91166713ee92b5652759d5a99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73847da2413e66ea3d804e832c92c34b5d5fcf9739f57cd3a65bfe3e90053062dbf6bd440738b71871acad7d2cc5c6bac7e979f84fa7ca0480980f527170df4c
|
7
|
+
data.tar.gz: c3c386c6da60756e6bd57979b41961d091b72b1c9c1cbbb5d29edefea54cf365cda0fd245e5e9d5dc913ef8f44d2e1117327eafd3bc68ec3149dcff19d3a45c5
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class KivaApi::CommentsResponse
|
2
|
+
attr_reader :response
|
3
|
+
|
4
|
+
def initialize(response)
|
5
|
+
@response = response.parsed_response
|
6
|
+
end
|
7
|
+
|
8
|
+
def comments
|
9
|
+
if @response["entities"]
|
10
|
+
comments = []
|
11
|
+
@response["entities"].each do |comment|
|
12
|
+
comments << {
|
13
|
+
body: comment["properties"]["body"],
|
14
|
+
date: comment["properties"]["date"],
|
15
|
+
author: comment["properties"]["authorName"]
|
16
|
+
}
|
17
|
+
end
|
18
|
+
comments
|
19
|
+
else
|
20
|
+
[]
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def comment_count
|
25
|
+
if @response["properties"].is_a?(Hash)
|
26
|
+
@response["properties"]["count"]
|
27
|
+
else
|
28
|
+
0
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/kiva_api/loan.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'httparty'
|
2
2
|
|
3
3
|
class KivaApi::Loan
|
4
|
-
|
5
|
-
attr_reader :response, :terms_response
|
4
|
+
attr_accessor :host, :loan_number
|
5
|
+
attr_reader :response, :terms_response, :comments
|
6
6
|
DEFAULT_HOST = 'https://api.kivaws.org/v2'
|
7
7
|
|
8
8
|
def initialize(loan_number = nil, host = nil)
|
@@ -15,6 +15,7 @@ class KivaApi::Loan
|
|
15
15
|
def get_data
|
16
16
|
@response = KivaApi::LoanResponse.new(HTTParty.get("#{@host}/loan/#{@loan_number}/"))
|
17
17
|
@terms_response = KivaApi::TermsResponse.new(HTTParty.get("#{@host}/loan/#{@loan_number}/terms"))
|
18
|
+
@comments = KivaApi::CommentsResponse.new(HTTParty.get("#{@host}/loan/#{@loan_number}/comments"))
|
18
19
|
end
|
19
20
|
|
20
21
|
private
|
data/lib/kiva_api/version.rb
CHANGED
data/lib/kiva_api.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.1
|
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-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- bin/setup
|
114
114
|
- kiva_api.gemspec
|
115
115
|
- lib/kiva_api.rb
|
116
|
+
- lib/kiva_api/comments_response.rb
|
116
117
|
- lib/kiva_api/loan.rb
|
117
118
|
- lib/kiva_api/loan_response.rb
|
118
119
|
- lib/kiva_api/terms_response.rb
|