-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunify_api.js
More file actions
38 lines (30 loc) · 1.03 KB
/
unify_api.js
File metadata and controls
38 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { BundleUp } from '../dist/index.js';
const apiKey = process.env.BUNDLEUP_API_KEY;
const connectionId = process.env.BUNDLEUP_CONNECTION_ID;
if (!apiKey) {
throw new Error('BUNDLEUP_API_KEY is required');
}
if (!connectionId) {
throw new Error('BUNDLEUP_CONNECTION_ID is required for unify example');
}
const client = new BundleUp(apiKey);
const unify = client.unify(connectionId);
console.log('Unify API example');
try {
const channels = await unify.chat.channels({ limit: 10 });
console.log(`Chat channels: ${channels.data?.length ?? 0}`);
} catch (error) {
console.error(`Failed to fetch chat channels: ${error.message}`);
}
try {
const repos = await unify.git.repos({ limit: 10 });
console.log(`Git repos: ${repos.data?.length ?? 0}`);
} catch (error) {
console.error(`Failed to fetch git repos: ${error.message}`);
}
try {
const issues = await unify.pm.issues({ limit: 10 });
console.log(`PM issues: ${issues.data?.length ?? 0}`);
} catch (error) {
console.error(`Failed to fetch PM issues: ${error.message}`);
}