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

"""
paypalserversdk

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from paypalserversdk.api_helper import APIHelper
from paypalserversdk.models.money import Money
from paypalserversdk.models.plan_override import PlanOverride
from paypalserversdk.models.subscriber_request import SubscriberRequest
from paypalserversdk.models.subscription_application_context import SubscriptionApplicationContext


class CreateSubscriptionRequest(object):

    """Implementation of the 'Create Subscription Request' model.

    The create subscription request details.

    Attributes:
        plan_id (str): The ID of the plan.
        start_time (str): The date and time, in [Internet date and time
            format](https://tools.ietf.org/html/rfc3339#section-5.6). Seconds
            are required while fractional seconds are optional. Note: The
            regular expression provides guidance but does not reject all
            invalid dates.
        quantity (str): The quantity of the product in the subscription.
        shipping_amount (Money): The currency and amount for a financial
            transaction, such as a balance or payment due.
        subscriber (SubscriberRequest): The subscriber request information .
        auto_renewal (bool): DEPRECATED. Indicates whether the subscription
            auto-renews after the billing cycles complete.
        application_context (SubscriptionApplicationContext): DEPRECATED. The
            application context, which customizes the payer experience during
            the subscription approval process with PayPal.
        custom_id (str): The custom id for the subscription. Can be invoice id.
        plan (PlanOverride): An inline plan object to customise the
            subscription. You can override plan level default attributes by
            providing customised values for the subscription in this object.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "plan_id": 'plan_id',
        "start_time": 'start_time',
        "quantity": 'quantity',
        "shipping_amount": 'shipping_amount',
        "subscriber": 'subscriber',
        "auto_renewal": 'auto_renewal',
        "application_context": 'application_context',
        "custom_id": 'custom_id',
        "plan": 'plan'
    }

    _optionals = [
        'start_time',
        'quantity',
        'shipping_amount',
        'subscriber',
        'auto_renewal',
        'application_context',
        'custom_id',
        'plan',
    ]

    def __init__(self,
                 plan_id=None,
                 start_time=APIHelper.SKIP,
                 quantity=APIHelper.SKIP,
                 shipping_amount=APIHelper.SKIP,
                 subscriber=APIHelper.SKIP,
                 auto_renewal=False,
                 application_context=APIHelper.SKIP,
                 custom_id=APIHelper.SKIP,
                 plan=APIHelper.SKIP):
        """Constructor for the CreateSubscriptionRequest class"""

        # Initialize members of the class
        self.plan_id = plan_id 
        if start_time is not APIHelper.SKIP:
            self.start_time = start_time 
        if quantity is not APIHelper.SKIP:
            self.quantity = quantity 
        if shipping_amount is not APIHelper.SKIP:
            self.shipping_amount = shipping_amount 
        if subscriber is not APIHelper.SKIP:
            self.subscriber = subscriber 
        self.auto_renewal = auto_renewal 
        if application_context is not APIHelper.SKIP:
            self.application_context = application_context 
        if custom_id is not APIHelper.SKIP:
            self.custom_id = custom_id 
        if plan is not APIHelper.SKIP:
            self.plan = plan 

    @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 not isinstance(dictionary, dict) or dictionary is None:
            return None

        # Extract variables from the dictionary
        plan_id = dictionary.get("plan_id") if dictionary.get("plan_id") else None
        start_time = dictionary.get("start_time") if dictionary.get("start_time") else APIHelper.SKIP
        quantity = dictionary.get("quantity") if dictionary.get("quantity") else APIHelper.SKIP
        shipping_amount = Money.from_dictionary(dictionary.get('shipping_amount')) if 'shipping_amount' in dictionary.keys() else APIHelper.SKIP
        subscriber = SubscriberRequest.from_dictionary(dictionary.get('subscriber')) if 'subscriber' in dictionary.keys() else APIHelper.SKIP
        auto_renewal = dictionary.get("auto_renewal") if dictionary.get("auto_renewal") else False
        application_context = SubscriptionApplicationContext.from_dictionary(dictionary.get('application_context')) if 'application_context' in dictionary.keys() else APIHelper.SKIP
        custom_id = dictionary.get("custom_id") if dictionary.get("custom_id") else APIHelper.SKIP
        plan = PlanOverride.from_dictionary(dictionary.get('plan')) if 'plan' in dictionary.keys() else APIHelper.SKIP
        # Return an object of this model
        return cls(plan_id,
                   start_time,
                   quantity,
                   shipping_amount,
                   subscriber,
                   auto_renewal,
                   application_context,
                   custom_id,
                   plan)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'plan_id={self.plan_id!r}, '
                f'start_time={(self.start_time if hasattr(self, "start_time") else None)!r}, '
                f'quantity={(self.quantity if hasattr(self, "quantity") else None)!r}, '
                f'shipping_amount={(self.shipping_amount if hasattr(self, "shipping_amount") else None)!r}, '
                f'subscriber={(self.subscriber if hasattr(self, "subscriber") else None)!r}, '
                f'auto_renewal={(self.auto_renewal if hasattr(self, "auto_renewal") else None)!r}, '
                f'application_context={(self.application_context if hasattr(self, "application_context") else None)!r}, '
                f'custom_id={(self.custom_id if hasattr(self, "custom_id") else None)!r}, '
                f'plan={(self.plan if hasattr(self, "plan") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'plan_id={self.plan_id!s}, '
                f'start_time={(self.start_time if hasattr(self, "start_time") else None)!s}, '
                f'quantity={(self.quantity if hasattr(self, "quantity") else None)!s}, '
                f'shipping_amount={(self.shipping_amount if hasattr(self, "shipping_amount") else None)!s}, '
                f'subscriber={(self.subscriber if hasattr(self, "subscriber") else None)!s}, '
                f'auto_renewal={(self.auto_renewal if hasattr(self, "auto_renewal") else None)!s}, '
                f'application_context={(self.application_context if hasattr(self, "application_context") else None)!s}, '
                f'custom_id={(self.custom_id if hasattr(self, "custom_id") else None)!s}, '
                f'plan={(self.plan if hasattr(self, "plan") else None)!s})')
