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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5aac1d2c8207508529a9ccdf00c0958066db0657
4
- data.tar.gz: 8ad0045da80784397252b5bfe7108c9f729d7694
3
+ metadata.gz: 77edfce7c300f6582f65205f797109729bba997a
4
+ data.tar.gz: 8f6fa5d47055eea64e31b7636ab59a6260a42c95
5
5
  SHA512:
6
- metadata.gz: 070be214cf4c9f5b37cb37a8344fc130e16522d58cb0d0b34acdcf2bae75a63c8506994feed7b5fcd156ed025620b990d2a60cc0e37d88e0d8a19de9a8c5960d
7
- data.tar.gz: d56c5a8ae77803ebb30fb7496f8dbc98f24bb67f40ca0ecbe97e17b2f5551d277025ccf3bd1ae3ca14d45d6b8a7c3ca7f0a46340add9e73d7bf23cbad1dddee5
6
+ metadata.gz: 1852593cefe69a224708b4ff78279fd121e20a35ae4a752bbfd90111d8e93bb40e29c3d558ba2b3cc137f9da90acc8909eeb79ee0c2881b25045b8f40ccf8ce2
7
+ data.tar.gz: 6fdbacb05cd5113d4955d05ecc3ae713769cc768cc5a4e41cb5449195999bfbf59a90704972d0872ebb3f2f24a347701226c45ac011cf85b728569f3351689b3
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Petfinder::Wrap
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/petfinder/wrap`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ A simple gem for the Petfinder API using JSON responses and a traversal method.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
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
- TODO: Write usage instructions here
25
+ If you are using in a rails app, place the following into your config/application.rb:
26
26
 
27
- ## Development
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
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
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
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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/[USERNAME]/petfinder-wrap.
55
+ Bug reports and pull requests are welcome on GitHub at https://github.com/pdeona/petfinder-wrap.
@@ -6,7 +6,7 @@ require_relative 'petfinder/client'
6
6
  require 'open-uri'
7
7
 
8
8
  module Petfinder
9
- VERSION = "1.0.0"
9
+ VERSION = "1.0.1.1"
10
10
 
11
11
  class Error < StandardError; end
12
12
 
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: petfinder-wrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro De Ona