Skip to content

Commit 0ee64f3

Browse files
authored
Update README.md
1 parent 0e8a7bc commit 0ee64f3

File tree

1 file changed

+9
-66
lines changed

1 file changed

+9
-66
lines changed

README.md

Lines changed: 9 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -10,80 +10,23 @@ API documentation is available at https://docs.ravenapp.dev/.
1010

1111
## Usage
1212

13-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/raven-typescript-example?file=app.ts&view=editor)
13+
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/edit/raven-typescript-example-yrzyda?file=app.ts&view=editor)
1414

1515
```typescript
16+
import { RavenApiClient } from '@ravenapp/raven';
1617

17-
import { RavenApi } from "raven";
18-
19-
const raven = new RavenApi.Client({
20-
authorization: `AuthKey ${api_key}`,
18+
const raven = new RavenApiClient({
19+
authorization: `AuthKey YOUR_AUTH_KEY`,
2120
});
2221

23-
const sendEventResponse = await raven.send({
24-
appId: ravenAppId,
25-
_body: {
26-
event: "sample_event_1",
27-
user: {
28-
mobile: "+919876543210",
29-
30-
whatsapp_mobile: "+919876543210", // if empty, `mobile` is considered for whatsapp
31-
},
32-
data: {
33-
name: "John Doe",
34-
date: "01 December 2020",
35-
},
36-
},
37-
});
38-
39-
if (sendEventResponse.ok) {
40-
console.log(`The id of the event is ${sendEventResponse.body.id}`);
41-
} else {
42-
console.error("Failed to send event", sendEventResponse.error);
43-
}
44-
```
45-
46-
## Examples
47-
48-
Below are a few examples of how to use the SDK to hit different endpoints. Check out our [API Reference](https://docs.ravenapp.dev/) to see all of our endpoints.
49-
50-
### Create User
51-
52-
```typescript
53-
const createUserResponse = await raven.user.createOrUpdate({
54-
appId: ravenAppId,
55-
_body: {
56-
userId: "test",
57-
mobile: "9876543210",
58-
59-
},
60-
});
61-
62-
if (createUserResponse.ok) {
63-
console.log(createUserResponse.body);
64-
} else {
65-
console.error("Failed to create user", createUserResponse.error);
66-
}
67-
```
68-
69-
### Add device
70-
71-
```typescript
72-
const addDeviceResponse = await raven.device.add({
73-
appId: ravenAppId,
74-
userId: createUserResponse.body.userId,
75-
_body: {
76-
fcmToken:
77-
"qweKu7bdTZumJpzxUqqpxe:APA91bE9FSScPK_kENPpBAj0URYDo4z0tE6aOrBtpgaA1I1OC7GBes1lR71EWRhavLGMzDMKPPLkUoqtvPHzCgq-8ObU4AOJjbPdpkyRWqc8mqrUV2EkvsziLZvFccwtyI7-lQQhSJDe",
78-
platform: RavenApi.Platform.Android,
22+
const response = await raven.send('YOUR_APP_ID', {
23+
event: 'Send text message.',
24+
data: {
25+
key: 'value',
7926
},
8027
});
8128

82-
if (addDeviceResponse.ok) {
83-
console.log(addDeviceResponse.body);
84-
} else {
85-
console.error("Failed to add device", addDeviceResponse.error);
86-
}
29+
console.log('Received response from Raven', response);
8730
```
8831

8932
## Beta status

0 commit comments

Comments
 (0)