class Giftrocket::Gift

Attributes

amount[RW]
catalog[RW]
events[RW]
id[RW]
message[RW]
order_id[RW]
raw[RW]
recipient[RW]
redemption_methods[RW]
sender[RW]
status[RW]
style_id[RW]

Public Class Methods

list(filters={}) click to toggle source
# File lib/giftrocket/gift.rb, line 22
def self.list(filters={})
  response = Giftrocket::Request.get(
    'gifts',
    query: filters.merge(Giftrocket.default_options),
    format: 'json'
  )[:gifts].map do |gift_attributes|
    Giftrocket::Gift.new(gift_attributes)
  end
end
new(attributes) click to toggle source
# 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.message = 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
retrieve(id) click to toggle source
# File lib/giftrocket/gift.rb, line 32
def self.retrieve(id)
  response = Giftrocket::Request.get "gifts/#{id}",
                                     query: Giftrocket.default_options,
                                     format: 'json'
  Giftrocket::Gift.new(response[:gift])
end