syntax = "proto3";

package wix.catalog.api.v1;

import "wix/api/validations.proto";
import "wix/api/entity.proto";
import "wix/api/annotations.proto";
import "wix/catalog/api/v1/media.proto";
import "wix/catalog/api/v1/productOption.proto";
import "wix/catalog/api/v1/price.proto";
import "wix/catalog/api/v1/costAndProfit.proto";
import "wix/catalog/api/v1/pageUrl.proto";
import "wix/catalog/api/v1/variant.proto";
import "google/protobuf/wrappers.proto";
import "google/protobuf/timestamp.proto";
import "com/wix/ecommerce/commons/api/measurementUnit.proto";
import "advanced-seo-api.proto";
import "com/wix/ecommerce/catalog_spi/api/v1/platform_catalog_spi.proto";
import "com/wix/ecommerce/catalog_spi/api/v1/secured_media.proto";


option java_package = "com.wix.ecommerce.catalog.api.v1";

message Product {
    option (wix.api.entity) = {
        fqdn: "wix.stores.catalog.v1.product"
        app_def_id: "215238eb-22a5-4c36-9e7b-e7c08025e04e"
        segment: USERS
        appendix_files: {
            type: AUTO_VELO
            path: "appendices/velo/product"
        };
        appendix_files: {
            type: DOCS_CONF
            path: "appendices/docs"
        };
    };
    // Product ID (generated automatically by the catalog).
    string id = 1 [(wix.api.readOnly) = true];
    /*
    Product name.

    Min: 1 character  
    Max: 80 characters
    */
    google.protobuf.StringValue name = 2 [(wix.api.minLength) = 1, (wix.api.maxLength) = 80];
    // A friendly URL name (generated automatically by the catalog when a product is created), can be updated.
    string slug = 3 [(wix.api.maxLength) = 100];
    // Whether the product is visible to site visitors.
    google.protobuf.BoolValue visible = 4;
    // Currently, only creating physical products ( `"productType": "physical"` ) is supported via the API.
    ProductType product_type = 5;
    // Product description. Accepts [rich text](https://dev.wix.com/api/rest/wix-stores/rich-text).
    google.protobuf.StringValue description = 6 [(wix.api.maxLength) = 8000];
    // Stock keeping unit. If [variant management](https://support.wix.com/en/article/wix-stores-adding-and-customizing-product-options#setting-different-prices-for-variants) is enabled, SKUs will be set per variant, and this field will be empty.
    google.protobuf.StringValue sku = 7 [(wix.api.maxLength) = 40];
    // Product weight. If [variant management](https://support.wix.com/en/article/wix-stores-adding-and-customizing-product-options#setting-different-prices-for-variants) is enabled, weight will be set per variant, and this field will be empty.
    google.protobuf.DoubleValue weight = 8 [(wix.api.min) = 0, (wix.api.max) = 999999999.99];
    // Product weight range. The minimum and maximum weights of all the variants.
    com.wix.ecommerce.catalog_spi.api.v1.NumericPropertyRange weight_range = 32 [(wix.api.readOnly) = true];
    // Product inventory status (in future this will be writable via Inventory API).
    Stock stock = 9 [(wix.api.readOnly) = true];
    // Deprecated (use `priceData` instead).
    PriceData price = 10 [(wix.api.readOnly) = true, deprecated = true];
    // Price data.
    PriceData priceData = 22;
    // Price data, converted to the currency specified in request header.
    PriceData converted_price_data = 25 [(wix.api.readOnly) = true];
    // Product price range. The minimum and maximum prices of all the variants.
    com.wix.ecommerce.catalog_spi.api.v1.NumericPropertyRange price_range = 31 [(wix.api.readOnly) = true];
    // Cost and profit data.
    CostAndProfitData cost_and_profit_data = 30;
    // Product cost range. The minimum and maximum costs of all the variants.
    com.wix.ecommerce.catalog_spi.api.v1.NumericPropertyRange cost_range = 33 [(wix.api.readOnly) = true];
    // Price per unit data.
    PricePerUnitData price_per_unit_data = 26;
    // Additional text that the store owner can assign to the product (e.g. shipping details, refund policy, etc.).
    repeated AdditionalInfoSection additional_info_sections = 11;
    // Deprecated (use `ribbon` instead).
    repeated Ribbon ribbons = 12 [(wix.api.readOnly) = true, deprecated = true];
    // Media items (images, videos etc) associated with this product (writable via [Add Product Media](https://dev.wix.com/api/rest/wix-stores/catalog/products/add-product-media) endpoint).
    Media media = 13 [(wix.api.readOnly) = true];
    // Text box for the customer to add a message to their order (e.g., customization request). Currently writable only from the UI.
    repeated CustomTextField custom_text_fields = 14 [(wix.api.readOnly) = true];
    // Whether variants are being managed for this product - enables unique SKU, price and weight per variant. Also affects inventory data.
    google.protobuf.BoolValue manage_variants = 15;
    // Options for this product.
    repeated ProductOption product_options = 16 [(wix.api.maxSize) = 6];
    // Product page URL for this product (generated automatically by the server).
    PageUrl product_page_url = 17 [(wix.api.readOnly) = true];
    // Product’s unique numeric ID (assigned in ascending order).
    // Primarily used for sorting and filtering when crawling all products.
    uint64 numericId = 18 [(wix.api.readOnly) = true];
    // Inventory item ID - ID referencing the inventory system.
    string inventory_item_id = 19 [(wix.api.readOnly) = true, (.wix.api.referenced_entity) = "wix.stores.v2.inventory"];
    // Discount deducted from the product's original price.
    Discount discount = 20;
    // A list of all collection IDs that this product is included in (writable via the Catalog > Collection APIs).
    repeated string collection_ids = 21 [(wix.api.readOnly) = true, (.wix.api.referenced_entity) = "wix.stores.catalog.v1.collection"];
    // Product variants, will be provided if the request was sent with the `includeVariants: true`.
    //
    // Max: 1,000 variants
    repeated Variant variants = 23 [(wix.api.readOnly) = true, (.wix.api.maxSize) = 1000];
    // Date and time the product was last updated.
    google.protobuf.Timestamp last_updated = 24 [(wix.api.readOnly) = true];
    // Date and time the product was created.
    google.protobuf.Timestamp created_date = 34 [(wix.api.readOnly) = true];
    // Custom SEO data for the product.
    com.wixpress.advanced.seo.SeoSchema seo_data = 27;
    // Product ribbon. Used to highlight relevant information about a product. For example, "Sale", "New Arrival", "Sold Out".
    google.protobuf.StringValue ribbon = 28 [(wix.api.maxLength) = 30];
    // Product brand. Including a brand name can help improve site and product [visibility on search engines](https://support.wix.com/en/article/adding-brand-names-to-boost-product-page-seo-in-wix-stores).
    google.protobuf.StringValue brand = 29 [(wix.api.minLength) = 1, (wix.api.maxLength) = 50];
    //tax group id
    google.protobuf.StringValue tax_group_id = 35 [(wix.api.format) = GUID, (wix.api.field_exposure) = INTERNAL];
    //internal field used by import/export to know how to link products in csv file to product ids
    string export_product_id = 36 [(wix.api.readOnly) = true, (wix.api.field_exposure) = PRIVATE, (wix.api.maxLength) = 100];

    //Digital file which will be downloaded by buyer after successful purchase.
    com.wix.ecommerce.catalog_spi.api.v1.SecuredMedia digital_file = 200 [(wix.api.readOnly) = true, (.wix.api.field_exposure) = INTERNAL];
}

enum ProductType {
    unspecified_product_type = 0;
    physical = 1;
    digital = 2;
}

enum WeightUnit {
    unspecified_weight_unit = 0;
    KG = 1;
    LB = 2;
}

message Ribbon {
    // Ribbon text
    string text = 1 [(wix.api.maxLength) = 30];
}

message Stock {
    enum InventoryStatus {
        // In stock
        IN_STOCK = 0;
        // Not in stock
        OUT_OF_STOCK = 1;
        // Some of the variants are not in stock
        PARTIALLY_OUT_OF_STOCK = 2;
    }

    // Whether inventory is being tracked
    bool track_inventory = 1;
    // Quantity currently left in inventory
    google.protobuf.Int32Value quantity = 2 [(wix.api.min) = 0, (wix.api.max) = 99999];
    // Whether the product is currently in stock (relevant only when tracking manually)
    // Deprecated (use `inventoryStatus` instead)
    bool in_stock = 3 [deprecated = true];
    // The current status of the inventory
    // + `IN_STOCK` - In stock
    // + `OUT_OF_STOCK` - Not in stock
    // + `PARTIALLY_OUT_OF_STOCK` - Some of the variants are not in stock
    InventoryStatus inventory_status = 4;
}

message AdditionalInfoSection {
    // Product info section title
    string title = 1 [(wix.api.maxLength) = 50];
    // Product info section description
    string description = 2 [(wix.api.maxLength) = 16000];
}


message CustomTextField {
    // Text box title
    string title = 1 [(wix.api.maxLength) = 100];
    // Text box input max length
    int32 max_length = 2 [(wix.api.max) = 500];
    // Whether this text box is mandatory
    bool mandatory = 3;
}

message PricePerUnitData {
    // Total quantity
    double total_quantity = 1 [(wix.api.min) = 0.01, (wix.api.max) = 999999999.99];
    // Total measurement unit
    com.wix.ecommerce.commons.api.MeasurementUnitEnum.MeasurementUnit total_measurement_unit = 2;
    // Base quantity
    double base_quantity = 3 [(wix.api.min) = 0.01, (wix.api.max) = 999999999.99];
    // Base measurement unit
    com.wix.ecommerce.commons.api.MeasurementUnitEnum.MeasurementUnit base_measurement_unit = 4;
}
