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

"""
paypalserversdk

This file was automatically generated by APIMATIC v3.0 (
 https://www.apimatic.io ).
"""
from paypalserversdk.api_helper import APIHelper


class CycleExecution(object):

    """Implementation of the 'Cycle Execution' model.

    The regular and trial execution details for a billing cycle.

    Attributes:
        tenure_type (TenureType): The type of the billing cycle.
        sequence (int): The order in which to run this cycle among other
            billing cycles.
        cycles_completed (int): The number of billing cycles that have
            completed.
        cycles_remaining (int): For a finite billing cycle, cycles_remaining
            is the number of remaining cycles. For an infinite billing cycle,
            cycles_remaining is set as 0.
        current_pricing_scheme_version (int): The active pricing scheme
            version for the billing 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 = {
        "tenure_type": 'tenure_type',
        "sequence": 'sequence',
        "cycles_completed": 'cycles_completed',
        "cycles_remaining": 'cycles_remaining',
        "current_pricing_scheme_version": 'current_pricing_scheme_version',
        "total_cycles": 'total_cycles'
    }

    _optionals = [
        'cycles_remaining',
        'current_pricing_scheme_version',
        'total_cycles',
    ]

    def __init__(self,
                 tenure_type=None,
                 sequence=None,
                 cycles_completed=None,
                 cycles_remaining=APIHelper.SKIP,
                 current_pricing_scheme_version=APIHelper.SKIP,
                 total_cycles=APIHelper.SKIP):
        """Constructor for the CycleExecution class"""

        # Initialize members of the class
        self.tenure_type = tenure_type 
        self.sequence = sequence 
        self.cycles_completed = cycles_completed 
        if cycles_remaining is not APIHelper.SKIP:
            self.cycles_remaining = cycles_remaining 
        if current_pricing_scheme_version is not APIHelper.SKIP:
            self.current_pricing_scheme_version = current_pricing_scheme_version 
        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
        tenure_type = dictionary.get("tenure_type") if dictionary.get("tenure_type") else None
        sequence = dictionary.get("sequence") if dictionary.get("sequence") else None
        cycles_completed = dictionary.get("cycles_completed") if dictionary.get("cycles_completed") else None
        cycles_remaining = dictionary.get("cycles_remaining") if dictionary.get("cycles_remaining") else APIHelper.SKIP
        current_pricing_scheme_version = dictionary.get("current_pricing_scheme_version") if dictionary.get("current_pricing_scheme_version") 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(tenure_type,
                   sequence,
                   cycles_completed,
                   cycles_remaining,
                   current_pricing_scheme_version,
                   total_cycles)

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

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