Class: Conekta::Order

Instance Attribute Summary collapse

Attributes inherited from Resource

#id

Attributes inherited from ConektaObject

#values

Instance Method Summary collapse

Methods included from Conekta::Operations::CustomAction

#custom_action

Methods included from Conekta::Operations::CreateMember

#create_member

Methods included from Conekta::Operations::Update

#update

Methods included from Conekta::Operations::Create

included

Methods included from Conekta::Operations::Where

handle_type_of_paging, included

Methods included from Conekta::Operations::Find

included

Methods inherited from Resource

_url, #_url, #create_member_with_relation, underscored_class

Methods inherited from ConektaObject

#class_name, class_name, #create_attr, #first, #inspect, #last, #set_val, #to_s, #unset_key

Constructor Details

#initialize(id = nil) ⇒ Order

Returns a new instance of Order.



14
15
16
17
18
19
20
21
22
# File 'lib/conekta/order.rb', line 14

def initialize(id=nil)
  @id = id
  @line_items ||= List.new("LineItem", {})
  @tax_lines ||= List.new("TaxLine", {})
  @shipping_lines ||= List.new("ShippingLine", {})
  @discount_lines ||= List.new("DiscountLine", {})
  @charges ||= List.new("Charge", {})
  super(id)
end

Instance Attribute Details

#amountObject

Returns the value of attribute amount.



10
11
12
# File 'lib/conekta/order.rb', line 10

def amount
  @amount
end

#chargesObject

Returns the value of attribute charges.



10
11
12
# File 'lib/conekta/order.rb', line 10

def charges
  @charges
end

#created_atObject

Returns the value of attribute created_at.



10
11
12
# File 'lib/conekta/order.rb', line 10

def created_at
  @created_at
end

#currencyObject

Returns the value of attribute currency.



10
11
12
# File 'lib/conekta/order.rb', line 10

def currency
  @currency
end

#customer_idObject

Returns the value of attribute customer_id.



10
11
12
# File 'lib/conekta/order.rb', line 10

def customer_id
  @customer_id
end

#discount_linesObject

Returns the value of attribute discount_lines.



10
11
12
# File 'lib/conekta/order.rb', line 10

def discount_lines
  @discount_lines
end

#line_itemsObject

Returns the value of attribute line_items.



10
11
12
# File 'lib/conekta/order.rb', line 10

def line_items
  @line_items
end

#livemodeObject

Returns the value of attribute livemode.



10
11
12
# File 'lib/conekta/order.rb', line 10

def livemode
  @livemode
end

#metadataObject

Returns the value of attribute metadata.



10
11
12
# File 'lib/conekta/order.rb', line 10

def 
  @metadata
end

#payment_statusObject

Returns the value of attribute payment_status.



10
11
12
# File 'lib/conekta/order.rb', line 10

def payment_status
  @payment_status
end

#shipping_contactObject

Returns the value of attribute shipping_contact.



10
11
12
# File 'lib/conekta/order.rb', line 10

def shipping_contact
  @shipping_contact
end

#shipping_linesObject

Returns the value of attribute shipping_lines.



10
11
12
# File 'lib/conekta/order.rb', line 10

def shipping_lines
  @shipping_lines
end

#tax_linesObject

Returns the value of attribute tax_lines.



10
11
12
# File 'lib/conekta/order.rb', line 10

def tax_lines
  @tax_lines
end

#updated_atObject

Returns the value of attribute updated_at.



10
11
12
# File 'lib/conekta/order.rb', line 10

def updated_at
  @updated_at
end

Instance Method Details

#authorize_capture(params = {}) ⇒ Object

State transitions



61
62
63
# File 'lib/conekta/order.rb', line 61

def authorize_capture(params={})
  custom_action(:post, 'capture', params)
end

#create_charge(params) ⇒ Object



52
53
54
# File 'lib/conekta/order.rb', line 52

def create_charge(params)
  self.create_member('charges', params)
end

#create_discount_line(params) ⇒ Object



48
49
50
# File 'lib/conekta/order.rb', line 48

def create_discount_line(params)
  self.create_member_with_relation('discount_lines', params, self)
end

#create_line_item(params) ⇒ Object

Attribute accessors



36
37
38
# File 'lib/conekta/order.rb', line 36

def create_line_item(params)
  self.create_member_with_relation('line_items', params, self)
end

#create_shipping_contact(params) ⇒ Object



56
57
58
# File 'lib/conekta/order.rb', line 56

def create_shipping_contact(params)
  self.update(shipping_contact: params).shipping_contact
end

#create_shipping_line(params) ⇒ Object



44
45
46
# File 'lib/conekta/order.rb', line 44

def create_shipping_line(params)
  self.create_member_with_relation('shipping_lines', params, self)
end

#create_tax_line(params) ⇒ Object



40
41
42
# File 'lib/conekta/order.rb', line 40

def create_tax_line(params)
  self.create_member_with_relation('tax_lines', params, self)
end

#load_from(response = nil) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/conekta/order.rb', line 24

def load_from(response = nil)
  if response
    super
  end

  order     = self
  submodels = [:line_items, :tax_lines, :shipping_lines, :discount_lines,
               :charges]
  create_submodels_lists(order, submodels)
end

#refund(params = {}) ⇒ Object



69
70
71
# File 'lib/conekta/order.rb', line 69

def refund(params={})
  custom_action(:post, 'refund', params)
end

#void(params = {}) ⇒ Object



65
66
67
# File 'lib/conekta/order.rb', line 65

def void(params={})
  custom_action(:post, 'void', params)
end