petfinder-wrap 1.0.0 → 1.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/README.md +27 -7
- data/lib/petfinder-wrap.rb +1 -1
- data/lib/petfinder/client.rb +9 -6
- 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: 77edfce7c300f6582f65205f797109729bba997a
|
4
|
+
data.tar.gz: 8f6fa5d47055eea64e31b7636ab59a6260a42c95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1852593cefe69a224708b4ff78279fd121e20a35ae4a752bbfd90111d8e93bb40e29c3d558ba2b3cc137f9da90acc8909eeb79ee0c2881b25045b8f40ccf8ce2
|
7
|
+
data.tar.gz: 6fdbacb05cd5113d4955d05ecc3ae713769cc768cc5a4e41cb5449195999bfbf59a90704972d0872ebb3f2f24a347701226c45ac011cf85b728569f3351689b3
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Petfinder::Wrap
|
2
2
|
|
3
|
-
|
3
|
+
A simple gem for the Petfinder API using JSON responses and a traversal method.
|
4
4
|
|
5
|
-
TODO:
|
5
|
+
TODO: build out <#Pet>.photos instance methods for max usability in rails apps.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -22,14 +22,34 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
If you are using in a rails app, place the following into your config/application.rb:
|
26
26
|
|
27
|
-
|
27
|
+
```ruby
|
28
|
+
Petfinder.configure do |config|
|
29
|
+
config.api_key = "YOUR API KEY HERE"
|
30
|
+
config.api_secret = "YOUR API SECRET HERE"
|
31
|
+
end
|
32
|
+
```
|
33
|
+
note: Currently, the API does not utilize a client secret for any requests. You are probably better off not setting this value in your code. In the future if they add PUT, POST, DELETE endpoints that require auth, the above config will work, if someone wants to build out those methods.
|
28
34
|
|
29
|
-
|
35
|
+
Afterward, you should be able to use
|
36
|
+
```ruby
|
37
|
+
client = Petfinder::Client.new
|
38
|
+
client.find_pets("dog", "33165") # => returns an array of Pets
|
39
|
+
client.find_pet("38747365") # => returns a single Pet
|
40
|
+
client.find_shelters("33131") # => returns an array of Shelters
|
41
|
+
client.get_shelter("FL54") # => returns a single Shelter object
|
42
|
+
```
|
30
43
|
|
31
|
-
|
44
|
+
Additionally, try methods like
|
45
|
+
```ruby
|
46
|
+
pet = client.find_pet("38747365")
|
47
|
+
pet.name # => returns the pet's name
|
48
|
+
pet.contact # => returns a hash of contact info
|
49
|
+
```
|
50
|
+
the same should function for shelters.
|
32
51
|
|
52
|
+
Please see below for bug reporting and pull requests.
|
33
53
|
## Contributing
|
34
54
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
55
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/pdeona/petfinder-wrap.
|
data/lib/petfinder-wrap.rb
CHANGED
data/lib/petfinder/client.rb
CHANGED
@@ -47,16 +47,19 @@ module Petfinder
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def find_shelters location
|
50
|
-
find_shelters_request = API_BASE_URI + "shelter.find?key=#{@api_key}&location=#{location}"
|
50
|
+
find_shelters_request = API_BASE_URI + "shelter.find?key=#{@api_key}&location=#{location}&format=json"
|
51
51
|
response = open(find_shelters_request).read
|
52
|
-
|
52
|
+
res = []
|
53
|
+
if resp = JSON.parse(response)
|
54
|
+
resp["petfinder"]["shelters"]["shelter"].each do |shelter|
|
55
|
+
res << Shelter.new(shelter)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
res
|
53
59
|
end
|
60
|
+
|
54
61
|
end
|
55
62
|
|
56
63
|
private
|
57
64
|
|
58
|
-
def parse_pet_resp response
|
59
|
-
|
60
|
-
end
|
61
|
-
|
62
65
|
end
|