Class: Upay::Order

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

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Order

Returns a new instance of Order.



3
4
5
6
7
8
9
10
# File 'lib/upay/order.rb', line 3

def initialize(args = {})
  args.each do |k,v|
    instance_variable_set("@#{k}", v)
  end
  instance_variable_set("@accountId", Upay.)
  instance_variable_set("@language", Upay.lang)
  instance_variable_set("@notifyUrl", Upay.notifyUrl)
end

Instance Method Details

#accountIdObject



12
# File 'lib/upay/order.rb', line 12

def accountId; @accountId end

#additionalValuesObject



16
# File 'lib/upay/order.rb', line 16

def additionalValues; @additionalValues end

#additionalValues=(additionalValues = {}) ⇒ Object



17
# File 'lib/upay/order.rb', line 17

def additionalValues=(additionalValues = {}); @additionalValues end

#buyerObject



29
# File 'lib/upay/order.rb', line 29

def buyer; @buyer end

#buyer=(buyer = {}) ⇒ Object



30
# File 'lib/upay/order.rb', line 30

def buyer=(buyer = {}) @buyer = buyer; end

#descriptionObject



23
# File 'lib/upay/order.rb', line 23

def description; @description end

#description=(description = nil) ⇒ Object



24
# File 'lib/upay/order.rb', line 24

def description=(description = nil) @description = description; end

#languageObject



13
# File 'lib/upay/order.rb', line 13

def language; @language end

#notifyUrlObject



14
# File 'lib/upay/order.rb', line 14

def notifyUrl; @notifyUrl end

#referenceCodeObject



20
# File 'lib/upay/order.rb', line 20

def referenceCode; @referenceCode end

#referenceCode=(referenceCode = nil) ⇒ Object



21
# File 'lib/upay/order.rb', line 21

def referenceCode=(referenceCode = nil) @referenceCode = referenceCode; end

#shippingAddressObject



32
# File 'lib/upay/order.rb', line 32

def shippingAddress; @shippingAddress end

#shippingAddress=(shippingAddress = {}) ⇒ Object



33
# File 'lib/upay/order.rb', line 33

def shippingAddress=(shippingAddress = {}) @shippingAddress = shippingAddress; end

#signatureObject



26
# File 'lib/upay/order.rb', line 26

def signature; @signature end

#signature=(signature = nil) ⇒ Object



27
# File 'lib/upay/order.rb', line 27

def signature=(signature = nil) @signature = signature; end

#to_hashObject



40
41
42
43
44
45
# File 'lib/upay/order.rb', line 40

def to_hash
  order_hash = self.instance_variables.each_with_object({}) { |var,hash| hash[var.to_s.delete("@").to_sym] = self.instance_variable_get(var)}
  order_hash[:buyer] = self.buyer.to_hash if self.buyer
  order_hash[:shippingAddress] = self.shippingAddress.to_hash if self.shippingAddress
  order_hash
end

#valid?Boolean

Returns:

  • (Boolean)


35
36
37
38
# File 'lib/upay/order.rb', line 35

def valid?
  validator = OrderValidator.new
  validator.valid?(self)
end