@sentdm/sentdm 0.32.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/client.d.mts +11 -8
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +11 -8
  5. package/client.d.ts.map +1 -1
  6. package/client.js +3 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +3 -0
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/contacts.d.mts +66 -1
  12. package/resources/contacts.d.mts.map +1 -1
  13. package/resources/contacts.d.ts +66 -1
  14. package/resources/contacts.d.ts.map +1 -1
  15. package/resources/contacts.js +24 -0
  16. package/resources/contacts.js.map +1 -1
  17. package/resources/contacts.mjs +24 -0
  18. package/resources/contacts.mjs.map +1 -1
  19. package/resources/conversations.d.mts +160 -0
  20. package/resources/conversations.d.mts.map +1 -0
  21. package/resources/conversations.d.ts +160 -0
  22. package/resources/conversations.d.ts.map +1 -0
  23. package/resources/conversations.js +59 -0
  24. package/resources/conversations.js.map +1 -0
  25. package/resources/conversations.mjs +55 -0
  26. package/resources/conversations.mjs.map +1 -0
  27. package/resources/index.d.mts +5 -4
  28. package/resources/index.d.mts.map +1 -1
  29. package/resources/index.d.ts +5 -4
  30. package/resources/index.d.ts.map +1 -1
  31. package/resources/index.js +3 -1
  32. package/resources/index.js.map +1 -1
  33. package/resources/index.mjs +1 -0
  34. package/resources/index.mjs.map +1 -1
  35. package/resources/messages.d.mts +7 -3
  36. package/resources/messages.d.mts.map +1 -1
  37. package/resources/messages.d.ts +7 -3
  38. package/resources/messages.d.ts.map +1 -1
  39. package/resources/messages.js +6 -1
  40. package/resources/messages.js.map +1 -1
  41. package/resources/messages.mjs +6 -1
  42. package/resources/messages.mjs.map +1 -1
  43. package/resources/profiles/campaigns.d.mts +112 -83
  44. package/resources/profiles/campaigns.d.mts.map +1 -1
  45. package/resources/profiles/campaigns.d.ts +112 -83
  46. package/resources/profiles/campaigns.d.ts.map +1 -1
  47. package/resources/profiles/campaigns.js +6 -5
  48. package/resources/profiles/campaigns.js.map +1 -1
  49. package/resources/profiles/campaigns.mjs +6 -5
  50. package/resources/profiles/campaigns.mjs.map +1 -1
  51. package/resources/profiles/index.d.mts +2 -2
  52. package/resources/profiles/index.d.mts.map +1 -1
  53. package/resources/profiles/index.d.ts +2 -2
  54. package/resources/profiles/index.d.ts.map +1 -1
  55. package/resources/profiles/profiles.d.mts +151 -139
  56. package/resources/profiles/profiles.d.mts.map +1 -1
  57. package/resources/profiles/profiles.d.ts +151 -139
  58. package/resources/profiles/profiles.d.ts.map +1 -1
  59. package/resources/profiles/profiles.js +39 -21
  60. package/resources/profiles/profiles.js.map +1 -1
  61. package/resources/profiles/profiles.mjs +39 -21
  62. package/resources/profiles/profiles.mjs.map +1 -1
  63. package/resources/templates.d.mts +87 -87
  64. package/resources/templates.d.mts.map +1 -1
  65. package/resources/templates.d.ts +87 -87
  66. package/resources/templates.d.ts.map +1 -1
  67. package/resources/users.d.mts +5 -3
  68. package/resources/users.d.mts.map +1 -1
  69. package/resources/users.d.ts +5 -3
  70. package/resources/users.d.ts.map +1 -1
  71. package/resources/users.js +5 -3
  72. package/resources/users.js.map +1 -1
  73. package/resources/users.mjs +5 -3
  74. package/resources/users.mjs.map +1 -1
  75. package/resources/webhooks.d.mts +226 -2
  76. package/resources/webhooks.d.mts.map +1 -1
  77. package/resources/webhooks.d.ts +226 -2
  78. package/resources/webhooks.d.ts.map +1 -1
  79. package/src/client.ts +53 -18
  80. package/src/resources/contacts.ts +96 -0
  81. package/src/resources/conversations.ts +238 -0
  82. package/src/resources/index.ts +25 -9
  83. package/src/resources/messages.ts +7 -3
  84. package/src/resources/profiles/campaigns.ts +160 -132
  85. package/src/resources/profiles/index.ts +8 -8
  86. package/src/resources/profiles/profiles.ts +185 -175
  87. package/src/resources/templates.ts +105 -105
  88. package/src/resources/users.ts +5 -3
  89. package/src/resources/webhooks.ts +269 -1
  90. package/src/version.ts +1 -1
  91. package/version.d.mts +1 -1
  92. package/version.d.ts +1 -1
  93. package/version.js +1 -1
  94. package/version.mjs +1 -1
@@ -0,0 +1,238 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import * as WebhooksAPI from './webhooks';
5
+ import { APIPromise } from '../core/api-promise';
6
+ import { buildHeaders } from '../internal/headers';
7
+ import { RequestOptions } from '../internal/request-options';
8
+ import { path } from '../internal/utils/path';
9
+
10
+ export class Conversations extends APIResource {
11
+ /**
12
+ * Retrieves a paginated list of the authenticated customer's messages across all
13
+ * conversations, ordered by created date (most recent first).
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const apiResponseOfConversationMessagesList =
18
+ * await client.conversations.list({
19
+ * page: 0,
20
+ * page_size: 0,
21
+ * });
22
+ * ```
23
+ */
24
+ list(
25
+ params: ConversationListParams,
26
+ options?: RequestOptions,
27
+ ): APIPromise<APIResponseOfConversationMessagesList> {
28
+ const { 'x-profile-id': xProfileID, ...query } = params;
29
+ return this._client.get('/v3/conversations', {
30
+ query,
31
+ ...options,
32
+ headers: buildHeaders([
33
+ { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
34
+ options?.headers,
35
+ ]),
36
+ });
37
+ }
38
+
39
+ /**
40
+ * Retrieves a paginated list of the messages in a single conversation (scoped to
41
+ * the authenticated customer), ordered by created date (most recent first).
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * const apiResponseOfConversationMessagesList =
46
+ * await client.conversations.listMessages(
47
+ * '08fab313-c9e2-502c-975e-08b0356c432e',
48
+ * { page: 0, page_size: 0 },
49
+ * );
50
+ * ```
51
+ */
52
+ listMessages(
53
+ id: string,
54
+ params: ConversationListMessagesParams,
55
+ options?: RequestOptions,
56
+ ): APIPromise<APIResponseOfConversationMessagesList> {
57
+ const { 'x-profile-id': xProfileID, ...query } = params;
58
+ return this._client.get(path`/v3/conversations/${id}`, {
59
+ query,
60
+ ...options,
61
+ headers: buildHeaders([
62
+ { ...(xProfileID != null ? { 'x-profile-id': xProfileID } : undefined) },
63
+ options?.headers,
64
+ ]),
65
+ });
66
+ }
67
+ }
68
+
69
+ /**
70
+ * Standard API response envelope for all v3 endpoints
71
+ */
72
+ export interface APIResponseOfConversationMessagesList {
73
+ /**
74
+ * A paginated list of messages — used by both conversation read endpoints.
75
+ */
76
+ data?: ConversationMessagesList | null;
77
+
78
+ /**
79
+ * Error information
80
+ */
81
+ error?: WebhooksAPI.ErrorDetail | null;
82
+
83
+ /**
84
+ * Request and response metadata
85
+ */
86
+ meta?: WebhooksAPI.APIMeta;
87
+
88
+ /**
89
+ * Indicates whether the request was successful
90
+ */
91
+ success?: boolean;
92
+ }
93
+
94
+ /**
95
+ * A paginated list of messages — used by both conversation read endpoints.
96
+ */
97
+ export interface ConversationMessagesList {
98
+ /**
99
+ * The messages on this page, most recent first.
100
+ */
101
+ messages?: Array<ConversationMessagesList.Message>;
102
+
103
+ /**
104
+ * Pagination metadata for list responses
105
+ */
106
+ pagination?: WebhooksAPI.PaginationMeta;
107
+ }
108
+
109
+ export namespace ConversationMessagesList {
110
+ /**
111
+ * Message response for v3 API — same shape as v2 with snake_case JSON conventions
112
+ */
113
+ export interface Message {
114
+ id?: string;
115
+
116
+ active_contact_price?: number | null;
117
+
118
+ channel?: string;
119
+
120
+ contact_id?: string;
121
+
122
+ created_at?: string;
123
+
124
+ customer_id?: string;
125
+
126
+ direction?: string;
127
+
128
+ events?: Array<Message.Event> | null;
129
+
130
+ /**
131
+ * Structured message body format for database storage. Preserves channel-specific
132
+ * components (header, body, footer, buttons).
133
+ */
134
+ message_body?: Message.MessageBody | null;
135
+
136
+ phone?: string;
137
+
138
+ phone_international?: string;
139
+
140
+ price?: number | null;
141
+
142
+ region_code?: string;
143
+
144
+ status?: string;
145
+
146
+ template_category?: string | null;
147
+
148
+ template_id?: string | null;
149
+
150
+ template_name?: string | null;
151
+ }
152
+
153
+ export namespace Message {
154
+ /**
155
+ * Represents a status change event in a message's lifecycle (v3)
156
+ */
157
+ export interface Event {
158
+ status: string;
159
+
160
+ timestamp: string;
161
+
162
+ description?: string | null;
163
+ }
164
+
165
+ /**
166
+ * Structured message body format for database storage. Preserves channel-specific
167
+ * components (header, body, footer, buttons).
168
+ */
169
+ export interface MessageBody {
170
+ buttons?: Array<MessageBody.Button> | null;
171
+
172
+ content?: string;
173
+
174
+ footer?: string | null;
175
+
176
+ header?: string | null;
177
+ }
178
+
179
+ export namespace MessageBody {
180
+ export interface Button {
181
+ postbackData?: string | null;
182
+
183
+ text?: string | null;
184
+
185
+ type?: string;
186
+
187
+ value?: string;
188
+ }
189
+ }
190
+ }
191
+ }
192
+
193
+ export interface ConversationListParams {
194
+ /**
195
+ * Query param
196
+ */
197
+ page: number;
198
+
199
+ /**
200
+ * Query param
201
+ */
202
+ page_size: number;
203
+
204
+ /**
205
+ * Header param: Profile UUID to scope the request to a child profile. Only
206
+ * organization API keys can use this header. The profile must belong to the
207
+ * calling organization.
208
+ */
209
+ 'x-profile-id'?: string;
210
+ }
211
+
212
+ export interface ConversationListMessagesParams {
213
+ /**
214
+ * Query param
215
+ */
216
+ page: number;
217
+
218
+ /**
219
+ * Query param
220
+ */
221
+ page_size: number;
222
+
223
+ /**
224
+ * Header param: Profile UUID to scope the request to a child profile. Only
225
+ * organization API keys can use this header. The profile must belong to the
226
+ * calling organization.
227
+ */
228
+ 'x-profile-id'?: string;
229
+ }
230
+
231
+ export declare namespace Conversations {
232
+ export {
233
+ type APIResponseOfConversationMessagesList as APIResponseOfConversationMessagesList,
234
+ type ConversationMessagesList as ConversationMessagesList,
235
+ type ConversationListParams as ConversationListParams,
236
+ type ConversationListMessagesParams as ConversationListMessagesParams,
237
+ };
238
+ }
@@ -3,6 +3,8 @@
3
3
  export {
4
4
  Contacts,
5
5
  type APIResponseOfContact,
6
+ type APIResponseOfContactMessageSummary,
7
+ type ContactMessageSummary,
6
8
  type ContactResponse,
7
9
  type ContactListResponse,
8
10
  type ContactCreateParams,
@@ -10,7 +12,15 @@ export {
10
12
  type ContactUpdateParams,
11
13
  type ContactListParams,
12
14
  type ContactDeleteParams,
15
+ type ContactRetrieveMessageSummaryParams,
13
16
  } from './contacts';
17
+ export {
18
+ Conversations,
19
+ type APIResponseOfConversationMessagesList,
20
+ type ConversationMessagesList,
21
+ type ConversationListParams,
22
+ type ConversationListMessagesParams,
23
+ } from './conversations';
14
24
  export { Me, type ProfileSettings, type MeRetrieveResponse, type MeRetrieveParams } from './me';
15
25
  export {
16
26
  Messages,
@@ -26,13 +36,13 @@ export {
26
36
  Profiles,
27
37
  type APIResponseOfProfileDetail,
28
38
  type BillingContactInfo,
39
+ type BrandBusinessInfo,
40
+ type BrandComplianceInfo,
41
+ type BrandContactInfo,
29
42
  type BrandsBrandData,
30
43
  type DestinationCountry,
31
44
  type PaymentDetails,
32
45
  type ProfileDetail,
33
- type SentDmServicesEndpointsCustomerApIv3ContractsRequestsBrandsBrandBusinessInfo,
34
- type SentDmServicesEndpointsCustomerApIv3ContractsRequestsBrandsBrandComplianceInfo,
35
- type SentDmServicesEndpointsCustomerApIv3ContractsRequestsBrandsBrandContactInfo,
36
46
  type TcrBrandRelationship,
37
47
  type TcrVertical,
38
48
  type ProfileListResponse,
@@ -47,15 +57,15 @@ export {
47
57
  export {
48
58
  Templates,
49
59
  type APIResponseTemplate,
50
- type SentDmServicesCommonContractsPocOsAuthenticationConfig,
51
- type SentDmServicesCommonContractsPocOsTemplateBody,
52
- type SentDmServicesCommonContractsPocOsTemplateButton,
53
- type SentDmServicesCommonContractsPocOsTemplateButtonProps,
54
- type SentDmServicesCommonContractsPocOsTemplateFooter,
55
- type SentDmServicesCommonContractsPocOsTemplateHeader,
60
+ type AuthenticationConfig,
56
61
  type Template,
62
+ type TemplateBody,
57
63
  type TemplateBodyContent,
64
+ type TemplateButton,
65
+ type TemplateButtonProps,
58
66
  type TemplateDefinition,
67
+ type TemplateFooter,
68
+ type TemplateHeader,
59
69
  type TemplateVariable,
60
70
  type TemplateListResponse,
61
71
  type TemplateCreateParams,
@@ -80,8 +90,14 @@ export {
80
90
  type APIMeta,
81
91
  type APIResponseWebhook,
82
92
  type ErrorDetail,
93
+ type InboundMessageEvent,
94
+ type InboundMessageEventPayload,
95
+ type MessageEvent,
96
+ type MessageEventPayload,
83
97
  type MutationRequest,
84
98
  type PaginationMeta,
99
+ type TemplateEvent,
100
+ type TemplateEventPayload,
85
101
  type WebhookEventType,
86
102
  type WebhookResponse,
87
103
  type WebhookListResponse,
@@ -68,7 +68,12 @@ export class Messages extends APIResource {
68
68
  * multi-channel broadcast — when multiple channels are specified (e.g. ["sms",
69
69
  * "whatsapp"]), a separate message is created for each (recipient, channel) pair.
70
70
  * Returns immediately with per-recipient message IDs for async tracking via
71
- * webhooks or the GET /messages/{id} endpoint.
71
+ * webhooks or the GET /messages/{id} endpoint. Sends gated before any delivery
72
+ * attempt do not reject the request — an account-level precondition such as
73
+ * insufficient balance, a template not approved for sending, or free-form content
74
+ * with no open conversation with the contact. The send is accepted with 202 and
75
+ * the affected messages are reported as BLOCKED on GET /messages/{id} and the
76
+ * message.blocked webhook.
72
77
  *
73
78
  * @example
74
79
  * ```ts
@@ -320,8 +325,7 @@ export namespace MessageSendResponse {
320
325
  recipients?: Array<Data.Recipient>;
321
326
 
322
327
  /**
323
- * Overall request status: "QUEUED" when the batch has been accepted and published
324
- * to Kafka.
328
+ * Overall request status: "QUEUED" when the batch has been accepted for delivery.
325
329
  */
326
330
  status?: string;
327
331