Class: Giftrocket::Style
- Inherits:
-
Object
- Object
- Giftrocket::Style
- Includes:
- HTTParty
- Defined in:
- lib/giftrocket/style.rb
Instance Attribute Summary collapse
-
#card ⇒ Object
Returns the value of attribute card.
-
#id ⇒ Object
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Style
constructor
A new instance of Style.
- #url ⇒ Object
Constructor Details
#initialize(attributes) ⇒ Style
9 10 11 12 13 |
# File 'lib/giftrocket/style.rb', line 9 def initialize(attributes) attributes = attributes.with_indifferent_access self.id = attributes[:id] self.card = attributes[:card] end |
Instance Attribute Details
#card ⇒ Object
Returns the value of attribute card.
7 8 9 |
# File 'lib/giftrocket/style.rb', line 7 def card @card end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/giftrocket/style.rb', line 7 def id @id end |
Class Method Details
.list ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/giftrocket/style.rb', line 19 def self.list response = get '/', query: Giftrocket., format: 'json' if response.success? response_json = JSON.parse(response.body).with_indifferent_access response_json[:styles].map do |style_attributes| Giftrocket::Style.new(style_attributes) end else raise Giftrocket::Error.new(response) end end |
Instance Method Details
#url ⇒ Object
15 16 17 |
# File 'lib/giftrocket/style.rb', line 15 def url card && card[:url] end |