@nubea-ecomm/wapo-sdk 0.1.0 → 0.2.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
@@ -1,11 +1,17 @@
1
1
  # @nubea-ecomm/wapo-sdk
2
2
 
3
+ [![Wapo SDK version](https://img.shields.io/npm/v/%40nubea-ecomm%2Fwapo-sdk?label=Wapo%20SDK&color=171717)](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
@@ -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: string;
16
+ password?: string;
12
17
  role?: UserRole;
13
18
  all_projects?: boolean;
14
19
  project_ids?: string[];
@@ -1,5 +1,8 @@
1
1
  import { Transport } from './transport.js';
2
2
  export class WapoAdminClient extends Transport {
3
+ emailSettings() {
4
+ return this.request('GET', '/admin/v1/settings/email');
5
+ }
3
6
  whatsappSettings() {
4
7
  return this.request('GET', '/admin/v1/settings/whatsapp');
5
8
  }
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;
@@ -134,6 +183,7 @@ export interface ConsoleUser {
134
183
  language: 'es' | 'pt' | 'en';
135
184
  avatar_variant: number;
136
185
  active: boolean;
186
+ invitation_pending?: boolean;
137
187
  created_at: string;
138
188
  }
139
189
  export interface WhatsAppSettings {
@@ -150,6 +200,19 @@ export interface ProjectSettings extends Project {
150
200
  theme: 'light' | 'dark';
151
201
  };
152
202
  }
203
+ export interface NotificationSettings {
204
+ recipients: string[];
205
+ whatsapp_disconnected: boolean;
206
+ customer_needs_attention: boolean;
207
+ daily_stats: boolean;
208
+ weekly_stats: boolean;
209
+ smtp_configured: boolean;
210
+ project_users: Array<{
211
+ id: string;
212
+ name: string;
213
+ email: string;
214
+ }>;
215
+ }
153
216
  export interface LogEntry {
154
217
  id: string;
155
218
  source: 'api' | 'meta' | 'messages' | 'webhooks' | 'events';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nubea-ecomm/wapo-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Typed JavaScript and TypeScript client for the Wapo messaging API",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",