Class: Xpost::Models::Order

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/xpost/models/order.rb

Constant Summary collapse

CONFIRMABLE_PARAMETERS =
Set[:status, :email, :buyer_name, :contact_number, :delivery_address, :items,
:shipment, :total, :currency, :payment_method, :payment_provider]
FOR_PICKUP_PARAMETERS =
Set[:pickup_address, :pickup_at]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Order

Returns a new instance of Order.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/xpost/models/order.rb', line 21

def initialize(options = {})
  @status           = options[:status]
  @email            = options[:email]
  @buyer_name       = options[:buyer_name]
  @contact_number   = options[:contact_number]
  @delivery_address = options[:delivery_address]
  @items            = options[:items]
  @shipment         = options[:shipment]
  @total            = options[:total]
  @currency         = options[:currency]
  @payment_method   = options[:payment_method]
  @payment_provider = options[:payment_provider]
  @pickup_address   = options[:pickup_address]
  @pickup_at        = options[:pickup_at]
end

Instance Attribute Details

#buyer_nameObject

Returns the value of attribute buyer_name.



13
14
15
# File 'lib/xpost/models/order.rb', line 13

def buyer_name
  @buyer_name
end

#contact_numberObject

Returns the value of attribute contact_number.



13
14
15
# File 'lib/xpost/models/order.rb', line 13

def contact_number
  @contact_number
end

#currencyObject

Returns the value of attribute currency.



14
15
16
# File 'lib/xpost/models/order.rb', line 14

def currency
  @currency
end

#delivery_addressObject

Returns the value of attribute delivery_address.



15
16
17
# File 'lib/xpost/models/order.rb', line 15

def delivery_address
  @delivery_address
end

#emailObject

Returns the value of attribute email.



13
14
15
# File 'lib/xpost/models/order.rb', line 13

def email
  @email
end

#itemsObject

Returns the value of attribute items.



16
17
18
# File 'lib/xpost/models/order.rb', line 16

def items
  @items
end

#payment_methodObject

Returns the value of attribute payment_method.



14
15
16
# File 'lib/xpost/models/order.rb', line 14

def payment_method
  @payment_method
end

#payment_providerObject

Returns the value of attribute payment_provider.



14
15
16
# File 'lib/xpost/models/order.rb', line 14

def payment_provider
  @payment_provider
end

#pickup_addressObject

Returns the value of attribute pickup_address.



15
16
17
# File 'lib/xpost/models/order.rb', line 15

def pickup_address
  @pickup_address
end

#shipmentObject

Returns the value of attribute shipment.



16
17
18
# File 'lib/xpost/models/order.rb', line 16

def shipment
  @shipment
end

#statusObject

Returns the value of attribute status.



16
17
18
# File 'lib/xpost/models/order.rb', line 16

def status
  @status
end

#totalObject

Returns the value of attribute total.



14
15
16
# File 'lib/xpost/models/order.rb', line 14

def total
  @total
end

Instance Method Details

#cancellable?Boolean

docs.quadx.xyz/#5f38afd0-66bb-468f-ab4e-993d4745a257 Sets the order status to canceled. An order can be canceled provided they have not passed the cutoff date and time as specified in the contract.

Returns:

  • (Boolean)


43
44
45
# File 'lib/xpost/models/order.rb', line 43

def cancellable?
  true
end

#confirmable?Boolean

Returns:

  • (Boolean)


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

def confirmable?
  self.valid? && self.delivery_address.present?
end

#updatable?Boolean

docs.quadx.xyz/#c831dc25-2de4-36c5-c321-8e9db0fc2105 The following fields can be updated provided they have not passed the cutoff date and time as specified in the contract.

Returns:

  • (Boolean)


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

def updatable?
  true
end