Sha256: 49eee680b6ef414ababf8899868d05c9b185a994a76f69ef2cfee3757dca3f59

Contents?: true

Size: 503 Bytes

Versions: 2

Compression:

Stored size: 503 Bytes

Contents

module GunBroker
  class Category

    # The top-level category ID.
    ROOT_CATEGORY_ID = 0

    def self.all(parent = ROOT_CATEGORY_ID)
      response = GunBroker::API.get('/Categories', { 'ParentCategoryID' => parent })
      response['results'].map { |attrs| new(attrs) }
    end

    def self.find(category_id)
      new(GunBroker::API.get("/Categories/#{category_id}"))
    end

    def initialize(attrs = {})
      @attrs = attrs
    end

    def id
      @attrs['categoryID']
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gun_broker-0.2.0 lib/gun_broker/category.rb
gun_broker-0.1.0 lib/gun_broker/category.rb