syntax = "proto3";

package wix.catalog.api.v1;

import "wix/catalog/api/v1/price.proto";
import "wix/catalog/api/v1/costAndProfit.proto";
import "wix/api/validations.proto";
import "google/protobuf/wrappers.proto";
import "wix/api/annotations.proto";
import "google/protobuf/struct.proto";
import "com/wix/ecommerce/commons/api/platformMedia.proto";
import "wix/inventory/api/v1/preOrderInfo.proto";

message VariantData {
    // Variant price.
    PriceData price = 1;
    //Variant price data converted to currency provided in header.
    PriceData converted_price_data = 7 [(wix.api.readOnly) = true];
    // Variant weight.
    google.protobuf.DoubleValue weight = 2;
    // Variant SKU (stock keeping unit).
    string sku = 3;
    // Quantity currently in inventory (relevant only when tracking by inventory).
    google.protobuf.Int32Value quantity = 4;
    // Whether the product is currently in stock (relevant only when tracking manually).
    bool in_stock = 5;
    // Whether the variant is visible to customers.
    bool visible = 6;
    // Variant ID.
    string variant_id = 8 [(wix.api.format) = GUID, (wix.api.field_exposure) = PRIVATE];
}

message VariantDataWithNoStock {
    // Variant price.
    PriceData priceData = 1;
    // Variant price data, converted to currency requested in header.
    PriceData converted_price_data = 6 [(wix.api.readOnly) = true];
    // Cost and profit data.
    CostAndProfitData cost_and_profit_data = 7;
    // Variant weight.
    double weight = 2;
    // Variant SKU (stock keeping unit).
    string sku = 3;
    // Whether the variant is visible to customers.
    bool visible = 5;
}

message Variant {
    // Requested Variant ID
    string id = 1 [(wix.api.format) = GUID];
    // Specific choices within a selection, as option-choice key-value pairs
    map<string, string> choices = 2;
    VariantDataWithNoStock variant = 3;
    // Variant inventory status.
    VariantStock stock = 4 [(wix.api.readOnly) = true];
}

message VariantOverride {
    // The specific choices available or chosen from within a selection (e.g., choosing the red Selection triggers the red Choice). You may specify all the relevant choices for a specific variant, or only some of the options, which will return all corresponding variants (Not relevant when passing variant IDs)
    map<string, string> choices = 1;
    // List of variant IDs
    // (Not relevant when passing choices)
    repeated string variantIds = 2;
    // Variant price
    google.protobuf.DoubleValue price = 3 [(wix.api.min) = 0, (wix.api.max) = 999999999.99];
    // Variant cost of goods
    google.protobuf.DoubleValue cost = 7 [(wix.api.min) = 0, (wix.api.max) = 999999999.99];
    // Variant weight
    google.protobuf.DoubleValue weight = 4 [(wix.api.min) = 0, (wix.api.max) = 999999999.99];
    // Variant SKU (stock keeping unit)
    google.protobuf.StringValue sku = 5 [(wix.api.maxLength) = 40];
    // Whether the variant is visible to  customers
    google.protobuf.BoolValue visible = 6;
}

message OptionWithChoice {
    //Option name e.g., Color, Size
    string option = 1;
    //Choice value e.g., Blue, Large
    string choice = 2;
}

message StoreVariant {
    // Store variant ID. Comprised of the `productId` and the `variantId`, separated by a hyphen: {productId}.{variantId}.
    string id = 12;
    // Variant ID.
    string variant_id = 1 [(wix.api.format) = GUID];
    //Product ID.
    string product_id = 2 [(wix.api.referenced_entity) = "wix.stores.catalog.v1.product"];
    // Variant name.
    string variant_name = 3 [(wix.api.minLength) = 1, (wix.api.maxLength) = 80];
    //Product name.
    string product_name = 4 [(wix.api.minLength) = 1, (wix.api.maxLength) = 80];
    //Whether the variant is managed or represents a product.
    bool managed_variant = 5;
    // Variant SKU (stock keeping unit).
    string sku = 6 [(wix.api.maxLength) = 40];
    // Variant inventory status.
    VariantStock stock = 7;
    // The selected options of this variant. For example, `{"Color": "Blue", "Size": "Large"}`.
    map<string, string> choices = 8;
    // Collections that include this variant.
    repeated string collection_ids = 9 [(wix.api.format) = GUID, (wix.api.referenced_entity) = "wix.stores.catalog.v1.collection"];
    // Media items (images, videos) associated with this variant.
    com.wix.ecommerce.commons.api.PlatformMedia media = 10 [(wix.api.readOnly) = true];
    map<string, google.protobuf.Value> custom_fields = 11 [(.wix.api.field_exposure) = PRIVATE];
    // Preorder information.
    .wix.inventory.api.v1.PreorderInfo preorder_info = 13;
}

message VariantStock {
    // Whether inventory is being tracked.
    bool track_quantity = 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).
    bool in_stock = 3;
    // The location of the inventory in question. None indicates the online-store default location.
    .google.protobuf.StringValue location_id = 4 [(.wix.api.field_exposure) = PRIVATE, (.wix.api.format) = GUID];
}
