import { IApiPayload } from '../../../../../_common';
import { IExecutionWorker } from '../ExecutionWorkers';

export declare enum EVENT_POST {
    PERSIST = "postPersist",
    UPDATE = "postUpdate",
    REMOVE = "postRemove"
}
export declare enum CONDITION_OPERAND {
    EQ = "eq",
    NEQ = "neq",
    IS_SET = "isset"
}
export declare enum IS_SET_VALUE {
    true = "1",
    false = "0"
}
export interface IWebhookCondition {
    /** primary identifier */
    id?: string;
    operator: CONDITION_OPERAND;
    value: string | number | boolean;
    property: string;
    /** indicates if the condition should be applied on the change set of the entity */
    applyOnChangeSet: boolean;
    webhook: Pick<IWebhook, "id">;
}
export interface ICreateWebhookPayload {
    /** if inactive no more entries are added to the queue, but all entries which are already in the queue will be sent out. */
    active: boolean;
    /** the FQCN of the class the webhook is registered for */
    fullyQualifiedClassName: string;
    /** collection of all events this webhook should react to */
    event: EVENT_POST[];
    /** the url to which the webhook payload is sent to */
    url: string;
    /** which execution worker handles this webhook */
    executionWorker: Pick<IExecutionWorker, "id">;
    /** the amount of retries set for the webhook (max: 5) */
    retries?: number;
    /** contains the auth type and the required parameters format: ['authType' => , 'parameters' => ] */
    authentication?: string;
    allConditionsRequired?: boolean;
    /** array of optional dh values, which should be included in the entity. encode with implode */
    optionalProperties?: string[];
}
export interface IUpdatedWebhook {
    /** primary identifier */
    id: string;
    /** if inactive no more entries are added to the queue, but all entries which are already in the queue will be sent out. */
    active: boolean;
    /** the FQCN of the class the webhook is registered for */
    fullyQualifiedClassName: string;
    /** collection of all events this webhook should react to */
    event: EVENT_POST[];
    /** the url to which the webhook payload is sent to */
    url: string;
    /** the amount of retries set for the webhook (max: 5) */
    retries: number;
    /** contains the auth type and the required parameters format: ['authType' => , 'parameters' => ] */
    authentication?: object;
    /** which execution worker handles this webhook */
    executionWorker: Pick<IExecutionWorker, "id">;
    allConditionsRequired: boolean;
    /** array of optional dh values, which should be included in the entity. encode with implode */
    optionalProperties: string[];
}
export interface IUpdatedWebhookPayload {
    webhook: IUpdatedWebhook;
    conditions?: IWebhookCondition[];
}
export interface IWebhook extends Omit<ICreateWebhookPayload, "executionWorker"> {
    /** primary identifier */
    id: string;
    /** if inactive no more entries are added to the queue, but all entries which are already in the queue will be sent out. */
    active: boolean;
    /** the FQCN of the class the webhook is registered for */
    fullyQualifiedClassName: string;
    /** collection of all events this webhook should react to */
    event: EVENT_POST[];
    /** the url to which the webhook payload is sent to */
    url: string;
    /** the amount of retries set for the webhook (max: 5) */
    retries: number;
    /** contains the auth type and the required parameters format: ['authType' => , 'parameters' => ] */
    authentication: string;
    /** which execution worker handles this webhook */
    executionWorker: IExecutionWorker;
    conditions: IWebhookCondition[];
    allConditionsRequired: boolean;
    /** array of optional dh values, which should be included in the entity. encode with implode */
    optionalProperties: string[];
    /** DateTime */
    created: string;
    createdBy: number;
    createdByUsername: string;
    /** the id of the request that created this line item */
    createdByRqId: string;
    /** DateTime */
    modified: string;
    modifiedBy: number;
    modifiedByUsername: string;
    /** the request id that last modified this line item */
    modifiedByRqId: string;
}
export interface ICreateWebhookResponse extends IApiPayload<IWebhook> {
    secretKey: string;
}
export interface ICreateWebhookConditionResponse extends IApiPayload<IWebhookCondition> {
    webhook: IWebhook;
}
