response-url.ts 960 B

12345678910111213141516171819202122232425262728293031323334
  1. import axios from 'axios';
  2. import type { RespondBodyForResponseUrl } from '../interfaces/response-url';
  3. export async function respond(responseUrl: string, body: RespondBodyForResponseUrl): Promise<void> {
  4. return axios.post(responseUrl, {
  5. replace_original: false,
  6. text: body.text,
  7. blocks: body.blocks,
  8. });
  9. }
  10. export async function respondInChannel(responseUrl: string, body: RespondBodyForResponseUrl): Promise<void> {
  11. return axios.post(responseUrl, {
  12. response_type: 'in_channel',
  13. replace_original: false,
  14. text: body.text,
  15. blocks: body.blocks,
  16. });
  17. }
  18. export async function replaceOriginal(responseUrl: string, body: RespondBodyForResponseUrl): Promise<void> {
  19. return axios.post(responseUrl, {
  20. replace_original: true,
  21. text: body.text,
  22. blocks: body.blocks,
  23. });
  24. }
  25. export async function deleteOriginal(responseUrl: string): Promise<void> {
  26. return axios.post(responseUrl, {
  27. delete_original: true,
  28. });
  29. }