// flynt-disable missing-string-validations
syntax = "proto3";

package wix.coupons.api.v2;

import "google/protobuf/wrappers.proto";
import "wix/coupons/api/v2/scope.proto";
import "wix/api/validations.proto";

option java_package = "com.wix.coupons.api.v2";

// Coupon information
message Specification {

    // Name of coupon.
    google.protobuf.StringValue name = 2;
    /*
    Coupon code. Must be unique for all coupons on your site.  

    Max: 20 characters
    */
    google.protobuf.StringValue code = 3;
    // Coupon valid from this date and time, in milliseconds.
    // For example, `"1554066000000"`.
    google.protobuf.Int64Value start_time = 4 [(.wix.api.min) = 1000000000000];
    // Coupon expires at this date and time, in milliseconds.
    // For example, `"1554325199999"`.
    google.protobuf.Int64Value expiration_time = 5 [(.wix.api.min) = 1000000000000];
    /* Maximum number of times the coupon can be used.

    >**Note:** Multiple purchases by the same customer or purchases by different customers are both counted toward `usageLimit`.
    */
    google.protobuf.Int32Value usage_limit = 6; 
    // Maximum number of times the coupon can be used per customer.
    google.protobuf.Int32Value limit_per_customer = 20; 
    /* Whether the coupon is limited to one item.  

    If `true` and a customer pays for multiple items, the discount applies to only the lowest priced item. 
    Coupons with a `bookings` `scope.namespace` are always limited to one item.
    */
    google.protobuf.BoolValue limited_to_one_item = 18; 
    // Whether the coupon applies to subscription products.
    google.protobuf.BoolValue applies_to_subscriptions = 21; 
    /* 
    Specifies the amount of discounted cycles for a subscription item.  
    
    + Can only be set when `scope.namespace = pricingPlans`.
    + If `discountedCycleCount` is empty, the coupon applies to all available cycles.
    + `discountedCycleCount` is ignored if `appliesToSubscriptions = true`.

    Max: `999`
    */
    google.protobuf.Int32Value discounted_cycle_count = 22;
    /*
    Whether the coupon is currently [active](https://support.wix.com/en/article/wix-stores-activating-and-deactivating-coupons).  

    Default: `true`
    */
    google.protobuf.BoolValue active = 8;
    oneof ScopeOrMinSubtotal {
        Scope scope = 16; // Specifies the type of line items this coupon will apply to. See [valid scope values](https://dev.wix.com/api/rest/coupons/coupons/valid-scope-values).
        google.protobuf.DoubleValue minimum_subtotal = 17; // Limit the coupon to carts with a subtotal above this number.
    }

    // Coupon type.
    message BuyXGetY { 
        // Number of purchased items required to receive free items.
        int32 x = 1; 
        // Number of items received for free if required number of items were purchased.
        int32 y = 2; 
    }
    oneof Behavior {
        double money_off_amount = 11; // Discount as a fixed amount.
        double percent_off_rate = 12; // Discount as a percentage.
        /*
        Free shipping.  
        
        If `true`, the coupon applies to all items in all `namespaces`.
        */
        bool free_shipping = 13;
        double fixed_price_amount = 14; // Fixed sale price.
        /*
        Receive free products when making a purchase.  

        For example, purchase `x` number of products and receive `y` number of products for free.
        */
        BuyXGetY buy_x_get_y = 15;
    }

    string type = 19; // Coupon type. Read-only.
}



