# connector-ows-playlist

A connector for communicating with the ows-playlist microservice.

This connector package export the `OwsPlaylist` class and its associated types.

## Installation

To install `connector-ows-playlist` in your project -

```
yarn add @theorchard/connector-ows-playlist
```

## Usage

Instantiate the `OwsPlaylist` class with `OwsPlaylistConfig` arguments.

```typescript
import {
    OwsPlaylist,
    OwsPlaylistConfig,
    PlaylistPlacementsArguments,
} from '@theorchard/connector-ows-playlist';

const config: OwsPlaylistConfig = {
    serviceName: 'ows-playlist',
    environment: 'test',
};

const dataSource: OwsPlaylist = new OwsPlaylist(config);
```

### getPlaylistPlacements

Fetches the playlist placements for a sound recording from ows-playlist
microservice.

```typescript
import {
    OwsPlaylist,
    OwsPlaylistConfig,
    PlaylistPlacementsArguments,
    PlaylistPlacementResponse,
} from '@theorchard/connector-ows-playlist';

const config: OwsPlaylistConfig = {
    serviceName: 'ows-playlist',
    environment: 'test',
};

const arg: PlaylistPlacementsArguments = {
    isrc: '1',
    limit: 100,
    offset: 0,
    orderBy: 'streams_all_time',
    orderDir: 'DESC',
    storeIds: [],
    minFollowers: 0,
    ownerCategories: [],
    streamCountries: [],
};

const dataSource: OwsPlaylist = new OwsPlaylist(config);
const placements: PlaylistPlacementResponse = await dataSource.getPlaylistPlacements(arg);
// do something with placements....
```
