Spaces:
Runtime error
Runtime error
File size: 2,301 Bytes
46252cd | 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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | /**
* Status (Stories) resource — WhatsApp status updates.
*
* Backed by `src/modules/status/status.controller.ts`.
* NOTE: this is WhatsApp "Status/Stories", distinct from session lifecycle status.
* @packageDocumentation
*/
import { encodeSegment } from '../http.js';
import type { OpenWAClient } from '../client.js';
import type {
SendImageStatusRequest,
SendTextStatusRequest,
SendVideoStatusRequest,
StatusRecord,
StatusResult,
} from '../types.js';
export class StatusResource {
constructor(private readonly client: OpenWAClient) {}
/** Get all status updates. */
list(sessionId: string): Promise<{ statuses: StatusRecord[] }> {
return this.client.request<{ statuses: StatusRecord[] }>({
method: 'GET',
path: `/api/sessions/${encodeSegment(sessionId)}/status`,
});
}
/** Get status updates from a specific contact. */
fromContact(sessionId: string, contactId: string): Promise<{ statuses: StatusRecord[] }> {
return this.client.request<{ statuses: StatusRecord[] }>({
method: 'GET',
path: `/api/sessions/${encodeSegment(sessionId)}/status/${encodeSegment(contactId)}`,
});
}
/** Post a text status update. */
sendText(sessionId: string, body: SendTextStatusRequest): Promise<StatusResult> {
return this.client.request<StatusResult>({
method: 'POST',
path: `/api/sessions/${encodeSegment(sessionId)}/status/send-text`,
body,
});
}
/** Post an image status update. */
sendImage(sessionId: string, body: SendImageStatusRequest): Promise<StatusResult> {
return this.client.request<StatusResult>({
method: 'POST',
path: `/api/sessions/${encodeSegment(sessionId)}/status/send-image`,
body,
});
}
/** Post a video status update. */
sendVideo(sessionId: string, body: SendVideoStatusRequest): Promise<StatusResult> {
return this.client.request<StatusResult>({
method: 'POST',
path: `/api/sessions/${encodeSegment(sessionId)}/status/send-video`,
body,
});
}
/** Delete a status update by id. */
delete(sessionId: string, statusId: string): Promise<void> {
return this.client.request<void>({
method: 'DELETE',
path: `/api/sessions/${encodeSegment(sessionId)}/status/${encodeSegment(statusId)}`,
});
}
}
|