// Copyright (c) 2018 Anki, Inc.
//
// 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 in the file LICENSE.txt or 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.

// Settings definition

syntax = "proto3";

package Anki.Vector.external_interface;

import "response_status.proto"; // App only

// *** App only proto below ***

enum ApiVersion {
  INVALID = 0;
  LATEST  = 1;
}

enum Volume {
  MUTE        = 0;
  LOW         = 1;
  MEDIUM_LOW  = 2;
  MEDIUM      = 3;
  MEDIUM_HIGH = 4;
  HIGH        = 5;
}

enum JdocType {
  ROBOT_SETTINGS = 0;
  ROBOT_LIFETIME_STATS = 1;
  ACCOUNT_SETTINGS = 2;
  USER_ENTITLEMENTS = 3;
}

enum JdocResolveMethod {
  PUSH_TO_CLOUD = 0;
  PULL_FROM_CLOUD = 1;
}

// RobotSetting enum values are not in all caps for historical reasons.
// Changing that now would involve a format migration because we're now
// saving robot settings jdocs in the cloud.
enum RobotSetting {
  clock_24_hour      = 0;
  eye_color          = 1;
  custom_eye_color   = 2;
  default_location   = 3;
  dist_is_metric     = 4;
  locale             = 5;
  master_volume      = 6;
  temp_is_fahrenheit = 7;
  time_zone          = 8;
  button_wakeword    = 9;
}

enum EyeColor {
  TIP_OVER_TEAL          = 0;
  OVERFIT_ORANGE         = 1;
  UNCANNY_YELLOW         = 2;
  NON_LINEAR_LIME        = 3;
  SINGULARITY_SAPPHIRE   = 4;
  FALSE_POSITIVE_PURPLE  = 5;
  CONFUSION_MATRIX_GREEN = 6;
}

message CustomEyeColor {
  float hue = 1;
  float saturation = 2;
  bool enabled = 3;
}

enum ButtonWakeWord {
  BUTTON_WAKEWORD_HEY_VECTOR    = 0;
  BUTTON_WAKEWORD_ALEXA         = 1;
}

message RobotSettingsConfig {
  oneof oneof_clock_24_hour { bool clock_24_hour = 1; }
  oneof oneof_eye_color { EyeColor eye_color = 2; }
  oneof oneof_custom_eye_color { CustomEyeColor custom_eye_color = 3; }
  oneof oneof_default_location { string default_location = 4; }
  oneof oneof_dist_is_metric { bool dist_is_metric = 5; }
  oneof oneof_locale { string locale = 6; }
  oneof oneof_master_volume { Volume master_volume = 7; }
  oneof oneof_temp_is_fahrenheit { bool temp_is_fahrenheit = 8; }
  oneof oneof_time_zone { string time_zone = 9; }
  oneof oneof_button_wakeword { ButtonWakeWord button_wakeword = 10; }
}

enum AccountSetting {
  DATA_COLLECTION = 0;
  APP_LOCALE = 1;
}

message AccountSettingsConfig {
  oneof oneof_data_collection { bool data_collection = 1; }
  oneof oneof_app_locale { string app_locale = 2; }
}

enum UserEntitlement {
  KICKSTARTER_EYES = 0;
}

message UserEntitlementsConfig {
  oneof oneof_kickstarter_eyes { bool kickstarter_eyes = 1; }
}

enum ResultCode {
  SETTINGS_ACCEPTED        = 0;
  ERROR_UPDATE_IN_PROGRESS = 1;
}

message Jdoc {
  uint64 doc_version = 1;
  uint64 fmt_version = 2;
  string client_metadata = 3;
  string json_doc = 4;
}

message NamedJdoc {
  JdocType jdoc_type = 1;
  Jdoc doc = 2;
}

message PullJdocsRequest {
  repeated JdocType jdoc_types = 1;
}

message PullJdocsResponse {
  ResponseStatus status = 1;
  repeated NamedJdoc named_jdocs = 2;
}

message UpdateSettingsRequest {
  RobotSettingsConfig settings = 1;
}

message UpdateSettingsResponse {
  ResponseStatus status = 1;
  ResultCode code = 2;
  Jdoc doc = 3;
}

message UpdateAccountSettingsRequest {
  AccountSettingsConfig account_settings = 1;
}

message UpdateAccountSettingsResponse {
  ResponseStatus status = 1;
  ResultCode code = 2;
  Jdoc doc = 3;
}

message UpdateUserEntitlementsRequest {
  UserEntitlementsConfig user_entitlements = 1;
}

message UpdateUserEntitlementsResponse {
  ResponseStatus status = 1;
  ResultCode code = 2;
  Jdoc doc = 3;
}

message JdocsChanged {
  repeated JdocType jdoc_types = 1;
}
