Class: Upay::Order
- Inherits:
-
Object
- Object
- Upay::Order
- Defined in:
- lib/upay/order.rb
Instance Method Summary collapse
- #accountId ⇒ Object
- #additionalValues ⇒ Object
- #additionalValues=(additionalValues = {}) ⇒ Object
- #buyer ⇒ Object
- #buyer=(buyer = {}) ⇒ Object
- #description ⇒ Object
- #description=(description = nil) ⇒ Object
-
#initialize(args = {}) ⇒ Order
constructor
A new instance of Order.
- #language ⇒ Object
- #notifyUrl ⇒ Object
- #referenceCode ⇒ Object
- #referenceCode=(referenceCode = nil) ⇒ Object
- #shippingAddress ⇒ Object
- #shippingAddress=(shippingAddress = {}) ⇒ Object
- #signature ⇒ Object
- #signature=(signature = nil) ⇒ Object
- #to_hash ⇒ Object
- #valid? ⇒ Boolean
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.account_id) instance_variable_set("@language", Upay.lang) instance_variable_set("@notifyUrl", Upay.notifyUrl) end |
Instance Method Details
#accountId ⇒ Object
12 |
# File 'lib/upay/order.rb', line 12 def accountId; @accountId end |
#additionalValues ⇒ Object
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 |
#buyer ⇒ Object
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 |
#description ⇒ Object
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 |
#language ⇒ Object
13 |
# File 'lib/upay/order.rb', line 13 def language; @language end |
#notifyUrl ⇒ Object
14 |
# File 'lib/upay/order.rb', line 14 def notifyUrl; @notifyUrl end |
#referenceCode ⇒ Object
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 |
#shippingAddress ⇒ Object
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 |
#signature ⇒ Object
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_hash ⇒ Object
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
35 36 37 38 |
# File 'lib/upay/order.rb', line 35 def valid? validator = OrderValidator.new validator.valid?(self) end |