// Copyright 2018 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.internal.firebase.inappmessaging.v1;

option java_package = "com.google.internal.firebase.inappmessaging.v1";
option java_outer_classname = "CampaignProto";

import "firebase/inappmessaging/proto/messages.proto";
import "firebase/inappmessaging/proto/common_types.proto";
import "firebase/inappmessaging/proto/experiment_payload.proto";

// User-specified properties for rolling out an experimental campaign into a new
// standard campaign.
message ExperimentalCampaignRollout {
  // Id of the experiment to roll out.
  string experiment_id = 1;

  // Index of the variant to roll out.
  int32 selected_variant_index = 2;

  // Priority of the new campaign.
  .firebase.inappmessaging.Priority priority = 3;

  // Start time of the new campaign.
  .firebase.inappmessaging.CampaignTime start_time = 4;

  // [optional] End time of the new campaign.
  .firebase.inappmessaging.CampaignTime end_time = 5;
}

// The 'thick' message that gets sent to clients
message ThickContent {
  // Campaign payload - used for impression tracking on the client
  oneof payload {
    VanillaCampaignPayload vanilla_payload = 1;
    ExperimentalCampaignPayload experimental_payload = 2;
  }

  // Content
  .firebase.inappmessaging.Content content = 3;
  // Priority of the campaign/message
  // If two messages have the same priority, the one from the
  // most-recently-started campaign will 'win'
  .firebase.inappmessaging.Priority priority = 4;

  // condition to trigger the FIAM
  repeated .firebase.inappmessaging.TriggeringCondition triggering_conditions =
    5;

  // old conversion_event = 6 field is deprecated.
  reserved 6;

  // if true, it's a campaign that's to be tested on client side. otherwise, it
  // it's a regular message to be rendered.
  bool is_test_campaign = 7;

  // [optional] user-defined data bundle. This data is meant for the developer
  // to use in the SDK at runtime when a campaign is displayed.
  map<string, string> data_bundle = 8;
}

message VanillaCampaignPayload {
  // Campaign id
  string campaign_id = 1;
  // [optional] if the campaign is the result of a rolled out campaign,
  // the old experimental campaign id here is used for impression tracking on
  // the client
  string experimental_campaign_id = 2;
  // Start time of the campaign - we use long vs Timestamp here to
  // minimize the size of the bundles sent back to the sdk clients
  int64 campaign_start_time_millis = 3;
  // [optional]  end time of the campaign - we use long vs Timestamp here to
  // minimize the size of the bundles sent back to the sdk clients
  int64 campaign_end_time_millis = 4;
  // [optional] the display name for the campaign given by the campaign creator.
  // we need it for generating fiam campaign analytic events on client SDK side
  string campaign_name = 5;
}

message ExperimentalCampaignPayload {
  // Campaign id
  string campaign_id = 1;
  // payload is sent for scion tracking of the experiment this is provied by ABT
  .firebase.inappmessaging.ExperimentPayload experiment_payload = 2;
  // FIAM configured start time of the experiment - we use long vs Timestamp
  // here to minimize the size of the bundles sent back to the sdk clients
  int64 campaign_start_time_millis = 3;
  // FIAM configured end time of the experiment - we use long vs Timestamp here
  // to minimize the size of the bundles sent back to the sdk clients. Note that
  // for an experiment the end time is defined by whichever is earliest of
  // (campaign end time, experiment time to live)
  int64 campaign_end_time_millis = 4;
  // The display name for the campaign given by the campaign creator.
  // we need it for generating fiam campaign analytic events on client SDK side
  string campaign_name = 5;
}