from pypipedrive.api import V1, V2
from pypipedrive.orm.model import Model
from pypipedrive.orm import fields as F


class ProductFields(Model):
    """
    Product fields represent the near-complete schema for a product in the 
    context of the company of the authorized user. Each company can have a 
    different schema for their products, with various custom fields. In the 
    context of using product fields as a schema for defining the data fields 
    of a product, it must be kept in mind that some types of custom fields can 
    have additional data fields which are not separate product fields per se. 
    Such is the case with monetary, daterange and timerange fields - each of 
    these fields will have one additional data field in addition to the one 
    presented in the context of product fields. For example, if there is a 
    monetary field with the key ``ffk9s9`` stored on the account, ``ffk9s9`` 
    would hold the numeric value of the field, and ``ffk9s9_currency`` would 
    hold the ISO currency code that goes along with the numeric value. To find 
    out which data fields are available, fetch one product and list its keys.

    See `ProductFields API reference <https://developers.pipedrive.com/docs/api/v1/ProductFields>`_.

    Get all product fields.

      * GET[Cost:10] ``v1/productFields``
      * GET[Cost:20] ``v2/productFields``

    Get one product field.

      * GET[Cost:2] ``v1/productFields/{id}``
      * GET[Cost:1] ``v2/productFields/{field_code}``

    Add a new product field.

      * POST[Cost:10] ``v1/productFields``
      * POST[Cost:5]  ``v2/productFields``

    Update a product field

      * PUT[Cost:10] ``v1/productFields/{id}``

    Delete multiple product fields in bulk

      * DELETE[Cost:10] ``v1/productFields``

    Delete a product field

      * DELETE[Cost:6] ``v1/productFields/{id}``
    """

    id                      = F.IntegerField("id", readonly=True)
    key                     = F.TextField("key")
    name                    = F.TextField("name")
    order_nr                = F.IntegerField("order_nr")
    picklist_data           = F.TextField("picklist_data")
    field_type              = F.TextField("field_type")
    add_time                = F.DatetimeField("add_time")
    update_time             = F.DatetimeField("update_time")
    last_updated_by_user_id = F.IntegerField("last_updated_by_user_id")
    created_by_user_id      = F.IntegerField("created_by_user_id")
    active_flag             = F.BooleanField("active_flag")
    edit_flag               = F.BooleanField("edit_flag")
    index_visible_flag      = F.BooleanField("index_visible_flag")
    details_visible_flag    = F.BooleanField("details_visible_flag")
    add_visible_flag        = F.BooleanField("add_visible_flag")
    important_flag          = F.BooleanField("important_flag")
    bulk_edit_allowed       = F.BooleanField("bulk_edit_allowed")
    searchable_flag         = F.BooleanField("searchable_flag")
    filtering_allowed       = F.BooleanField("filtering_allowed")
    sortable_flag           = F.BooleanField("sortable_flag")
    mandatory_flag          = F.BooleanField("mandatory_flag")
    options                 = F.OptionsField("options")

    class Meta:
        entity_name = "productFields"
        version     = V1