pyr 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -5
- data/lib/pyr/response.rb +5 -5
- data/lib/pyr/version.rb +1 -1
- 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: ea77ac4b5fe041319a0edff8e173cb200ea4f4f0
|
4
|
+
data.tar.gz: 8a988b40f80559222bce3a60697c96c5272b770f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f74b966917b39d84d78d4bfa85f0019aafab98d8bac66eb558687fca72ad6ce68ed23b20de280178a83611839b5e3dec29ad726adcb211772f1acc1c2c48917
|
7
|
+
data.tar.gz: 3dbb8631337eb18f10010626a9e788961d62c22f64c1926857b0f05652f14a942cf2a6eeba7414cc4c3c18d03b5e349626801c04aabca9279cc1be595311dbbc
|
data/README.md
CHANGED
@@ -28,20 +28,20 @@ response = PYR.call :reps do |r|
|
|
28
28
|
r.long = -72.5778415
|
29
29
|
end
|
30
30
|
|
31
|
-
response.
|
32
|
-
=> "
|
31
|
+
response.path
|
32
|
+
=> "reps?lat=44.5588028&long=-72.5778415"
|
33
33
|
|
34
34
|
## or ##
|
35
35
|
|
36
36
|
response = PYR.call(:reps) { |r| r.address = 'Vermont' }
|
37
37
|
|
38
|
-
response.
|
39
|
-
=> "
|
38
|
+
response.path
|
39
|
+
=> "reps?address=Vermont"
|
40
40
|
|
41
41
|
response.code
|
42
42
|
=> 200
|
43
43
|
|
44
|
-
response.
|
44
|
+
response.reason_phrase
|
45
45
|
=> "OK"
|
46
46
|
|
47
47
|
response.headers
|
@@ -102,6 +102,10 @@ office = PYR.call(:reps, 'S000033').objects.first.office_locations.district.firs
|
|
102
102
|
# Pass in the object itself as the param to PYR.call
|
103
103
|
office.office_id == PYR.call(office).objects.first.office_id
|
104
104
|
=> true
|
105
|
+
|
106
|
+
# Or use #call on the object itself
|
107
|
+
office.office_id == office.call.objects.first.office_id
|
108
|
+
=> true
|
105
109
|
```
|
106
110
|
|
107
111
|
### Querying by Phone Your Rep URI
|
data/lib/pyr/response.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module PYR
|
4
4
|
# The object returned by a request call to the API.
|
5
5
|
class Response
|
6
|
-
attr_reader :body, :
|
6
|
+
attr_reader :body, :path, :code, :reason_phrase, :headers, :objects, :controller
|
7
7
|
|
8
8
|
def initialize(base_url: nil, resource: nil, response_object: nil)
|
9
9
|
assign_url_and_controller(base_url, resource, response_object)
|
@@ -14,18 +14,18 @@ module PYR
|
|
14
14
|
def assign_url_and_controller(base_url, resource, response_object)
|
15
15
|
if resource
|
16
16
|
@controller = resource.controller
|
17
|
-
@
|
17
|
+
@path = resource.to_s
|
18
18
|
elsif base_url
|
19
19
|
@controller = base_url.sub!(API_BASE_URI, '').split('/').first
|
20
|
-
@
|
20
|
+
@path = base_url
|
21
21
|
elsif response_object
|
22
22
|
@controller = response_object.controller
|
23
|
-
@
|
23
|
+
@path = response_object.self.sub(API_BASE_URI, '')
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
def fetch_and_parse_payload
|
28
|
-
response = API_CONN.get
|
28
|
+
response = API_CONN.get path
|
29
29
|
@body = response.body
|
30
30
|
@code = response.status
|
31
31
|
@reason_phrase = response.reason_phrase
|
data/lib/pyr/version.rb
CHANGED