Class: Giftrocket::Catalog

Inherits:
Object
  • Object
show all
Defined in:
lib/giftrocket/catalog.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Catalog

Returns a new instance of Catalog.



6
7
8
9
10
11
# File 'lib/giftrocket/catalog.rb', line 6

def initialize(attributes)
  attributes = attributes.with_indifferent_access
  self.id = attributes[:id]
  self.name = attributes[:name]
  self.raw = attributes
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



4
5
6
# File 'lib/giftrocket/catalog.rb', line 4

def data
  @data
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/giftrocket/catalog.rb', line 4

def id
  @id
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/giftrocket/catalog.rb', line 4

def name
  @name
end

#rawObject

Returns the value of attribute raw.



4
5
6
# File 'lib/giftrocket/catalog.rb', line 4

def raw
  @raw
end

Class Method Details

.list(filters = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/giftrocket/catalog.rb', line 13

def self.list(filters={})
  Giftrocket::Request.get(
    'catalog',
    query: filters.merge(Giftrocket.default_options),
    format: 'json'
  )[:catalog].map do |item|
    Giftrocket::Catalog.new(item)
  end
end