# -*- 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.subscription_pricing_scheme import SubscriptionPricingScheme


class BillingCycleOverride(object):

    """Implementation of the 'Billing Cycle Override' model.

    The billing cycle details to override at subscription level. The
    subscription billing cycle definition has to adhere to the plan billing
    cycle definition.

    Attributes:
        pricing_scheme (SubscriptionPricingScheme): The pricing scheme details.
        sequence (int): The order in which this cycle is to run among other
            billing cycles. For example, a trial billing cycle has a
            `sequence` of `1` while a regular billing cycle has a `sequence`
            of `2`, so that trial cycle runs before the regular cycle.
        total_cycles (int): The number of times this billing cycle gets
            executed. Trial billing cycles can only be executed a finite
            number of times (value between 1 and 999 for total_cycles).
            Regular billing cycles can be executed infinite times (value of 0
            for total_cycles) or a finite number of times (value between 1 and
            999 for total_cycles).

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "sequence": 'sequence',
        "pricing_scheme": 'pricing_scheme',
        "total_cycles": 'total_cycles'
    }

    _optionals = [
        'pricing_scheme',
        'total_cycles',
    ]

    def __init__(self,
                 sequence=None,
                 pricing_scheme=APIHelper.SKIP,
                 total_cycles=APIHelper.SKIP):
        """Constructor for the BillingCycleOverride class"""

        # Initialize members of the class
        if pricing_scheme is not APIHelper.SKIP:
            self.pricing_scheme = pricing_scheme 
        self.sequence = sequence 
        if total_cycles is not APIHelper.SKIP:
            self.total_cycles = total_cycles 

    @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
        sequence = dictionary.get("sequence") if dictionary.get("sequence") else None
        pricing_scheme = SubscriptionPricingScheme.from_dictionary(dictionary.get('pricing_scheme')) if 'pricing_scheme' in dictionary.keys() else APIHelper.SKIP
        total_cycles = dictionary.get("total_cycles") if dictionary.get("total_cycles") else APIHelper.SKIP
        # Return an object of this model
        return cls(sequence,
                   pricing_scheme,
                   total_cycles)

    def __repr__(self):
        return (f'{self.__class__.__name__}('
                f'pricing_scheme={(self.pricing_scheme if hasattr(self, "pricing_scheme") else None)!r}, '
                f'sequence={self.sequence!r}, '
                f'total_cycles={(self.total_cycles if hasattr(self, "total_cycles") else None)!r})')

    def __str__(self):
        return (f'{self.__class__.__name__}('
                f'pricing_scheme={(self.pricing_scheme if hasattr(self, "pricing_scheme") else None)!s}, '
                f'sequence={self.sequence!s}, '
                f'total_cycles={(self.total_cycles if hasattr(self, "total_cycles") else None)!s})')
