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

package wix.coupons.api.v1;

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

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

    message AppliedDiscount {
        double discountAmount = 1; // the amount of the discount in case discount is given per line
        double afterDiscountAmount = 2; // the amount of the line item after applying the discount
        repeated string appliedLineId = 3; // if this discount is related to lineIds they will be listed here
    }

    // represents a single line in the cart
    message LineItem {
        string lineId = 1; // the id of the cart line item (could be 1,2,3) (mandatory)
        string externalId = 2; // the id of the item in the external system - usually will be product id
        double amount = 3; // the amount of the line item (while quantity = 1)
        int32 quantity = 4; // the quantity of this line item. must be > 0
        repeated string scopes = 5; // which scopes does this line item refers to
        AppliedDiscount appliedDiscount = 6; // after calculation - the applied discount on that line
    }

    message Totals {
        double subTotal = 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; // the shipping amount before applying the coupon
        AppliedDiscount appliedDiscount = 2; // after calculation - the discount on shipping
    }

    repeated LineItem lineItems = 1; // array of line items of the cart
    Shipping shipping = 2; // the shipping line in the cart
    Totals totals = 3; // summary of cart totals
}

