// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

syntax = "proto3";

package google.cloud.retail.v2alpha;

import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/timestamp.proto";

option csharp_namespace = "Google.Cloud.Retail.V2Alpha";
option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail";
option java_multiple_files = true;
option java_outer_classname = "CommonProto";
option java_package = "com.google.cloud.retail.v2alpha";
option objc_class_prefix = "RETAIL";
option php_namespace = "Google\\Cloud\\Retail\\V2alpha";
option ruby_package = "Google::Cloud::Retail::V2alpha";

// A custom attribute that is not explicitly modeled in
// [Product][google.cloud.retail.v2alpha.Product]].
message CustomAttribute {
  // The textual values of this custom attribute. For example, `["yellow",
  // "green"]` when the key is "color".
  //
  // At most 400 values are allowed. Empty values are not allowed. Each value
  // must be a UTF-8 encoded string with a length limit of 256 characters.
  // Otherwise, an INVALID_ARGUMENT error is returned.
  //
  // Exactly one of [text][google.cloud.retail.v2alpha.CustomAttribute.text] or
  // [numbers][google.cloud.retail.v2alpha.CustomAttribute.numbers] should be
  // set. Otherwise, a INVALID_ARGUMENT error is returned.
  repeated string text = 1;

  // The numerical values of this custom attribute. For example, `[2.3, 15.4]`
  // when the key is "lengths_cm".
  //
  // At most 400 values are allowed.Otherwise, an INVALID_ARGUMENT error is
  // returned.
  //
  // Exactly one of [text][google.cloud.retail.v2alpha.CustomAttribute.text] or
  // [numbers][google.cloud.retail.v2alpha.CustomAttribute.numbers] should be
  // set. Otherwise, a INVALID_ARGUMENT error is returned.
  repeated double numbers = 2;
}

// [Product][google.cloud.retail.v2alpha.Product] thumbnail/detail image.
message Image {
  // Required. URI of the image.
  //
  // This field must be a valid UTF-8 encoded URI with a length limit of 5,000
  // characters. Otherwise, an INVALID_ARGUMENT error is returned.
  //
  // Google Merchant Center property
  // [image_link](https://support.google.com/merchants/answer/6324350).
  // Schema.org property [Product.image](http://schema.org/image).
  string uri = 1 [(google.api.field_behavior) = REQUIRED];

  // Height of the image in number of pixels.
  //
  // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is
  // returned.
  int32 height = 2;

  // Width of the image in number of pixels.
  //
  // This field must be nonnegative. Otherwise, an INVALID_ARGUMENT error is
  // returned.
  int32 width = 3;
}

// The price information of a [Product][google.cloud.retail.v2alpha.Product].
message PriceInfo {
  // The 3-letter currency code defined in [ISO
  // 4217][https://www.iso.org/iso-4217-currency-codes.html].
  //
  // If this field is an unrecognizable currency code, an INVALID_ARGUMENT
  // error is returned.
  string currency_code = 1;

  // Price of the product.
  //
  // Google Merchant Center property
  // [price](https://support.google.com/merchants/answer/6324371).
  // Schema.org property
  // [Offer.priceSpecification](https://schema.org/priceSpecification).
  float price = 2;

  // Price of the product without any discount. If zero, by default set to be
  // the [price][google.cloud.retail.v2alpha.PriceInfo.price].
  float original_price = 3;

  // The costs associated with the sale of a particular product. Used for gross
  // profit reporting.
  //
  // * Profit = [price][google.cloud.retail.v2alpha.PriceInfo.price] -
  // [cost][google.cloud.retail.v2alpha.PriceInfo.cost]
  //
  // Google Merchant Center property
  // [cost_of_goods_sold](https://support.google.com/merchants/answer/9017895)
  float cost = 4;
}

// Information of an end user.
message UserInfo {
  // Highly recommended for logged-in users. Unique identifier for logged-in
  // user, such as a user name.
  //
  // The field must be a UTF-8 encoded string with a length limit of 128
  // characters. Otherwise, an INVALID_ARGUMENT error is returned.
  string user_id = 1;

  // The end user's IP address. This field is used to extract location
  // information for personalization.
  //
  // This field must be either an IPv4 address (e.g. "104.133.9.80") or an IPv6
  // address (e.g. "2001:0db8:85a3:0000:0000:8a2e:0370:7334"). Otherwise, an
  // INVALID_ARGUMENT error is returned.
  //
  // This should not be set when using the JavaScript tag in
  // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent]
  // or if
  // [direct_user_request][google.cloud.retail.v2alpha.UserInfo.direct_user_request]
  // is set. Otherwise, a FAILED_PRECONDITION error is returned.
  string ip_address = 2;

  // User agent as included in the HTTP header.
  //
  // The field must be a UTF-8 encoded string with a length limit of 1,000
  // characters. Otherwise, an INVALID_ARGUMENT error is returned.
  //
  // This should not be set when using the client side event reporting with
  // GTM or JavaScript tag in
  // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent]
  // or if
  // [direct_user_request][google.cloud.retail.v2alpha.UserInfo.direct_user_request]
  // is set. Otherwise, a FAILED_PRECONDITION error is returned.
  string user_agent = 3;

  // True if the request is made directly from the end user, in which case the
  // [ip_address][google.cloud.retail.v2alpha.UserInfo.ip_address] and
  // [user_agent][google.cloud.retail.v2alpha.UserInfo.user_agent] can be
  // populated from the HTTP request. This flag should be set only if the API
  // request is made directly from the end user such as a mobile app (and not if
  // a gateway or a server is processing and pushing the user events).
  //
  // This should not be set when using the JavaScript tag in
  // [UserEventService.CollectUserEvent][google.cloud.retail.v2alpha.UserEventService.CollectUserEvent].
  // Otherwise, a FAILED_PRECONDITION error is returned.
  bool direct_user_request = 4;
}
