Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Universal sdk code snippets #274

Merged
merged 3 commits into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 55 additions & 2 deletions docusaurus/video/docusaurus/docs/api/basics/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,64 @@ import TabItem from '@theme/TabItem';

## Creating users

// TODO API endpoint
<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
const newUser: UserObjectRequest = {
id: 'userid',
role: "user",
custom: {
color: 'red'
},
name: 'This is a test user',
image: 'link/to/profile/image'
};
await client.upsertUsers({
users: {
[newUser.id]: newUser,
},
});
```

</TabItem>
</Tabs>

## Updating users

// TODO API endpoint
<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
const user: UserObjectRequest = {
id: 'userid',
role: "user",
custom: {
color: 'red'
},
name: 'This is a test user',
image: 'link/to/profile/image'
};
client.upsertUsers({
users: {
[user.id]: user,
},
});

// or
client.updateUsersPartial({users: [
{
id: user.id,
set: {
color: 'blue'
},
unset: ['name'],
}
]});
```

</TabItem>
</Tabs>

## User tokens

Expand Down
12 changes: 6 additions & 6 deletions docusaurus/video/docusaurus/docs/api/basics/calls.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import TabItem from '@theme/TabItem';
```js
const callType = 'default';
const callId = 'my-first-call';
const call = client.call(callType, callId);
const call = client.video.call(callType, callId);

call.create({ data: { created_by_id: 'john' } });
// or
Expand Down Expand Up @@ -98,7 +98,7 @@ curl -X POST "https://video.stream-io-api.com/video/call/default/${CALL_ID}?api_
<TabItem value="js" label="JavaScript">

```js
call.update({ settings_override: { audio: { mic_default_on: true } } });
call.update({ settings_override: { audio: { mic_default_on: true, default_device: "speaker" } } });

// or to update custom data
call.update({ custom: { color: 'red' } });
Expand Down Expand Up @@ -273,23 +273,23 @@ curl -X PUT "https://video.stream-io-api.com/video/call/default/${CALL_ID}/membe

```js
// default sorting
client.queryCalls();
client.video.queryCalls();

// sorting and pagination
const queryCallsReq = {
sort: [{ field: 'starts_at', direction: -1 }],
limit: 2,
};
response = await client.queryCalls(queryCallsReq);
response = await client.video.queryCalls(queryCallsReq);

// loading next page
client.queryCalls({
client.video.queryCalls({
...queryCallsReq,
next: response.next,
});

// filtering
client.queryCalls({
client.video.queryCalls({
filter_conditions: { backstage: { $eq: false } },
});
```
Expand Down
23 changes: 10 additions & 13 deletions docusaurus/video/docusaurus/docs/api/basics/get_started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import TabItem from '@theme/TabItem';
<TabItem value="js" label="JavaScript">

```bash
npm install @stream-io/video-client
npm install @stream-io/node-sdk
// or using yarn
yarn add @stream-io/video-client
yarn add @stream-io/node-sdk
```

</TabItem>
Expand All @@ -42,9 +42,9 @@ go get github.com/GetStream/video-go-sdk
<TabItem value="js" label="JavaScript">

```js
const client = new StreamVideoServerClient('<Your API key>', {
secret: '<API secret>',
});
const apiKey = '';
const secret = '';
client = new StreamClient(apiKey, secret);
```

</TabItem>
Expand Down Expand Up @@ -135,7 +135,7 @@ func main() {
```js
const callType = 'default';
const callId = 'my-first-call';
const call = client.call(callType, callId);
const call = client.video.call(callType, callId);

call.create({ data: { created_by_id: 'john' } });

Expand Down Expand Up @@ -295,7 +295,7 @@ curl -X PUT "https://video.stream-io-api.com/video/call/default/${CALL_ID}/membe
<TabItem value="js" label="JavaScript">

```js
call.update({ settings_override: { audio: { mic_default_on: true } } });
call.update({ settings_override: { audio: { mic_default_on: true, default_device: "speaker" } } });

// or to update custom data
call.update({ custom: { color: 'red' } });
Expand Down Expand Up @@ -383,10 +383,10 @@ curl -X PUT "https://video.stream-io-api.com/video/call/default/${CALL_ID}?api_k
<TabItem value="js" label="JavaScript">

```js
call.startBroadcasting();
call.startHLSBroadcasting();

// to end broadcasting
call.stopBroadcasting();
call.stopHLSBroadcasting();
```

</TabItem>
Expand Down Expand Up @@ -570,10 +570,7 @@ curl -X POST "https://video.stream-io-api.com/video/call/default/${CALL_ID}/star
<TabItem value="js" label="JavaScript">

```js
call.queryRecordings();

// optionally query recordings for a specific session
call.queryRecordings('<session ID>');
call.listRecordings();
```

</TabItem>
Expand Down
32 changes: 32 additions & 0 deletions docusaurus/video/docusaurus/docs/api/call_types/geofencing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,35 @@ sidebar_position: 3
slug: /call_types/geofencing
title: Geofencing
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
client.video.createCallType({
name: '<call type name>',
settings: {
geofencing: {
names: ['european_union'],
},
},
});

//override settings on call level
call.create({
data: {
created_by_id: 'john',
settings_override: {
geofencing: {
names: ['european_union'],
},
},
},
});
```

</TabItem>
</Tabs>
77 changes: 77 additions & 0 deletions docusaurus/video/docusaurus/docs/api/call_types/manage-types.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
id: manage_types
sidebar_position: 2
slug: /call_types/manage
title: Manage Types
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

## Read call types

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
client.video.listCallTypes();

//or
client.getCallType({name: 'livestream'});
```

</TabItem>
</Tabs>

## Create call type

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
client.video.createCallType({
name: 'allhands',
settings: {
audio: { mic_default_on: true, default_device: 'speaker' },
},
grants: {
admin: [
VideoOwnCapability.SEND_AUDIO,
VideoOwnCapability.SEND_VIDEO,
VideoOwnCapability.MUTE_USERS,
],
user: [VideoOwnCapability.SEND_AUDIO, VideoOwnCapability.SEND_VIDEO],
},
});
```

</TabItem>
</Tabs>

## Update call type

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
client.video.updateCallType('allhands', {
settings: {
audio: { mic_default_on: false, default_device: 'earpiece' },
},
});
```

</TabItem>
</Tabs>

## Delete call type

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
client.video.deleteCallType({name: 'allhands'});
```

</TabItem>
</Tabs>
25 changes: 24 additions & 1 deletion docusaurus/video/docusaurus/docs/api/call_types/permissions.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
---
id: call_types_permissions
sidebar_position: 2
sidebar_position: 3
slug: /call_types/permissions
title: Permissions
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
client.video.createCallType({
name: '<call type name>',
grants: {
admin: [
VideoOwnCapability.SEND_AUDIO,
VideoOwnCapability.SEND_VIDEO,
VideoOwnCapability.MUTE_USERS,
],
user: [VideoOwnCapability.SEND_AUDIO, VideoOwnCapability.SEND_VIDEO],
},
});
```

</TabItem>
</Tabs>
63 changes: 62 additions & 1 deletion docusaurus/video/docusaurus/docs/api/call_types/settings.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,67 @@
---
id: call_types_settings
sidebar_position: 4
sidebar_position: 5
slug: /call_types/settings
title: Settings
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

## Settings

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
client.video.createCallType({
name: '<call type name>',
settings: {
screensharing: {
access_request_enabled: false,
enabled: true,
},
},
});

// override settings on call level
call.create({
data: {
created_by_id: 'john',
settings_override: {
screensharing: {
enabled: false,
},
},
},
});
```

</TabItem>
</Tabs>

## Notification settings

<Tabs groupId="examples">
<TabItem value="js" label="JavaScript">

```js
client.video.createCallType({
name: '<call type name>',
notification_settings: {
enabled: true,
call_notification: {
apns: {
title: '{{ user.display_name }} invites you to a call',
},
enabled: true,
},
session_started: {
enabled: false,
},
},
});
```

</TabItem>
</Tabs>
Loading