Sha256: 5dd1ead0285a7a6fcd98440e155f8cbf5b46f0456d4c618bcad9cf0717cb2532

Contents?: true

Size: 961 Bytes

Versions: 7

Compression:

Stored size: 961 Bytes

Contents

require 'vng/resource'

module Vng
  # Provides methods to interact with Vonigo breeds.
  class Breed < Resource
    PATH = '/api/v1/resources/breeds/'

    attr_reader :id, :name, :species, :option_id, :low_weight, :high_weight

    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

    # TODO: Needs pagination
    def self.all
      data = request path: PATH

      data['Breeds'].map do |breed|
        id = breed['breedID']
        name = breed['breed']
        species = breed['species']
        option_id = breed['optionID']
        low_weight = breed['breedLowWeight']
        high_weight = breed['breedHighWeight']

        new id: id, name: name, species: species, option_id: option_id, low_weight: low_weight, high_weight: high_weight
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
vng-0.1.20 lib/vng/breed.rb
vng-0.1.19 lib/vng/breed.rb
vng-0.1.18 lib/vng/breed.rb
vng-0.1.17 lib/vng/breed.rb
vng-0.1.16 lib/vng/breed.rb
vng-0.1.15 lib/vng/breed.rb
vng-0.1.14 lib/vng/breed.rb