Module: AboutYou::SDK::Model::BasketVariantItem
- Included in:
- BasketItem, BasketSetItem
- Defined in:
- lib/AboutYou/Model/Basket/basket_variant_item.rb
Overview
BasketVairantItem is a class representing a basket variant item
Instance Attribute Summary collapse
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#json_object ⇒ Object
Returns the value of attribute json_object.
-
#product ⇒ Object
Returns the value of attribute product.
-
#variant ⇒ Object
Get the product variant.
-
#variant_id ⇒ Object
Returns the value of attribute variant_id.
Instance Method Summary collapse
- #check_app_id(app_id) ⇒ Object
- #check_variant_id(variant_id) ⇒ Object
-
#errors? ⇒ Boolean
Boolean.
-
#initialize(variant_id, additional_data = nil, app_id = nil) ⇒ Object
Constructor.
-
#old_price ⇒ Object
Get the variant old price in euro cents.
-
#tax ⇒ Object
Get the tax.
-
#total_net ⇒ Object
Integer.
-
#total_price ⇒ Object
Get the total price.
-
#total_vat ⇒ Object
Get the value added tax.
-
#unique_key ⇒ Object
String.
Instance Attribute Details
#app_id ⇒ Object
Returns the value of attribute app_id.
16 17 18 |
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 16 def app_id @app_id end |
#json_object ⇒ Object
Returns the value of attribute json_object.
12 13 14 |
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 12 def json_object @json_object end |
#product ⇒ Object
Returns the value of attribute product.
13 14 15 |
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 13 def product @product end |
#variant ⇒ Object
Get the product variant.
91 92 93 |
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 91 def variant @variant end |
#variant_id ⇒ Object
Returns the value of attribute variant_id.
15 16 17 |
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 15 def variant_id @variant_id end |
Instance Method Details
#check_app_id(app_id) ⇒ Object
116 117 118 119 |
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 116 def check_app_id(app_id) fail '\InvalidArgumentException! the app id must be an integer' unless app_id.is_a?(Integer) end |
#check_variant_id(variant_id) ⇒ Object
111 112 113 114 |
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 111 def check_variant_id(variant_id) fail '\InvalidArgumentException! the variant id must be an integer' unless variant_id.is_a?(Integer) end |
#errors? ⇒ Boolean
Returns boolean.
39 40 41 |
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 39 def errors? error_code > 0 end |
#initialize(variant_id, additional_data = nil, app_id = nil) ⇒ Object
Constructor.
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 24 def initialize(variant_id, additional_data = nil, app_id = nil) check_variant_id(variant_id) check_addition_data(additional_data) self.variant_od = variant_id self.additional_data = additional_data return unless app_id check_app_id(app_id) self.app_id = app_id end |
#old_price ⇒ Object
Get the variant old price in euro cents.
82 83 84 |
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 82 def old_price variant.old_price end |
#tax ⇒ Object
Get the tax.
57 58 59 |
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 57 def tax json_object['tax'] end |
#total_net ⇒ Object
Returns integer.
73 74 75 |
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 73 def total_net json_object['total_net'] end |
#total_price ⇒ Object
Get the total price.
48 49 50 |
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 48 def total_price json_object['total_price'] end |
#total_vat ⇒ Object
Get the value added tax.
66 67 68 |
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 66 def total_vat json_object['total_vat'] end |
#unique_key ⇒ Object
Returns string.
101 102 103 104 105 106 107 108 109 |
# File 'lib/AboutYou/Model/Basket/basket_variant_item.rb', line 101 def unique_key key = variant_id if additionalData additionalData.sort! key += ':' + additionalData.to_json end key end |