@nubea-ecomm/wapo-sdk 0.1.0 → 0.3.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 +6 -0
- package/dist/admin-client.d.ts +6 -1
- package/dist/admin-client.js +3 -0
- package/dist/auth-client.d.ts +28 -1
- package/dist/auth-client.js +35 -0
- package/dist/client.d.ts +31 -1
- package/dist/client.js +36 -0
- package/dist/types.d.ts +64 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
# @nubea-ecomm/wapo-sdk
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@nubea-ecomm/wapo-sdk)
|
|
4
|
+
|
|
3
5
|
Typed JavaScript and TypeScript client for the public Wapo messaging API.
|
|
4
6
|
|
|
5
7
|
## Install
|
|
6
8
|
|
|
9
|
+
Choose the command for your package manager:
|
|
10
|
+
|
|
7
11
|
```bash
|
|
8
12
|
npm install @nubea-ecomm/wapo-sdk
|
|
13
|
+
# or: pnpm add @nubea-ecomm/wapo-sdk
|
|
14
|
+
# or: yarn add @nubea-ecomm/wapo-sdk
|
|
9
15
|
```
|
|
10
16
|
|
|
11
17
|
Node.js 18 or newer is required. Modern browsers with `fetch` and
|
package/dist/admin-client.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Transport } from './transport.js';
|
|
2
2
|
import type { UserRole, ApiKey, Page, Project, ConsoleUser, WhatsAppSettings } from './types.js';
|
|
3
3
|
export declare class WapoAdminClient extends Transport {
|
|
4
|
+
emailSettings(): Promise<{
|
|
5
|
+
data: {
|
|
6
|
+
smtp_configured: boolean;
|
|
7
|
+
};
|
|
8
|
+
}>;
|
|
4
9
|
whatsappSettings(): Promise<{
|
|
5
10
|
data: WhatsAppSettings;
|
|
6
11
|
}>;
|
|
@@ -8,7 +13,7 @@ export declare class WapoAdminClient extends Transport {
|
|
|
8
13
|
createUser(input: {
|
|
9
14
|
name: string;
|
|
10
15
|
email: string;
|
|
11
|
-
password
|
|
16
|
+
password?: string;
|
|
12
17
|
role?: UserRole;
|
|
13
18
|
all_projects?: boolean;
|
|
14
19
|
project_ids?: string[];
|
package/dist/admin-client.js
CHANGED
package/dist/auth-client.d.ts
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import { Transport } from './transport.js';
|
|
2
|
-
import type { ConsoleUser } from './types.js';
|
|
2
|
+
import type { ConsoleUser, Project } from './types.js';
|
|
3
3
|
export declare class WapoAuthClient extends Transport {
|
|
4
|
+
sessions(): Promise<{
|
|
5
|
+
data: {
|
|
6
|
+
id: string;
|
|
7
|
+
expires_at: string;
|
|
8
|
+
current: boolean;
|
|
9
|
+
}[];
|
|
10
|
+
}>;
|
|
11
|
+
revokeSession(id: string): Promise<unknown>;
|
|
12
|
+
changePassword(currentPassword: string, password: string): Promise<unknown>;
|
|
13
|
+
register(input: {
|
|
14
|
+
name: string;
|
|
15
|
+
email: string;
|
|
16
|
+
password: string;
|
|
17
|
+
}): Promise<unknown>;
|
|
18
|
+
confirm(token: string): Promise<unknown>;
|
|
19
|
+
resendConfirmation(email: string): Promise<unknown>;
|
|
20
|
+
recover(email: string): Promise<unknown>;
|
|
21
|
+
resetPassword(token: string, password: string): Promise<unknown>;
|
|
22
|
+
createProject(name: string): Promise<{
|
|
23
|
+
data: Project;
|
|
24
|
+
}>;
|
|
25
|
+
acceptProjectInvitation(token: string): Promise<{
|
|
26
|
+
data: {
|
|
27
|
+
project_id: string;
|
|
28
|
+
accepted: boolean;
|
|
29
|
+
};
|
|
30
|
+
}>;
|
|
4
31
|
me(): Promise<{
|
|
5
32
|
data: {
|
|
6
33
|
user: ConsoleUser;
|
package/dist/auth-client.js
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
import { Transport } from './transport.js';
|
|
2
2
|
export class WapoAuthClient extends Transport {
|
|
3
|
+
sessions() {
|
|
4
|
+
return this.request('GET', '/auth/v1/sessions');
|
|
5
|
+
}
|
|
6
|
+
revokeSession(id) {
|
|
7
|
+
return this.request('DELETE', `/auth/v1/sessions/${encodeURIComponent(id)}`);
|
|
8
|
+
}
|
|
9
|
+
changePassword(currentPassword, password) {
|
|
10
|
+
return this.request('POST', '/auth/v1/password', {
|
|
11
|
+
current_password: currentPassword,
|
|
12
|
+
password,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
register(input) {
|
|
16
|
+
return this.request('POST', '/auth/v1/register', input);
|
|
17
|
+
}
|
|
18
|
+
confirm(token) {
|
|
19
|
+
return this.request('POST', '/auth/v1/confirm', { token });
|
|
20
|
+
}
|
|
21
|
+
resendConfirmation(email) {
|
|
22
|
+
return this.request('POST', '/auth/v1/confirm/resend', { email });
|
|
23
|
+
}
|
|
24
|
+
recover(email) {
|
|
25
|
+
return this.request('POST', '/auth/v1/recover', { email });
|
|
26
|
+
}
|
|
27
|
+
resetPassword(token, password) {
|
|
28
|
+
return this.request('POST', '/auth/v1/recover/end', { token, password });
|
|
29
|
+
}
|
|
30
|
+
createProject(name) {
|
|
31
|
+
return this.request('POST', '/auth/v1/projects', {
|
|
32
|
+
name,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
acceptProjectInvitation(token) {
|
|
36
|
+
return this.request('POST', `/auth/v1/project-invitations/${encodeURIComponent(token)}`);
|
|
37
|
+
}
|
|
3
38
|
me() {
|
|
4
39
|
return this.request('GET', '/auth/v1/me');
|
|
5
40
|
}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Transport } from './transport.js';
|
|
2
|
-
import type { ApiKey, MessageTemplate, TemplateInput, ProjectSettings, Connection, Conversation, Customer, CustomerInput, Message, Page, SetupLink, SetupLinkInput, Webhook } from './types.js';
|
|
2
|
+
import type { ApiKey, MessageTemplate, TemplateInput, ProjectSettings, NotificationSettings, Connection, BusinessProfile, BusinessProfileInput, Contact, ContactInput, Conversation, Customer, CustomerInput, Message, Page, SetupLink, SetupLinkInput, Webhook } from './types.js';
|
|
3
3
|
export declare class WapoClient extends Transport {
|
|
4
4
|
project(): Promise<{
|
|
5
5
|
data: ProjectSettings;
|
|
@@ -10,6 +10,12 @@ export declare class WapoClient extends Transport {
|
|
|
10
10
|
}): Promise<{
|
|
11
11
|
data: ProjectSettings;
|
|
12
12
|
}>;
|
|
13
|
+
notificationSettings(): Promise<{
|
|
14
|
+
data: NotificationSettings;
|
|
15
|
+
}>;
|
|
16
|
+
updateNotificationSettings(input: Omit<NotificationSettings, 'smtp_configured' | 'project_users'>): Promise<{
|
|
17
|
+
data: NotificationSettings;
|
|
18
|
+
}>;
|
|
13
19
|
me(): Promise<{
|
|
14
20
|
data: {
|
|
15
21
|
project_id: string;
|
|
@@ -47,6 +53,30 @@ export declare class WapoClient extends Transport {
|
|
|
47
53
|
data: Connection;
|
|
48
54
|
}>;
|
|
49
55
|
deleteConnection(id: string): Promise<unknown>;
|
|
56
|
+
businessProfile(connectionId: string): Promise<{
|
|
57
|
+
data: BusinessProfile;
|
|
58
|
+
}>;
|
|
59
|
+
updateBusinessProfile(connectionId: string, input: BusinessProfileInput): Promise<{
|
|
60
|
+
data: BusinessProfile;
|
|
61
|
+
}>;
|
|
62
|
+
listContacts(options?: {
|
|
63
|
+
after?: string;
|
|
64
|
+
search?: string;
|
|
65
|
+
connection_id?: string;
|
|
66
|
+
marketing_status?: 'stopped' | 'resumed';
|
|
67
|
+
}): Promise<Page<Contact>>;
|
|
68
|
+
contact(id: string): Promise<{
|
|
69
|
+
data: Contact;
|
|
70
|
+
}>;
|
|
71
|
+
createContact(input: ContactInput): Promise<{
|
|
72
|
+
data: Contact;
|
|
73
|
+
}>;
|
|
74
|
+
updateContact(id: string, input: Partial<Pick<ContactInput, 'display_name' | 'email' | 'properties'>> & {
|
|
75
|
+
use_provider_name?: true;
|
|
76
|
+
}): Promise<{
|
|
77
|
+
data: Contact;
|
|
78
|
+
}>;
|
|
79
|
+
eraseContact(id: string): Promise<unknown>;
|
|
50
80
|
listMessages(connectionId?: string): Promise<Page<Message>>;
|
|
51
81
|
sendText(connectionId: string, to: string, text: string, idempotencyKey: string): Promise<{
|
|
52
82
|
data: Message;
|
package/dist/client.js
CHANGED
|
@@ -7,6 +7,12 @@ export class WapoClient extends Transport {
|
|
|
7
7
|
updateProject(input) {
|
|
8
8
|
return this.request('PATCH', '/v1/project', input);
|
|
9
9
|
}
|
|
10
|
+
notificationSettings() {
|
|
11
|
+
return this.request('GET', '/v1/notification-settings');
|
|
12
|
+
}
|
|
13
|
+
updateNotificationSettings(input) {
|
|
14
|
+
return this.request('PATCH', '/v1/notification-settings', input);
|
|
15
|
+
}
|
|
10
16
|
me() {
|
|
11
17
|
return this.request('GET', '/v1/me');
|
|
12
18
|
}
|
|
@@ -40,6 +46,36 @@ export class WapoClient extends Transport {
|
|
|
40
46
|
deleteConnection(id) {
|
|
41
47
|
return this.request('DELETE', `/v1/connections/${encode(id)}`);
|
|
42
48
|
}
|
|
49
|
+
businessProfile(connectionId) {
|
|
50
|
+
return this.request('GET', `/v1/connections/${encode(connectionId)}/business-profile`);
|
|
51
|
+
}
|
|
52
|
+
updateBusinessProfile(connectionId, input) {
|
|
53
|
+
return this.request('PATCH', `/v1/connections/${encode(connectionId)}/business-profile`, input);
|
|
54
|
+
}
|
|
55
|
+
listContacts(options = {}) {
|
|
56
|
+
const query = new URLSearchParams();
|
|
57
|
+
if (options.after)
|
|
58
|
+
query.set('after', options.after);
|
|
59
|
+
if (options.search)
|
|
60
|
+
query.set('search', options.search);
|
|
61
|
+
if (options.connection_id)
|
|
62
|
+
query.set('connection_id', options.connection_id);
|
|
63
|
+
if (options.marketing_status)
|
|
64
|
+
query.set('marketing_status', options.marketing_status);
|
|
65
|
+
return this.request('GET', `/v1/contacts${query.size ? `?${query.toString()}` : ''}`);
|
|
66
|
+
}
|
|
67
|
+
contact(id) {
|
|
68
|
+
return this.request('GET', `/v1/contacts/${encode(id)}`);
|
|
69
|
+
}
|
|
70
|
+
createContact(input) {
|
|
71
|
+
return this.request('POST', '/v1/contacts', input);
|
|
72
|
+
}
|
|
73
|
+
updateContact(id, input) {
|
|
74
|
+
return this.request('PATCH', `/v1/contacts/${encode(id)}`, input);
|
|
75
|
+
}
|
|
76
|
+
eraseContact(id) {
|
|
77
|
+
return this.request('DELETE', `/v1/contacts/${encode(id)}`);
|
|
78
|
+
}
|
|
43
79
|
listMessages(connectionId) {
|
|
44
80
|
return this.request('GET', `/v1/messages${connectionId ? `?connection_id=${encode(connectionId)}` : ''}`);
|
|
45
81
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -33,6 +33,55 @@ export interface Connection {
|
|
|
33
33
|
credential_status?: 'valid' | 'expired';
|
|
34
34
|
access_token_expires_at?: string;
|
|
35
35
|
}
|
|
36
|
+
export type BusinessVertical = 'ALCOHOL' | 'APPAREL' | 'AUTO' | 'BEAUTY' | 'EDU' | 'ENTERTAIN' | 'EVENT_PLAN' | 'FINANCE' | 'GOVT' | 'GROCERY' | 'HEALTH' | 'HOTEL' | 'NONPROFIT' | 'ONLINE_GAMBLING' | 'OTC_DRUGS' | 'OTHER' | 'PHYSICAL_GAMBLING' | 'PROF_SERVICES' | 'RESTAURANT' | 'RETAIL' | 'TRAVEL';
|
|
37
|
+
export interface BusinessProfile {
|
|
38
|
+
about?: string;
|
|
39
|
+
address?: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
email?: string;
|
|
42
|
+
profile_picture_url?: string;
|
|
43
|
+
websites?: string[];
|
|
44
|
+
vertical?: BusinessVertical;
|
|
45
|
+
}
|
|
46
|
+
export interface BusinessProfileInput extends Omit<BusinessProfile, 'profile_picture_url'> {
|
|
47
|
+
profile_picture_handle?: string;
|
|
48
|
+
}
|
|
49
|
+
export type ContactProperty = string | number | boolean | null;
|
|
50
|
+
export interface MarketingPreference {
|
|
51
|
+
status: 'stopped' | 'resumed';
|
|
52
|
+
marketing_allowed: boolean;
|
|
53
|
+
detail: string;
|
|
54
|
+
source: '' | 'meta_webhook' | 'meta_delivery_error' | 'meta_synchronous_error';
|
|
55
|
+
sequence: number;
|
|
56
|
+
last_event_at?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface Contact {
|
|
59
|
+
id: string;
|
|
60
|
+
connection_id: string;
|
|
61
|
+
customer_id?: string;
|
|
62
|
+
wa_id: string;
|
|
63
|
+
phone_number: string;
|
|
64
|
+
business_scoped_user_id?: string;
|
|
65
|
+
parent_business_scoped_user_id?: string;
|
|
66
|
+
username?: string;
|
|
67
|
+
profile_name?: string;
|
|
68
|
+
display_name: string;
|
|
69
|
+
display_name_source: 'local' | 'meta' | 'username' | 'phone';
|
|
70
|
+
email?: string;
|
|
71
|
+
properties: Record<string, ContactProperty>;
|
|
72
|
+
phone_number_id: string;
|
|
73
|
+
connection_name?: string;
|
|
74
|
+
marketing_preference: MarketingPreference;
|
|
75
|
+
created_at: string;
|
|
76
|
+
updated_at: string;
|
|
77
|
+
}
|
|
78
|
+
export interface ContactInput {
|
|
79
|
+
connection_id: string;
|
|
80
|
+
phone_number: string;
|
|
81
|
+
display_name: string;
|
|
82
|
+
email?: string;
|
|
83
|
+
properties?: Record<string, ContactProperty>;
|
|
84
|
+
}
|
|
36
85
|
export interface Message {
|
|
37
86
|
id: string;
|
|
38
87
|
connection_id: string;
|
|
@@ -125,6 +174,7 @@ export interface CustomerInput {
|
|
|
125
174
|
metadata?: Record<string, unknown>;
|
|
126
175
|
}
|
|
127
176
|
export interface ConsoleUser {
|
|
177
|
+
project_roles?: Record<string, 'admin' | 'member' | 'viewer' | 'billing'>;
|
|
128
178
|
role: UserRole;
|
|
129
179
|
all_projects: boolean;
|
|
130
180
|
project_ids: string[];
|
|
@@ -134,6 +184,7 @@ export interface ConsoleUser {
|
|
|
134
184
|
language: 'es' | 'pt' | 'en';
|
|
135
185
|
avatar_variant: number;
|
|
136
186
|
active: boolean;
|
|
187
|
+
invitation_pending?: boolean;
|
|
137
188
|
created_at: string;
|
|
138
189
|
}
|
|
139
190
|
export interface WhatsAppSettings {
|
|
@@ -150,6 +201,19 @@ export interface ProjectSettings extends Project {
|
|
|
150
201
|
theme: 'light' | 'dark';
|
|
151
202
|
};
|
|
152
203
|
}
|
|
204
|
+
export interface NotificationSettings {
|
|
205
|
+
recipients: string[];
|
|
206
|
+
whatsapp_disconnected: boolean;
|
|
207
|
+
customer_needs_attention: boolean;
|
|
208
|
+
daily_stats: boolean;
|
|
209
|
+
weekly_stats: boolean;
|
|
210
|
+
smtp_configured: boolean;
|
|
211
|
+
project_users: Array<{
|
|
212
|
+
id: string;
|
|
213
|
+
name: string;
|
|
214
|
+
email: string;
|
|
215
|
+
}>;
|
|
216
|
+
}
|
|
153
217
|
export interface LogEntry {
|
|
154
218
|
id: string;
|
|
155
219
|
source: 'api' | 'meta' | 'messages' | 'webhooks' | 'events';
|