adopt_a_pet 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85768d77d009bb82f767f155bcbd3cab6d27bcb3
4
- data.tar.gz: 3cd64da528b83b8dfaa9d727a16728f59d1cf9bf
3
+ metadata.gz: b971bf03e5be4346c5f39c85f282c2f054a8bbfa
4
+ data.tar.gz: f859d8da6eda2ce9aeca541d301ada8ceae91ff1
5
5
  SHA512:
6
- metadata.gz: cd0686a40bdbe77b722b9abafa72eecc35aba9d9b8f61f996f4b43f031224b1dd5f078c7a9cf056a5ed50e6f53122e976396eafc0ca3482d82e027db7e4a9903
7
- data.tar.gz: f871bb63fec835c047808c590f5c07c6f0b3c86925df6ed109780f201c69e5c92440db785acbeb911d8e622304eccaac87b46f5bdc72af6dd61259a747fd38ba
6
+ metadata.gz: d2c627e3323954655631dd7e0c93506e2b8cd943d57da01cf78661ad7c199b7bbfbf086ed6c8595f9d8fb9c8c02e91946569d324d4f22ba61b6a437ae7a812d9
7
+ data.tar.gz: 8154cf26d0399c273d30f440a86ae212345d94d4297689094bda3be770be92d2e97198a5bdf4ad75c15d94fc891aad483efaa7e13c8b69910790e9ff853396e0
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
 
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
+ .*.swp
@@ -7,3 +7,5 @@ Style/FrozenStringLiteralComment:
7
7
  Enabled: false
8
8
  Metrics/LineLength:
9
9
  Max: 100
10
+ Style/RegexpLiteral:
11
+ EnforcedStyle: percent_r
Binary file
@@ -70,6 +70,7 @@ module AdoptAPet
70
70
  # @author Stephen Dolan
71
71
  #
72
72
  # @param [Integer] pet_id the ID of a single pet
73
+ # @param [Hash] opts a placeholder for any options the user would like to submit
73
74
  #
74
75
  # @return [Pet] a Pet object
75
76
  #
@@ -77,8 +78,8 @@ module AdoptAPet
77
78
  # client = AdoptAPet::Client.new('my_key')
78
79
  # pet = client.limited_pet_details(123456)
79
80
  # my_pet_special_needs = pet.special_needs
80
- def limited_pet_details(pet_id)
81
- query = { pet_id: pet_id }
81
+ def limited_pet_details(pet_id, options = {})
82
+ query = options.merge(pet_id: pet_id)
82
83
  response = perform_get('/search/limited_pet_details', query)
83
84
  Pet.new(response.dig('pet'))
84
85
  end
@@ -87,6 +88,7 @@ module AdoptAPet
87
88
  # @author Stephen Dolan
88
89
  #
89
90
  # @param [Integer] pet_id the ID of a single pet
91
+ # @param [Hash] opts a placeholder for any options the user would like to submit
90
92
  #
91
93
  # @return [Pet] a Pet object
92
94
  #
@@ -94,8 +96,8 @@ module AdoptAPet
94
96
  # client = AdoptAPet::Client.new('my_key')
95
97
  # pet = client.pet_details(123456)
96
98
  # my_pet_housetrained = pet.housetrained
97
- def pet_details(pet_id)
98
- query = { pet_id: pet_id }
99
+ def pet_details(pet_id, options = {})
100
+ query = options.merge(pet_id: pet_id)
99
101
  response = perform_get('/search/pet_details', query)
100
102
  Pet.new(response.dig('pet'))
101
103
  end
@@ -105,12 +107,12 @@ module AdoptAPet
105
107
  # Instantiate a Faraday connector with a base URL and adapter
106
108
  # @author stephen dolan
107
109
  #
108
- # @return [faraday::connection] a faraday object to make requests
110
+ # @return [Faraday::Connection] a faraday object to make requests
109
111
  def setup_connection
110
112
  # Set up a flexible connection to append the URI to and make requests with
111
113
  Faraday.new(url: 'https://api.adoptapet.com') do |faraday|
112
114
  # Include to log responses to STDOUT
113
- faraday.response :logger
115
+ # faraday.response :logger
114
116
 
115
117
  # Don't encode identical URL paramaeters with []
116
118
  faraday.options.params_encoder = Faraday::FlatParamsEncoder
@@ -134,13 +136,13 @@ module AdoptAPet
134
136
  options = options.merge(output: :json)
135
137
 
136
138
  # Always include the API key
137
- options = options.merge(key: self.api_key)
139
+ options = options.merge(key: api_key)
138
140
 
139
141
  # Always set the API version to version 1
140
142
  options = options.merge(v: 1)
141
143
 
142
144
  # Make the request
143
- response = self.conn.get(uri, options)
145
+ response = conn.get(uri, options)
144
146
 
145
147
  # Validate the body and transform into a Ruby object
146
148
  process_json_response(response.body)
@@ -84,6 +84,7 @@ module AdoptAPet
84
84
  extract(object, %w[pet_id], 'id')
85
85
  extract(object, %w[sex], 'sex')
86
86
  extract(object, %w[size], 'size')
87
+ extract(object, %w[age], 'age')
87
88
  extract(object, %w[species], 'species')
88
89
  extract(object, %w[act_quickly], 'act_quickly')
89
90
  extract(object, %w[color], 'color')
@@ -98,8 +99,8 @@ module AdoptAPet
98
99
  extract(object, %w[good_with_kids], 'good_with_kids')
99
100
  extract(object, %w[primary_breed], 'primary_breed')
100
101
  extract(object, %w[secondary_breed], 'secondary_breed')
101
- extract(object, %w[state_code], 'addr_state_code')
102
- extract(object, %w[city], 'addr_city')
102
+ extract(object, %w[addr_state_code], 'state_code')
103
+ extract(object, %w[addr_city], 'city')
103
104
  extract(object, %w[name pet_name], 'name')
104
105
  extract(object, %w[details_url pet_details_url], 'details_url')
105
106
  self.photos = ResponseHelper.extract_photos(object)
@@ -138,9 +139,6 @@ module AdoptAPet
138
139
  response_item = object.dig(source) unless object.dig(source).nil?
139
140
  end
140
141
 
141
- # Don't set the key if we couldn't find a value
142
- return if response_item.nil?
143
-
144
142
  # Set the Pet attribute at to_key to the object value
145
143
  send("#{to_key}=", response_item)
146
144
  end
@@ -1,3 +1,3 @@
1
1
  module AdoptAPet
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adopt_a_pet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Dolan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-22 00:00:00.000000000 Z
11
+ date: 2017-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -110,6 +110,7 @@ files:
110
110
  - LICENSE.txt
111
111
  - README.md
112
112
  - Rakefile
113
+ - adopt_a_pet-0.1.0.gem
113
114
  - adopt_a_pet.gemspec
114
115
  - bin/console
115
116
  - bin/setup