response-url.ts 981 B

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