# 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 Optional
from pydantic import BaseModel, StrictBool, StrictStr, constr, validator
from marqeta_client.models.card_personalization import CardPersonalization
from marqeta_client.models.shipping import Shipping

class CardProductFulfillment(BaseModel):
    """
    CardProductFulfillment
    """
    shipping: Optional[Shipping] = None
    card_personalization: CardPersonalization = ...
    payment_instrument: Optional[StrictStr] = 'PHYSICAL_MSR'
    package_id: Optional[constr(strict=True, max_length=50, min_length=1)] = '0'
    all_zero_card_security_code: Optional[StrictBool] = False
    bin_prefix: Optional[StrictStr] = None
    bulk_ship: Optional[StrictBool] = False
    pan_length: Optional[StrictStr] = '16'
    fulfillment_provider: Optional[StrictStr] = 'PERFECTPLASTIC'
    allow_card_creation: Optional[StrictBool] = True
    uppercase_name_lines: Optional[StrictBool] = True
    enable_offline_pin: Optional[StrictBool] = False
    __properties = ["shipping", "card_personalization", "payment_instrument", "package_id", "all_zero_card_security_code", "bin_prefix", "bulk_ship", "pan_length", "fulfillment_provider", "allow_card_creation", "uppercase_name_lines", "enable_offline_pin"]

    @validator('payment_instrument')
    def payment_instrument_validate_enum(cls, v):
        if v is None:
            return v

        if v not in ('PHYSICAL_MSR', 'PHYSICAL_ICC', 'PHYSICAL_CONTACTLESS', 'PHYSICAL_COMBO', 'VIRTUAL_PAN'):
            raise ValueError("must be one of enum values ('PHYSICAL_MSR', 'PHYSICAL_ICC', 'PHYSICAL_CONTACTLESS', 'PHYSICAL_COMBO', 'VIRTUAL_PAN')")
        return v

    @validator('fulfillment_provider')
    def fulfillment_provider_validate_enum(cls, v):
        if v is None:
            return v

        if v not in ('PERFECTPLASTIC', 'ARROWEYE', 'IDEMIA', 'IDEMIA_UK', 'IDEMIA_FR', 'IDEMIA_CZ', 'IDEMIA_APAC', 'IDEMIA_PL', 'IDEMIA_AU', 'IDEMIA_LA', 'GEMALTO', 'NITECREST', 'OBERTHUR', 'ALLPAY'):
            raise ValueError("must be one of enum values ('PERFECTPLASTIC', 'ARROWEYE', 'IDEMIA', 'IDEMIA_UK', 'IDEMIA_FR', 'IDEMIA_CZ', 'IDEMIA_APAC', 'IDEMIA_PL', 'IDEMIA_AU', 'IDEMIA_LA', 'GEMALTO', 'NITECREST', 'OBERTHUR', 'ALLPAY')")
        return v

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

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

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

        _obj = CardProductFulfillment.parse_obj({
            "shipping": Shipping.from_dict(obj.get("shipping")) if obj.get("shipping") is not None else None,
            "card_personalization": CardPersonalization.from_dict(obj.get("card_personalization")) if obj.get("card_personalization") is not None else None,
            "payment_instrument": obj.get("payment_instrument") if obj.get("payment_instrument") is not None else 'PHYSICAL_MSR',
            "package_id": obj.get("package_id") if obj.get("package_id") is not None else '0',
            "all_zero_card_security_code": obj.get("all_zero_card_security_code") if obj.get("all_zero_card_security_code") is not None else False,
            "bin_prefix": obj.get("bin_prefix"),
            "bulk_ship": obj.get("bulk_ship") if obj.get("bulk_ship") is not None else False,
            "pan_length": obj.get("pan_length") if obj.get("pan_length") is not None else '16',
            "fulfillment_provider": obj.get("fulfillment_provider") if obj.get("fulfillment_provider") is not None else 'PERFECTPLASTIC',
            "allow_card_creation": obj.get("allow_card_creation") if obj.get("allow_card_creation") is not None else True,
            "uppercase_name_lines": obj.get("uppercase_name_lines") if obj.get("uppercase_name_lines") is not None else True,
            "enable_offline_pin": obj.get("enable_offline_pin") if obj.get("enable_offline_pin") is not None else False
        })
        return _obj

