diff --git a/README.md b/README.md index d9b7d88..d2f03a4 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,8 @@ const sms = await textbee.getSms(deviceId, smsId) const { batch, messages } = await textbee.getSmsBatch(deviceId, smsBatchId) ``` +`batch.status` and the batch counts come from the messages in the batch, so they change as each message reports. `successCount` counts messages sent or delivered, and `failureCount` counts failed ones. `pendingCount`, `dispatchedCount`, `sentCount`, `deliveredCount` and `unknownCount` break the rest down by state. + ## Verifying webhooks textbee signs each webhook delivery with HMAC-SHA256 and sends the hex digest in the `X-Signature` header. Pass the raw request body, not a re-serialized object, whenever your framework gives you access to it. diff --git a/src/types.ts b/src/types.ts index 5ab2c5f..264c024 100644 --- a/src/types.ts +++ b/src/types.ts @@ -187,13 +187,29 @@ export interface Message { updatedAt?: string } +/** + * A send batch. The status and counts are calculated from the batch's + * messages, so they change as each message reports. + */ export interface SmsBatch { _id: string message: string recipientCount: number recipientPreview?: string + /** Messages sent or delivered: `sentCount + deliveredCount`. */ successCount: number + /** Messages that failed. */ failureCount: number + /** Messages not yet handed to the phone. */ + pendingCount?: number + /** Messages handed to the phone with no result yet. */ + dispatchedCount?: number + /** Messages sent with no delivery report yet. */ + sentCount?: number + /** Messages with a delivery report. */ + deliveredCount?: number + /** Messages with no report from the phone within 20 minutes. */ + unknownCount?: number status: | 'pending' | 'processing' @@ -202,7 +218,10 @@ export interface SmsBatch { | 'failed' | 'unknown' error?: string + /** When the batch reached its current final status. Absent while processing. */ completedAt?: string + /** When the status and counts were last calculated. */ + statusCheckedAt?: string createdAt?: string updatedAt?: string }