syntax = "proto3";

package com.wixpress.appservice.api;

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

// Subscribe to a specific webhook, if the app has not yet requested this permission, we'll add it now
message WebhookSubscribeRequest {
  string app_id = 1 [(wix.api.format) = GUID];
  string webhook_slug = 2 [(wix.api.minLength) = 1];
  string callback_url = 3 [(wix.api.format) = URI]; // Should we allow different callback urls for each webhook? each domain? one for each app?
  string permission_id = 4 [(wix.api.minLength) = 1];
}

message DeleteWebhookRequest {
  string app_id = 1 [(wix.api.format) = GUID];
  string webhook_slug = 2 [(wix.api.minLength) = 1];
}

message DeleteWebhookResponse {
}

message UpdateWebhookRequest {
  string app_id = 1 [(wix.api.format) = GUID];
  string webhook_slug = 2 [(wix.api.minLength) = 1];
  string callback_url = 3 [(wix.api.format) = URI]; // Should we allow different callback urls for each webhook? each domain? one for each app?
}

message UpdateWebhookResponse {
}

message WebhookSubscribeResponse {
}

message AppWebhookMessage {
  string key = 1; // key = appId
  AppWebhookMessageValue value = 2;
}

message AppWebhook {
  string webhook_slug = 1;
  string callback_url = 2 [(wix.api.format) = URI];
}

message AppWebhookMessageValue {
  repeated AppWebhook webhooks = 1;
}

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

message WebhookSecretResponse {
  google.protobuf.StringValue webhooks_private_key = 2; // Used to sign webhooks that are sent to tpas
}
// fake main entity for flynt
message WebhooksEntity {
  option (.wix.api.entity) = {
    fqdn: "wix.devcenter.webhooks.v1.webhooks_entity"
    segment: USERS
  };
}

