mailchannels-sdk 0.6.0 → 0.7.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.
package/README.md CHANGED
@@ -43,8 +43,8 @@ This library provides a simple way to interact with the [MailChannels API](https
43
43
 
44
44
  ## <a name="requirements">📏 Requirements</a>
45
45
 
46
- - MailChannels account
47
- - Email API key
46
+ - [Create a MailChannels account](https://www.mailchannels.com/pricing/#for_devs)
47
+ - [Create an API key](https://console.mailchannels.net/settings/accountSettings#APIKeys)
48
48
 
49
49
  ## <a name="quick-setup">🏃 Quick setup</a>
50
50
 
@@ -12,18 +12,41 @@ declare class MailChannelsClient {
12
12
  patch<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
13
13
  }
14
14
 
15
+ interface ErrorResponse {
16
+ message: string;
17
+ statusCode: number | null;
18
+ }
19
+
15
20
  interface SuccessResponse {
16
21
  /**
17
22
  * Whether the operation was successful.
18
23
  */
19
24
  success: boolean;
20
- error: string | null;
25
+ /**
26
+ * Error information if the operation failed.
27
+ */
28
+ error: ErrorResponse | null;
21
29
  }
22
30
 
23
- interface DataResponse<T> {
24
- data: T | null;
25
- error: string | null;
26
- }
31
+ type DataResponse<T> = {
32
+ /**
33
+ * The response data.
34
+ */
35
+ data: T;
36
+ /**
37
+ * Error information if the operation failed.
38
+ */
39
+ error: null;
40
+ } | {
41
+ /**
42
+ * The response data.
43
+ */
44
+ data: null;
45
+ /**
46
+ * Error information if the operation failed.
47
+ */
48
+ error: ErrorResponse;
49
+ };
27
50
 
28
51
  interface EmailsSendRecipient {
29
52
  /**
@@ -229,41 +252,34 @@ type EmailsSendOptions = EmailsSendOptionsBase & (
229
252
  }
230
253
  );
231
254
 
232
- interface EmailsSendResponse {
255
+ type EmailsSendResponse = SuccessResponse & DataResponse<{
233
256
  /**
234
- * Indicates if the email was successfully sent.
235
- */
236
- success: boolean;
237
- data: {
238
- /**
239
257
  * Fully rendered message if `dryRun` was set to `true`. A string representation of a rendered message, one per personalization in the request.
240
258
  */
241
- rendered?: string[];
242
- /**
259
+ rendered?: string[];
260
+ /**
243
261
  * The Request ID is a unique identifier generated by the service to track the HTTP request. It will also be included in all webhooks for reference.
244
262
  */
245
- requestId?: string;
246
- results?: {
247
- /**
263
+ requestId?: string;
264
+ results?: {
265
+ /**
248
266
  * The index of the personalization in the request. Starts at 0.
249
267
  */
250
- index?: number;
251
- /**
268
+ index?: number;
269
+ /**
252
270
  * The Message ID is a unique identifier generated by the service. Each personalization has a distinct Message ID, which is also used in the `Message-Id` header and included in webhooks.
253
271
  */
254
- messageId: string;
255
- /**
272
+ messageId: string;
273
+ /**
256
274
  * A human-readable explanation of the status.
257
275
  */
258
- reason?: string;
259
- /**
276
+ reason?: string;
277
+ /**
260
278
  * The status of the message. Note that 'sent' is a temporary status; the final status will be provided through webhooks, if configured.
261
279
  */
262
- status: "sent" | "failed";
263
- }[];
264
- } | null;
265
- error: string | null;
266
- }
280
+ status: "sent" | "failed";
281
+ }[];
282
+ }>;
267
283
 
268
284
  interface EmailsCreateDkimKeyOptions {
269
285
  /**
@@ -1924,4 +1940,4 @@ declare class MailChannels extends MailChannelsClient {
1924
1940
  }
1925
1941
 
1926
1942
  export { Domains, Emails, Lists, MailChannels, MailChannelsClient, Metrics, Service, SubAccounts, Suppressions, Users, Webhooks };
1927
- export type { DataResponse, DomainsBulkCreateLoginLinkResult, DomainsBulkCreateLoginLinks, DomainsBulkCreateLoginLinksResponse, DomainsBulkProvisionOptions, DomainsBulkProvisionResponse, DomainsCreateLoginLink, DomainsCreateLoginLinkResponse, DomainsData, DomainsDownstreamAddress, DomainsListDownstreamAddressesOptions, DomainsListDownstreamAddressesResponse, DomainsListOptions, DomainsListResponse, DomainsProvisionOptions, DomainsProvisionResponse, EmailsCheckDomainDkim, EmailsCheckDomainOptions, EmailsCheckDomainResponse, EmailsCheckDomainVerdict, EmailsCreateDkimKeyOptions, EmailsCreateDkimKeyResponse, EmailsDkimKey, EmailsDkimKeyStatus, EmailsGetDkimKeysOptions, EmailsGetDkimKeysResponse, EmailsRotateDkimKeyOptions, EmailsRotateDkimKeyResponse, EmailsSendAttachment, EmailsSendOptions, EmailsSendOptionsBase, EmailsSendRecipient, EmailsSendResponse, EmailsSendTracking, EmailsUpdateDkimKeyOptions, ListEntriesResponse, ListEntry, ListEntryOptions, ListEntryResponse, ListNames, MetricsBucket, MetricsEngagement, MetricsEngagementResponse, MetricsOptions, MetricsPerformance, MetricsPerformanceResponse, MetricsRecipientBehaviour, MetricsRecipientBehaviourResponse, MetricsSenders, MetricsSendersOptions, MetricsSendersResponse, MetricsSendersType, MetricsUsageResponse, MetricsVolume, MetricsVolumeResponse, Optional, ServiceReportOptions, ServiceSubscriptionsResponse, SubAccountsAccount, SubAccountsApiKey, SubAccountsCreateApiKeyResponse, SubAccountsCreateResponse, SubAccountsCreateSmtpPasswordResponse, SubAccountsLimit, SubAccountsLimitResponse, SubAccountsListApiKeyOptions, SubAccountsListApiKeyResponse, SubAccountsListOptions, SubAccountsListResponse, SubAccountsListSmtpPasswordResponse, SubAccountsSmtpPassword, SubAccountsUsage, SubAccountsUsageResponse, SuccessResponse, SuppressionsCreateOptions, SuppressionsListEntry, SuppressionsListOptions, SuppressionsListResponse, SuppressionsSource, SuppressionsTypes, UsersCreateOptions, UsersCreateResponse, WebhooksListResponse, WebhooksSigningKeyResponse, WebhooksValidateResponse };
1943
+ export type { DataResponse, DomainsBulkCreateLoginLinkResult, DomainsBulkCreateLoginLinks, DomainsBulkCreateLoginLinksResponse, DomainsBulkProvisionOptions, DomainsBulkProvisionResponse, DomainsCreateLoginLink, DomainsCreateLoginLinkResponse, DomainsData, DomainsDownstreamAddress, DomainsListDownstreamAddressesOptions, DomainsListDownstreamAddressesResponse, DomainsListOptions, DomainsListResponse, DomainsProvisionOptions, DomainsProvisionResponse, EmailsCheckDomainDkim, EmailsCheckDomainOptions, EmailsCheckDomainResponse, EmailsCheckDomainVerdict, EmailsCreateDkimKeyOptions, EmailsCreateDkimKeyResponse, EmailsDkimKey, EmailsDkimKeyStatus, EmailsGetDkimKeysOptions, EmailsGetDkimKeysResponse, EmailsRotateDkimKeyOptions, EmailsRotateDkimKeyResponse, EmailsSendAttachment, EmailsSendOptions, EmailsSendOptionsBase, EmailsSendRecipient, EmailsSendResponse, EmailsSendTracking, EmailsUpdateDkimKeyOptions, ErrorResponse, ListEntriesResponse, ListEntry, ListEntryOptions, ListEntryResponse, ListNames, MetricsBucket, MetricsEngagement, MetricsEngagementResponse, MetricsOptions, MetricsPerformance, MetricsPerformanceResponse, MetricsRecipientBehaviour, MetricsRecipientBehaviourResponse, MetricsSenders, MetricsSendersOptions, MetricsSendersResponse, MetricsSendersType, MetricsUsageResponse, MetricsVolume, MetricsVolumeResponse, Optional, ServiceReportOptions, ServiceSubscriptionsResponse, SubAccountsAccount, SubAccountsApiKey, SubAccountsCreateApiKeyResponse, SubAccountsCreateResponse, SubAccountsCreateSmtpPasswordResponse, SubAccountsLimit, SubAccountsLimitResponse, SubAccountsListApiKeyOptions, SubAccountsListApiKeyResponse, SubAccountsListOptions, SubAccountsListResponse, SubAccountsListSmtpPasswordResponse, SubAccountsSmtpPassword, SubAccountsUsage, SubAccountsUsageResponse, SuccessResponse, SuppressionsCreateOptions, SuppressionsListEntry, SuppressionsListOptions, SuppressionsListResponse, SuppressionsSource, SuppressionsTypes, UsersCreateOptions, UsersCreateResponse, WebhooksListResponse, WebhooksSigningKeyResponse, WebhooksValidateResponse };
@@ -12,18 +12,41 @@ declare class MailChannelsClient {
12
12
  patch<T>(path: string, options?: Omit<FetchOptions<"json">, "method">): Promise<T>;
13
13
  }
14
14
 
15
+ interface ErrorResponse {
16
+ message: string;
17
+ statusCode: number | null;
18
+ }
19
+
15
20
  interface SuccessResponse {
16
21
  /**
17
22
  * Whether the operation was successful.
18
23
  */
19
24
  success: boolean;
20
- error: string | null;
25
+ /**
26
+ * Error information if the operation failed.
27
+ */
28
+ error: ErrorResponse | null;
21
29
  }
22
30
 
23
- interface DataResponse<T> {
24
- data: T | null;
25
- error: string | null;
26
- }
31
+ type DataResponse<T> = {
32
+ /**
33
+ * The response data.
34
+ */
35
+ data: T;
36
+ /**
37
+ * Error information if the operation failed.
38
+ */
39
+ error: null;
40
+ } | {
41
+ /**
42
+ * The response data.
43
+ */
44
+ data: null;
45
+ /**
46
+ * Error information if the operation failed.
47
+ */
48
+ error: ErrorResponse;
49
+ };
27
50
 
28
51
  interface EmailsSendRecipient {
29
52
  /**
@@ -229,41 +252,34 @@ type EmailsSendOptions = EmailsSendOptionsBase & (
229
252
  }
230
253
  );
231
254
 
232
- interface EmailsSendResponse {
255
+ type EmailsSendResponse = SuccessResponse & DataResponse<{
233
256
  /**
234
- * Indicates if the email was successfully sent.
235
- */
236
- success: boolean;
237
- data: {
238
- /**
239
257
  * Fully rendered message if `dryRun` was set to `true`. A string representation of a rendered message, one per personalization in the request.
240
258
  */
241
- rendered?: string[];
242
- /**
259
+ rendered?: string[];
260
+ /**
243
261
  * The Request ID is a unique identifier generated by the service to track the HTTP request. It will also be included in all webhooks for reference.
244
262
  */
245
- requestId?: string;
246
- results?: {
247
- /**
263
+ requestId?: string;
264
+ results?: {
265
+ /**
248
266
  * The index of the personalization in the request. Starts at 0.
249
267
  */
250
- index?: number;
251
- /**
268
+ index?: number;
269
+ /**
252
270
  * The Message ID is a unique identifier generated by the service. Each personalization has a distinct Message ID, which is also used in the `Message-Id` header and included in webhooks.
253
271
  */
254
- messageId: string;
255
- /**
272
+ messageId: string;
273
+ /**
256
274
  * A human-readable explanation of the status.
257
275
  */
258
- reason?: string;
259
- /**
276
+ reason?: string;
277
+ /**
260
278
  * The status of the message. Note that 'sent' is a temporary status; the final status will be provided through webhooks, if configured.
261
279
  */
262
- status: "sent" | "failed";
263
- }[];
264
- } | null;
265
- error: string | null;
266
- }
280
+ status: "sent" | "failed";
281
+ }[];
282
+ }>;
267
283
 
268
284
  interface EmailsCreateDkimKeyOptions {
269
285
  /**
@@ -1924,4 +1940,4 @@ declare class MailChannels extends MailChannelsClient {
1924
1940
  }
1925
1941
 
1926
1942
  export { Domains, Emails, Lists, MailChannels, MailChannelsClient, Metrics, Service, SubAccounts, Suppressions, Users, Webhooks };
1927
- export type { DataResponse, DomainsBulkCreateLoginLinkResult, DomainsBulkCreateLoginLinks, DomainsBulkCreateLoginLinksResponse, DomainsBulkProvisionOptions, DomainsBulkProvisionResponse, DomainsCreateLoginLink, DomainsCreateLoginLinkResponse, DomainsData, DomainsDownstreamAddress, DomainsListDownstreamAddressesOptions, DomainsListDownstreamAddressesResponse, DomainsListOptions, DomainsListResponse, DomainsProvisionOptions, DomainsProvisionResponse, EmailsCheckDomainDkim, EmailsCheckDomainOptions, EmailsCheckDomainResponse, EmailsCheckDomainVerdict, EmailsCreateDkimKeyOptions, EmailsCreateDkimKeyResponse, EmailsDkimKey, EmailsDkimKeyStatus, EmailsGetDkimKeysOptions, EmailsGetDkimKeysResponse, EmailsRotateDkimKeyOptions, EmailsRotateDkimKeyResponse, EmailsSendAttachment, EmailsSendOptions, EmailsSendOptionsBase, EmailsSendRecipient, EmailsSendResponse, EmailsSendTracking, EmailsUpdateDkimKeyOptions, ListEntriesResponse, ListEntry, ListEntryOptions, ListEntryResponse, ListNames, MetricsBucket, MetricsEngagement, MetricsEngagementResponse, MetricsOptions, MetricsPerformance, MetricsPerformanceResponse, MetricsRecipientBehaviour, MetricsRecipientBehaviourResponse, MetricsSenders, MetricsSendersOptions, MetricsSendersResponse, MetricsSendersType, MetricsUsageResponse, MetricsVolume, MetricsVolumeResponse, Optional, ServiceReportOptions, ServiceSubscriptionsResponse, SubAccountsAccount, SubAccountsApiKey, SubAccountsCreateApiKeyResponse, SubAccountsCreateResponse, SubAccountsCreateSmtpPasswordResponse, SubAccountsLimit, SubAccountsLimitResponse, SubAccountsListApiKeyOptions, SubAccountsListApiKeyResponse, SubAccountsListOptions, SubAccountsListResponse, SubAccountsListSmtpPasswordResponse, SubAccountsSmtpPassword, SubAccountsUsage, SubAccountsUsageResponse, SuccessResponse, SuppressionsCreateOptions, SuppressionsListEntry, SuppressionsListOptions, SuppressionsListResponse, SuppressionsSource, SuppressionsTypes, UsersCreateOptions, UsersCreateResponse, WebhooksListResponse, WebhooksSigningKeyResponse, WebhooksValidateResponse };
1943
+ export type { DataResponse, DomainsBulkCreateLoginLinkResult, DomainsBulkCreateLoginLinks, DomainsBulkCreateLoginLinksResponse, DomainsBulkProvisionOptions, DomainsBulkProvisionResponse, DomainsCreateLoginLink, DomainsCreateLoginLinkResponse, DomainsData, DomainsDownstreamAddress, DomainsListDownstreamAddressesOptions, DomainsListDownstreamAddressesResponse, DomainsListOptions, DomainsListResponse, DomainsProvisionOptions, DomainsProvisionResponse, EmailsCheckDomainDkim, EmailsCheckDomainOptions, EmailsCheckDomainResponse, EmailsCheckDomainVerdict, EmailsCreateDkimKeyOptions, EmailsCreateDkimKeyResponse, EmailsDkimKey, EmailsDkimKeyStatus, EmailsGetDkimKeysOptions, EmailsGetDkimKeysResponse, EmailsRotateDkimKeyOptions, EmailsRotateDkimKeyResponse, EmailsSendAttachment, EmailsSendOptions, EmailsSendOptionsBase, EmailsSendRecipient, EmailsSendResponse, EmailsSendTracking, EmailsUpdateDkimKeyOptions, ErrorResponse, ListEntriesResponse, ListEntry, ListEntryOptions, ListEntryResponse, ListNames, MetricsBucket, MetricsEngagement, MetricsEngagementResponse, MetricsOptions, MetricsPerformance, MetricsPerformanceResponse, MetricsRecipientBehaviour, MetricsRecipientBehaviourResponse, MetricsSenders, MetricsSendersOptions, MetricsSendersResponse, MetricsSendersType, MetricsUsageResponse, MetricsVolume, MetricsVolumeResponse, Optional, ServiceReportOptions, ServiceSubscriptionsResponse, SubAccountsAccount, SubAccountsApiKey, SubAccountsCreateApiKeyResponse, SubAccountsCreateResponse, SubAccountsCreateSmtpPasswordResponse, SubAccountsLimit, SubAccountsLimitResponse, SubAccountsListApiKeyOptions, SubAccountsListApiKeyResponse, SubAccountsListOptions, SubAccountsListResponse, SubAccountsListSmtpPasswordResponse, SubAccountsSmtpPassword, SubAccountsUsage, SubAccountsUsageResponse, SuccessResponse, SuppressionsCreateOptions, SuppressionsListEntry, SuppressionsListOptions, SuppressionsListResponse, SuppressionsSource, SuppressionsTypes, UsersCreateOptions, UsersCreateResponse, WebhooksListResponse, WebhooksSigningKeyResponse, WebhooksValidateResponse };