# coding: utf-8

"""
    Conekta API

    Conekta sdk  # noqa: E501

    The version of the OpenAPI document: 2.1.0
    Contact: engineering@conekta.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


from __future__ import annotations
import pprint
import re  # noqa: F401
import json


from typing import List, Optional
from pydantic import BaseModel, Field, StrictBool, StrictInt, StrictStr, conlist

class CheckoutRequest(BaseModel):
    """
    [Checkout](https://developers.conekta.com/v2.1.0/reference/payment-link) details 
    """
    allowed_payment_methods: conlist(StrictStr) = Field(..., description="Are the payment methods available for this link")
    expires_at: Optional[StrictInt] = Field(None, description="Unix timestamp of checkout expiration")
    failure_url: Optional[StrictStr] = Field(None, description="Redirection url back to the site in case of failed payment, applies only to HostedPayment.")
    monthly_installments_enabled: Optional[StrictBool] = None
    monthly_installments_options: Optional[conlist(StrictInt)] = None
    name: Optional[StrictStr] = Field(None, description="Reason for payment")
    on_demand_enabled: Optional[StrictBool] = None
    success_url: Optional[StrictStr] = Field(None, description="Redirection url back to the site in case of successful payment, applies only to HostedPayment")
    type: Optional[StrictStr] = Field(None, description="This field represents the type of checkout")
    __properties = ["allowed_payment_methods", "expires_at", "failure_url", "monthly_installments_enabled", "monthly_installments_options", "name", "on_demand_enabled", "success_url", "type"]

    class Config:
        """Pydantic configuration"""
        allow_population_by_field_name = True
        validate_assignment = True

    def to_str(self) -> str:
        """Returns the string representation of the model using alias"""
        return pprint.pformat(self.dict(by_alias=True))

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        return json.dumps(self.to_dict())

    @classmethod
    def from_json(cls, json_str: str) -> CheckoutRequest:
        """Create an instance of CheckoutRequest from a JSON string"""
        return cls.from_dict(json.loads(json_str))

    def to_dict(self):
        """Returns the dictionary representation of the model using alias"""
        _dict = self.dict(by_alias=True,
                          exclude={
                          },
                          exclude_none=True)
        return _dict

    @classmethod
    def from_dict(cls, obj: dict) -> CheckoutRequest:
        """Create an instance of CheckoutRequest from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return CheckoutRequest.parse_obj(obj)

        _obj = CheckoutRequest.parse_obj({
            "allowed_payment_methods": obj.get("allowed_payment_methods"),
            "expires_at": obj.get("expires_at"),
            "failure_url": obj.get("failure_url"),
            "monthly_installments_enabled": obj.get("monthly_installments_enabled"),
            "monthly_installments_options": obj.get("monthly_installments_options"),
            "name": obj.get("name"),
            "on_demand_enabled": obj.get("on_demand_enabled"),
            "success_url": obj.get("success_url"),
            "type": obj.get("type")
        })
        return _obj

