# Connection

This class defines a Connection from an [[User]] to an external service.

## Extends

- `ResourceProperty`\<`bkper.Connection`\>

### Constructor

```ts
new Connection(payload?, config?): Connection;
```

#### Parameters

| Parameter | Type |
| :------ | :------ |
| `payload?` | `Connection` |
| `config?` | [`Config`](https://bkper.com/docs/api/bkper-js/interfaces/config.md) |

#### Returns

`Connection`

#### Overrides

```ts
ResourceProperty<bkper.Connection>.constructor
```

### payload

```ts
payload: Connection;
```

The underlying payload data for this resource

#### Inherited from

```ts
ResourceProperty.payload
```

### clearTokenProperties()

```ts
clearTokenProperties(): void;
```

Cleans any token property stored in the Connection.

#### Returns

`void`

***

### create()

```ts
create(): Promise;
```

Performs create new Connection.

#### Returns

`Promise`\<`Connection`\>

The created Connection, for chaining

***

### deleteProperty()

```ts
deleteProperty(key): this;
```

Deletes a custom property.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `key` | `string` | The property key |

#### Returns

`this`

This resource, for chaining

#### Inherited from

```ts
ResourceProperty.deleteProperty
```

***

### getAgentId()

```ts
getAgentId(): string | undefined;
```

Gets the agentId of the Connection.

#### Returns

`string` \| `undefined`

The Connection's agentId

***

### getDateAddedMs()

```ts
getDateAddedMs(): string | undefined;
```

Gets the date when the Connection was added.

#### Returns

`string` \| `undefined`

The Connection add date in milliseconds

***

### getEmail()

```ts
getEmail(): string | undefined;
```

Gets the email of the owner of the Connection.

#### Returns

`string` \| `undefined`

The Connection owner's email

***

### getId()

```ts
getId(): string | undefined;
```

Gets the id of the Connection.

#### Returns

`string` \| `undefined`

The Connection's id

***

### getIntegrations()

```ts
getIntegrations(): Promise;
```

Gets the existing [[Integrations]] on the Connection.

#### Returns

`Promise`\<[`Integration`](https://bkper.com/docs/api/bkper-js/classes/integration.md)[]\>

The existing Integration objects

***

### getLogo()

```ts
getLogo(): string | undefined;
```

Gets the logo of the Connection.

#### Returns

`string` \| `undefined`

The Connection logo

***

### getName()

```ts
getName(): string | undefined;
```

Gets the name of the Connection.

#### Returns

`string` \| `undefined`

The Connection name

***

### getProperties()

```ts
getProperties(): object;
```

Gets the custom properties stored in this resource.

#### Returns

`object`

Object with key/value pair properties

#### Inherited from

```ts
ResourceProperty.getProperties
```

***

### getProperty()

```ts
getProperty(...keys): string | undefined;
```

Gets the property value for given keys. First property found will be retrieved.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| ...`keys` | `string`[] | The property keys to search for |

#### Returns

`string` \| `undefined`

The property value or undefined if not found

#### Inherited from

```ts
ResourceProperty.getProperty
```

***

### getPropertyKeys()

```ts
getPropertyKeys(): string[];
```

Gets the custom properties keys stored in this resource.

#### Returns

`string`[]

Array of property keys sorted alphabetically

#### Inherited from

```ts
ResourceProperty.getPropertyKeys
```

***

### getType()

```ts
getType(): "APP" | "BANK" | undefined;
```

Gets the type of the Connection.

#### Returns

`"APP"` \| `"BANK"` \| `undefined`

The Connection type

***

### getUUID()

```ts
getUUID(): string | undefined;
```

Gets the universal unique identifier of this Connection.

#### Returns

`string` \| `undefined`

The Connection's universal unique identifier name

***

### getVisibleProperties()

```ts
getVisibleProperties(): object;
```

Gets the visible custom properties stored in this resource.
Hidden properties (those ending with "_") are excluded from the result.

#### Returns

`object`

Object with key/value pair properties, excluding hidden properties

#### Inherited from

```ts
ResourceProperty.getVisibleProperties
```

***

### json()

```ts
json(): Connection;
```

Gets an immutable copy of the JSON payload for this resource.

#### Returns

`Connection`

An immutable copy of the json payload

#### Inherited from

```ts
ResourceProperty.json
```

***

### remove()

```ts
remove(): Promise;
```

Performs remove Connection.

#### Returns

`Promise`\<`Connection`\>

The removed Connection object

***

### setAgentId()

```ts
setAgentId(agentId): Connection;
```

Sets the Connection agentId.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `agentId` | `string` | The Connection agentId |

#### Returns

`Connection`

The Connection, for chaining

***

### setName()

```ts
setName(name): Connection;
```

Sets the name of the Connection.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `name` | `string` | The name of the Connection |

#### Returns

`Connection`

The Connection, for chaining

***

### setProperties()

```ts
setProperties(properties): this;
```

Sets the custom properties of this resource.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `properties` | \{ \[`key`: `string`\]: `string`; \} | Object with key/value pair properties |

#### Returns

`this`

This resource, for chaining

#### Inherited from

```ts
ResourceProperty.setProperties
```

***

### setProperty()

```ts
setProperty(key, value): this;
```

Sets a custom property in this resource.

Property keys are normalized and validated by the API when saved. Keep keys
to 30 characters or fewer after normalization. Use a trailing underscore
(`_`) for hidden/internal properties.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `key` | `string` | The property key |
| `value` | `string` \| `null` \| `undefined` | The property value, or null/undefined to clean it |

#### Returns

`this`

This resource, for chaining

#### Inherited from

```ts
ResourceProperty.setProperty
```

***

### setType()

```ts
setType(type): Connection;
```

Sets the Connection type.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `type` | `"APP"` \| `"BANK"` | The Connection type |

#### Returns

`Connection`

The Connection, for chaining

***

### setUUID()

```ts
setUUID(uuid): Connection;
```

Sets the universal unique identifier of the Connection.

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `uuid` | `string` | The universal unique identifier of the Connection |

#### Returns

`Connection`

The Connection, for chaining

***

### setVisibleProperties()

```ts
setVisibleProperties(properties): this;
```

Sets the custom properties of this resource, filtering out hidden properties.
Hidden properties are those whose keys end with an underscore "_".

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `properties` | \{ \[`key`: `string`\]: `string`; \} | Object with key/value pair properties |

#### Returns

`this`

This resource, for chaining

#### Inherited from

```ts
ResourceProperty.setVisibleProperties
```

***

### setVisibleProperty()

```ts
setVisibleProperty(key, value): this;
```

Sets a custom property in this resource, filtering out hidden properties.
Hidden properties are those whose keys end with an underscore "_".

#### Parameters

| Parameter | Type | Description |
| :------ | :------ | :------ |
| `key` | `string` | The property key |
| `value` | `string` \| `null` \| `undefined` | The property value, or null/undefined to clean it |

#### Returns

`this`

This resource, for chaining

#### Inherited from

```ts
ResourceProperty.setVisibleProperty
```

***

### update()

```ts
update(): Promise;
```

Performs update Connection.

#### Returns

`Promise`\<`Connection`\>

The updated Connection object
