# -*- coding: utf-8 -*-

"""
    ontraportlib.models.product
 
    This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io ) on 11/14/2017
"""
import  ontraportlib.models.price
import  ontraportlib.models.base_model

class Product(ontraportlib.models.base_model.BaseModel):

    """Implementation of the 'Product' model.

    TODO: type model description here.

    Attributes:
        price (list of Price): TODO: type description here.
        quantity (int): How many of this product are being purchased?
        total (float): What is the total amount of this sale?
        delay_start (int): Days to delay start.
        id (int): This must be an existing Product ID.
        level_1 (float): Partner Level 1 commission percentage.
        level_2 (float): Partner Level 2 commission percentage.
        offer_to_affiliates (bool): Is this offered to Partners (affiliates)?
        owner (int): Product owner (Staff ID).
        setup_fee (float): One-time setup fee.
        setup_fee_date (string): Date to charge setup fee (when setup_fee_when
            is "on_date").
        setup_fee_when (SetupFeeWhenEnum): When should setup fee be applied?
        shipping (bool): Does this product have an associated shipping cost?
        subscription_count (int): TODO: type description here.
        subscription_fee (float): TODO: type description here.
        subscription_unit (SubscriptionUnitEnum): TODO: type description
            here.
        tax (bool): Is this product taxable?
        taxable (bool): Is this item taxable?
        trial_period_count (int): Length of trial period (also set
            trial_period_units).
        trial_period_unit (TrialPeriodUnitEnum): Units describing length of
            trial period.
        trial_price (float): Price during trial period.
        mtype (Type13Enum): TODO: type description here.

    """

    def __init__(self, 
                 price = None,
                 quantity = None,
                 total = None,
                 delay_start = None,
                 id = None,
                 level_1 = None,
                 level_2 = None,
                 offer_to_affiliates = False,
                 owner = None,
                 setup_fee = None,
                 setup_fee_date = None,
                 setup_fee_when = None,
                 shipping = False,
                 subscription_count = None,
                 subscription_fee = None,
                 subscription_unit = None,
                 tax = False,
                 taxable = None,
                 trial_period_count = None,
                 trial_period_unit = None,
                 trial_price = None,
                 mtype = None):
        """Constructor for the Product class"""
        
        # Initialize members of the class
        self.price = price
        self.quantity = quantity
        self.total = total
        self.delay_start = delay_start
        self.id = id
        self.level_1 = level_1
        self.level_2 = level_2
        self.offer_to_affiliates = offer_to_affiliates
        self.owner = owner
        self.setup_fee = setup_fee
        self.setup_fee_date = setup_fee_date
        self.setup_fee_when = setup_fee_when
        self.shipping = shipping
        self.subscription_count = subscription_count
        self.subscription_fee = subscription_fee
        self.subscription_unit = subscription_unit
        self.tax = tax
        self.taxable = taxable
        self.trial_period_count = trial_period_count
        self.trial_period_unit = trial_period_unit
        self.trial_price = trial_price
        self.mtype = mtype

        # Create a mapping from Model property names to API property names
        self.names = {
            "price" : "price",
            "quantity" : "quantity",
            "total" : "total",
            "delay_start" : "delay_start",
            "id" : "id",
            "level_1" : "level1",
            "level_2" : "level2",
            "offer_to_affiliates" : "offer_to_affiliates",
            "owner" : "owner",
            "setup_fee" : "setup_fee",
            "setup_fee_date" : "setup_fee_date",
            "setup_fee_when" : "setup_fee_when",
            "shipping" : "shipping",
            "subscription_count" : "subscription_count",
            "subscription_fee" : "subscription_fee",
            "subscription_unit" : "subscription_unit",
            "tax" : "tax",
            "taxable" : "taxable",
            "trial_period_count" : "trial_period_count",
            "trial_period_unit" : "trial_period_unit",
            "trial_price" : "trial_price",
            "mtype" : "type",
        }


    @classmethod
    def from_dictionary(cls, 
                        dictionary):
        """Creates an instance of this model from a dictionary
       
        Args:
            dictionary (dictionary): A dictionary representation of the object as
            obtained from the deserialization of the server's response. The keys
            MUST match property names in the API description.
            
        Returns:
            object: An instance of this structure class.
            
        """
        if dictionary == None:
            return None
        else:
            # Extract variables from the dictionary
            price = None
            if dictionary.get("price") != None:
                price = list()
                for structure in dictionary.get("price"):
                    price.append(ontraportlib.models.price.Price.from_dictionary(structure))
            quantity = dictionary.get("quantity")
            total = dictionary.get("total")
            delay_start = dictionary.get("delay_start")
            id = dictionary.get("id")
            level_1 = dictionary.get("level1")
            level_2 = dictionary.get("level2")
            offer_to_affiliates = dictionary.get("offer_to_affiliates") if dictionary.get("offer_to_affiliates") else False
            owner = dictionary.get("owner")
            setup_fee = dictionary.get("setup_fee")
            setup_fee_date = dictionary.get("setup_fee_date")
            setup_fee_when = dictionary.get("setup_fee_when")
            shipping = dictionary.get("shipping") if dictionary.get("shipping") else False
            subscription_count = dictionary.get("subscription_count")
            subscription_fee = dictionary.get("subscription_fee")
            subscription_unit = dictionary.get("subscription_unit")
            tax = dictionary.get("tax") if dictionary.get("tax") else False
            taxable = dictionary.get("taxable")
            trial_period_count = dictionary.get("trial_period_count")
            trial_period_unit = dictionary.get("trial_period_unit")
            trial_price = dictionary.get("trial_price")
            mtype = dictionary.get("type")
            # Return an object of this model
            return cls(price,
                       quantity,
                       total,
                       delay_start,
                       id,
                       level_1,
                       level_2,
                       offer_to_affiliates,
                       owner,
                       setup_fee,
                       setup_fee_date,
                       setup_fee_when,
                       shipping,
                       subscription_count,
                       subscription_fee,
                       subscription_unit,
                       tax,
                       taxable,
                       trial_period_count,
                       trial_period_unit,
                       trial_price,
                       mtype)
