@zavudev/sdk 0.5.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/CHANGELOG.md +22 -0
- package/client.d.mts +14 -8
- package/client.d.mts.map +1 -1
- package/client.d.ts +14 -8
- package/client.d.ts.map +1 -1
- package/client.js +8 -0
- package/client.js.map +1 -1
- package/client.mjs +8 -0
- package/client.mjs.map +1 -1
- package/core/pagination.d.mts +54 -0
- package/core/pagination.d.mts.map +1 -0
- package/core/pagination.d.ts +54 -0
- package/core/pagination.d.ts.map +1 -0
- package/core/pagination.js +101 -0
- package/core/pagination.js.map +1 -0
- package/core/pagination.mjs +95 -0
- package/core/pagination.mjs.map +1 -0
- package/index.d.mts +1 -0
- package/index.d.mts.map +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/index.mjs +1 -0
- package/index.mjs.map +1 -1
- package/package.json +11 -1
- package/pagination.d.mts +2 -0
- package/pagination.d.mts.map +1 -0
- package/pagination.d.ts +2 -0
- package/pagination.d.ts.map +1 -0
- package/pagination.js +6 -0
- package/pagination.js.map +1 -0
- package/pagination.mjs +2 -0
- package/pagination.mjs.map +1 -0
- package/resources/contacts.d.mts +5 -9
- package/resources/contacts.d.mts.map +1 -1
- package/resources/contacts.d.ts +5 -9
- package/resources/contacts.d.ts.map +1 -1
- package/resources/contacts.js +2 -1
- package/resources/contacts.js.map +1 -1
- package/resources/contacts.mjs +2 -1
- package/resources/contacts.mjs.map +1 -1
- package/resources/index.d.mts +4 -4
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +4 -4
- package/resources/index.d.ts.map +1 -1
- package/resources/messages.d.mts +16 -13
- package/resources/messages.d.mts.map +1 -1
- package/resources/messages.d.ts +16 -13
- package/resources/messages.d.ts.map +1 -1
- package/resources/messages.js +6 -2
- package/resources/messages.js.map +1 -1
- package/resources/messages.mjs +6 -2
- package/resources/messages.mjs.map +1 -1
- package/resources/senders.d.mts +5 -9
- package/resources/senders.d.mts.map +1 -1
- package/resources/senders.d.ts +5 -9
- package/resources/senders.d.ts.map +1 -1
- package/resources/senders.js +2 -1
- package/resources/senders.js.map +1 -1
- package/resources/senders.mjs +2 -1
- package/resources/senders.mjs.map +1 -1
- package/resources/templates.d.mts +9 -10
- package/resources/templates.d.mts.map +1 -1
- package/resources/templates.d.ts +9 -10
- package/resources/templates.d.ts.map +1 -1
- package/resources/templates.js +6 -2
- package/resources/templates.js.map +1 -1
- package/resources/templates.mjs +6 -2
- package/resources/templates.mjs.map +1 -1
- package/src/client.ts +32 -8
- package/src/core/pagination.ts +152 -0
- package/src/index.ts +1 -0
- package/src/pagination.ts +2 -0
- package/src/resources/contacts.ts +7 -14
- package/src/resources/index.ts +4 -4
- package/src/resources/messages.ts +19 -18
- package/src/resources/senders.ts +7 -14
- package/src/resources/templates.ts +11 -15
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/src/client.ts
CHANGED
|
@@ -13,15 +13,17 @@ import * as Shims from './internal/shims';
|
|
|
13
13
|
import * as Opts from './internal/request-options';
|
|
14
14
|
import { VERSION } from './version';
|
|
15
15
|
import * as Errors from './core/error';
|
|
16
|
+
import * as Pagination from './core/pagination';
|
|
17
|
+
import { AbstractPage, type CursorParams, CursorResponse } from './core/pagination';
|
|
16
18
|
import * as Uploads from './core/uploads';
|
|
17
19
|
import * as API from './resources/index';
|
|
18
20
|
import { APIPromise } from './core/api-promise';
|
|
19
21
|
import {
|
|
20
22
|
Contact,
|
|
21
23
|
ContactListParams,
|
|
22
|
-
ContactListResponse,
|
|
23
24
|
ContactUpdateParams,
|
|
24
25
|
Contacts,
|
|
26
|
+
ContactsCursor,
|
|
25
27
|
} from './resources/contacts';
|
|
26
28
|
import {
|
|
27
29
|
Introspect,
|
|
@@ -34,28 +36,28 @@ import {
|
|
|
34
36
|
Message,
|
|
35
37
|
MessageContent,
|
|
36
38
|
MessageListParams,
|
|
37
|
-
MessageListResponse,
|
|
38
39
|
MessageReactParams,
|
|
39
40
|
MessageResponse,
|
|
40
41
|
MessageSendParams,
|
|
41
42
|
MessageStatus,
|
|
42
43
|
MessageType,
|
|
43
44
|
Messages,
|
|
45
|
+
MessagesCursor,
|
|
44
46
|
} from './resources/messages';
|
|
45
47
|
import {
|
|
46
48
|
Sender,
|
|
47
49
|
SenderCreateParams,
|
|
48
50
|
SenderListParams,
|
|
49
|
-
SenderListResponse,
|
|
50
51
|
SenderUpdateParams,
|
|
51
52
|
Senders,
|
|
53
|
+
SendersCursor,
|
|
52
54
|
} from './resources/senders';
|
|
53
55
|
import {
|
|
54
56
|
Template,
|
|
55
57
|
TemplateCreateParams,
|
|
56
58
|
TemplateListParams,
|
|
57
|
-
TemplateListResponse,
|
|
58
59
|
Templates,
|
|
60
|
+
TemplatesCursor,
|
|
59
61
|
WhatsappCategory,
|
|
60
62
|
} from './resources/templates';
|
|
61
63
|
import { type Fetch } from './internal/builtin-types';
|
|
@@ -523,6 +525,25 @@ export class Zavudev {
|
|
|
523
525
|
return { response, options, controller, requestLogID, retryOfRequestLogID, startTime };
|
|
524
526
|
}
|
|
525
527
|
|
|
528
|
+
getAPIList<Item, PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>>(
|
|
529
|
+
path: string,
|
|
530
|
+
Page: new (...args: any[]) => PageClass,
|
|
531
|
+
opts?: RequestOptions,
|
|
532
|
+
): Pagination.PagePromise<PageClass, Item> {
|
|
533
|
+
return this.requestAPIList(Page, { method: 'get', path, ...opts });
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
requestAPIList<
|
|
537
|
+
Item = unknown,
|
|
538
|
+
PageClass extends Pagination.AbstractPage<Item> = Pagination.AbstractPage<Item>,
|
|
539
|
+
>(
|
|
540
|
+
Page: new (...args: ConstructorParameters<typeof Pagination.AbstractPage>) => PageClass,
|
|
541
|
+
options: FinalRequestOptions,
|
|
542
|
+
): Pagination.PagePromise<PageClass, Item> {
|
|
543
|
+
const request = this.makeRequest(options, null, undefined);
|
|
544
|
+
return new Pagination.PagePromise<PageClass, Item>(this as any as Zavudev, request, Page);
|
|
545
|
+
}
|
|
546
|
+
|
|
526
547
|
async fetchWithTimeout(
|
|
527
548
|
url: RequestInfo,
|
|
528
549
|
init: RequestInit | undefined,
|
|
@@ -771,6 +792,9 @@ Zavudev.Introspect = Introspect;
|
|
|
771
792
|
export declare namespace Zavudev {
|
|
772
793
|
export type RequestOptions = Opts.RequestOptions;
|
|
773
794
|
|
|
795
|
+
export import Cursor = Pagination.Cursor;
|
|
796
|
+
export { type CursorParams as CursorParams, type CursorResponse as CursorResponse };
|
|
797
|
+
|
|
774
798
|
export {
|
|
775
799
|
Messages as Messages,
|
|
776
800
|
type Channel as Channel,
|
|
@@ -779,7 +803,7 @@ export declare namespace Zavudev {
|
|
|
779
803
|
type MessageResponse as MessageResponse,
|
|
780
804
|
type MessageStatus as MessageStatus,
|
|
781
805
|
type MessageType as MessageType,
|
|
782
|
-
type
|
|
806
|
+
type MessagesCursor as MessagesCursor,
|
|
783
807
|
type MessageListParams as MessageListParams,
|
|
784
808
|
type MessageReactParams as MessageReactParams,
|
|
785
809
|
type MessageSendParams as MessageSendParams,
|
|
@@ -789,7 +813,7 @@ export declare namespace Zavudev {
|
|
|
789
813
|
Templates as Templates,
|
|
790
814
|
type Template as Template,
|
|
791
815
|
type WhatsappCategory as WhatsappCategory,
|
|
792
|
-
type
|
|
816
|
+
type TemplatesCursor as TemplatesCursor,
|
|
793
817
|
type TemplateCreateParams as TemplateCreateParams,
|
|
794
818
|
type TemplateListParams as TemplateListParams,
|
|
795
819
|
};
|
|
@@ -797,7 +821,7 @@ export declare namespace Zavudev {
|
|
|
797
821
|
export {
|
|
798
822
|
Senders as Senders,
|
|
799
823
|
type Sender as Sender,
|
|
800
|
-
type
|
|
824
|
+
type SendersCursor as SendersCursor,
|
|
801
825
|
type SenderCreateParams as SenderCreateParams,
|
|
802
826
|
type SenderUpdateParams as SenderUpdateParams,
|
|
803
827
|
type SenderListParams as SenderListParams,
|
|
@@ -806,7 +830,7 @@ export declare namespace Zavudev {
|
|
|
806
830
|
export {
|
|
807
831
|
Contacts as Contacts,
|
|
808
832
|
type Contact as Contact,
|
|
809
|
-
type
|
|
833
|
+
type ContactsCursor as ContactsCursor,
|
|
810
834
|
type ContactUpdateParams as ContactUpdateParams,
|
|
811
835
|
type ContactListParams as ContactListParams,
|
|
812
836
|
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { ZavudevError } from './error';
|
|
4
|
+
import { FinalRequestOptions } from '../internal/request-options';
|
|
5
|
+
import { defaultParseResponse } from '../internal/parse';
|
|
6
|
+
import { type Zavudev } from '../client';
|
|
7
|
+
import { APIPromise } from './api-promise';
|
|
8
|
+
import { type APIResponseProps } from '../internal/parse';
|
|
9
|
+
import { maybeObj } from '../internal/utils/values';
|
|
10
|
+
|
|
11
|
+
export type PageRequestOptions = Pick<FinalRequestOptions, 'query' | 'headers' | 'body' | 'path' | 'method'>;
|
|
12
|
+
|
|
13
|
+
export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
|
|
14
|
+
#client: Zavudev;
|
|
15
|
+
protected options: FinalRequestOptions;
|
|
16
|
+
|
|
17
|
+
protected response: Response;
|
|
18
|
+
protected body: unknown;
|
|
19
|
+
|
|
20
|
+
constructor(client: Zavudev, response: Response, body: unknown, options: FinalRequestOptions) {
|
|
21
|
+
this.#client = client;
|
|
22
|
+
this.options = options;
|
|
23
|
+
this.response = response;
|
|
24
|
+
this.body = body;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
abstract nextPageRequestOptions(): PageRequestOptions | null;
|
|
28
|
+
|
|
29
|
+
abstract getPaginatedItems(): Item[];
|
|
30
|
+
|
|
31
|
+
hasNextPage(): boolean {
|
|
32
|
+
const items = this.getPaginatedItems();
|
|
33
|
+
if (!items.length) return false;
|
|
34
|
+
return this.nextPageRequestOptions() != null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async getNextPage(): Promise<this> {
|
|
38
|
+
const nextOptions = this.nextPageRequestOptions();
|
|
39
|
+
if (!nextOptions) {
|
|
40
|
+
throw new ZavudevError(
|
|
41
|
+
'No next page expected; please check `.hasNextPage()` before calling `.getNextPage()`.',
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return await this.#client.requestAPIList(this.constructor as any, nextOptions);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async *iterPages(): AsyncGenerator<this> {
|
|
49
|
+
let page: this = this;
|
|
50
|
+
yield page;
|
|
51
|
+
while (page.hasNextPage()) {
|
|
52
|
+
page = await page.getNextPage();
|
|
53
|
+
yield page;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
|
|
58
|
+
for await (const page of this.iterPages()) {
|
|
59
|
+
for (const item of page.getPaginatedItems()) {
|
|
60
|
+
yield item;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* This subclass of Promise will resolve to an instantiated Page once the request completes.
|
|
68
|
+
*
|
|
69
|
+
* It also implements AsyncIterable to allow auto-paginating iteration on an unawaited list call, eg:
|
|
70
|
+
*
|
|
71
|
+
* for await (const item of client.items.list()) {
|
|
72
|
+
* console.log(item)
|
|
73
|
+
* }
|
|
74
|
+
*/
|
|
75
|
+
export class PagePromise<
|
|
76
|
+
PageClass extends AbstractPage<Item>,
|
|
77
|
+
Item = ReturnType<PageClass['getPaginatedItems']>[number],
|
|
78
|
+
>
|
|
79
|
+
extends APIPromise<PageClass>
|
|
80
|
+
implements AsyncIterable<Item>
|
|
81
|
+
{
|
|
82
|
+
constructor(
|
|
83
|
+
client: Zavudev,
|
|
84
|
+
request: Promise<APIResponseProps>,
|
|
85
|
+
Page: new (...args: ConstructorParameters<typeof AbstractPage>) => PageClass,
|
|
86
|
+
) {
|
|
87
|
+
super(
|
|
88
|
+
client,
|
|
89
|
+
request,
|
|
90
|
+
async (client, props) =>
|
|
91
|
+
new Page(client, props.response, await defaultParseResponse(client, props), props.options),
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Allow auto-paginating iteration on an unawaited list call, eg:
|
|
97
|
+
*
|
|
98
|
+
* for await (const item of client.items.list()) {
|
|
99
|
+
* console.log(item)
|
|
100
|
+
* }
|
|
101
|
+
*/
|
|
102
|
+
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
|
|
103
|
+
const page = await this;
|
|
104
|
+
for await (const item of page) {
|
|
105
|
+
yield item;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface CursorResponse<Item> {
|
|
111
|
+
items: Array<Item>;
|
|
112
|
+
|
|
113
|
+
nextCursor: string;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface CursorParams {
|
|
117
|
+
cursor?: string;
|
|
118
|
+
|
|
119
|
+
limit?: number;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export class Cursor<Item> extends AbstractPage<Item> implements CursorResponse<Item> {
|
|
123
|
+
items: Array<Item>;
|
|
124
|
+
|
|
125
|
+
nextCursor: string;
|
|
126
|
+
|
|
127
|
+
constructor(client: Zavudev, response: Response, body: CursorResponse<Item>, options: FinalRequestOptions) {
|
|
128
|
+
super(client, response, body, options);
|
|
129
|
+
|
|
130
|
+
this.items = body.items || [];
|
|
131
|
+
this.nextCursor = body.nextCursor || '';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
getPaginatedItems(): Item[] {
|
|
135
|
+
return this.items ?? [];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
nextPageRequestOptions(): PageRequestOptions | null {
|
|
139
|
+
const cursor = this.nextCursor;
|
|
140
|
+
if (!cursor) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
...this.options,
|
|
146
|
+
query: {
|
|
147
|
+
...maybeObj(this.options.query),
|
|
148
|
+
cursor,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { Zavudev as default } from './client';
|
|
|
5
5
|
export { type Uploadable, toFile } from './core/uploads';
|
|
6
6
|
export { APIPromise } from './core/api-promise';
|
|
7
7
|
export { Zavudev, type ClientOptions } from './client';
|
|
8
|
+
export { PagePromise } from './core/pagination';
|
|
8
9
|
export {
|
|
9
10
|
ZavudevError,
|
|
10
11
|
APIError,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../core/resource';
|
|
4
4
|
import { APIPromise } from '../core/api-promise';
|
|
5
|
+
import { Cursor, type CursorParams, PagePromise } from '../core/pagination';
|
|
5
6
|
import { RequestOptions } from '../internal/request-options';
|
|
6
7
|
import { path } from '../internal/utils/path';
|
|
7
8
|
|
|
@@ -26,8 +27,8 @@ export class Contacts extends APIResource {
|
|
|
26
27
|
list(
|
|
27
28
|
query: ContactListParams | null | undefined = {},
|
|
28
29
|
options?: RequestOptions,
|
|
29
|
-
):
|
|
30
|
-
return this._client.
|
|
30
|
+
): PagePromise<ContactsCursor, Contact> {
|
|
31
|
+
return this._client.getAPIList('/v1/contacts', Cursor<Contact>, { query, ...options });
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
/**
|
|
@@ -38,6 +39,8 @@ export class Contacts extends APIResource {
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
export type ContactsCursor = Cursor<Contact>;
|
|
43
|
+
|
|
41
44
|
export interface Contact {
|
|
42
45
|
id: string;
|
|
43
46
|
|
|
@@ -70,12 +73,6 @@ export interface Contact {
|
|
|
70
73
|
verified?: boolean;
|
|
71
74
|
}
|
|
72
75
|
|
|
73
|
-
export interface ContactListResponse {
|
|
74
|
-
items: Array<Contact>;
|
|
75
|
-
|
|
76
|
-
nextCursor?: string | null;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
76
|
export interface ContactUpdateParams {
|
|
80
77
|
/**
|
|
81
78
|
* Preferred channel for this contact. Set to null to clear.
|
|
@@ -85,18 +82,14 @@ export interface ContactUpdateParams {
|
|
|
85
82
|
metadata?: { [key: string]: string };
|
|
86
83
|
}
|
|
87
84
|
|
|
88
|
-
export interface ContactListParams {
|
|
89
|
-
cursor?: string;
|
|
90
|
-
|
|
91
|
-
limit?: number;
|
|
92
|
-
|
|
85
|
+
export interface ContactListParams extends CursorParams {
|
|
93
86
|
phoneNumber?: string;
|
|
94
87
|
}
|
|
95
88
|
|
|
96
89
|
export declare namespace Contacts {
|
|
97
90
|
export {
|
|
98
91
|
type Contact as Contact,
|
|
99
|
-
type
|
|
92
|
+
type ContactsCursor as ContactsCursor,
|
|
100
93
|
type ContactUpdateParams as ContactUpdateParams,
|
|
101
94
|
type ContactListParams as ContactListParams,
|
|
102
95
|
};
|
package/src/resources/index.ts
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
export {
|
|
4
4
|
Contacts,
|
|
5
5
|
type Contact,
|
|
6
|
-
type ContactListResponse,
|
|
7
6
|
type ContactUpdateParams,
|
|
8
7
|
type ContactListParams,
|
|
8
|
+
type ContactsCursor,
|
|
9
9
|
} from './contacts';
|
|
10
10
|
export {
|
|
11
11
|
Introspect,
|
|
@@ -21,24 +21,24 @@ export {
|
|
|
21
21
|
type MessageResponse,
|
|
22
22
|
type MessageStatus,
|
|
23
23
|
type MessageType,
|
|
24
|
-
type MessageListResponse,
|
|
25
24
|
type MessageListParams,
|
|
26
25
|
type MessageReactParams,
|
|
27
26
|
type MessageSendParams,
|
|
27
|
+
type MessagesCursor,
|
|
28
28
|
} from './messages';
|
|
29
29
|
export {
|
|
30
30
|
Senders,
|
|
31
31
|
type Sender,
|
|
32
|
-
type SenderListResponse,
|
|
33
32
|
type SenderCreateParams,
|
|
34
33
|
type SenderUpdateParams,
|
|
35
34
|
type SenderListParams,
|
|
35
|
+
type SendersCursor,
|
|
36
36
|
} from './senders';
|
|
37
37
|
export {
|
|
38
38
|
Templates,
|
|
39
39
|
type Template,
|
|
40
40
|
type WhatsappCategory,
|
|
41
|
-
type TemplateListResponse,
|
|
42
41
|
type TemplateCreateParams,
|
|
43
42
|
type TemplateListParams,
|
|
43
|
+
type TemplatesCursor,
|
|
44
44
|
} from './templates';
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../core/resource';
|
|
4
4
|
import { APIPromise } from '../core/api-promise';
|
|
5
|
+
import { Cursor, type CursorParams, PagePromise } from '../core/pagination';
|
|
5
6
|
import { buildHeaders } from '../internal/headers';
|
|
6
7
|
import { RequestOptions } from '../internal/request-options';
|
|
7
8
|
import { path } from '../internal/utils/path';
|
|
@@ -26,14 +27,17 @@ export class Messages extends APIResource {
|
|
|
26
27
|
*
|
|
27
28
|
* @example
|
|
28
29
|
* ```ts
|
|
29
|
-
*
|
|
30
|
+
* // Automatically fetches more pages as needed.
|
|
31
|
+
* for await (const message of client.messages.list()) {
|
|
32
|
+
* // ...
|
|
33
|
+
* }
|
|
30
34
|
* ```
|
|
31
35
|
*/
|
|
32
36
|
list(
|
|
33
37
|
query: MessageListParams | null | undefined = {},
|
|
34
38
|
options?: RequestOptions,
|
|
35
|
-
):
|
|
36
|
-
return this._client.
|
|
39
|
+
): PagePromise<MessagesCursor, Message> {
|
|
40
|
+
return this._client.getAPIList('/v1/messages', Cursor<Message>, { query, ...options });
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
/**
|
|
@@ -99,6 +103,8 @@ export class Messages extends APIResource {
|
|
|
99
103
|
}
|
|
100
104
|
}
|
|
101
105
|
|
|
106
|
+
export type MessagesCursor = Cursor<Message>;
|
|
107
|
+
|
|
102
108
|
/**
|
|
103
109
|
* Delivery channel. Use 'auto' for intelligent routing.
|
|
104
110
|
*/
|
|
@@ -129,14 +135,19 @@ export interface Message {
|
|
|
129
135
|
content?: MessageContent;
|
|
130
136
|
|
|
131
137
|
/**
|
|
132
|
-
*
|
|
138
|
+
* MAU cost in USD (charged for first contact of the month).
|
|
133
139
|
*/
|
|
134
140
|
cost?: number | null;
|
|
135
141
|
|
|
136
142
|
/**
|
|
137
|
-
* Provider
|
|
143
|
+
* Provider cost in USD (Telnyx, SES, etc.).
|
|
138
144
|
*/
|
|
139
|
-
costProvider?:
|
|
145
|
+
costProvider?: number | null;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Total cost in USD (MAU + provider cost).
|
|
149
|
+
*/
|
|
150
|
+
costTotal?: number | null;
|
|
140
151
|
|
|
141
152
|
errorCode?: string | null;
|
|
142
153
|
|
|
@@ -299,22 +310,12 @@ export type MessageType =
|
|
|
299
310
|
| 'reaction'
|
|
300
311
|
| 'template';
|
|
301
312
|
|
|
302
|
-
export interface
|
|
303
|
-
items: Array<Message>;
|
|
304
|
-
|
|
305
|
-
nextCursor?: string | null;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
export interface MessageListParams {
|
|
313
|
+
export interface MessageListParams extends CursorParams {
|
|
309
314
|
/**
|
|
310
315
|
* Delivery channel. Use 'auto' for intelligent routing.
|
|
311
316
|
*/
|
|
312
317
|
channel?: Channel;
|
|
313
318
|
|
|
314
|
-
cursor?: string;
|
|
315
|
-
|
|
316
|
-
limit?: number;
|
|
317
|
-
|
|
318
319
|
status?: MessageStatus;
|
|
319
320
|
|
|
320
321
|
to?: string;
|
|
@@ -403,7 +404,7 @@ export declare namespace Messages {
|
|
|
403
404
|
type MessageResponse as MessageResponse,
|
|
404
405
|
type MessageStatus as MessageStatus,
|
|
405
406
|
type MessageType as MessageType,
|
|
406
|
-
type
|
|
407
|
+
type MessagesCursor as MessagesCursor,
|
|
407
408
|
type MessageListParams as MessageListParams,
|
|
408
409
|
type MessageReactParams as MessageReactParams,
|
|
409
410
|
type MessageSendParams as MessageSendParams,
|
package/src/resources/senders.ts
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../core/resource';
|
|
4
4
|
import { APIPromise } from '../core/api-promise';
|
|
5
|
+
import { Cursor, type CursorParams, PagePromise } from '../core/pagination';
|
|
5
6
|
import { buildHeaders } from '../internal/headers';
|
|
6
7
|
import { RequestOptions } from '../internal/request-options';
|
|
7
8
|
import { path } from '../internal/utils/path';
|
|
@@ -34,8 +35,8 @@ export class Senders extends APIResource {
|
|
|
34
35
|
list(
|
|
35
36
|
query: SenderListParams | null | undefined = {},
|
|
36
37
|
options?: RequestOptions,
|
|
37
|
-
):
|
|
38
|
-
return this._client.
|
|
38
|
+
): PagePromise<SendersCursor, Sender> {
|
|
39
|
+
return this._client.getAPIList('/v1/senders', Cursor<Sender>, { query, ...options });
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
/**
|
|
@@ -49,6 +50,8 @@ export class Senders extends APIResource {
|
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
|
|
53
|
+
export type SendersCursor = Cursor<Sender>;
|
|
54
|
+
|
|
52
55
|
export interface Sender {
|
|
53
56
|
id: string;
|
|
54
57
|
|
|
@@ -69,12 +72,6 @@ export interface Sender {
|
|
|
69
72
|
updatedAt?: string;
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
export interface SenderListResponse {
|
|
73
|
-
items: Array<Sender>;
|
|
74
|
-
|
|
75
|
-
nextCursor?: string | null;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
75
|
export interface SenderCreateParams {
|
|
79
76
|
name: string;
|
|
80
77
|
|
|
@@ -89,16 +86,12 @@ export interface SenderUpdateParams {
|
|
|
89
86
|
setAsDefault?: boolean;
|
|
90
87
|
}
|
|
91
88
|
|
|
92
|
-
export interface SenderListParams {
|
|
93
|
-
cursor?: string;
|
|
94
|
-
|
|
95
|
-
limit?: number;
|
|
96
|
-
}
|
|
89
|
+
export interface SenderListParams extends CursorParams {}
|
|
97
90
|
|
|
98
91
|
export declare namespace Senders {
|
|
99
92
|
export {
|
|
100
93
|
type Sender as Sender,
|
|
101
|
-
type
|
|
94
|
+
type SendersCursor as SendersCursor,
|
|
102
95
|
type SenderCreateParams as SenderCreateParams,
|
|
103
96
|
type SenderUpdateParams as SenderUpdateParams,
|
|
104
97
|
type SenderListParams as SenderListParams,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../core/resource';
|
|
4
4
|
import { APIPromise } from '../core/api-promise';
|
|
5
|
+
import { Cursor, type CursorParams, PagePromise } from '../core/pagination';
|
|
5
6
|
import { buildHeaders } from '../internal/headers';
|
|
6
7
|
import { RequestOptions } from '../internal/request-options';
|
|
7
8
|
import { path } from '../internal/utils/path';
|
|
@@ -45,14 +46,17 @@ export class Templates extends APIResource {
|
|
|
45
46
|
*
|
|
46
47
|
* @example
|
|
47
48
|
* ```ts
|
|
48
|
-
*
|
|
49
|
+
* // Automatically fetches more pages as needed.
|
|
50
|
+
* for await (const template of client.templates.list()) {
|
|
51
|
+
* // ...
|
|
52
|
+
* }
|
|
49
53
|
* ```
|
|
50
54
|
*/
|
|
51
55
|
list(
|
|
52
56
|
query: TemplateListParams | null | undefined = {},
|
|
53
57
|
options?: RequestOptions,
|
|
54
|
-
):
|
|
55
|
-
return this._client.
|
|
58
|
+
): PagePromise<TemplatesCursor, Template> {
|
|
59
|
+
return this._client.getAPIList('/v1/templates', Cursor<Template>, { query, ...options });
|
|
56
60
|
}
|
|
57
61
|
|
|
58
62
|
/**
|
|
@@ -71,6 +75,8 @@ export class Templates extends APIResource {
|
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
|
|
78
|
+
export type TemplatesCursor = Cursor<Template>;
|
|
79
|
+
|
|
74
80
|
export interface Template {
|
|
75
81
|
id: string;
|
|
76
82
|
|
|
@@ -168,12 +174,6 @@ export namespace Template {
|
|
|
168
174
|
*/
|
|
169
175
|
export type WhatsappCategory = 'UTILITY' | 'MARKETING' | 'AUTHENTICATION';
|
|
170
176
|
|
|
171
|
-
export interface TemplateListResponse {
|
|
172
|
-
items: Array<Template>;
|
|
173
|
-
|
|
174
|
-
nextCursor?: string | null;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
177
|
export interface TemplateCreateParams {
|
|
178
178
|
body: string;
|
|
179
179
|
|
|
@@ -189,17 +189,13 @@ export interface TemplateCreateParams {
|
|
|
189
189
|
whatsappCategory?: WhatsappCategory;
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
export interface TemplateListParams {
|
|
193
|
-
cursor?: string;
|
|
194
|
-
|
|
195
|
-
limit?: number;
|
|
196
|
-
}
|
|
192
|
+
export interface TemplateListParams extends CursorParams {}
|
|
197
193
|
|
|
198
194
|
export declare namespace Templates {
|
|
199
195
|
export {
|
|
200
196
|
type Template as Template,
|
|
201
197
|
type WhatsappCategory as WhatsappCategory,
|
|
202
|
-
type
|
|
198
|
+
type TemplatesCursor as TemplatesCursor,
|
|
203
199
|
type TemplateCreateParams as TemplateCreateParams,
|
|
204
200
|
type TemplateListParams as TemplateListParams,
|
|
205
201
|
};
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.7.0'; // x-release-please-version
|
package/version.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.7.0";
|
|
2
2
|
//# sourceMappingURL=version.d.mts.map
|
package/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.
|
|
1
|
+
export declare const VERSION = "0.7.0";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/version.js
CHANGED
package/version.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.
|
|
1
|
+
export const VERSION = '0.7.0'; // x-release-please-version
|
|
2
2
|
//# sourceMappingURL=version.mjs.map
|