Class: FbGraph::Order

Inherits:
Node
  • Object
show all
Defined in:
lib/fb_graph/order.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#access_token, #endpoint, #identifier, #raw_attributes

Instance Method Summary collapse

Methods inherited from Node

#connection, #destroy, fetch, #fetch

Methods included from Comparison

#==

Constructor Details

#initialize(identifier, attributes = {}) ⇒ Order

Returns a new instance of Order



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fb_graph/order.rb', line 5

def initialize(identifier, attributes = {})
  super
  if app = attributes[:application]
    @application = Application.new(app[:id], app)
  end
  if from = attributes[:from]
    @from = User.new(from[:id], from)
  end
  if to = attributes[:to]
    @to = User.new(to[:id], to)
  end
  @amount = attributes[:amount]
  @status = attributes[:status]
  @country = attributes[:country]
  if attributes[:created_time]
    @created_time = Time.parse(attributes[:created_time]).utc
  end
  if attributes[:updated_time]
    @updated_time = Time.parse(attributes[:updated_time]).utc
  end
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount



3
4
5
# File 'lib/fb_graph/order.rb', line 3

def amount
  @amount
end

#applicationObject

Returns the value of attribute application



3
4
5
# File 'lib/fb_graph/order.rb', line 3

def application
  @application
end

#countryObject

Returns the value of attribute country



3
4
5
# File 'lib/fb_graph/order.rb', line 3

def country
  @country
end

#created_timeObject

Returns the value of attribute created_time



3
4
5
# File 'lib/fb_graph/order.rb', line 3

def created_time
  @created_time
end

#fromObject

Returns the value of attribute from



3
4
5
# File 'lib/fb_graph/order.rb', line 3

def from
  @from
end

#statusObject

Returns the value of attribute status



3
4
5
# File 'lib/fb_graph/order.rb', line 3

def status
  @status
end

#toObject

Returns the value of attribute to



3
4
5
# File 'lib/fb_graph/order.rb', line 3

def to
  @to
end

#updated_timeObject

Returns the value of attribute updated_time



3
4
5
# File 'lib/fb_graph/order.rb', line 3

def updated_time
  @updated_time
end

Instance Method Details

#cancel!(options = {}) ⇒ Object Also known as: canceled!



37
38
39
# File 'lib/fb_graph/order.rb', line 37

def cancel!(options = {})
  update options.merge(:status => :canceled)
end

#refund!(options = {}) ⇒ Object Also known as: refunded!



32
33
34
# File 'lib/fb_graph/order.rb', line 32

def refund!(options = {})
  update options.merge(:status => :refunded)
end

#settle!(options = {}) ⇒ Object Also known as: settled!



27
28
29
# File 'lib/fb_graph/order.rb', line 27

def settle!(options = {})
  update options.merge(:status => :settled)
end

#update(attributes = {}) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/fb_graph/order.rb', line 42

def update(attributes = {})
  _attributes_ = attributes.dup
  params = {
    :access_token => _attributes_.delete(:access_token) || self.access_token,
    :status => _attributes_.delete(:status),
    :message => _attributes_.delete(:message),
    :refund_funding_source => _attributes_.delete(:refund_funding_source),
    :refund_reason => _attributes_.delete(:refund_reason),
    :params => _attributes_
  }
  super params
end