Class: Giftrocket::Gift
- Inherits:
-
Object
- Object
- Giftrocket::Gift
- Includes:
- HTTParty
- Defined in:
- lib/giftrocket/gift.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
Returns the value of attribute amount.
-
#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.
-
#recipient ⇒ Object
Returns the value of attribute recipient.
-
#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.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/giftrocket/gift.rb', line 9 def initialize(attributes) attributes = attributes.with_indifferent_access 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.recipient = Giftrocket::User.new(attributes[:recipient]) self.events = attributes[:events] end |
Instance Attribute Details
#amount ⇒ Object
Returns the value of attribute amount.
7 8 9 |
# File 'lib/giftrocket/gift.rb', line 7 def amount @amount end |
#events ⇒ Object
Returns the value of attribute events.
7 8 9 |
# File 'lib/giftrocket/gift.rb', line 7 def events @events end |
#id ⇒ Object
Returns the value of attribute id.
7 8 9 |
# File 'lib/giftrocket/gift.rb', line 7 def id @id end |
#message ⇒ Object
Returns the value of attribute message.
7 8 9 |
# File 'lib/giftrocket/gift.rb', line 7 def end |
#order_id ⇒ Object
Returns the value of attribute order_id.
7 8 9 |
# File 'lib/giftrocket/gift.rb', line 7 def order_id @order_id end |
#recipient ⇒ Object
Returns the value of attribute recipient.
7 8 9 |
# File 'lib/giftrocket/gift.rb', line 7 def recipient @recipient end |
#status ⇒ Object
Returns the value of attribute status.
7 8 9 |
# File 'lib/giftrocket/gift.rb', line 7 def status @status end |
#style_id ⇒ Object
Returns the value of attribute style_id.
7 8 9 |
# File 'lib/giftrocket/gift.rb', line 7 def style_id @style_id end |
Class Method Details
.list ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/giftrocket/gift.rb', line 21 def self.list response = get '/', query: Giftrocket., format: 'json' if response.success? response_json = JSON.parse(response.body).with_indifferent_access response_json[:gifts].map do |gift_attributes| Giftrocket::Gift.new(gift_attributes) end else raise Giftrocket::Error.new(response) end end |
.retrieve(id) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/giftrocket/gift.rb', line 33 def self.retrieve(id) response = get "/#{id}", query: Giftrocket., format: 'json' if response.success? response_json = JSON.parse(response.body).with_indifferent_access Giftrocket::Gift.new(response_json[:gift]) else raise Giftrocket::Error.new(response) end end |