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.



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

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

#checkoutObject

Returns the value of attribute checkout.



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

def checkout
  @checkout
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



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

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

#create_charge(params) ⇒ Object



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

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

#create_discount_line(params) ⇒ Object



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

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

#create_line_item(params) ⇒ Object

Attribute accessors



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

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

#create_shipping_contact(params) ⇒ Object



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

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

#create_shipping_line(params) ⇒ Object



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

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

#create_tax_line(params) ⇒ Object



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

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

#load_from(response = nil) ⇒ Object



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

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



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

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

#void(params = {}) ⇒ Object



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

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