Class: Vng::Breed
- Inherits:
-
Object
- Object
- Vng::Breed
- Defined in:
- lib/vng/breed.rb
Overview
Provides methods to interact with Vonigo breeds.
Instance Attribute Summary collapse
-
#high_weight ⇒ Object
readonly
Returns the value of attribute high_weight.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#low_weight ⇒ Object
readonly
Returns the value of attribute low_weight.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#option_id ⇒ Object
readonly
Returns the value of attribute option_id.
-
#species ⇒ Object
readonly
Returns the value of attribute species.
Class Method Summary collapse
-
.all ⇒ Object
TODO: Needs pagination.
Instance Method Summary collapse
-
#initialize(id:, name:, species:, option_id:, low_weight:, high_weight:) ⇒ Breed
constructor
A new instance of Breed.
Constructor Details
#initialize(id:, name:, species:, option_id:, low_weight:, high_weight:) ⇒ Breed
Returns a new instance of Breed.
6 7 8 9 10 11 12 13 |
# File 'lib/vng/breed.rb', line 6 def initialize(id:, name:, species:, option_id:, low_weight:, high_weight:) @id = id @name = name @species = species @option_id = option_id @low_weight = low_weight @high_weight = high_weight end |
Instance Attribute Details
#high_weight ⇒ Object (readonly)
Returns the value of attribute high_weight.
4 5 6 |
# File 'lib/vng/breed.rb', line 4 def high_weight @high_weight end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/vng/breed.rb', line 4 def id @id end |
#low_weight ⇒ Object (readonly)
Returns the value of attribute low_weight.
4 5 6 |
# File 'lib/vng/breed.rb', line 4 def low_weight @low_weight end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/vng/breed.rb', line 4 def name @name end |
#option_id ⇒ Object (readonly)
Returns the value of attribute option_id.
4 5 6 |
# File 'lib/vng/breed.rb', line 4 def option_id @option_id end |
#species ⇒ Object (readonly)
Returns the value of attribute species.
4 5 6 |
# File 'lib/vng/breed.rb', line 4 def species @species end |
Class Method Details
.all ⇒ Object
TODO: Needs pagination
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/vng/breed.rb', line 16 def self.all body = { securityToken: Vng.configuration.security_token, } uri = URI::HTTPS.build host: 'aussiepetmobileusatraining2.vonigo.com', path: '/api/v1/resources/breeds/' request = Net::HTTP::Post.new(uri.request_uri) request.initialize_http_header 'Content-Type' => 'application/json' request.body = body.to_json response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| http.request request end JSON(response.body)['Breeds'].map do |body| id = body['breedID'] name = body['breed'] species = body['species'] option_id = body['optionID'] low_weight = body['breedLowWeight'] high_weight = body['breedHighWeight'] new id: id, name: name, species: species, option_id: option_id, low_weight: low_weight, high_weight: high_weight end end |