# connector-universal-links

A [`RESTDataSource`](https://www.apollographql.com/docs/apollo-server/data/data-sources/#rest-data-source) for
interacting with [Firebase](https://firebase.google.com/) in order to generate universal links.
Also interacts with [JotURL](https://joturl.com/) by using forked SDK.
And can return just long web url.

## Usage

### Configuring the Connector

```js
import { UniversalLinksConnector } from '@theorchard/connector-universal-links';

const orchard = {
    firebaseApiKey: 'secretsecretsecret',
    insightsUrl: 'https://insights.theorchard.com',
    firebaseDomain: 'theorchard.page.link',
    jotUrlUserName: 'secretsecretsecret',
    jotUrlPublicApiKey: 'secretsecretsecret',
    jotUrlPrivateApiKey: 'secretsecretsecret',
    jotUrlDomainId: 'secretsecretsecret',
    jotUrlProjectId: 'secretsecretsecret',
};

const awal = {
    firebaseApiKey: 'secretsecretsecret',
    insightsUrl: 'https://insights.awal.com',
    firebaseDomain: 'theorchard.page.link',
    jotUrlUserName: 'secretsecretsecret',
    jotUrlPublicApiKey: 'secretsecretsecret',
    jotUrlPrivateApiKey: 'secretsecretsecret',
    jotUrlDomainId: 'secretsecretsecret',
    jotUrlProjectId: 'secretsecretsecret',
};

const config = {
    orchard,
    awal,
};

const brand = 'orchard';

const linkProvider = 'firebase';

const universalLinks = new UniversalLinksConnector(config, brand, linkProvider);
```

### createGlobalSoundRecordingLink

GlobalSoundRecording link generation.

#### Arguments example:

```js
const globalParticipant = {
    id: '9b8f00f4-1860-41d6-a87e-5f871ca81949',
    name: 'The Drums',
    imageUrl: 'https://i.scdn.co/image/e987e41400348652bf62a695bdb471becd7549f2',
};
const globalSoundRecording = {
    isrc: 'GBUM71105426',
    imageUrl: 'https://images.theorchard.com/release/large_cover/843436/099/843436099121.jpg',
    name: 'Money',
    globalParticipants: [{ name: 'The Drums' }],
};
const storeIds = [1, 286];
const countries = ['US', 'UK'];
```

#### Usage

```js
const result = await universalLinks.createGlobalSoundRecordingLink({
    globalSoundRecording,
    storeIds,
    countries,
});
```

### createGlobalParticipantLink

GlobalParticipant link generation.

#### Arguments example:

```js
const globalParticipant = {
    id: '9b8f00f4-1860-41d6-a87e-5f871ca81949',
    name: 'The Drums',
    imageUrl: 'https://i.scdn.co/image/e987e41400348652bf62a695bdb471becd7549f2',
};
```

#### Usage

```js
const result = await universalLinks.createGlobalParticipantLink({
    globalParticipant,
});
```
