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



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

def action_id
  data[:action_id]
end

#addressObject



78
79
80
# File 'lib/kentaa/api/resources/order.rb', line 78

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

#companyObject



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

def company
  data[:company]
end

#currencyObject



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

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



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

def first_name
  data[:first_name]
end

#infixObject



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

def infix
  data[:infix]
end

#invoicenumberObject



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

def invoicenumber
  data[:invoicenumber]
end

#itemsObject



90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/kentaa/api/resources/order.rb', line 90

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



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

def last_name
  data[:last_name]
end

#localeObject



86
87
88
# File 'lib/kentaa/api/resources/order.rb', line 86

def locale
  data[:locale]
end

#nameObject



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

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

#payment_statusObject



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

def payment_status
  data[:payment_status]
end

#phoneObject



82
83
84
# File 'lib/kentaa/api/resources/order.rb', line 82

def phone
  data[:phone]
end

#project_idObject



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

def project_id
  data[:project_id]
end

#public_idObject



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

def public_id
  data[:public_id]
end

#segment_idObject



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

def segment_id
  data[:segment_id]
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



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

def site_id
  data[:site_id]
end

#total_amountObject



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

def total_amount
  BigDecimal(data[:total_amount])
end