MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / Api

Class Api

packages/sdk/src/index.ts:6–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4export { integrationMiddleware } from './middleware';
5
6export default class Api {
7 private instance: Axios;
8
9 private get = (path: string) =>
10 this.instance.get(path).then((res) => res.data);
11
12 private post = (path: string, data = {}) =>
13 this.instance.post(path, data).then((res) => res.data);
14
15 private put = (path: string, data = {}) =>
16 this.instance.put(path, data).then((res) => res.data);
17
18 private delete = (path: string) =>
19 this.instance.delete(path).then((res) => res.data);
20
21 constructor({
22 apiKey,
23 type = 'external',
24 linenUrl = 'https://www.linen.dev',
25 }: {
26 apiKey: string;
27 type?: 'internal' | 'external';
28 linenUrl?: string;
29 }) {
30 const key = type === 'internal' ? 'x-api-internal' : 'x-api-key';
31 this.instance = axios.create({
32 baseURL: `${linenUrl}`,
33 headers: { [key]: apiKey },
34 });
35 }
36
37 whoAmI(): Promise<{ accountId: string } | null> {
38 return this.get(`/api/integrations/me`);
39 }
40
41 // channels ----
42
43 getChannel(
44 search: LinenTypes.channelGetType
45 ): Promise<{ id: string; accountId: string } | null> {
46 return this.get(`/api/integrations/channels?${qs(search)}`);
47 }
48
49 findOrCreateChannel(
50 props: LinenTypes.channelFindOrCreateType
51 ): Promise<{ id: string }> {
52 return this.post(`/api/integrations/channels`, props);
53 }
54
55 getChannelIntegration(
56 search: LinenTypes.channelGetIntegrationType
57 ): Promise<LinenTypes.ChannelsIntegration | null> {
58 return this.get(`/api/integrations/channels/integration?${qs(search)}`);
59 }
60
61 updateChannelIntegration(
62 data: LinenTypes.channelPutIntegrationType
63 ): Promise<{ data: any } | null> {

Callers

nothing calls this directly

Calls 4

getMethod · 0.45
postMethod · 0.45
putMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected