Class: Kentaa::Api::Resources::Order

Inherits:
Resource show all
Defined in:
lib/kentaa/api/resources/order.rb

Instance Attribute Summary

Attributes inherited from Resource

#id

Attributes inherited from Base

#config, #endpoint_path, #options, #resource_class

Instance Method Summary collapse

Methods inherited from Resource

#create, #created_at, #delete, #initialize, #load, #save, #updated_at

Methods inherited from Base

attribute_key, #initialize, #load, #loaded?

Constructor Details

This class inherits a constructor from Kentaa::Api::Resources::Resource

Instance Method Details

#action_idObject



26
27
28
# File 'lib/kentaa/api/resources/order.rb', line 26

def action_id
  data[:action_id]
end

#addressObject



66
67
68
# File 'lib/kentaa/api/resources/order.rb', line 66

def address
  @address ||= Kentaa::Api::Resources::Address.new(data[:address]) if data[:address]
end

#companyObject



46
47
48
# File 'lib/kentaa/api/resources/order.rb', line 46

def company
  data[:company]
end

#currencyObject



50
51
52
# File 'lib/kentaa/api/resources/order.rb', line 50

def currency
  data[:currency]
end

#entityObject



10
11
12
13
14
15
16
# File 'lib/kentaa/api/resources/order.rb', line 10

def entity
  if action_id
    Kentaa::Api::Resources::Action.new(config, id: action_id, options: options)
  else
    Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
  end
end

#first_nameObject



30
31
32
# File 'lib/kentaa/api/resources/order.rb', line 30

def first_name
  data[:first_name]
end

#infixObject



34
35
36
# File 'lib/kentaa/api/resources/order.rb', line 34

def infix
  data[:infix]
end

#invoicenumberObject



58
59
60
# File 'lib/kentaa/api/resources/order.rb', line 58

def invoicenumber
  data[:invoicenumber]
end

#itemsObject



78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/kentaa/api/resources/order.rb', line 78

def items
  @items ||= begin
    items = []

    if data[:items]
      data[:items].each do |item|
        items << Kentaa::Api::Resources::OrderItem.new(item)
      end
    end

    items
  end
end

#last_nameObject



38
39
40
# File 'lib/kentaa/api/resources/order.rb', line 38

def last_name
  data[:last_name]
end

#localeObject



74
75
76
# File 'lib/kentaa/api/resources/order.rb', line 74

def locale
  data[:locale]
end

#nameObject



42
43
44
# File 'lib/kentaa/api/resources/order.rb', line 42

def name
  [first_name, infix, last_name].reject { |s| s.to_s.empty? }.join(' ')
end

#payment_statusObject



62
63
64
# File 'lib/kentaa/api/resources/order.rb', line 62

def payment_status
  data[:payment_status]
end

#phoneObject



70
71
72
# File 'lib/kentaa/api/resources/order.rb', line 70

def phone
  data[:phone]
end

#siteObject



18
19
20
# File 'lib/kentaa/api/resources/order.rb', line 18

def site
  Kentaa::Api::Resources::Site.new(config, id: site_id, options: options)
end

#site_idObject



22
23
24
# File 'lib/kentaa/api/resources/order.rb', line 22

def site_id
  data[:site_id]
end

#total_amountObject



54
55
56
# File 'lib/kentaa/api/resources/order.rb', line 54

def total_amount
  BigDecimal(data[:total_amount])
end