/*
 * Created by johann.ortiz@pluto.tv on 01/25/2024.
 * Copyright (c) PlutoTV Inc 2024.
 */

syntax = "proto3";

package campaignpackage;

option go_package = "github.com/Pluto-tv/service-dal/golang_client";
option java_package = "tv.pluto.ip.dal.campaign";

service CampaignManager {
  rpc GetAllPaged(GetAllPagedRequest) returns (GetAllPagedResponse) {}
}

message Badge {
  string background_color = 1;
  string text_color = 2;
  string text = 3;
  string sponsored_text = 4;
}

message CampaignImage {
  string content_type = 1;
  string content_id = 2;
  string url = 3;
  bool is_custom_upload = 4;
}

message PrimetimeBillboard {
  string content_type = 1;
  string content_id = 2;
  Badge badge = 3;
  CampaignImage tile_image = 4;
  CampaignImage background_image = 5;
}

message Campaign {
  string id = 1;
  string created_at = 2;
  string updated_at = 3;
  string slug = 4;
  bool published = 5;
  string name = 6;
  string display_name = 7;
  string description = 8;
  string author = 9;
  string active_region = 10;
  repeated string distribution = 11;
  repeated string region_filter = 12;
  string start = 13;
  string end = 14;
  bool pluto_office_only = 15;
  repeated PrimetimeBillboard primetime_billboards = 16;
}

message Metadata {
  int32 current_offset = 1;
  int32 total_items = 2;
}

message Filter {
  // field to filter on
  string field = 1;
  // value for the filter
  string value = 2;
  // type of the filter string (default), number, bool
  string type = 3;
  // operator to filter by (values must be AND or OR)
  string operator = 4;
}

message GetAllPagedSort {
  // field to sort on
  string field = 1;
  // sort direction 1 | -1
  int32 value = 2;
}

message GetAllPagedRequest {
  int32 limit = 1;
  int32 offset = 2;
  repeated GetAllPagedSort sort = 3;
  repeated Filter filters = 4;
  bool disable_total_count = 5;
  // when set to true the `name` value will be sent to MongoDB as regex expression
  // when set to false the `name` value will be sent to MongoDB as a literal string
  bool enable_regex = 6;
}

message GetAllPagedResponse {
  repeated Campaign documents = 1;
  Metadata metadata = 2;
}
