@raphaelvserafim/client-api-whatsapp 1.0.9 → 1.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.
Files changed (66) hide show
  1. package/README.md +512 -297
  2. package/dist/WhatsApp.d.ts +177 -33
  3. package/dist/WhatsApp.js +146 -167
  4. package/dist/WhatsApp.js.map +1 -1
  5. package/dist/client/HttpClient.d.ts +6 -0
  6. package/dist/client/HttpClient.js +29 -0
  7. package/dist/client/HttpClient.js.map +1 -0
  8. package/dist/client/IHttpClient.d.ts +9 -0
  9. package/dist/client/IHttpClient.js +3 -0
  10. package/dist/client/IHttpClient.js.map +1 -0
  11. package/dist/errors.d.ts +5 -0
  12. package/dist/errors.js +13 -0
  13. package/dist/errors.js.map +1 -0
  14. package/dist/index.d.ts +16 -1
  15. package/dist/index.js +37 -3
  16. package/dist/index.js.map +1 -1
  17. package/dist/services/ActionService.d.ts +9 -0
  18. package/dist/services/ActionService.js +32 -0
  19. package/dist/services/ActionService.js.map +1 -0
  20. package/dist/services/BusinessService.d.ts +10 -0
  21. package/dist/services/BusinessService.js +43 -0
  22. package/dist/services/BusinessService.js.map +1 -0
  23. package/dist/services/CallService.d.ts +10 -0
  24. package/dist/services/CallService.js +38 -0
  25. package/dist/services/CallService.js.map +1 -0
  26. package/dist/services/ChatService.d.ts +19 -0
  27. package/dist/services/ChatService.js +63 -0
  28. package/dist/services/ChatService.js.map +1 -0
  29. package/dist/services/CommunityService.d.ts +35 -0
  30. package/dist/services/CommunityService.js +125 -0
  31. package/dist/services/CommunityService.js.map +1 -0
  32. package/dist/services/ContactService.d.ts +21 -0
  33. package/dist/services/ContactService.js +68 -0
  34. package/dist/services/ContactService.js.map +1 -0
  35. package/dist/services/GroupService.d.ts +37 -0
  36. package/dist/services/GroupService.js +117 -0
  37. package/dist/services/GroupService.js.map +1 -0
  38. package/dist/services/InstanceService.d.ts +29 -0
  39. package/dist/services/InstanceService.js +130 -0
  40. package/dist/services/InstanceService.js.map +1 -0
  41. package/dist/services/LabelService.d.ts +18 -0
  42. package/dist/services/LabelService.js +49 -0
  43. package/dist/services/LabelService.js.map +1 -0
  44. package/dist/services/MessageService.d.ts +60 -0
  45. package/dist/services/MessageService.js +171 -0
  46. package/dist/services/MessageService.js.map +1 -0
  47. package/dist/services/NewsletterService.d.ts +23 -0
  48. package/dist/services/NewsletterService.js +129 -0
  49. package/dist/services/NewsletterService.js.map +1 -0
  50. package/dist/services/StatusService.d.ts +14 -0
  51. package/dist/services/StatusService.js +46 -0
  52. package/dist/services/StatusService.js.map +1 -0
  53. package/dist/types/index.d.ts +206 -11
  54. package/dist/types/index.js +12 -0
  55. package/dist/types/index.js.map +1 -1
  56. package/package.json +6 -11
  57. package/.babelrc +0 -3
  58. package/dist/exemple.d.ts +0 -1
  59. package/dist/exemple.js +0 -264
  60. package/dist/exemple.js.map +0 -1
  61. package/src/WhatsApp.ts +0 -245
  62. package/src/exemple.ts +0 -312
  63. package/src/index.ts +0 -2
  64. package/src/types/index.ts +0 -190
  65. package/tsconfig.compile.json +0 -15
  66. package/tsconfig.json +0 -35
@@ -0,0 +1,125 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommunityService = void 0;
4
+ const types_1 = require("../types");
5
+ class CommunityService {
6
+ constructor(http) {
7
+ this.http = http;
8
+ }
9
+ async list() {
10
+ return this.http.request({
11
+ route: types_1.Routes.COMMUNITY,
12
+ method: types_1.HttpMethod.GET,
13
+ });
14
+ }
15
+ async create(data) {
16
+ return this.http.request({
17
+ route: types_1.Routes.COMMUNITY,
18
+ method: types_1.HttpMethod.POST,
19
+ body: data,
20
+ });
21
+ }
22
+ async info(id) {
23
+ return this.http.request({
24
+ route: `${types_1.Routes.COMMUNITY}/${id}`,
25
+ method: types_1.HttpMethod.GET,
26
+ });
27
+ }
28
+ async update(id, data) {
29
+ return this.http.request({
30
+ route: `${types_1.Routes.COMMUNITY}/${id}`,
31
+ method: types_1.HttpMethod.PUT,
32
+ body: data,
33
+ });
34
+ }
35
+ async leave(id) {
36
+ return this.http.request({
37
+ route: `${types_1.Routes.COMMUNITY}/${id}`,
38
+ method: types_1.HttpMethod.DELETE,
39
+ });
40
+ }
41
+ async updatePicture(id, url) {
42
+ return this.http.request({
43
+ route: `${types_1.Routes.COMMUNITY}/${id}/picture`,
44
+ method: types_1.HttpMethod.PUT,
45
+ body: { url },
46
+ });
47
+ }
48
+ async getInviteCode(id) {
49
+ return this.http.request({
50
+ route: `${types_1.Routes.COMMUNITY}/${id}/invite`,
51
+ method: types_1.HttpMethod.POST,
52
+ });
53
+ }
54
+ async removeParticipants(id, participants) {
55
+ return this.http.request({
56
+ route: `${types_1.Routes.COMMUNITY}/${id}/participants`,
57
+ method: types_1.HttpMethod.DELETE,
58
+ body: { participants },
59
+ });
60
+ }
61
+ async getRequestParticipants(id) {
62
+ return this.http.request({
63
+ route: `${types_1.Routes.COMMUNITY}/${id}/request_participants_list`,
64
+ method: types_1.HttpMethod.GET,
65
+ });
66
+ }
67
+ async updateRequestParticipants(id, data) {
68
+ return this.http.request({
69
+ route: `${types_1.Routes.COMMUNITY}/${id}/request_participants_list`,
70
+ method: types_1.HttpMethod.PUT,
71
+ body: data,
72
+ });
73
+ }
74
+ async acceptInvite(code) {
75
+ return this.http.request({
76
+ route: `${types_1.Routes.COMMUNITY}/invite/accept`,
77
+ method: types_1.HttpMethod.POST,
78
+ body: { code },
79
+ });
80
+ }
81
+ async getInviteInfo(code) {
82
+ return this.http.request({
83
+ route: `${types_1.Routes.COMMUNITY}/invite/info`,
84
+ method: types_1.HttpMethod.GET,
85
+ params: { code },
86
+ });
87
+ }
88
+ async createGroup(id, data) {
89
+ return this.http.request({
90
+ route: `${types_1.Routes.COMMUNITY}/${id}/group`,
91
+ method: types_1.HttpMethod.POST,
92
+ body: data,
93
+ });
94
+ }
95
+ async ephemeral(id, expiration) {
96
+ return this.http.request({
97
+ route: `${types_1.Routes.COMMUNITY}/${id}/ephemeral`,
98
+ method: types_1.HttpMethod.POST,
99
+ body: { expiration },
100
+ });
101
+ }
102
+ async updateSettings(id, setting) {
103
+ return this.http.request({
104
+ route: `${types_1.Routes.COMMUNITY}/${id}/settings`,
105
+ method: types_1.HttpMethod.PATCH,
106
+ body: { setting },
107
+ });
108
+ }
109
+ async memberAddMode(id, mode) {
110
+ return this.http.request({
111
+ route: `${types_1.Routes.COMMUNITY}/${id}/member-add-mode`,
112
+ method: types_1.HttpMethod.PATCH,
113
+ body: { mode },
114
+ });
115
+ }
116
+ async joinApproval(id, mode) {
117
+ return this.http.request({
118
+ route: `${types_1.Routes.COMMUNITY}/${id}/join-approval`,
119
+ method: types_1.HttpMethod.PATCH,
120
+ body: { mode },
121
+ });
122
+ }
123
+ }
124
+ exports.CommunityService = CommunityService;
125
+ //# sourceMappingURL=CommunityService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommunityService.js","sourceRoot":"","sources":["../../src/services/CommunityService.ts"],"names":[],"mappings":";;;AACA,oCAIkB;AAElB,MAAa,gBAAgB;IAC3B,YAA6B,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;IAAG,CAAC;IAElD,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAA4C;YAClE,KAAK,EAAE,cAAM,CAAC,SAAS;YACvB,MAAM,EAAE,kBAAU,CAAC,GAAG;SACvB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAqB;QAChC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAA0C;YAChE,KAAK,EAAE,cAAM,CAAC,SAAS;YACvB,MAAM,EAAE,kBAAU,CAAC,IAAI;YACvB,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAU;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAA0C;YAChE,KAAK,EAAE,GAAG,cAAM,CAAC,SAAS,I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KAAK,CAAC,SAAS,CAAC,EAAU,EAAE,UAAkB;QAC5C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc;YACpC,KAAK,EAAE,GAAG,cAAM,CAAC,SAAS,IAAI,EAAE,YAAY;YAC5C,MAAM,EAAE,kBAAU,CAAC,IAAI;YACvB,IAAI,EAAE,EAAE,UAAU,EAAE;SACrB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,EAAU,EAAE,OAAe;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc;YACpC,KAAK,EAAE,GAAG,cAAM,CAAC,SAAS,IAAI,EAAE,WAAW;YAC3C,MAAM,EAAE,kBAAU,CAAC,KAAK;YACxB,IAAI,EAAE,EAAE,OAAO,EAAE;SAClB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,EAAU,EAAE,IAAY;QAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc;YACpC,KAAK,EAAE,GAAG,cAAM,CAAC,SAAS,IAAI,EAAE,kBAAkB;YAClD,MAAM,EAAE,kBAAU,CAAC,KAAK;YACxB,IAAI,EAAE,EAAE,IAAI,EAAE;SACf,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,EAAU,EAAE,IAAY;QACzC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc;YACpC,KAAK,EAAE,GAAG,cAAM,CAAC,SAAS,IAAI,EAAE,gBAAgB;YAChD,MAAM,EAAE,kBAAU,CAAC,KAAK;YACxB,IAAI,EAAE,EAAE,IAAI,EAAE;SACf,CAAC,CAAC;IACL,CAAC;CACF;AArID,4CAqIC","sourcesContent":["import { IHttpClient } from '../client/IHttpClient';\nimport {\n Routes, HttpMethod, ApiResponse, CommunityInfo, InviteCodeResponse,\n CommunityCreate, CommunityUpdate, GroupParticipant, GroupParticipantsAction,\n CommunityGroupCreate,\n} from '../types';\n\nexport class CommunityService {\n constructor(private readonly http: IHttpClient) {}\n\n async list(): Promise<{ status: number; data: CommunityInfo[] }> {\n return this.http.request<{ status: number; data: CommunityInfo[] }>({\n route: Routes.COMMUNITY,\n method: HttpMethod.GET,\n });\n }\n\n async create(data: CommunityCreate): Promise<{ status: number; data: CommunityInfo }> {\n return this.http.request<{ status: number; data: CommunityInfo }>({\n route: Routes.COMMUNITY,\n method: HttpMethod.POST,\n body: data,\n });\n }\n\n async info(id: string): Promise<{ status: number; data: CommunityInfo }> {\n return this.http.request<{ status: number; data: CommunityInfo }>({\n route: `${Routes.COMMUNITY}/${id}`,\n method: HttpMethod.GET,\n });\n }\n\n async update(id: string, data: CommunityUpdate): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.COMMUNITY}/${id}`,\n method: HttpMethod.PUT,\n body: data,\n });\n }\n\n async leave(id: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.COMMUNITY}/${id}`,\n method: HttpMethod.DELETE,\n });\n }\n\n async updatePicture(id: string, url: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.COMMUNITY}/${id}/picture`,\n method: HttpMethod.PUT,\n body: { url },\n });\n }\n\n async getInviteCode(id: string): Promise<InviteCodeResponse> {\n return this.http.request<InviteCodeResponse>({\n route: `${Routes.COMMUNITY}/${id}/invite`,\n method: HttpMethod.POST,\n });\n }\n\n async removeParticipants(id: string, participants: string[]): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.COMMUNITY}/${id}/participants`,\n method: HttpMethod.DELETE,\n body: { participants },\n });\n }\n\n async getRequestParticipants(id: string): Promise<{ status: number; data: GroupParticipant[] }> {\n return this.http.request<{ status: number; data: GroupParticipant[] }>({\n route: `${Routes.COMMUNITY}/${id}/request_participants_list`,\n method: HttpMethod.GET,\n });\n }\n\n async updateRequestParticipants(id: string, data: GroupParticipantsAction): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.COMMUNITY}/${id}/request_participants_list`,\n method: HttpMethod.PUT,\n body: data,\n });\n }\n\n async acceptInvite(code: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.COMMUNITY}/invite/accept`,\n method: HttpMethod.POST,\n body: { code },\n });\n }\n\n async getInviteInfo(code: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.COMMUNITY}/invite/info`,\n method: HttpMethod.GET,\n params: { code },\n });\n }\n\n async createGroup(id: string, data: CommunityGroupCreate): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.COMMUNITY}/${id}/group`,\n method: HttpMethod.POST,\n body: data,\n });\n }\n\n async ephemeral(id: string, expiration: number): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.COMMUNITY}/${id}/ephemeral`,\n method: HttpMethod.POST,\n body: { expiration },\n });\n }\n\n async updateSettings(id: string, setting: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.COMMUNITY}/${id}/settings`,\n method: HttpMethod.PATCH,\n body: { setting },\n });\n }\n\n async memberAddMode(id: string, mode: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.COMMUNITY}/${id}/member-add-mode`,\n method: HttpMethod.PATCH,\n body: { mode },\n });\n }\n\n async joinApproval(id: string, mode: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.COMMUNITY}/${id}/join-approval`,\n method: HttpMethod.PATCH,\n body: { mode },\n });\n }\n}\n"]}
@@ -0,0 +1,21 @@
1
+ import { IHttpClient } from '../client/IHttpClient';
2
+ import { ApiResponse, ContactInfo } from '../types';
3
+ export declare class ContactService {
4
+ private readonly http;
5
+ constructor(http: IHttpClient);
6
+ list(): Promise<{
7
+ status: number;
8
+ data: ContactInfo[];
9
+ }>;
10
+ profile(id: string): Promise<{
11
+ status: number;
12
+ data: ContactInfo;
13
+ }>;
14
+ add(number: string, name: string): Promise<ApiResponse>;
15
+ remove(number: string): Promise<ApiResponse>;
16
+ block(number: string, action: 'block' | 'unblock'): Promise<ApiResponse>;
17
+ clearSession(number: string): Promise<ApiResponse>;
18
+ getStatus(number: string): Promise<ApiResponse>;
19
+ listBlocked(): Promise<ApiResponse>;
20
+ resolveLids(lids: string[]): Promise<ApiResponse>;
21
+ }
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ContactService = void 0;
4
+ const types_1 = require("../types");
5
+ class ContactService {
6
+ constructor(http) {
7
+ this.http = http;
8
+ }
9
+ async list() {
10
+ return this.http.request({
11
+ route: types_1.Routes.CONTACTS,
12
+ method: types_1.HttpMethod.GET,
13
+ });
14
+ }
15
+ async profile(id) {
16
+ return this.http.request({
17
+ route: `${types_1.Routes.CONTACTS}/${id}`,
18
+ method: types_1.HttpMethod.GET,
19
+ });
20
+ }
21
+ async add(number, name) {
22
+ return this.http.request({
23
+ route: types_1.Routes.CONTACTS,
24
+ method: types_1.HttpMethod.POST,
25
+ body: { number, name },
26
+ });
27
+ }
28
+ async remove(number) {
29
+ return this.http.request({
30
+ route: `${types_1.Routes.CONTACTS}/${number}`,
31
+ method: types_1.HttpMethod.DELETE,
32
+ });
33
+ }
34
+ async block(number, action) {
35
+ return this.http.request({
36
+ route: `${types_1.Routes.CONTACTS}/${number}`,
37
+ method: types_1.HttpMethod.PATCH,
38
+ params: { action },
39
+ });
40
+ }
41
+ async clearSession(number) {
42
+ return this.http.request({
43
+ route: `${types_1.Routes.CONTACTS}/${number}/session`,
44
+ method: types_1.HttpMethod.DELETE,
45
+ });
46
+ }
47
+ async getStatus(number) {
48
+ return this.http.request({
49
+ route: `${types_1.Routes.CONTACTS}/${number}/status`,
50
+ method: types_1.HttpMethod.GET,
51
+ });
52
+ }
53
+ async listBlocked() {
54
+ return this.http.request({
55
+ route: `${types_1.Routes.CONTACTS}/blocked`,
56
+ method: types_1.HttpMethod.GET,
57
+ });
58
+ }
59
+ async resolveLids(lids) {
60
+ return this.http.request({
61
+ route: `${types_1.Routes.CONTACTS}/resolve-lids`,
62
+ method: types_1.HttpMethod.POST,
63
+ body: { lids },
64
+ });
65
+ }
66
+ }
67
+ exports.ContactService = ContactService;
68
+ //# sourceMappingURL=ContactService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContactService.js","sourceRoot":"","sources":["../../src/services/ContactService.ts"],"names":[],"mappings":";;;AACA,oCAAwE;AAExE,MAAa,cAAc;IACzB,YAA6B,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;IAAG,CAAC;IAElD,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAA0C;YAChE,KAAK,EAAE,cAAM,CAAC,QAAQ;YACtB,MAAM,EAAE,kBAAU,CAAC,GAAG;SACvB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,EAAU;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAwC;YAC9D,KAAK,EAAE,GAAG,cAAM,CAAC,QAAQ,IAAI,EAAE,EAAE;YACjC,MAAM,EAAE,kBAAU,CAAC,GAAG;SACvB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,MAAc,EAAE,IAAY;QACpC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc;YACpC,KAAK,EAAE,cAAM,CAAC,QAAQ;YACtB,MAAM,EAAE,kBAAU,CAAC,IAAI;YACvB,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;SACvB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAc;QACzB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc;YACpC,KAAK,EAAE,GAAG,cAAM,CAAC,QAAQ,IAAI,MAAM,EAAE;YACrC,MAAM,EAAE,kBAAU,CAAC,MAAM;SAC1B,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,MAAc,EAAE,MAA2B;QACrD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc;YACpC,KAAK,EAAE,GAAG,cAAM,CAAC,QAAQ,IAAI,MAAM,EAAE;YACrC,MAAM,EAAE,kBAAU,CAAC,KAAK;YACxB,MAAM,EAAE,EAAE,MAAM,EAAE;SACnB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,MAAc;QAC/B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc;YACpC,KAAK,EAAE,GAAG,cAAM,CAAC,QAAQ,IAAI,MAAM,UAAU;YAC7C,MAAM,EAAE,kBAAU,CAAC,MAAM;SAC1B,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,MAAc;QAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc;YACpC,KAAK,EAAE,GAAG,cAAM,CAAC,QAAQ,IAAI,MAAM,SAAS;YAC5C,MAAM,EAAE,kBAAU,CAAC,GAAG;SACvB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc;YACpC,KAAK,EAAE,GAAG,cAAM,CAAC,QAAQ,UAAU;YACnC,MAAM,EAAE,kBAAU,CAAC,GAAG;SACvB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,IAAc;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc;YACpC,KAAK,EAAE,GAAG,cAAM,CAAC,QAAQ,eAAe;YACxC,MAAM,EAAE,kBAAU,CAAC,IAAI;YACvB,IAAI,EAAE,EAAE,IAAI,EAAE;SACf,CAAC,CAAC;IACL,CAAC;CACF;AApED,wCAoEC","sourcesContent":["import { IHttpClient } from '../client/IHttpClient';\nimport { Routes, HttpMethod, ApiResponse, ContactInfo } from '../types';\n\nexport class ContactService {\n constructor(private readonly http: IHttpClient) {}\n\n async list(): Promise<{ status: number; data: ContactInfo[] }> {\n return this.http.request<{ status: number; data: ContactInfo[] }>({\n route: Routes.CONTACTS,\n method: HttpMethod.GET,\n });\n }\n\n async profile(id: string): Promise<{ status: number; data: ContactInfo }> {\n return this.http.request<{ status: number; data: ContactInfo }>({\n route: `${Routes.CONTACTS}/${id}`,\n method: HttpMethod.GET,\n });\n }\n\n async add(number: string, name: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: Routes.CONTACTS,\n method: HttpMethod.POST,\n body: { number, name },\n });\n }\n\n async remove(number: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.CONTACTS}/${number}`,\n method: HttpMethod.DELETE,\n });\n }\n\n async block(number: string, action: 'block' | 'unblock'): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.CONTACTS}/${number}`,\n method: HttpMethod.PATCH,\n params: { action },\n });\n }\n\n async clearSession(number: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.CONTACTS}/${number}/session`,\n method: HttpMethod.DELETE,\n });\n }\n\n async getStatus(number: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.CONTACTS}/${number}/status`,\n method: HttpMethod.GET,\n });\n }\n\n async listBlocked(): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.CONTACTS}/blocked`,\n method: HttpMethod.GET,\n });\n }\n\n async resolveLids(lids: string[]): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.CONTACTS}/resolve-lids`,\n method: HttpMethod.POST,\n body: { lids },\n });\n }\n}\n"]}
@@ -0,0 +1,37 @@
1
+ import { IHttpClient } from '../client/IHttpClient';
2
+ import { ApiResponse, GroupInfo, InviteCodeResponse, GroupParticipant, GroupParticipantsAction } from '../types';
3
+ export declare class GroupService {
4
+ private readonly http;
5
+ constructor(http: IHttpClient);
6
+ list(): Promise<{
7
+ status: number;
8
+ data: GroupInfo[];
9
+ }>;
10
+ info(id: string): Promise<{
11
+ status: number;
12
+ data: GroupInfo;
13
+ }>;
14
+ create(name: string, participants: string[]): Promise<{
15
+ status: number;
16
+ data: GroupInfo;
17
+ }>;
18
+ update(id: string, name: string, description: string): Promise<ApiResponse>;
19
+ changeSettings(id: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked'): Promise<ApiResponse>;
20
+ leave(id: string): Promise<ApiResponse>;
21
+ getMembers(id: string): Promise<{
22
+ status: number;
23
+ data: GroupParticipant[];
24
+ }>;
25
+ getInviteInfo(code: string): Promise<ApiResponse>;
26
+ getInviteCode(id: string): Promise<InviteCodeResponse>;
27
+ updatePicture(id: string, url: string): Promise<ApiResponse>;
28
+ removePicture(id: string): Promise<ApiResponse>;
29
+ addParticipants(id: string, participants: string[]): Promise<ApiResponse>;
30
+ removeParticipants(id: string, participants: string[]): Promise<ApiResponse>;
31
+ updateParticipantRole(id: string, action: 'promote' | 'demote', participants: string[]): Promise<ApiResponse>;
32
+ getRequestParticipants(id: string): Promise<{
33
+ status: number;
34
+ data: GroupParticipant[];
35
+ }>;
36
+ updateRequestParticipants(id: string, data: GroupParticipantsAction): Promise<ApiResponse>;
37
+ }
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GroupService = void 0;
4
+ const types_1 = require("../types");
5
+ class GroupService {
6
+ constructor(http) {
7
+ this.http = http;
8
+ }
9
+ async list() {
10
+ return this.http.request({
11
+ route: types_1.Routes.GROUPS,
12
+ method: types_1.HttpMethod.GET,
13
+ });
14
+ }
15
+ async info(id) {
16
+ return this.http.request({
17
+ route: `${types_1.Routes.GROUPS}/${id}`,
18
+ method: types_1.HttpMethod.GET,
19
+ });
20
+ }
21
+ async create(name, participants) {
22
+ return this.http.request({
23
+ route: types_1.Routes.GROUPS,
24
+ method: types_1.HttpMethod.POST,
25
+ body: { name, participants },
26
+ });
27
+ }
28
+ async update(id, name, description) {
29
+ return this.http.request({
30
+ route: `${types_1.Routes.GROUPS}/${id}`,
31
+ method: types_1.HttpMethod.PUT,
32
+ body: { name, description },
33
+ });
34
+ }
35
+ async changeSettings(id, setting) {
36
+ return this.http.request({
37
+ route: `${types_1.Routes.GROUPS}/${id}`,
38
+ method: types_1.HttpMethod.PATCH,
39
+ params: { setting },
40
+ });
41
+ }
42
+ async leave(id) {
43
+ return this.http.request({
44
+ route: `${types_1.Routes.GROUPS}/${id}`,
45
+ method: types_1.HttpMethod.DELETE,
46
+ });
47
+ }
48
+ async getMembers(id) {
49
+ return this.http.request({
50
+ route: `${types_1.Routes.GROUPS}/${id}/members`,
51
+ method: types_1.HttpMethod.GET,
52
+ });
53
+ }
54
+ async getInviteInfo(code) {
55
+ return this.http.request({
56
+ route: `${types_1.Routes.GROUPS}/invite/info`,
57
+ method: types_1.HttpMethod.GET,
58
+ params: { code },
59
+ });
60
+ }
61
+ async getInviteCode(id) {
62
+ return this.http.request({
63
+ route: `${types_1.Routes.GROUPS}/${id}/invite`,
64
+ method: types_1.HttpMethod.GET,
65
+ });
66
+ }
67
+ async updatePicture(id, url) {
68
+ return this.http.request({
69
+ route: `${types_1.Routes.GROUPS}/${id}/picture`,
70
+ method: types_1.HttpMethod.PUT,
71
+ body: { url },
72
+ });
73
+ }
74
+ async removePicture(id) {
75
+ return this.http.request({
76
+ route: `${types_1.Routes.GROUPS}/${id}/picture`,
77
+ method: types_1.HttpMethod.DELETE,
78
+ });
79
+ }
80
+ async addParticipants(id, participants) {
81
+ return this.http.request({
82
+ route: `${types_1.Routes.GROUPS}/${id}/participants`,
83
+ method: types_1.HttpMethod.POST,
84
+ body: { participants },
85
+ });
86
+ }
87
+ async removeParticipants(id, participants) {
88
+ return this.http.request({
89
+ route: `${types_1.Routes.GROUPS}/${id}/participants`,
90
+ method: types_1.HttpMethod.DELETE,
91
+ body: { participants },
92
+ });
93
+ }
94
+ async updateParticipantRole(id, action, participants) {
95
+ return this.http.request({
96
+ route: `${types_1.Routes.GROUPS}/${id}/role`,
97
+ method: types_1.HttpMethod.PATCH,
98
+ body: { participants },
99
+ params: { action },
100
+ });
101
+ }
102
+ async getRequestParticipants(id) {
103
+ return this.http.request({
104
+ route: `${types_1.Routes.GROUPS}/${id}/request_participants_list`,
105
+ method: types_1.HttpMethod.GET,
106
+ });
107
+ }
108
+ async updateRequestParticipants(id, data) {
109
+ return this.http.request({
110
+ route: `${types_1.Routes.GROUPS}/${id}/request_participants_list`,
111
+ method: types_1.HttpMethod.PUT,
112
+ body: data,
113
+ });
114
+ }
115
+ }
116
+ exports.GroupService = GroupService;
117
+ //# sourceMappingURL=GroupService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GroupService.js","sourceRoot":"","sources":["../../src/services/GroupService.ts"],"names":[],"mappings":";;;AACA,oCAGkB;AAElB,MAAa,YAAY;IACvB,YAA6B,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;IAAG,CAAC;IAElD,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAwC;YAC9D,KAAK,EAAE,cAAM,CAAC,MAAM;YACpB,MAAM,EAAE,kBAAU,CAAC,GAAG;SACvB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAU;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAsC;YAC5D,KAAK,EAAE,GAAG,cAAM,CAAC,MAAM,IAAI,EAAE,EAAE;YAC/B,MAAM,EAAE,kBAAU,CAAC,GAAG;SACvB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,YAAsB;QAC/C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAsC;YAC5D,KAAK,EAAE,cAAM,CAAC,MAAM;YACpB,MAAM,EAAE,kBAAU,CAAC,IAAI;YACvB,IAAI,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE;SAC7B,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,EAA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AI,CAAC,OAAO,CAAc;YACpC,KAAK,EAAE,GAAG,cAAM,CAAC,MAAM,IAAI,EAAE,OAAO;YACpC,MAAM,EAAE,kBAAU,CAAC,KAAK;YACxB,IAAI,EAAE,EAAE,YAAY,EAAE;YACtB,MAAM,EAAE,EAAE,MAAM,EAAE;SACnB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,sBAAsB,CAAC,EAAU;QACrC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAA+C;YACrE,KAAK,EAAE,GAAG,cAAM,CAAC,MAAM,IAAI,EAAE,4BAA4B;YACzD,MAAM,EAAE,kBAAU,CAAC,GAAG;SACvB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,yBAAyB,CAAC,EAAU,EAAE,IAA6B;QACvE,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAc;YACpC,KAAK,EAAE,GAAG,cAAM,CAAC,MAAM,IAAI,EAAE,4BAA4B;YACzD,MAAM,EAAE,kBAAU,CAAC,GAAG;YACtB,IAAI,EAAE,IAAI;SACX,CAAC,CAAC;IACL,CAAC;CACF;AA5HD,oCA4HC","sourcesContent":["import { IHttpClient } from '../client/IHttpClient';\nimport {\n Routes, HttpMethod, ApiResponse, GroupInfo, InviteCodeResponse,\n GroupParticipant, GroupParticipantsAction,\n} from '../types';\n\nexport class GroupService {\n constructor(private readonly http: IHttpClient) {}\n\n async list(): Promise<{ status: number; data: GroupInfo[] }> {\n return this.http.request<{ status: number; data: GroupInfo[] }>({\n route: Routes.GROUPS,\n method: HttpMethod.GET,\n });\n }\n\n async info(id: string): Promise<{ status: number; data: GroupInfo }> {\n return this.http.request<{ status: number; data: GroupInfo }>({\n route: `${Routes.GROUPS}/${id}`,\n method: HttpMethod.GET,\n });\n }\n\n async create(name: string, participants: string[]): Promise<{ status: number; data: GroupInfo }> {\n return this.http.request<{ status: number; data: GroupInfo }>({\n route: Routes.GROUPS,\n method: HttpMethod.POST,\n body: { name, participants },\n });\n }\n\n async update(id: string, name: string, description: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.GROUPS}/${id}`,\n method: HttpMethod.PUT,\n body: { name, description },\n });\n }\n\n async changeSettings(id: string, setting: 'announcement' | 'not_announcement' | 'locked' | 'unlocked'): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.GROUPS}/${id}`,\n method: HttpMethod.PATCH,\n params: { setting },\n });\n }\n\n async leave(id: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.GROUPS}/${id}`,\n method: HttpMethod.DELETE,\n });\n }\n\n async getMembers(id: string): Promise<{ status: number; data: GroupParticipant[] }> {\n return this.http.request<{ status: number; data: GroupParticipant[] }>({\n route: `${Routes.GROUPS}/${id}/members`,\n method: HttpMethod.GET,\n });\n }\n\n async getInviteInfo(code: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.GROUPS}/invite/info`,\n method: HttpMethod.GET,\n params: { code },\n });\n }\n\n async getInviteCode(id: string): Promise<InviteCodeResponse> {\n return this.http.request<InviteCodeResponse>({\n route: `${Routes.GROUPS}/${id}/invite`,\n method: HttpMethod.GET,\n });\n }\n\n async updatePicture(id: string, url: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.GROUPS}/${id}/picture`,\n method: HttpMethod.PUT,\n body: { url },\n });\n }\n\n async removePicture(id: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.GROUPS}/${id}/picture`,\n method: HttpMethod.DELETE,\n });\n }\n\n async addParticipants(id: string, participants: string[]): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.GROUPS}/${id}/participants`,\n method: HttpMethod.POST,\n body: { participants },\n });\n }\n\n async removeParticipants(id: string, participants: string[]): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.GROUPS}/${id}/participants`,\n method: HttpMethod.DELETE,\n body: { participants },\n });\n }\n\n async updateParticipantRole(id: string, action: 'promote' | 'demote', participants: string[]): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.GROUPS}/${id}/role`,\n method: HttpMethod.PATCH,\n body: { participants },\n params: { action },\n });\n }\n\n async getRequestParticipants(id: string): Promise<{ status: number; data: GroupParticipant[] }> {\n return this.http.request<{ status: number; data: GroupParticipant[] }>({\n route: `${Routes.GROUPS}/${id}/request_participants_list`,\n method: HttpMethod.GET,\n });\n }\n\n async updateRequestParticipants(id: string, data: GroupParticipantsAction): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.GROUPS}/${id}/request_participants_list`,\n method: HttpMethod.PUT,\n body: data,\n });\n }\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import { IHttpClient } from '../client/IHttpClient';
2
+ import { WebhookBody, InfoInstance, Connect, ApiResponse, PairingCodeResponse, MobileRegisterData, WebhookStatistics } from '../types';
3
+ export declare class InstanceService {
4
+ private readonly http;
5
+ constructor(http: IHttpClient);
6
+ connect(): Promise<Connect>;
7
+ info(): Promise<InfoInstance>;
8
+ logout(): Promise<ApiResponse>;
9
+ setting(data: {
10
+ markMessageRead: boolean;
11
+ saveMedia: boolean;
12
+ receiveStatusMessage: boolean;
13
+ receivePresence: boolean;
14
+ }): Promise<ApiResponse>;
15
+ updateWebhook(body: WebhookBody): Promise<ApiResponse>;
16
+ pairingCode(phoneNumber: string): Promise<PairingCodeResponse>;
17
+ addMongoDb(uri: string, dbName: string): Promise<ApiResponse>;
18
+ setProxy(proxy: string): Promise<ApiResponse>;
19
+ resync(): Promise<ApiResponse>;
20
+ restart(): Promise<ApiResponse>;
21
+ updateProfileStatus(text: string): Promise<ApiResponse>;
22
+ updateProfilePicture(url: string): Promise<ApiResponse>;
23
+ removeProfilePicture(): Promise<ApiResponse>;
24
+ updateProfileName(name: string): Promise<ApiResponse>;
25
+ mobileRegisterPrepare(data: MobileRegisterData): Promise<ApiResponse>;
26
+ mobileRequestCode(method: string): Promise<ApiResponse>;
27
+ mobileVerifyCode(code: string): Promise<ApiResponse>;
28
+ webhookStatistics(): Promise<WebhookStatistics>;
29
+ }
@@ -0,0 +1,130 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InstanceService = void 0;
4
+ const types_1 = require("../types");
5
+ class InstanceService {
6
+ constructor(http) {
7
+ this.http = http;
8
+ }
9
+ async connect() {
10
+ return this.http.request({
11
+ route: types_1.Routes.INSTANCES,
12
+ method: types_1.HttpMethod.POST,
13
+ });
14
+ }
15
+ async info() {
16
+ return this.http.request({
17
+ route: types_1.Routes.INSTANCES,
18
+ method: types_1.HttpMethod.GET,
19
+ });
20
+ }
21
+ async logout() {
22
+ return this.http.request({
23
+ route: types_1.Routes.INSTANCES,
24
+ method: types_1.HttpMethod.DELETE,
25
+ });
26
+ }
27
+ async setting(data) {
28
+ return this.http.request({
29
+ route: types_1.Routes.INSTANCES,
30
+ method: types_1.HttpMethod.PATCH,
31
+ params: data,
32
+ });
33
+ }
34
+ async updateWebhook(body) {
35
+ return this.http.request({
36
+ route: types_1.Routes.INSTANCES,
37
+ method: types_1.HttpMethod.PUT,
38
+ body,
39
+ });
40
+ }
41
+ async pairingCode(phoneNumber) {
42
+ return this.http.request({
43
+ route: `${types_1.Routes.INSTANCES}/pairing-code`,
44
+ method: types_1.HttpMethod.POST,
45
+ body: { phoneNumber },
46
+ });
47
+ }
48
+ async addMongoDb(uri, dbName) {
49
+ return this.http.request({
50
+ route: `${types_1.Routes.INSTANCES}/mongodb`,
51
+ method: types_1.HttpMethod.POST,
52
+ body: { uri, dbName },
53
+ });
54
+ }
55
+ async setProxy(proxy) {
56
+ return this.http.request({
57
+ route: `${types_1.Routes.INSTANCES}/proxy`,
58
+ method: types_1.HttpMethod.POST,
59
+ body: { proxy },
60
+ });
61
+ }
62
+ async resync() {
63
+ return this.http.request({
64
+ route: `${types_1.Routes.INSTANCES}/resync`,
65
+ method: types_1.HttpMethod.POST,
66
+ });
67
+ }
68
+ async restart() {
69
+ return this.http.request({
70
+ route: `${types_1.Routes.INSTANCES}/restart`,
71
+ method: types_1.HttpMethod.POST,
72
+ });
73
+ }
74
+ async updateProfileStatus(text) {
75
+ return this.http.request({
76
+ route: `${types_1.Routes.INSTANCES}/status`,
77
+ method: types_1.HttpMethod.PUT,
78
+ body: { text },
79
+ });
80
+ }
81
+ async updateProfilePicture(url) {
82
+ return this.http.request({
83
+ route: `${types_1.Routes.INSTANCES}/profile/picture`,
84
+ method: types_1.HttpMethod.PUT,
85
+ body: { url },
86
+ });
87
+ }
88
+ async removeProfilePicture() {
89
+ return this.http.request({
90
+ route: `${types_1.Routes.INSTANCES}/profile/picture`,
91
+ method: types_1.HttpMethod.DELETE,
92
+ });
93
+ }
94
+ async updateProfileName(name) {
95
+ return this.http.request({
96
+ route: `${types_1.Routes.INSTANCES}/profile/name`,
97
+ method: types_1.HttpMethod.PUT,
98
+ body: { name },
99
+ });
100
+ }
101
+ async mobileRegisterPrepare(data) {
102
+ return this.http.request({
103
+ route: `${types_1.Routes.INSTANCES}/mobile/prepare`,
104
+ method: types_1.HttpMethod.POST,
105
+ body: data,
106
+ });
107
+ }
108
+ async mobileRequestCode(method) {
109
+ return this.http.request({
110
+ route: `${types_1.Routes.INSTANCES}/mobile/request-code`,
111
+ method: types_1.HttpMethod.POST,
112
+ body: { method },
113
+ });
114
+ }
115
+ async mobileVerifyCode(code) {
116
+ return this.http.request({
117
+ route: `${types_1.Routes.INSTANCES}/mobile/verify`,
118
+ method: types_1.HttpMethod.POST,
119
+ body: { code },
120
+ });
121
+ }
122
+ async webhookStatistics() {
123
+ return this.http.request({
124
+ route: `${types_1.Routes.INSTANCES}/webhook/statistics`,
125
+ method: types_1.HttpMethod.GET,
126
+ });
127
+ }
128
+ }
129
+ exports.InstanceService = InstanceService;
130
+ //# sourceMappingURL=InstanceService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InstanceService.js","sourceRoot":"","sources":["../../src/services/InstanceService.ts"],"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,EAAE,IAAI,EAAE;SACf,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAoB;YAC1C,KAAK,EAAE,GAAG,cAAM,CAAC,SAAS,qBAAqB;YAC/C,MAAM,EAAE,kBAAU,CAAC,GAAG;SACvB,CAAC,CAAC;IACL,CAAC;CACF;AA3ID,0CA2IC","sourcesContent":["import { IHttpClient } from '../client/IHttpClient';\nimport {\n Routes, HttpMethod, WebhookBody, InfoInstance, Connect,\n ApiResponse, PairingCodeResponse, MobileRegisterData, WebhookStatistics,\n} from '../types';\n\nexport class InstanceService {\n constructor(private readonly http: IHttpClient) {}\n\n async connect(): Promise<Connect> {\n return this.http.request<Connect>({\n route: Routes.INSTANCES,\n method: HttpMethod.POST,\n });\n }\n\n async info(): Promise<InfoInstance> {\n return this.http.request<InfoInstance>({\n route: Routes.INSTANCES,\n method: HttpMethod.GET,\n });\n }\n\n async logout(): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: Routes.INSTANCES,\n method: HttpMethod.DELETE,\n });\n }\n\n async setting(data: { markMessageRead: boolean; saveMedia: boolean; receiveStatusMessage: boolean; receivePresence: boolean }): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: Routes.INSTANCES,\n method: HttpMethod.PATCH,\n params: data,\n });\n }\n\n async updateWebhook(body: WebhookBody): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: Routes.INSTANCES,\n method: HttpMethod.PUT,\n body,\n });\n }\n\n async pairingCode(phoneNumber: string): Promise<PairingCodeResponse> {\n return this.http.request<PairingCodeResponse>({\n route: `${Routes.INSTANCES}/pairing-code`,\n method: HttpMethod.POST,\n body: { phoneNumber },\n });\n }\n\n async addMongoDb(uri: string, dbName: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.INSTANCES}/mongodb`,\n method: HttpMethod.POST,\n body: { uri, dbName },\n });\n }\n\n async setProxy(proxy: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.INSTANCES}/proxy`,\n method: HttpMethod.POST,\n body: { proxy },\n });\n }\n\n async resync(): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.INSTANCES}/resync`,\n method: HttpMethod.POST,\n });\n }\n\n async restart(): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.INSTANCES}/restart`,\n method: HttpMethod.POST,\n });\n }\n\n async updateProfileStatus(text: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.INSTANCES}/status`,\n method: HttpMethod.PUT,\n body: { text },\n });\n }\n\n async updateProfilePicture(url: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.INSTANCES}/profile/picture`,\n method: HttpMethod.PUT,\n body: { url },\n });\n }\n\n async removeProfilePicture(): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.INSTANCES}/profile/picture`,\n method: HttpMethod.DELETE,\n });\n }\n\n async updateProfileName(name: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.INSTANCES}/profile/name`,\n method: HttpMethod.PUT,\n body: { name },\n });\n }\n\n async mobileRegisterPrepare(data: MobileRegisterData): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.INSTANCES}/mobile/prepare`,\n method: HttpMethod.POST,\n body: data,\n });\n }\n\n async mobileRequestCode(method: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.INSTANCES}/mobile/request-code`,\n method: HttpMethod.POST,\n body: { method },\n });\n }\n\n async mobileVerifyCode(code: string): Promise<ApiResponse> {\n return this.http.request<ApiResponse>({\n route: `${Routes.INSTANCES}/mobile/verify`,\n method: HttpMethod.POST,\n body: { code },\n });\n }\n\n async webhookStatistics(): Promise<WebhookStatistics> {\n return this.http.request<WebhookStatistics>({\n route: `${Routes.INSTANCES}/webhook/statistics`,\n method: HttpMethod.GET,\n });\n }\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import { IHttpClient } from '../client/IHttpClient';
2
+ import { ApiResponse, LabelInfo, ChatInfo } from '../types';
3
+ export declare class LabelService {
4
+ private readonly http;
5
+ constructor(http: IHttpClient);
6
+ list(): Promise<{
7
+ status: number;
8
+ data: LabelInfo[];
9
+ }>;
10
+ create(name: string, labelId?: string): Promise<ApiResponse>;
11
+ getChats(labelId: string): Promise<{
12
+ status: number;
13
+ data: ChatInfo[];
14
+ }>;
15
+ addToChat(labelId: string, to: string): Promise<ApiResponse>;
16
+ delete(labelId: string): Promise<ApiResponse>;
17
+ removeFromChat(labelId: string, to: string): Promise<ApiResponse>;
18
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LabelService = void 0;
4
+ const types_1 = require("../types");
5
+ class LabelService {
6
+ constructor(http) {
7
+ this.http = http;
8
+ }
9
+ async list() {
10
+ return this.http.request({
11
+ route: types_1.Routes.LABELS,
12
+ method: types_1.HttpMethod.GET,
13
+ });
14
+ }
15
+ async create(name, labelId) {
16
+ return this.http.request({
17
+ route: types_1.Routes.LABELS,
18
+ method: types_1.HttpMethod.POST,
19
+ body: { name, labelId },
20
+ });
21
+ }
22
+ async getChats(labelId) {
23
+ return this.http.request({
24
+ route: `${types_1.Routes.LABELS}/${labelId}`,
25
+ method: types_1.HttpMethod.GET,
26
+ });
27
+ }
28
+ async addToChat(labelId, to) {
29
+ return this.http.request({
30
+ route: `${types_1.Routes.LABELS}/${labelId}`,
31
+ method: types_1.HttpMethod.POST,
32
+ body: { to },
33
+ });
34
+ }
35
+ async delete(labelId) {
36
+ return this.http.request({
37
+ route: `${types_1.Routes.LABELS}/${labelId}`,
38
+ method: types_1.HttpMethod.DELETE,
39
+ });
40
+ }
41
+ async removeFromChat(labelId, to) {
42
+ return this.http.request({
43
+ route: `${types_1.Routes.LABELS}/${labelId}/chat/${to}`,
44
+ method: types_1.HttpMethod.DELETE,
45
+ });
46
+ }
47
+ }
48
+ exports.LabelService = LabelService;
49
+ //# sourceMappingURL=LabelService.js.map