syntax = "proto3";

package com.wixpress.appservice.api;

import "google/protobuf/empty.proto";
import "google/api/annotations.proto";
import "wix/api/validations.proto";
import "wix/api/annotations.proto";
import "wix/api/entity.proto";
import "google/protobuf/wrappers.proto";

// ====================================================================================================================
// Entities
// ====================================================================================================================

message Language {
    string language_code = 1 [(wix.api.format) = LANGUAGE]; // two letter code ISO 639-1
    string language_name = 2; // language name in English
}

message Translation {
    option (.wix.api.entity) = {
        fqdn: "wix.devcenter.translations.v1.translation"
        segment: USERS
    };
    string translation_id = 1 [(wix.api.format) = GUID];
    string language_code = 2 [(wix.api.format) = LANGUAGE];
    bool is_active = 3;
    bool is_components_translations_active = 4;
}

message LanguageAddedToAppEvent {
    string app_id = 1 [(wix.api.format) = GUID];
    string language_code = 2 [(wix.api.format) = LANGUAGE]; // two letter code ISO 639-1
}

message LanguageUpdatedInAppEvent {
    string app_id = 1 [(wix.api.format) = GUID];
    string language_code = 2 [(wix.api.format) = LANGUAGE]; // two letter code ISO 639-1
    google.protobuf.BoolValue components_translation_activated = 3; // if yes - components translation will be available from next publish. if not - components will be available only in "en"
    google.protobuf.BoolValue market_translation_activated = 4; // if yes - market data translation will be available from next publish. if not - market data will be available only in "en"
}

message LanguagesCopyAppEvent {
    string app_id = 1 [(wix.api.format) = GUID];
    repeated Translation languages = 2;
}

// ====================================================================================================================
// Request/Response
// ====================================================================================================================

message GetSupportedLanguagesResponse {
    repeated Language languages = 1;
}

message GetTranslationsByAppIdRequest {
    string app_id = 1 [(wix.api.format) = GUID];
}

message GetTranslationsByAppIdResponse {
    string app_id = 1 [(wix.api.format) = GUID];
    repeated Translation translations = 2;
}

message CreateTranslationsRequest {
    string app_id = 1 [(wix.api.format) = GUID];
    repeated string language_codes = 2 [(wix.api.format) = LANGUAGE];
}

message CreateTranslationsResponse {
    string app_id = 1 [(wix.api.format) = GUID];
    repeated Translation translations = 2;
}

message ActivateTranslationRequest {
    string translation_id = 1 [(wix.api.format) = GUID];
}

message ActivateTranslationResponse {
    bool is_active = 1;
}

message DeactivateTranslationRequest {
    string translation_id = 1 [(wix.api.format) = GUID];
}

message DeactivateTranslationResponse {
    bool is_active = 1;
}

message ActivateComponentsTranslationRequest {
    string translation_id = 1 [(wix.api.format) = GUID];
}

message ActivateComponentsTranslationResponse {
    bool is_components_translations_active = 1;
}

message DeactivateComponentsTranslationRequest {
    string translation_id = 1 [(wix.api.format) = GUID];
}

message DeactivateComponentsTranslationResponse {
    bool is_components_translations_active = 1;
}