> For the complete documentation index, see [llms.txt](https://teamleader-sdk.mcore-services.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://teamleader-sdk.mcore-services.dev/api-reference/deals/deal-sources.md).

# Deal Sources

Manage deal sources in Teamleader Focus.

```php
Teamleader::dealSources()
```

|                          |                                                                       |
| ------------------------ | --------------------------------------------------------------------- |
| Class                    | `McoreServices\TeamleaderSDK\Resources\Deals\Sources`                 |
| Create / update / delete | — / — / —                                                             |
| Pagination               | `page_size` / `page_number`; no totals — a short page is the last one |

## Endpoints

* `dealSources.list`

## Filters

Passed as the first argument to `list()`. Any other key throws.

| Filter | Description                             |
| ------ | --------------------------------------- |
| `ids`  | Array of deal source UUIDs to filter by |
| `term` | Search the deal source name             |

## Sorting

Pass `sort` (and optionally `sort_order`) in the options. Any other field throws.

| Field  | Description                       |
| ------ | --------------------------------- |
| `name` | Deal source name (ascending only) |

## Methods

### `search()`

```php
search(string $query, array $options = []): array
```

Search deal sources by name

Uses the `term` filter, which dealSources.list has declared since specification 1.221.0. Before v2.2.5 this fetched the first page and filtered it in PHP, so a source past the first 20 was never found.

* `$query` — Search query

### `all()`

```php
all(int $maxPages = 50): array
```

Get every deal source, walking all pages

Before v2.2.5 this was list() with no options — the first 20 sources only — so selectOptions() and getStatistics() silently dropped the rest.

* `$maxPages` — Runaway guard: 50 pages of 100

**Throws** `InvalidArgumentException` When $maxPages is reached with sources still pending

### `list()`

```php
list(array $filters = [], array $options = []): array
```

List deal sources with filtering, pagination and sorting

* `$filters` — `ids`, `term`
* `$options` — page\_size, page\_number, sort (name), sort\_order (asc)

**Throws** `InvalidArgumentException` On an unknown filter, or a sort other than name/asc

### `selectOptions()`

```php
selectOptions(): array
```

Get deal sources in select option format for forms

### `info()`

```php
info($id, $includes = null): array
```

Override info method to clarify it's not available

### `getStatistics()`

```php
getStatistics(): array
```

Get statistics about deal sources

### `exists()`

```php
exists(string $sourceId): bool
```

Validate if a deal source ID exists

### `byIds()`

```php
byIds(array $ids): array
```

Get deal sources by specific IDs

* `$ids` — Array of deal source UUIDs

### `getName()`

```php
getName(string $sourceId): ?string
```

Get deal source name by ID

## Examples

Get all deal sources:

```php
$sources = Teamleader::dealSources()->list();
```

Get specific deal sources by ID:

```php
$sources = Teamleader::dealSources()->list(['ids' => ['uuid1', 'uuid2']]);
```

Get deal sources sorted by name (default):

```php
$sources = Teamleader::dealSources()->list([], ['sort' => [['field' => 'name', 'order' => 'asc']]]);
```

Get deal sources with pagination:

```php
$sources = Teamleader::dealSources()->list([], ['page_size' => 50, 'page_number' => 1]);
```
