syntax = "proto3";

package com.wixpress.appservice.api;

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


enum ExtensionType {
  NONE_EXTENSION = 0;
  PAYMENTS_GATEWAY_EXTENSION = 1;
  COUPONS_EXTENSION = 2;
  DROPSHIPPING_EXTENSION = 3;
  FULFILMENT_EXTENSION = 4;
  DROPSHIPPING_SUPPLIER_EXTENSION = 5;
  FULFILLMENT_CENTER_EXTENSION = 6;
  RESTAURANTS_POS_EXTENSION = 7;
  ART_STORE_EXTENSION = 8;
  ASCEND_AUTOMATION_EXTENSION = 9;
  CONTACT_LABELS_EXTENSION = 10;
}

message Metadata {
  string title = 1;
  string name = 2;
  string description = 3;
  string kb_link = 4;
  string navigation = 5;
}

message Extension {
  option (.wix.api.entity) = {
    fqdn: "wix.devcenter.extensions.v1.extension"
    segment: USERS
  };
  string extension_id = 1 [(wix.api.format) = GUID];
  string schema = 2;
  ExtensionType extension_type = 3;
  Metadata meta_data = 4;
  Status status = 5;
}

message GetExtensionsRequest {
}

message GetExtensionsResponse {
  repeated Extension extensions = 1;
}

message CreateExtensionRequest {
  string schema = 1;
  ExtensionType extension_type = 2;
  Metadata meta_data = 3;
}

message CreateExtensionResponse {
  string extension_id = 1 [(wix.api.readOnly) = true, (wix.api.format) = GUID];
  string schema = 2;
  ExtensionType extension_type = 3;
  Metadata meta_data = 4;
  Status status = 5;
}

message UpdateExtensionRequest {
  string extension_id = 1 [(wix.api.format) = GUID];
  google.protobuf.StringValue schema = 2;
  ExtensionType extension_type = 3;
  Metadata meta_data = 4;
  Status status = 5;
}

message UpdateExtensionResponse {
  string extension_id = 1 [(wix.api.readOnly) = true, (wix.api.format) = GUID];
  string schema = 2;
  ExtensionType extension_type = 3;
  Metadata meta_data = 4;
  Status status = 5;
}

message GetExtendersRequest {
  ExtensionType extension_type = 1;
  bool includeDraft = 2;
  bool onlyInstalledOnSite = 3;
}

message GetExtendersResponse {
  repeated Extender extenders = 1;
}

message Extender {
  string app_id = 1 [(wix.api.format) = GUID];
  google.protobuf.StringValue version = 2;
  bool is_draft = 3;
  AppExtensionMessageValue extension_data = 4;
}

message AppExtensionMessageValue {
  ExtensionData extension_data = 1;
}

message ExtensionData {
  string data = 1;
  ExtensionType extension_type = 2;
}

enum Status {
  NONE_EXTENSION_STATUS = 0;
  INTERNAL = 1;
  EXTERNAL = 2;
}