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

"""
    mundiapi.models.create_credit_card_payment_request

    This file was automatically generated by APIMATIC v2.0 ( https://apimatic.io )
"""
import mundiapi.models.create_card_request

class CreateCreditCardPaymentRequest(object):

    """Implementation of the 'CreateCreditCardPaymentRequest' model.

    The settings for creating a credit card payment

    Attributes:
        installments (int): Number of installments
        statement_descriptor (string): The text that will be shown on the
            credit card's statement
        card (CreateCardRequest): Credit card data
        retries (int): Number of retries
        update_subscription_card (bool): Indicates if the card from the
            subscription must be updated
        card_id (string): The credit card id
        card_token (string): TODO: type description here.
        recurrence (bool): Indicates a recurrence
        capture (bool): Indicates if the operation should be only
            authorization or auth and capture.

    """

    # Create a mapping from Model property names to API property names
    _names = {
        "installments" : "installments",
        "statement_descriptor" : "statement_descriptor",
        "card" : "card",
        "retries" : "retries",
        "update_subscription_card" : "update_subscription_card",
        "card_id" : "card_id",
        "card_token" : "card_token",
        "recurrence" : "recurrence",
        "capture" : "capture"
    }

    def __init__(self,
                 installments=1,
                 statement_descriptor=None,
                 card=None,
                 retries=None,
                 update_subscription_card=None,
                 card_id=None,
                 card_token=None,
                 recurrence=None,
                 capture=True):
        """Constructor for the CreateCreditCardPaymentRequest class"""

        # Initialize members of the class
        self.installments = installments
        self.statement_descriptor = statement_descriptor
        self.card = card
        self.retries = retries
        self.update_subscription_card = update_subscription_card
        self.card_id = card_id
        self.card_token = card_token
        self.recurrence = recurrence
        self.capture = capture


    @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 is None:
            return None

        # Extract variables from the dictionary
        installments = dictionary.get("installments") if dictionary.get("installments") else 1
        statement_descriptor = dictionary.get("statement_descriptor")
        card = mundiapi.models.create_card_request.CreateCardRequest.from_dictionary(dictionary.get("card")) if dictionary.get("card") else None
        retries = dictionary.get("retries")
        update_subscription_card = dictionary.get("update_subscription_card")
        card_id = dictionary.get("card_id")
        card_token = dictionary.get("card_token")
        recurrence = dictionary.get("recurrence")
        capture = dictionary.get("capture") if dictionary.get("capture") else True

        # Return an object of this model
        return cls(installments,
                   statement_descriptor,
                   card,
                   retries,
                   update_subscription_card,
                   card_id,
                   card_token,
                   recurrence,
                   capture)


