// flynt-disable missing-array-limits
// flynt-disable missing-field-comments
// flynt-disable missing-string-validations
syntax = "proto3";

package wix.coupons.api.v2;

import "wix/coupons/api/v2/scope.proto";

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

// Cart is passed to coupon service's apply function in order to
// apply the coupons calculation on it
message Cart {

    message AppliedDiscount {
        double discount_amount = 1; // Discount amount, in case discount is applied per line.
        double after_discount_amount = 2; // Line item price after applied discount.
    }

    // represents a single line in the cart
    message LineItem {
        string line_id = 1; //  Cart line item ID - represents index position (required).
        string external_id = 2; // Item ID in the external system - will usually be a product ID.
        double amount = 3; // Line item amount (while quantity = 1).
        int32 quantity = 4; // Line item quantity. Must be greater than 0.
        repeated Scope scopes = 5; // Coupon scopes this line item applies to.
        AppliedDiscount applied_discount = 6; // Applied discount on line item after calculation.
        bool subscription= 7; // // Whether the line item is of type subscription.
    }

    message Totals {
        double sub_total = 1; // Cart subtotal.
        double discount = 2; // Sum of all discounts.
        double total = 3;
    }

    // represents the shipping line in the cart
    // the coupons need to know about it because of the free shipping coupon
    message Shipping {
        double amount = 1; // Shipping price before applying the coupon.
        AppliedDiscount applied_discount = 2; // Discount on shipping price.
    }

    repeated LineItem line_items = 1; // Array of cart line items.
    Shipping shipping = 2; // Cart shipping information.
    Totals totals = 3; // Summary of cart totals.
}

