# coding: utf-8

"""
    Pinterest REST API

    Pinterest's REST API

    The version of the OpenAPI document: 5.23.0
    Contact: blah+oapicf@cliffano.com
    Generated by OpenAPI Generator (https://openapi-generator.tech)

    Do not edit the class manually.
"""  # noqa: E501


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

from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing_extensions import Annotated
from pinterestsdk.models.country import Country
from typing import Optional, Set
from typing_extensions import Self

class LocalStoreUpdate(BaseModel):
    """
    LocalStoreUpdate
    """ # noqa: E501
    address_primary: Optional[StrictStr] = Field(default=None, description="Primary address line of the store.")
    address_secondary: Optional[StrictStr] = Field(default=None, description="Secondary address line of the store.")
    city: Optional[StrictStr] = Field(default=None, description="City where the store is located.")
    country: Optional[Country] = Field(default=None, description="Country code where the store is located.")
    id: Annotated[str, Field(strict=True)] = Field(description="The ID of the local store.")
    latitude: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Geographic latitude coordinate of the store.")
    longitude: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Geographic longitude coordinate of the store.")
    name: Optional[StrictStr] = Field(default=None, description="The name of the local store.")
    postal_code: Optional[StrictStr] = Field(default=None, description="Postal or ZIP code of the store.")
    region: Optional[StrictStr] = Field(default=None, description="State or region code where the store is located.")
    store_code: Optional[StrictStr] = Field(default=None, description="Merchant provided code for the local store. Unique within the merchant's catalog.")
    __properties: ClassVar[List[str]] = ["address_primary", "address_secondary", "city", "country", "id", "latitude", "longitude", "name", "postal_code", "region", "store_code"]

    @field_validator('id')
    def id_validate_regular_expression(cls, value):
        """Validates the regular expression"""
        if not re.match(r"^\d+$", value):
            raise ValueError(r"must validate the regular expression /^\d+$/")
        return value

    model_config = ConfigDict(
        populate_by_name=True,
        validate_assignment=True,
        protected_namespaces=(),
    )


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

    def to_json(self) -> str:
        """Returns the JSON representation of the model using alias"""
        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
        return json.dumps(self.to_dict())

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

    def to_dict(self) -> Dict[str, Any]:
        """Return the dictionary representation of the model using alias.

        This has the following differences from calling pydantic's
        `self.model_dump(by_alias=True)`:

        * `None` is only added to the output dict for nullable fields that
          were set at model initialization. Other fields with value `None`
          are ignored.
        """
        excluded_fields: Set[str] = set([
        ])

        _dict = self.model_dump(
            by_alias=True,
            exclude=excluded_fields,
            exclude_none=True,
        )
        return _dict

    @classmethod
    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
        """Create an instance of LocalStoreUpdate from a dict"""
        if obj is None:
            return None

        if not isinstance(obj, dict):
            return cls.model_validate(obj)

        _obj = cls.model_validate({
            "address_primary": obj.get("address_primary"),
            "address_secondary": obj.get("address_secondary"),
            "city": obj.get("city"),
            "country": obj.get("country"),
            "id": obj.get("id"),
            "latitude": obj.get("latitude"),
            "longitude": obj.get("longitude"),
            "name": obj.get("name"),
            "postal_code": obj.get("postal_code"),
            "region": obj.get("region"),
            "store_code": obj.get("store_code")
        })
        return _obj


