mirror of
https://github.com/balzack/databag.git
synced 2025-04-24 02:25:26 +00:00
implementing focus module
This commit is contained in:
parent
01031d65d6
commit
66a09949ea
10
app/sdk/src/net/getChannelTopicDetail.ts
Normal file
10
app/sdk/src/net/getChannelTopicDetail.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
import { TopicDetailEntity } from '../entities';
|
||||
|
||||
export async function getChannelTopicDetail(node: string, secure: boolean, token: string, channelId: string, topicId: string): Promise<TopicDetailEntity> {
|
||||
const endpoint = `http${secure ? 's' : ''}://${node}/content/channels/${channelId}/topics/${topicId}/detail?agent=${token}`;
|
||||
const detail = await fetchWithTimeout(endpoint, { method: 'GET' });
|
||||
checkResponse(detail.status);
|
||||
return await detail.json();
|
||||
}
|
||||
|
15
app/sdk/src/net/getChannelTopics.ts
Normal file
15
app/sdk/src/net/getChannelTopics.ts
Normal file
@ -0,0 +1,15 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
import { TopicEntity } from '../entities';
|
||||
|
||||
export async function getChannelTopics(node: string, secure: boolean, token: string, channelId: stirng, revision: number | null, count: number | null, begin: number | null, end: number | null): Promise<{marker: number, revision: number, topics: TopicEntity[]}> {
|
||||
const params = (revision ? `&revision=${revision}` : '') + (count ? `&count=${count}` : '') + (begin ? `&begin=${begin}` : '') + (end ? `&end=${end}` : '');
|
||||
const endpoint = `http${secure ? 's' : ''}://${node}/content/channels/${channelId}/topics?agent=${token}${params}`;
|
||||
const topics = await fetchWithTimeout(endpoint, { method: 'GET' });
|
||||
checkResponse(topics.status);
|
||||
return {
|
||||
marker: topics.headers.get('topic-marker'),
|
||||
revision: topics.headers.get('topic-revision'),
|
||||
topics: await topics.json(),
|
||||
}
|
||||
}
|
||||
|
9
app/sdk/src/net/getContactChannelTopicDetail.ts
Normal file
9
app/sdk/src/net/getContactChannelTopicDetail.ts
Normal file
@ -0,0 +1,9 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
import { TopicDetailEntity } from '../entities';
|
||||
|
||||
export async function getContactChannelTopicDetail(node: string, secure: boolean, guidToken: string, channelId: string, topicId: string): Promise<TopicDetailEntity> {
|
||||
const endpoint = `http${secure ? 's' : ''}://${node}/content/channels/${channelId}/topics/${topicId}/detail?contact=${guidToken}`;
|
||||
const detail = await fetchWithTimeout(endpoint, { method: 'GET' });
|
||||
checkResponse(detail.status);
|
||||
return await detail.json();
|
||||
}
|
14
app/sdk/src/net/getContactChannelTopics.ts
Normal file
14
app/sdk/src/net/getContactChannelTopics.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { checkResponse, fetchWithTimeout } from './fetchUtil';
|
||||
import { TopicEntity } from '../entities';
|
||||
|
||||
export async function getContactChannelTopics(node: string, secure: boolean, guidToken: string, channelId: string, revision: number | null, count: number | null, begin: number | null, end: number | null): Promise<{ marker: number, revision: number, topics: TopicEntity[]}> {
|
||||
const params = (revision ? `&revision=${revision}` : '') + (count ? `&count=${count}` : '') + (begin ? `&begin=${begin}` : '') + (end ? `&end=${end}` : '');
|
||||
const endpoint = `http${secure ? 's' : ''}://${node}/content/channels/${channelId}/topics?contact=${guidToken}${params}`;
|
||||
const topics = await fetchWithTimeout(endpoint, { method: 'GET' });
|
||||
checkResponse(topics.status);
|
||||
return {
|
||||
marker: topics.headers.get('topic-marker'),
|
||||
revision: topics.headers.get('topic-revision'),
|
||||
topics: await topics.json(),
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user