AdoptAPet
Ruby gem wrapper for the Adopt-A-Pet API
Installation
Add this line to your application's Gemfile:
gem 'adopt_a_pet'
And then execute:
$ bundle
Or install it yourself as:
$ gem install adopt_a_pet
Get Your API Key
Get your Adopt-A-Pet API key by logging into a shelter account, then visiting the API signup page.
Usage
Instantiate a Client
client = AdoptAPet::Client.new('your_api_key')
Examples
Return a list of pets at shelter '12345'
pet_response = client.pets_at_shelter('12345')
# Determine the number of returned pets
pet_response.count
# => 50
# Get the first pet's name
pet_response.first.name
# => "Rocky"
# Get the first pet's photo
pet_response.first.photos.first.dig(:original).url
# => "https://s3.amazonaws.com/pet-uploads.adoptapet.com/6/f/3/92702234.jpg"
Return a list of pets at shelters '12345' and '56789'
pet_response = client.pets_at_shelters(['12345', '56789'])
# Determine the number of returned pets
pet_response.count
# => 50
# Get the first pet's name
pet_response.first.name
# => "Rocky"
# Get the first pet's photo
pet_response.first.photos.first.dig(:original).url
# => "https://s3.amazonaws.com/pet-uploads.adoptapet.com/6/f/3/92702434.jpg"
Return limited details for the pet with ID '1234'
pet = client.limited_pet_details('1234')
pet.name
# => "Rocky"
pet.id
# => "123456"
pet.purebred
# => "0"
Get full pet details for the pet with ID '1234'
pet = client.pet_details('1234')
pet.name
# => "Rocky"
pet.id
# => "123456"
pet.housetrained
# => "1"
Development
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.
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.
Contributing
Bug reports and pull requests are welcome on GitHub at https://gitlab.com/stephendolan/adopt_a_pet. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
License
The gem is available as open source under the terms of the MIT License.