@blazeo.com/calendar-client 1.0.22 → 1.0.24
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 +45 -0
- package/dist/index.d.ts +353 -258
- package/dist/index.js +305 -144
- package/dist/index.mjs +301 -144
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,8 +44,53 @@ await cal.create(); // POST to backend
|
|
|
44
44
|
- **EventModel (instance):** `get`, `create`, `cancel`, `getCancellable`, `getAvailability`, `setReminder`
|
|
45
45
|
- **FlowModel:** Same pattern as Calendar — `FlowModel.create({}, { env })` with no fields; static `get`, `getRaw`, `list`, `createFlow`, `updateFlow`, `delete`, `duplicate`, appearance/embed/public/preview helpers; instance methods mirror those using `flowId` on the snapshot
|
|
46
46
|
- **LeadModel:** `LeadModel.create({}, { env })`; static `get`, `getRaw`, `getByEmail`, `getByCompany`; instance `get`, `getByEmail`, `getByCompany` (uses `leadId` / `email` / `companyKey` on the snapshot)
|
|
47
|
+
- **AuthModel (calendar OAuth / Connect Calendar):** `getCalendarProviders`, `getAuthorizationUrl`, `getAuthorizationStatus`, `openOAuthPopup`, `onCalendarAuthMessage` — see [Calendar authorization flow](#calendar-authorization-direct-ui)
|
|
47
48
|
- **RootStore:** `addCalendar`, `addEvent`
|
|
48
49
|
|
|
50
|
+
### Calendar authorization (direct UI)
|
|
51
|
+
|
|
52
|
+
When the user connects Google or Outlook from the Scheduling modal:
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
import {
|
|
56
|
+
configure,
|
|
57
|
+
AuthModel,
|
|
58
|
+
CalendarEmailProvider,
|
|
59
|
+
CALENDAR_AUTH_MESSAGE_TYPE,
|
|
60
|
+
} from '@blazeo.com/calendar-client';
|
|
61
|
+
|
|
62
|
+
configure({ baseUrl: 'https://your-appointment-api.example.com' });
|
|
63
|
+
|
|
64
|
+
const participantId = '...'; // logged-in participant GUID
|
|
65
|
+
|
|
66
|
+
// Optional: already connected?
|
|
67
|
+
const statusRes = await AuthModel.getAuthorizationStatus(participantId);
|
|
68
|
+
if (statusRes.status === 'success' && statusRes.data?.isAuthorized) {
|
|
69
|
+
// show connected UI
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Load provider cards (Google / Gmail, Microsoft Outlook)
|
|
73
|
+
const providersRes = await AuthModel.getCalendarProviders();
|
|
74
|
+
const providers = providersRes.data; // [{ key: 'google', displayName: 'Google / Gmail', ... }, ...]
|
|
75
|
+
|
|
76
|
+
// User clicks Google
|
|
77
|
+
const urlRes = await AuthModel.getAuthorizationUrl(participantId, 'google');
|
|
78
|
+
const popup = AuthModel.openOAuthPopup(urlRes.data.authorizationUrl);
|
|
79
|
+
|
|
80
|
+
const unsubscribe = AuthModel.onCalendarAuthMessage(async (payload) => {
|
|
81
|
+
if (payload.status === 'success') {
|
|
82
|
+
const check = await AuthModel.getAuthorizationStatus(participantId);
|
|
83
|
+
if (check.data?.isAuthorized) {
|
|
84
|
+
// close modal, show success
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// On modal unmount: unsubscribe(); popup?.close();
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`email_provider` for `getAuthorizationUrl`: `google`, `gmail`, `1`, `outlook`, `microsoft`, or `2`.
|
|
93
|
+
|
|
49
94
|
All methods return `Promise<{ status, data?, message? }>`. Check `response.status === 'success'` and use `response.data`.
|
|
50
95
|
|
|
51
96
|
## Samples
|