// 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 firebase.inappmessaging;

option java_package = "com.google.firebase.inappmessaging";
option java_outer_classname = "MessagesProto";

// Content of a Firebase in-app message.
message Content {
  oneof message_details {
    // Banner mode
    BannerMessage banner = 1;
    // Modal mode
    ModalMessage modal = 2;
    // Entire message is provided by the developer as an image
    ImageOnlyMessage image_only = 3;
    // Card mode
    CardMessage card = 4;
  }
}

message CardMessage {
  // [required] Message title.
  Text title = 1;

  // [optional] Message body.
  Text body = 2;

  // [required] HTTPS url of the image to display in portrait orientation of
  // the device.
  string portrait_image_url = 3;

  // [optional] HTTPS url of the image to display in landscape orientation
  // of the device. If missing, the client will default to using the
  // portrait image url.
  string landscape_image_url = 4;

  // [required] Message background color.
  string background_hex_color = 5;

  // [required] Message button.
  // Clicking this button will trigger the modal's primary action
  Button primary_action_button = 6;

  // [required] The action to take when clicking on the primary button.
  // This is required if primary action button is set
  Action primary_action = 7;

  // [optional] Message button.
  // Clicking this button will trigger the modal's secondary action
  // If the secondary action is not provided, the button simply dismisses the
  // message.
  Button secondary_action_button = 8;

  // [optional] The action to take when the secondary action button is clicked.
  Action secondary_action = 9;
}

message ImageOnlyMessage {
  // The url of the image to be sent as the message.
  string image_url = 1;

  // [optional] The Action to take when clicking anywhere on the image.
  Action action = 2;
}

message BannerMessage {
  // [required] Message title.
  Text title = 1;

  // [optional] Message body.
  Text body = 2;

  // [optional] Image to display (https url - it will be downloaded onto the
  // device) No prefix required.
  string image_url = 3;

  // [optional] Action to take when banner is clicked
  Action action = 4;

  // [optional]  Message background color.
  string background_hex_color = 5;
}

message ModalMessage {
  // [required] Message title.
  Text title = 1;

  // [optional] Message body.
  Text body = 2;

  // [optional] Image to display (https url - it will be downloaded onto the device)
  // No prefix required.
  string image_url = 3;

  // [optional] Message button.
  // Clicking this button will trigger the modal's action
  // Currently, the two must be set together:
  // action.isSet() iff actionButton.isSet()
  Button action_button = 4;

  // [optional] The Action to take when clicking on the button.
  // Currently, the two must be set together:
  // action.isSet() iff actionButton.isSet()
  Action action = 5;

  // [optional]  Message background color.
  string background_hex_color = 6;
}

message Text {
  // Message text.
  string text = 1;

  // Message font color.
  string hex_color = 2;

  // old field message font is deprecated
  // string font_code = 3;
  reserved 3;
}

message Button {
  // Button text.
  Text text = 1;

  // Button background color.
  string button_hex_color = 2;
}

// This defines the action to be taken on click:
// For now, only the url to navigate to.
message Action {
  // Action url
  string action_url = 1;
}