syntax = "proto3";

package worldmonitor.consumer_prices.v1;

import "sebuf/http/annotations.proto";
import "worldmonitor/consumer_prices/v1/consumer_prices_data.proto";

// ListRetailerPriceSpreadsRequest parameters for the retailer spread RPC.
message ListRetailerPriceSpreadsRequest {
  // market_code is the ISO 3166-1 alpha-2 market identifier.
  string market_code = 1 [(sebuf.http.query) = { name: "market_code" }];
  // basket_slug selects which basket to compare across retailers.
  string basket_slug = 2 [(sebuf.http.query) = { name: "basket_slug" }];
}

// ListRetailerPriceSpreadsResponse holds cheapest-basket rankings.
message ListRetailerPriceSpreadsResponse {
  // market_code echoes the requested market.
  string market_code = 1 [(sebuf.http.query) = { name: "market_code" }];
  // as_of is the Unix millisecond timestamp of the snapshot.
  int64 as_of = 2;
  // basket_slug echoes the requested basket.
  string basket_slug = 3;
  // currency_code is the ISO 4217 currency code.
  string currency_code = 4;
  // retailers holds retailer basket totals, sorted cheapest first.
  repeated RetailerSpread retailers = 5;
  // spread_pct is the percentage difference between cheapest and most expensive retailer.
  double spread_pct = 6;
  // upstream_unavailable is true when the companion service could not be reached.
  bool upstream_unavailable = 7;
}
