Class: Giftrocket::Style

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Style

Returns a new instance of Style.



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

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

Instance Attribute Details

#cardObject

Returns the value of attribute card.



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

def card
  @card
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

Class Method Details

.list(filters = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/giftrocket/style.rb', line 16

def self.list(filters={})
  options = filters.merge(Giftrocket.default_options)
  response = Giftrocket::Request.get 'styles',
                                 query: options,
                                 format: 'json'

  response[:styles].map do |style_attributes|
    Giftrocket::Style.new(style_attributes)
  end
end

Instance Method Details

#urlObject



12
13
14
# File 'lib/giftrocket/style.rb', line 12

def url
  card && card[:url]
end