Class: Akatus::Order

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Order

Returns a new instance of Order.



7
8
9
10
11
12
# File 'lib/akatus/order.rb', line 7

def initialize(attributes = {})
  attributes.each do |name, value|  
    send("#{name}=", value)  
  end  
  self.products = []
end

Instance Attribute Details

#address(attributes = {}) ⇒ Object

Returns the value of attribute address.



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

def address
  @address
end

#buyer_emailObject

Returns the value of attribute buyer_email.



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

def buyer_email
  @buyer_email
end

#buyer_nameObject

Returns the value of attribute buyer_name.



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

def buyer_name
  @buyer_name
end

#credit_card(attributes = {}) ⇒ Object

Returns the value of attribute credit_card.



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

def credit_card
  @credit_card
end

#discount_amountObject

Returns the value of attribute discount_amount.



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

def discount_amount
  @discount_amount
end

#freight_amountObject

Returns the value of attribute freight_amount.



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

def freight_amount
  @freight_amount
end

#installmentsObject

Returns the value of attribute installments.



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

def installments
  @installments
end

#payment_methodObject

Returns the value of attribute payment_method.



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

def payment_method
  @payment_method
end

#phone(attributes = {}) ⇒ Object

Returns the value of attribute phone.



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

def phone
  @phone
end

#productsObject

Returns the value of attribute products.



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

def products
  @products
end

#referenceObject

Returns the value of attribute reference.



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

def reference
  @reference
end

#weightObject

Returns the value of attribute weight.



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

def weight
  @weight
end

Instance Method Details

#add_product(attributes = {}) ⇒ Object



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

def add_product(attributes = {})
  self.products << Product.new({
    :code             =>     attributes[:code],
    :name             =>     attributes[:name],
    :weight           =>     attributes[:weight],
    :quantity         =>     attributes[:quantity],
    :freight_amount   =>     attributes[:freight_amount],
    :discount_amount  =>     attributes[:discount_amount],
    :price            =>     attributes[:price]
  })  
end

#credit_card?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'lib/akatus/order.rb', line 59

def credit_card?
  %w{cartao_visa cartao_master cartao_amex cartao_diners cartao_elo cartao_hipercard}.include? payment_method
end