syntax = "proto3";

package com.wixpress.authorization.invite.service;

import "wix/api/annotations.proto";
import "wix/api/validations.proto";
import "wix/api/permissions.proto";
import "wix/api/entity.proto";
import "AppInvite.proto";

service AppInviteService {
    option (.wix.api.service_exposure) = PRIVATE;
    option (wix.api.service_entity).message = "com.wixpress.authorization.invite.service.AppInvite";

    rpc CreateAppInvite (CreateAppInviteRequest) returns (CreateAppInviteResponse){
        option (.wix.api.required) = "CreateAppInviteRequest.invite.app_id";
        option (.wix.api.required) = "CreateAppInviteRequest.invite.policy_ids";
        option (.wix.api.required) = "CreateAppInviteRequest.invite.dest_email";
        option (.wix.api.permission) = {
            name: "DEV_CENTER.CREATE_APP_INVITE"
            type: MANUAL
        };
    }
    rpc GetAppInvite (GetAppInviteRequest) returns (GetAppInviteResponse){
        option (.wix.api.required) = "GetAppInviteRequest.invite_id";
        option (.wix.api.permission) = {
            name: "DEV_CENTER.GET_APP_INVITE"
            type: MANUAL
        };
    }

    rpc GetAppInvites (GetAppInvitesRequest) returns (GetAppInvitesResponse){
        option (.wix.api.required) = "GetAppInvitesRequest.app_id";
        option (.wix.api.permission) = {
            name: "DEV_CENTER.GET_APP_INVITE"
            type: MANUAL
        };
    }

    rpc DeleteAppInvite (DeleteAppInviteRequest) returns (DeleteAppInviteResponse){
        option (.wix.api.required) = "DeleteAppInviteRequest.invite_id";
        option (.wix.api.permission) = {
            name: "DEV_CENTER.DELETE_APP_INVITE"
            type: MANUAL
        };
    }

    rpc AcceptAppInvite (AcceptAppInviteRequest) returns (AcceptAppInviteResponse){
        option (.wix.api.required) = "AcceptAppInviteRequest.invite_id";
        option (.wix.api.permission) = {
            name: "DEV_CENTER.ACCEPT_APP_INVITE"
            type: MANUAL
        };
    }

    //Reset an Active (Pending/Declined/Expired) invitation by setting the invitation as "Pending" and reset its expiration date.
    rpc ResetAppInvite (ResetAppInviteRequest) returns (ResetAppInviteResponse){
        option (.wix.api.required) = "ResetAppInviteRequest.invite_id";
        option (.wix.api.permission) = {
            name: "DEV_CENTER.RESEND_APP_INVITE"
            type: MANUAL
        };
    };
}

message CreateAppInviteRequest {
    AppInvite invite = 1;
}

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

message GetAppInvitesRequest {
    string app_id = 1 [(wix.api.format) = GUID];
    repeated string accepted_by_account_ids = 2 [(wix.api.format) = GUID, (.wix.api.maxSize) = 100];
    repeated string statuses = 3 [(.wix.api.maxLength) = 20, (.wix.api.maxSize) = 10];
}

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

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

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

message CreateAppInviteResponse {
    AppInvite invite = 1;
}

message GetAppInviteResponse {
    AppInvite invite = 1;
}

message GetAppInvitesResponse {
    repeated AppInvite invites = 1;
}

message DeleteAppInviteResponse {}

message AcceptAppInviteResponse {
    AppInvite invite = 1;
}

message ResetAppInviteResponse {
    AppInvite invite = 1;
}