# coding: utf-8

"""
    Marqeta Core API

    Simplified management of your payment programs  # noqa: E501

    The version of the OpenAPI document: 3.0.0
    Contact: dev@swadesh.co
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""


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


from typing import Dict, Optional
from pydantic import BaseModel, StrictBool, StrictStr, constr
from marqeta_client.models.activation_actions import ActivationActions
from marqeta_client.models.card_fulfillment_request import CardFulfillmentRequest
from marqeta_client.models.expiration_offset import ExpirationOffset

class CardRequest(BaseModel):
    """
    CardRequest
    """
    card_product_token: constr(strict=True, max_length=36, min_length=1) = ...
    expedite: Optional[StrictBool] = False
    metadata: Optional[Dict[str, StrictStr]] = None
    expiration_offset: Optional[ExpirationOffset] = None
    token: Optional[constr(strict=True, max_length=36, min_length=1)] = None
    user_token: constr(strict=True, max_length=36, min_length=1) = ...
    fulfillment: Optional[CardFulfillmentRequest] = None
    reissue_pan_from_card_token: Optional[constr(strict=True, max_length=36, min_length=0)] = None
    new_pan_from_card_token: Optional[constr(strict=True, max_length=36, min_length=0)] = None
    translate_pin_from_card_token: Optional[constr(strict=True, max_length=36, min_length=0)] = None
    activation_actions: Optional[ActivationActions] = None
    bulk_issuance_token: Optional[StrictStr] = None
    __properties = ["card_product_token", "expedite", "metadata", "expiration_offset", "token", "user_token", "fulfillment", "reissue_pan_from_card_token", "new_pan_from_card_token", "translate_pin_from_card_token", "activation_actions", "bulk_issuance_token"]

    class Config:
        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) -> CardRequest:
        """Create an instance of CardRequest 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)
        # override the default output from pydantic by calling `to_dict()` of expiration_offset
        if self.expiration_offset:
            _dict['expiration_offset'] = self.expiration_offset.to_dict()
        # override the default output from pydantic by calling `to_dict()` of fulfillment
        if self.fulfillment:
            _dict['fulfillment'] = self.fulfillment.to_dict()
        # override the default output from pydantic by calling `to_dict()` of activation_actions
        if self.activation_actions:
            _dict['activation_actions'] = self.activation_actions.to_dict()
        return _dict

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

        if type(obj) is not dict:
            return CardRequest.parse_obj(obj)

        _obj = CardRequest.parse_obj({
            "card_product_token": obj.get("card_product_token"),
            "expedite": obj.get("expedite") if obj.get("expedite") is not None else False,
            "metadata": obj.get("metadata"),
            "expiration_offset": ExpirationOffset.from_dict(obj.get("expiration_offset")) if obj.get("expiration_offset") is not None else None,
            "token": obj.get("token"),
            "user_token": obj.get("user_token"),
            "fulfillment": CardFulfillmentRequest.from_dict(obj.get("fulfillment")) if obj.get("fulfillment") is not None else None,
            "reissue_pan_from_card_token": obj.get("reissue_pan_from_card_token"),
            "new_pan_from_card_token": obj.get("new_pan_from_card_token"),
            "translate_pin_from_card_token": obj.get("translate_pin_from_card_token"),
            "activation_actions": ActivationActions.from_dict(obj.get("activation_actions")) if obj.get("activation_actions") is not None else None,
            "bulk_issuance_token": obj.get("bulk_issuance_token")
        })
        return _obj

