@dispatchtickets/sdk 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# @dispatchtickets/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@dispatchtickets/sdk)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
|
|
6
|
+
Official TypeScript SDK for the [Dispatch Tickets](https://dispatchtickets.com) API.
|
|
4
7
|
|
|
5
8
|
## Installation
|
|
6
9
|
|
|
@@ -37,6 +40,38 @@ await client.comments.create('ws_abc123', ticket.id, {
|
|
|
37
40
|
});
|
|
38
41
|
```
|
|
39
42
|
|
|
43
|
+
## Portal API (End-User Access)
|
|
44
|
+
|
|
45
|
+
For customer-facing integrations, use `DispatchPortal` to let end-users view and manage their own tickets:
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
import { DispatchTickets, DispatchPortal } from '@dispatchtickets/sdk';
|
|
49
|
+
|
|
50
|
+
// 1. Backend: Generate a portal token for your user
|
|
51
|
+
const admin = new DispatchTickets({ apiKey: 'sk_live_xxx' });
|
|
52
|
+
const { token } = await admin.brands.generatePortalToken('br_xxx', {
|
|
53
|
+
email: user.email,
|
|
54
|
+
name: user.name,
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// 2. Frontend: Use the token to access tickets
|
|
58
|
+
const portal = new DispatchPortal({ token });
|
|
59
|
+
|
|
60
|
+
// List user's tickets
|
|
61
|
+
const { data: tickets } = await portal.tickets.list();
|
|
62
|
+
|
|
63
|
+
// Create a new ticket
|
|
64
|
+
const ticket = await portal.tickets.create({
|
|
65
|
+
title: 'Help with my order',
|
|
66
|
+
body: 'Order #12345 has not arrived...',
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Add a comment
|
|
70
|
+
await portal.tickets.addComment(ticket.id, 'Here is more information...');
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Portal tokens are scoped to a single customer and expire after 1 hour. See the [Integration Guide](https://dispatchtickets.com/docs/integration) for complete examples.
|
|
74
|
+
|
|
40
75
|
## Configuration
|
|
41
76
|
|
|
42
77
|
```typescript
|
|
@@ -477,6 +512,8 @@ This creates a `docs/` folder with HTML documentation for all exported types and
|
|
|
477
512
|
|
|
478
513
|
## Links
|
|
479
514
|
|
|
515
|
+
- [Website](https://dispatchtickets.com)
|
|
516
|
+
- [Integration Guide](https://dispatchtickets.com/docs/integration)
|
|
480
517
|
- [API Reference (Swagger)](https://dispatch-tickets-api.onrender.com/docs)
|
|
481
518
|
- [GitHub](https://github.com/Epic-Design-Labs/app-dispatchtickets-sdk)
|
|
482
519
|
- [Changelog](./CHANGELOG.md)
|