Skip to main content

WebHooks

Defined in: domain/WebHooks.ts:17

Represents a collection of WebHook entities for a specific project.

Remarks​

Use WebHooks.getInstance to retrieve an instance of this collection for a given project.

Example​

const webhooks = await WebHooks.getInstance(101);
const allWebHooks = webhooks.getItems();

Extends​

Constructors​

Constructor​

new WebHooks(transform): WebHooks;

Defined in: domain/DeletableCollection.ts:40

Constructs a new DeletableCollection.

Parameters​

transform​

Optional function to transform raw API data to entity type T.

null | (data) => WebHook

Returns​

WebHooks

Inherited from​

DeletableCollection.constructor

Accessors​

length​

Get Signature​

get length(): number;

Defined in: domain/DomainCollection.ts:214

The number of items in the collection.

Returns​

number

The item count.

Inherited from​

DeletableCollection.length

Methods​

[iterator]()​

iterator: Iterator<WebHook>;

Defined in: domain/DomainCollection.ts:228

Iterator support for for...of loops.

Returns​

Iterator<WebHook>

Example​

for (const item of collection) {
console.log(item);
}

Inherited from​

DeletableCollection.[iterator]


create()​

create(item): Promise<WebHook>;

Defined in: domain/UpdatableCollection.ts:46

Creates a new item in the collection and adds it locally.

Parameters​

item​

WebHook

The item to create.

Returns​

Promise<WebHook>

A promise that resolves to the created item.

Throws​

If an item with the same ID already exists.

Inherited from​

DeletableCollection.create


delete()​

delete(id): Promise<boolean>;

Defined in: domain/DeletableCollection.ts:86

Soft-deletes an item in the collection by its ID.

Parameters​

id​

number

The ID of the item to delete.

Returns​

Promise<boolean>

A promise that resolves to true if the item was found and marked as deleted, false otherwise.

Inherited from​

DeletableCollection.delete


findById()​

findById(id): undefined | WebHook;

Defined in: domain/DomainCollection.ts:186

Finds an item in the collection by its ID.

Parameters​

id​

number

The unique identifier of the item.

Returns​

undefined | WebHook

The found item, or undefined if not found.

Inherited from​

DeletableCollection.findById


forEach()​

forEach(callback): void;

Defined in: domain/DomainCollection.ts:244

Executes a provided function once for each item in the collection.

Parameters​

callback​

(item, index, collection) => void

Function to execute for each item.

Returns​

void

Example​

collection.forEach((item, idx) => {
console.log(idx, item);
});

Inherited from​

DeletableCollection.forEach


get()​

get(index): undefined | WebHook;

Defined in: domain/DomainCollection.ts:205

Gets the item at the specified index.

Parameters​

index​

number

The zero-based index of the item.

Returns​

undefined | WebHook

The item at the given index, or undefined if out of bounds.

Inherited from​

DeletableCollection.get


getItems()​

getItems(showDeleted): WebHook[];

Defined in: domain/DeletableCollection.ts:121

Gets items in the collection, optionally filtering by deletion status.

Parameters​

showDeleted​

TrueFalseOnly = TrueFalseOnly.False

Controls which items are returned:

Returns​

WebHook[]

An array of items matching the filter.

Inherited from​

DeletableCollection.getItems


map()​

map<R>(fn): R[];

Defined in: domain/DomainCollection.ts:254

Creates a new array populated with the results of calling a provided function on every item.

Type Parameters​

R​

R

Parameters​

fn​

(item, index, collection) => R

Function that produces an element of the new array.

Returns​

R[]

A new array with each element being the result of the callback function.

Inherited from​

DeletableCollection.map


refresh()​

refresh(): Promise<void>;

Defined in: domain/DeletableCollection.ts:48

Refreshes the collection by fetching items from the API, including deleted items.

Returns​

Promise<void>

A promise that resolves when the items are loaded.

Inherited from​

DeletableCollection.refresh


toArray()​

toArray(): WebHook[];

Defined in: domain/DomainCollection.ts:263

Returns a shallow copy of all items as a plain array.

Returns​

WebHook[]

A new array containing the same items.

Inherited from​

DeletableCollection.toArray


undelete()​

undelete(id): Promise<boolean>;

Defined in: domain/DeletableCollection.ts:102

Restores a previously deleted item in the collection by its ID.

Parameters​

id​

number

The ID of the item to restore.

Returns​

Promise<boolean>

A promise that resolves to true if the item was found and restored, false otherwise.

Inherited from​

DeletableCollection.undelete


update()​

update(update): Promise<null | WebHook>;

Defined in: domain/UpdatableCollection.ts:68

Updates an existing item in the collection.

Parameters​

update​

WebHook

The updated item.

Returns​

Promise<null | WebHook>

A promise that resolves to the updated item, or null if not found.

Inherited from​

DeletableCollection.update


getCollection()​

static getCollection<T, U, Self>(this, transform): Self & {
[n: number]: undefined | T;
length: number;
};

Defined in: domain/DomainCollection.ts:83

Static factory to create a proxied, array-like collection instance.

The returned proxy enables:

  • Numeric index access (collection[0])
  • Iteration (for...of)
  • Length property (collection.length)

Type Parameters​

T​

T extends Id<U>

U​

U

Self​

Self extends DomainCollection<T, U>

Parameters​

this​

(transform) => Self

The concrete subclass constructor.

transform​

Optional function to transform raw API data into entities.

null | (data) => T

Returns​

Self & { [n: number]: undefined | T; length: number; }

A proxied DomainCollection with array-like behavior.

Example​

const orgs = Organisations.create();
console.log(orgs.length); // behaves like an array
console.log(orgs[0]); // index access

Inherited from​

DeletableCollection.getCollection


getInstance()​

static getInstance(project_id?): Promise<WebHooks>;

Defined in: domain/WebHooks.ts:28

Retrieves an instance of the WebHooks collection for the specified project.

Parameters​

project_id?​

number

The ID of the project whose webhooks to retrieve.

Returns​

Promise<WebHooks>

A promise that resolves to a WebHooks instance.