# coding: utf-8

"""
    TrueLayer Authtentication

    No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)  # noqa: E501

    The version of the OpenAPI document: v1.0
    Generated by: https://openapi-generator.tech
"""


import pprint
import re  # noqa: F401

import six

import marshmallow
from marshmallow import Schema, validates, ValidationError, post_load, missing

from truelayer.auth import fields
from truelayer.auth.configuration import Configuration



class TokenResponseSchema(Schema):
    """NOTE: This class is auto generated by OpenAPI Generator.
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """
    access_token = marshmallow.fields.String(required=True)

    expires_in = marshmallow.fields.Integer(required=True)

    token_type = marshmallow.fields.String(required=True)

    refresh_token = marshmallow.fields.String()

    expires_at = fields.DateTime()

    @validates("access_token")
    def validates_access_token(self, access_token):
        if access_token is None:  # noqa: E501
            raise ValidationError("Invalid value for `access_token`, must not be `None`")  # noqa: E501
        pass

    @validates("expires_in")
    def validates_expires_in(self, expires_in):
        if expires_in is None:  # noqa: E501
            raise ValidationError("Invalid value for `expires_in`, must not be `None`")  # noqa: E501
        pass

    @validates("token_type")
    def validates_token_type(self, token_type):
        if token_type is None:  # noqa: E501
            raise ValidationError("Invalid value for `token_type`, must not be `None`")  # noqa: E501
        pass

    @validates("refresh_token")
    def validates_refresh_token(self, refresh_token):
        pass

    @validates("expires_at")
    def validates_expires_at(self, expires_at):
        pass

    @post_load
    def post_load(self, data, **kwargs):
        config = Configuration()
        config.client_side_validation = False
        return TokenResponse(local_vars_configuration=config, **data)


class TokenResponse(object):
    """NOTE: This class is auto generated by OpenAPI Generator.
    Ref: https://openapi-generator.tech

    Do not edit the class manually.
    """

    """
    Attributes:
      openapi_types (dict): The key is attribute name
                            and the value is attribute type.
      attribute_map (dict): The key is attribute name
                            and the value is json key in definition.
    """
    openapi_types = {
        'access_token': 'str',
        'expires_in': 'int',
        'token_type': 'str',
        'refresh_token': 'str',
        'expires_at': 'datetime'
    }

    attribute_map = {
        'access_token': 'access_token',
        'expires_in': 'expires_in',
        'token_type': 'token_type',
        'refresh_token': 'refresh_token',
        'expires_at': 'expires_at'
    }

    def __init__(self, access_token=missing, expires_in=missing, token_type='Bearer', refresh_token=missing, expires_at=missing, local_vars_configuration=None):  # noqa: E501
        """TokenResponse - a model defined in OpenAPI"""  # noqa: E501
        if local_vars_configuration is None:
            local_vars_configuration = Configuration()
        self.local_vars_configuration = local_vars_configuration

        self.discriminator = None
        if self.local_vars_configuration.client_side_validation:
            validated = TokenResponseSchema().load({
                'access_token': access_token,
                'expires_in': expires_in,
                'token_type': token_type,
                'refresh_token': refresh_token,
                'expires_at': expires_at
            })
            self.access_token = validated.access_token
            self.expires_in = validated.expires_in
            self.token_type = validated.token_type
            self.refresh_token = validated.refresh_token
            self.expires_at = validated.expires_at
        else:
            self.access_token = access_token
            self.expires_in = expires_in
            self.token_type = token_type
            self.refresh_token = refresh_token
            self.expires_at = expires_at

    def to_dict(self):
        """Returns the model properties as a dict"""
        return TokenResponseSchema().dump(self)

    def to_str(self):
        """Returns the string representation of the model"""
        return pprint.pformat(self.to_dict())

    def __repr__(self):
        """For `print` and `pprint`"""
        return self.to_str()

    def __eq__(self, other):
        """Returns true if both objects are equal"""
        if not isinstance(other, TokenResponse):
            return False

        return self.to_dict() == other.to_dict()

    def __ne__(self, other):
        """Returns true if both objects are not equal"""
        if not isinstance(other, TokenResponse):
            return True

        return self.to_dict() != other.to_dict()
