chromium/components/commerce/core/proto/cart_db_content.proto

// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

syntax = "proto3";

option optimize_for = LITE_RUNTIME;

package cart_db;

// Represents an amount of money with its currency type.
// Next id: 4
message MoneyProto {
  // Three-letter currency code defined in ISO 4217.
  string currency_code = 1;
  // The whole units of amount.
  // e.g. for "USD", 1 unit is one US dollar.
  // This should be a int64_t, use string because base::Value does not support
  // int64_t.
  string units = 2;
  // Number of nano (10^-9) units of amount.
  // The value must be between -999,999,999 and +999,999,999 inclusive.
  // If `units` is positive, `nanos` must be positive or zero.
  // If `units` is zero, `nanos` can be positive, zero, or negative.
  // If `units` is negative, `nanos` must be negative or zero.
  // For example $-1.75 is represented as `units`=-1 and `nanos`=-750,000,000.
  int32 nanos = 3;
}

// Used storing discount for a specific rule.
// Next id: 6
message RuleDiscountInfoProto {
  // This should be a int64_t, use string because base::Value does not support
  // int64_t.
  string rule_id = 1;

  oneof discount {
    int32 percent_off = 2;
    MoneyProto amount_off = 3;
  }

  string merchant_rule_id = 4;

  string raw_merchant_offer_id = 5;
}

message CouponInfoProto {
  string promo_id = 1;
}

// Used for storing the discount information of this cart.
// Next id: 8
message ChromeCartDiscountProto {
  // String indicating the content of the discount on this cart (e.g. 15% off).
  string discount_text = 1;
  // Timestamp on the last time the discount is fetched.
  double last_fetched_timestamp = 2;

  // This should be a int64_t, use string because base::Value does not support
  // int64_t.
  string merchant_id = 3;

  reserved 4;

  repeated RuleDiscountInfoProto rule_discount_info = 5;

  bool has_coupons = 6;
  repeated CouponInfoProto coupon_info = 7;
}

// Used for storing information of products within the cart.
// Next id: 10
message ChromeCartProductProto {
  // String indicating the ID of the product. The format of IDs may vary among
  // different merchants.
  string product_id = 1;
}

// Used for storing ChromeCart Content.
message ChromeCartContentProto {
  // Original key for data.
  string key = 1;

  // Merchant name of the site that the cart belongs to.
  string merchant = 2;

  // URL that leads to the cart page.
  string merchant_cart_url = 3;

  // Timestamp that last time user interacts with this cart.
  double timestamp = 4;

  // Image URLs of products within the cart.
  repeated string product_image_urls = 5;

  // Whether the cart has been temporarily hidden. Hidden cart will be
  // re-activated when cart content changes or user visits that cart page.
  bool is_hidden = 6;

  // Whether the cart has been permanently removed. Removed cart will be deleted
  // from the database.
  bool is_removed = 7;

  // TODO(crbug.com/40181210): Rename this to cart_discount.
  // Information about current discount on the cart.
  ChromeCartDiscountProto discount_info = 8;

  // Information of products within the cart.
  repeated ChromeCartProductProto product_infos = 9;
}