Build a TypeScript backend client for Visito's M2M API.
Base URL: https://api.visitoai.com/m2m/v1
Auth header: Authorization: Bearer process.env.VISITO_M2M_TOKEN
Implement:
1. listChannels(): GET /channels
2. listConversations(params): GET /conversations
3. getConversation(conversationId): GET /conversations/{conversationId}
4. sendReply(conversationId, body, idempotencyKey):
POST /conversations/{conversationId}/reply
5. listWhatsappTemplates(channelId): GET /whatsapp-templates/{channelId}
6. sendWhatsappTemplate(channelId, body, idempotencyKey):
POST /whatsapp-templates/{channelId}/send
Requirements:
- keep token server-side only
- require Idempotency-Key for sendReply and sendWhatsappTemplate
- parse JSON error responses with error.code and error.message
- retry 429 and 5xx with exponential backoff
- do not retry 400, 401, 403, or 404
- return typed queued responses for 202 sends