# coding: utf-8

"""
    GraphQL support

    GraphQL endpoint to query Knowledge Graphs

    The version of the OpenAPI document: 1.0
    Contact: hello@wordlift.io
    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 datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from typing_extensions import Annotated
from typing import Optional, Set
from typing_extensions import Self

class MerchantView(BaseModel):
    """
    An array of objects.
    """ # noqa: E501
    access_token: StrictStr = Field(description="The Google merchant access token")
    account_id: Optional[StrictInt] = Field(default=None, description="The account id")
    automatic_synchronization: Optional[StrictBool] = Field(default=None, description="Whether the Merchant data will be synchronized automatically")
    created_at: Optional[datetime] = Field(default=None, description="The create date-time")
    custom_seller: Optional[StrictStr] = Field(default=None, description="Custom seller entity - if applicable.")
    dataset_domain: Optional[StrictStr] = Field(default=None, description="The custom domain (for example data.example.org)")
    dataset_name: Optional[StrictStr] = Field(default=None, description="The dataset path (for example /data)")
    default_products_filter_action: StrictStr = Field(description="Default Products filter action to apply during sync process.")
    deleted: StrictBool = Field(description="True if the merchant has been deleted")
    deleted_at: Optional[datetime] = Field(default=None, description="The delete date-time")
    google_merchant_id: StrictInt = Field(description="The Google Merchant id")
    id: Optional[StrictInt] = Field(default=None, description="The unique id")
    ignore_brand: Optional[StrictBool] = Field(default=None, description="Whether to ignore the `brand` property during validation")
    ignore_image: Optional[StrictBool] = Field(default=None, description="Whether to ignore the `image` property during validation")
    modified_at: Optional[datetime] = Field(default=None, description="The last modified date-time")
    publisher_name: StrictStr = Field(description="The publisher name (shows in schema publisher)")
    refresh_token: StrictStr = Field(description="The Google merchant refresh token")
    sid: Optional[StrictStr] = None
    sync_has_errors: Optional[StrictBool] = None
    sync_id: Optional[StrictInt] = None
    sync_products_created: Optional[StrictInt] = None
    sync_products_deleted: Optional[StrictInt] = None
    sync_products_errored: Optional[StrictInt] = None
    sync_products_skipped: Optional[StrictInt] = None
    sync_products_total: Optional[StrictInt] = None
    sync_products_unchanged: Optional[StrictInt] = None
    sync_products_updated: Optional[StrictInt] = None
    sync_started_at: Optional[datetime] = Field(default=None, description="The started date-time.")
    sync_stopped_at: Optional[datetime] = Field(default=None, description="The stopped date-time.")
    url: Optional[StrictStr] = Field(default=None, description="The website URL")
    url_strategy: Optional[Annotated[str, Field(min_length=0, strict=True, max_length=50)]] = Field(default='canonicalLinkAndLink', description="Which strategy to use to write the url schema.")
    writer_service: Optional[StrictStr] = Field(default=None, description="How to write the merchant data to the graph, if unsure, do not set anything (by default `wordpressMerchantWriter`).")
    __properties: ClassVar[List[str]] = ["access_token", "account_id", "automatic_synchronization", "created_at", "custom_seller", "dataset_domain", "dataset_name", "default_products_filter_action", "deleted", "deleted_at", "google_merchant_id", "id", "ignore_brand", "ignore_image", "modified_at", "publisher_name", "refresh_token", "sid", "sync_has_errors", "sync_id", "sync_products_created", "sync_products_deleted", "sync_products_errored", "sync_products_skipped", "sync_products_total", "sync_products_unchanged", "sync_products_updated", "sync_started_at", "sync_stopped_at", "url", "url_strategy", "writer_service"]

    @field_validator('default_products_filter_action')
    def default_products_filter_action_validate_enum(cls, value):
        """Validates the enum"""
        if value not in set(['PROCESS', 'IGNORE']):
            raise ValueError("must be one of enum values ('PROCESS', 'IGNORE')")
        return value

    @field_validator('url_strategy')
    def url_strategy_validate_enum(cls, value):
        """Validates the enum"""
        if value is None:
            return value

        if value not in set(['canonicalLinkAndLink', 'canonicalLinkOtherwiseLink']):
            raise ValueError("must be one of enum values ('canonicalLinkAndLink', 'canonicalLinkOtherwiseLink')")
        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 MerchantView 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.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        * OpenAPI `readOnly` fields are excluded.
        """
        excluded_fields: Set[str] = set([
            "account_id",
            "created_at",
            "deleted_at",
            "id",
            "modified_at",
            "sync_started_at",
            "sync_stopped_at",
        ])

        _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 MerchantView from a dict"""
        if obj is None:
            return None

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

        _obj = cls.model_validate({
            "access_token": obj.get("access_token"),
            "account_id": obj.get("account_id"),
            "automatic_synchronization": obj.get("automatic_synchronization"),
            "created_at": obj.get("created_at"),
            "custom_seller": obj.get("custom_seller"),
            "dataset_domain": obj.get("dataset_domain"),
            "dataset_name": obj.get("dataset_name"),
            "default_products_filter_action": obj.get("default_products_filter_action") if obj.get("default_products_filter_action") is not None else 'PROCESS',
            "deleted": obj.get("deleted") if obj.get("deleted") is not None else False,
            "deleted_at": obj.get("deleted_at"),
            "google_merchant_id": obj.get("google_merchant_id"),
            "id": obj.get("id"),
            "ignore_brand": obj.get("ignore_brand"),
            "ignore_image": obj.get("ignore_image"),
            "modified_at": obj.get("modified_at"),
            "publisher_name": obj.get("publisher_name"),
            "refresh_token": obj.get("refresh_token"),
            "sid": obj.get("sid"),
            "sync_has_errors": obj.get("sync_has_errors"),
            "sync_id": obj.get("sync_id"),
            "sync_products_created": obj.get("sync_products_created"),
            "sync_products_deleted": obj.get("sync_products_deleted"),
            "sync_products_errored": obj.get("sync_products_errored"),
            "sync_products_skipped": obj.get("sync_products_skipped"),
            "sync_products_total": obj.get("sync_products_total"),
            "sync_products_unchanged": obj.get("sync_products_unchanged"),
            "sync_products_updated": obj.get("sync_products_updated"),
            "sync_started_at": obj.get("sync_started_at"),
            "sync_stopped_at": obj.get("sync_stopped_at"),
            "url": obj.get("url"),
            "url_strategy": obj.get("url_strategy") if obj.get("url_strategy") is not None else 'canonicalLinkAndLink',
            "writer_service": obj.get("writer_service")
        })
        return _obj


