Module: Petfinder::Api

Included in:
Client
Defined in:
lib/petfinder/api.rb

Instance Method Summary collapse

Instance Method Details

#animal(id) ⇒ Object



13
14
15
# File 'lib/petfinder/api.rb', line 13

def animal(id)
  Mash.new(request("animals/#{id}")['animal'])
end

#animals(params = {}) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/petfinder/api.rb', line 4

def animals(params = {})
  response = request('animals', params)

  animals = response['animals'].map { |animal| Mash.new(animal) }
  pagination = Mash.new(response['pagination'])

  [animals, pagination]
end

#breeds(type) ⇒ Object



25
26
27
# File 'lib/petfinder/api.rb', line 25

def breeds(type)
  request("types/#{type}/breeds")['breeds'].map { |breed| Mash.new(breed) }
end

#organization(id) ⇒ Object



38
39
40
# File 'lib/petfinder/api.rb', line 38

def organization(id)
  Mash.new(request("organizations/#{id}")['organization'])
end

#organizations(params = {}) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/petfinder/api.rb', line 29

def organizations(params = {})
  response = request('organizations', params)

  organizations = response['organizations'].map { |org| Mash.new(org) }
  pagination = Mash.new(response['pagination'])

  [organizations, pagination]
end

#type(type) ⇒ Object



21
22
23
# File 'lib/petfinder/api.rb', line 21

def type(type)
  Mash.new(request("types/#{type}")['type'])
end

#typesObject



17
18
19
# File 'lib/petfinder/api.rb', line 17

def types
  request("types")['types'].map { |type| Mash.new(type) }
end