get_your_rep 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/get_your_rep/open_states.rb +9 -8
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b5f769e58bb91ca979e0f229c3dadba02b7f0c34
|
|
4
|
+
data.tar.gz: b424ff7f61fee46fbea66a6276ffd862191101b6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0488d142b46f8d9ef184dfad2584ef24b024626beda353eb953ea40c3694a510f45505617d350f0d4c6f9082b8d9eba314f05a52b47cfe86b4c583cef480b1a9'
|
|
7
|
+
data.tar.gz: 5ae6e4bcc469611ea104fe964488a66197e1ebab08589e0eac86501301186c1cbeb4df658abf235283e6339f6c613b50a1fa1e86261b85c18e1acf8168ed19c1
|
|
@@ -11,10 +11,7 @@ module GetYourRep
|
|
|
11
11
|
@coordinates = get_coordinates(address)
|
|
12
12
|
@response = get_rep
|
|
13
13
|
|
|
14
|
-
if @response.empty?
|
|
15
|
-
puts 'Could not find your rep. Your location search might be too broad, try refining it.'
|
|
16
|
-
return GetYourRep::Delegation.new
|
|
17
|
-
elsif @response.first['error']
|
|
14
|
+
if @response.empty? || @response.is_a?(String) || @response.first['error']
|
|
18
15
|
puts 'Error message received. Confirm and re-enter your address and check your parameters.'
|
|
19
16
|
puts @response
|
|
20
17
|
return GetYourRep::Delegation.new
|
|
@@ -34,10 +31,14 @@ module GetYourRep
|
|
|
34
31
|
|
|
35
32
|
# Sets parameters for and executes Open States API request.
|
|
36
33
|
def self.get_rep
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
if @coordinates
|
|
35
|
+
lat = @coordinates.first
|
|
36
|
+
long = @coordinates.last
|
|
37
|
+
url = "http://openstates.org/api/v1/legislators/geo/?lat=#{lat}&long=#{long}"
|
|
38
|
+
HTTParty.get(url).parsed_response
|
|
39
|
+
else
|
|
40
|
+
[]
|
|
41
|
+
end
|
|
41
42
|
end
|
|
42
43
|
|
|
43
44
|
# Parses the JSON response and assembles it into a Delegation object.
|