Class: Giftrocket::Gift
- Inherits:
-
Object
- Object
- Giftrocket::Gift
- Defined in:
- lib/giftrocket/gift.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#catalog ⇒ Object
Returns the value of attribute catalog.
-
#events ⇒ Object
Returns the value of attribute events.
-
#id ⇒ Object
Returns the value of attribute id.
-
#message ⇒ Object
Returns the value of attribute message.
-
#order_id ⇒ Object
Returns the value of attribute order_id.
-
#raw ⇒ Object
Returns the value of attribute raw.
-
#recipient ⇒ Object
Returns the value of attribute recipient.
-
#redemption_methods ⇒ Object
Returns the value of attribute redemption_methods.
-
#sender ⇒ Object
Returns the value of attribute sender.
-
#status ⇒ Object
Returns the value of attribute status.
-
#style_id ⇒ Object
Returns the value of attribute style_id.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Gift
constructor
A new instance of Gift.
Constructor Details
#initialize(attributes) ⇒ Gift
Returns a new instance of Gift.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/giftrocket/gift.rb', line 6 def initialize(attributes) attributes = attributes.with_indifferent_access self.raw = attributes self.id = attributes[:id] self.order_id = attributes[:order_id] self.amount = attributes[:amount] self. = attributes[:message] self.style_id = attributes[:style_id] self.status = attributes[:status] self.sender = attributes[:sender] self.recipient = Giftrocket::User.new(attributes[:recipient]) self.events = attributes[:events] self.catalog = attributes[:catalog] self.redemption_methods = attributes[:redemption_methods] end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
4 5 6 |
# File 'lib/giftrocket/gift.rb', line 4 def amount @amount end |
#catalog ⇒ Object
Returns the value of attribute catalog.
4 5 6 |
# File 'lib/giftrocket/gift.rb', line 4 def catalog @catalog end |
#events ⇒ Object
Returns the value of attribute events.
4 5 6 |
# File 'lib/giftrocket/gift.rb', line 4 def events @events end |
#id ⇒ Object
Returns the value of attribute id.
4 5 6 |
# File 'lib/giftrocket/gift.rb', line 4 def id @id end |
#message ⇒ Object
Returns the value of attribute message.
4 5 6 |
# File 'lib/giftrocket/gift.rb', line 4 def @message end |
#order_id ⇒ Object
Returns the value of attribute order_id.
4 5 6 |
# File 'lib/giftrocket/gift.rb', line 4 def order_id @order_id end |
#raw ⇒ Object
Returns the value of attribute raw.
4 5 6 |
# File 'lib/giftrocket/gift.rb', line 4 def raw @raw end |
#recipient ⇒ Object
Returns the value of attribute recipient.
4 5 6 |
# File 'lib/giftrocket/gift.rb', line 4 def recipient @recipient end |
#redemption_methods ⇒ Object
Returns the value of attribute redemption_methods.
4 5 6 |
# File 'lib/giftrocket/gift.rb', line 4 def redemption_methods @redemption_methods end |
#sender ⇒ Object
Returns the value of attribute sender.
4 5 6 |
# File 'lib/giftrocket/gift.rb', line 4 def sender @sender end |
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'lib/giftrocket/gift.rb', line 4 def status @status end |
#style_id ⇒ Object
Returns the value of attribute style_id.
4 5 6 |
# File 'lib/giftrocket/gift.rb', line 4 def style_id @style_id end |
Class Method Details
.list(filters = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/giftrocket/gift.rb', line 22 def self.list(filters={}) response = Giftrocket::Request.get( 'gifts', query: filters.merge(Giftrocket.), format: 'json' )[:gifts].map do |gift_attributes| Giftrocket::Gift.new(gift_attributes) end end |
.retrieve(id) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/giftrocket/gift.rb', line 32 def self.retrieve(id) response = Giftrocket::Request.get "gifts/#{id}", query: Giftrocket., format: 'json' Giftrocket::Gift.new(response[:gift]) end |