syntax = "proto3";
package pricing;

service Pricing {
  // Set price data to a given SKU
  rpc SetPrice(SetPriceRequest) returns (PriceObject);
  // Get price data about a given SKU
  rpc GetPrice(GetPriceRequest) returns (PriceObject);
  // Get bulk price date (stream)
  rpc GetPriceBulk(GetPriceBulkRequest) returns (stream PriceObject);
  // Get price history by SKU
  rpc GetPriceHistory(GetPriceRequest) returns (stream PriceHistoryObject);
  // 1. Notify to re-price when new UPL arrives
  // 2. Get Price history by SKU
  // 3. Get latest changes
  // 4. Auto pricing (First price,  Min margin, Average margin)
  //                  --            --          --

  // Get latest price changes for a given period of time
  rpc GetLatestPriceChanges(PriceChangesRequest) returns (PriceIds);
}

message PriceChangesRequest {
  string date_from = 1; // RFC3339
  string date_till = 2; // RFC3339
}

message PriceIds { repeated uint32 price_ids = 1; }

message SetPriceRequest {
  // Set price to this SKU
  uint32 sku = 1;
  // Set price as a net retail price of this value
  uint32 price_net_retail = 2;
  // Set VAT as a String, should use a common seralization
  string vat = 3;
  // Set price as as gross retail price of this value
  uint32 price_gross_retail = 4;
  // Created by a userid
  uint32 created_by = 5;
}

message PriceObject {
  // Price details related to this SKU
  uint32 sku = 1;
  // Net retail price
  uint32 price_net_retail = 2;
  // VAT as String
  string vat = 3;
  // Gross retail price
  uint32 price_gross_retail = 4;
}

message PriceHistoryObject {
  uint32 price_net_retail = 1;
  string vat = 2;
  uint32 price_gross_retail = 3;
  string created_at = 4;
  uint32 created_by = 5;
}

message GetPriceRequest { uint32 sku = 1; }

message GetPriceBulkRequest { repeated uint32 skus = 1; }