Class: KondutoOrder
- Inherits:
-
Object
- Object
- KondutoOrder
- Defined in:
- lib/konduto-ruby/konduto_order.rb
Instance Attribute Summary collapse
-
#analyze ⇒ Object
Returns the value of attribute analyze.
-
#billing_address ⇒ Object
Returns the value of attribute billing_address.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#customer ⇒ Object
Returns the value of attribute customer.
-
#device ⇒ Object
Returns the value of attribute device.
-
#first_message ⇒ Object
Returns the value of attribute first_message.
-
#geolocation ⇒ Object
Returns the value of attribute geolocation.
-
#id ⇒ Object
Returns the value of attribute id.
-
#installments ⇒ Object
Returns the value of attribute installments.
-
#ip ⇒ Object
Returns the value of attribute ip.
-
#messages_enchanged ⇒ Object
Returns the value of attribute messages_enchanged.
-
#navigation ⇒ Object
Returns the value of attribute navigation.
-
#payment ⇒ Object
Returns the value of attribute payment.
-
#purchased_at ⇒ Object
Returns the value of attribute purchased_at.
-
#recommendation ⇒ Object
Returns the value of attribute recommendation.
-
#score ⇒ Object
Returns the value of attribute score.
-
#seller ⇒ Object
Returns the value of attribute seller.
-
#shipping_address ⇒ Object
Returns the value of attribute shipping_address.
-
#shipping_amount ⇒ Object
Returns the value of attribute shipping_amount.
-
#shopping_cart ⇒ Object
Returns the value of attribute shopping_cart.
-
#status ⇒ Object
Returns the value of attribute status.
-
#tax_amount ⇒ Object
Returns the value of attribute tax_amount.
-
#timestamp ⇒ Object
Returns the value of attribute timestamp.
-
#total_amount ⇒ Object
Returns the value of attribute total_amount.
-
#travel ⇒ Object
Returns the value of attribute travel.
-
#visitor ⇒ Object
Returns the value of attribute visitor.
Instance Method Summary collapse
- #add_item(product) ⇒ Object
- #add_payment(payment) ⇒ Object
-
#initialize(*args) ⇒ KondutoOrder
constructor
A new instance of KondutoOrder.
- #to_hash ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(*args) ⇒ KondutoOrder
Returns a new instance of KondutoOrder.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/konduto-ruby/konduto_order.rb', line 22 def initialize(*args) params = args[0] self.shopping_cart = [] self.payment = [] if params.nil? self.shipping_address = KondutoAddress.new self.billing_address = KondutoAddress.new self.customer = KondutoCustomer.new self.seller = KondutoSeller.new self.travel = KondutoTravel.new self.device = KondutoDevice.new self.geolocation = KondutoGeolocation.new self. = KondutoNavigation.new else params = KondutoUtils.deep_symbolize_keys params if params[shipping_address].nil? self.shipping_address = KondutoAddress.new else self.shipping_address = KondutoAddress.new params[:shipping_address] params.delete :shipping_address end if params[:billing_address].nil? self.billing_address = KondutoAddress.new else self.billing_address = KondutoAddress.new params[:billing_address] params.delete :billing_address end if params[:customer].nil? self.customer = KondutoCustomer.new else self.customer = KondutoCustomer.new params[:customer] params.delete :customer end if params[:seller].nil? self.seller = KondutoSeller.new else self.seller = KondutoSeller.new params[:seller] params.delete :seller end if params[:travel].nil? self.travel = KondutoTravel.new else self.travel = KondutoTravel.new params[:travel] params.delete :travel end if params[:device].nil? self.device = KondutoDevice.new else self.device = KondutoDevice.new params[:device] params.delete :device end if params[:geolocation].nil? self.geolocation = KondutoGeolocation.new else self.geolocation = KondutoGeolocation.new params[:geolocation] params.delete :geolocation end if params[:navigation].nil? self. = KondutoNavigation.new else self. = KondutoNavigation.new params[:navigation] params.delete :navigation end unless params[:payment].nil? || params[:payment].empty? params[:payment].each do |p| self.payment << KondutoPayment.new(p) end params.delete :payment end unless params[:shopping_cart].nil? || params[:shopping_cart].empty? params[:shopping_cart].each do |i| self.shopping_cart << KondutoItem.new(i) end params.delete :shopping_cart end params.each do |k,v| instance_variable_set("@#{k}", v) unless v.nil? end end end |
Instance Attribute Details
#analyze ⇒ Object
Returns the value of attribute analyze.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def analyze @analyze end |
#billing_address ⇒ Object
Returns the value of attribute billing_address.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def billing_address @billing_address end |
#currency ⇒ Object
Returns the value of attribute currency.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def currency @currency end |
#customer ⇒ Object
Returns the value of attribute customer.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def customer @customer end |
#device ⇒ Object
Returns the value of attribute device.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def device @device end |
#first_message ⇒ Object
Returns the value of attribute first_message.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def @first_message end |
#geolocation ⇒ Object
Returns the value of attribute geolocation.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def geolocation @geolocation end |
#id ⇒ Object
Returns the value of attribute id.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def id @id end |
#installments ⇒ Object
Returns the value of attribute installments.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def installments @installments end |
#ip ⇒ Object
Returns the value of attribute ip.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def ip @ip end |
#messages_enchanged ⇒ Object
Returns the value of attribute messages_enchanged.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def @messages_enchanged end |
#navigation ⇒ Object
Returns the value of attribute navigation.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def @navigation end |
#payment ⇒ Object
Returns the value of attribute payment.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def payment @payment end |
#purchased_at ⇒ Object
Returns the value of attribute purchased_at.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def purchased_at @purchased_at end |
#recommendation ⇒ Object
Returns the value of attribute recommendation.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def recommendation @recommendation end |
#score ⇒ Object
Returns the value of attribute score.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def score @score end |
#seller ⇒ Object
Returns the value of attribute seller.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def seller @seller end |
#shipping_address ⇒ Object
Returns the value of attribute shipping_address.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def shipping_address @shipping_address end |
#shipping_amount ⇒ Object
Returns the value of attribute shipping_amount.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def shipping_amount @shipping_amount end |
#shopping_cart ⇒ Object
Returns the value of attribute shopping_cart.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def shopping_cart @shopping_cart end |
#status ⇒ Object
Returns the value of attribute status.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def status @status end |
#tax_amount ⇒ Object
Returns the value of attribute tax_amount.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def tax_amount @tax_amount end |
#timestamp ⇒ Object
Returns the value of attribute timestamp.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def @timestamp end |
#total_amount ⇒ Object
Returns the value of attribute total_amount.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def total_amount @total_amount end |
#travel ⇒ Object
Returns the value of attribute travel.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def travel @travel end |
#visitor ⇒ Object
Returns the value of attribute visitor.
17 18 19 |
# File 'lib/konduto-ruby/konduto_order.rb', line 17 def visitor @visitor end |
Instance Method Details
#add_item(product) ⇒ Object
113 114 115 |
# File 'lib/konduto-ruby/konduto_order.rb', line 113 def add_item (product) self.shopping_cart << product end |
#add_payment(payment) ⇒ Object
117 118 119 |
# File 'lib/konduto-ruby/konduto_order.rb', line 117 def add_payment (payment) self.payment << payment end |
#to_hash ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/konduto-ruby/konduto_order.rb', line 121 def to_hash hash = { id:self.id, visitor:self.visitor, total_amount:self.total_amount, shipping_amount:self.shipping_amount, tax_amount:self.tax_amount, currency:self.currency, installments:self.installments, ip:self.ip, first_message:self., messages_exchanged:self., purchased_at:self.purchased_at, analyze:self.analyze, customer:self.customer.to_hash, payment: KondutoUtils.array_to_hash(self.payment), billing:self.billing_address.to_hash, shipping:self.shipping_address.to_hash, shopping_cart:KondutoUtils.array_to_hash(self.shopping_cart), travel:self.travel.to_hash, seller:self.seller.to_hash, device:self.device.to_hash, geolocation:self.geolocation.to_hash, navigation:self..to_hash } KondutoUtils.remove_nil_keys_from_hash(hash) end |
#to_json ⇒ Object
149 150 151 |
# File 'lib/konduto-ruby/konduto_order.rb', line 149 def to_json self.to_hash.to_json end |