module AboutYou::SDK::Model::BasketVariantItem
BasketVairantItem is a class representing a basket variant item
Attributes
the app id of this variant item
the json object from which this instance was created from
the product of this variant item
the variant of this variant item
the variant id of this variant item
Public Class Methods
Constructor for the AboutYou::SDK::Model::BasketVariantItem
class
-
Args :
-
variant_id
-> the id of the variant item -
additional_data
-> additional data of the variant item -
app_id
-> the app id for the variant item
-
-
Returns :
-
an instance of
AboutYou::SDK::Model::BasketVariantItem
-
# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 30 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 self unless app_id check_app_id(app_id) self.app_id = app_id self end
Public Instance Methods
This method checks if an app id is valid
-
Fails :
-
if
app_id
is not an integer
-
# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 150 def check_app_id(app_id) fail '\InvalidArgumentException! the app id must be an integer' unless app_id.is_a?(Integer) end
This method checks if a variant id is valid
-
Fails :
-
if
variant_id
is not an integer
-
# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 139 def check_variant_id(variant_id) fail '\InvalidArgumentException! the variant id must be an integer' unless variant_id.is_a?(Integer) end
This method checks if there are errors in the variant item
-
Returns :
-
Boolean determining whether there are errors or not
-
# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 50 def errors? error_code > 0 end
Getter for the old price of the variant
-
Returns :
-
an Integer containing the old price of the variant
-
# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 100 def old_price variant.old_price end
Getter for the tax
-
Returns :
-
an Integer containing the tax
-
# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 70 def tax json_object['tax'] end
Getter for the total net
-
Returns :
-
an Integer containing the total net
-
# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 90 def total_net json_object['total_net'] end
Getter for the total price
-
Returns :
-
an Integer containing the total price
-
# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 60 def total_price json_object['total_price'] end
Getter for the total vat
-
Returns :
-
an Integer containing the total vat
-
# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 80 def total_vat json_object['total_vat'] end
This method is used for creating a unique key for the basket set
-
Returns :
-
a String containing a unique key for the basket set
-
# File lib/AboutYou/Model/Basket/basket_variant_item.rb, line 123 def unique_key key = variant_id if additionalData additionalData.sort! key += ':' + additionalData.to_json end key end