getricky 0.1.4 → 0.1.6

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.
@@ -131,6 +131,25 @@ class RickyApi extends HeyApiClient {
131
131
  ...options
132
132
  });
133
133
  }
134
+ /**
135
+ * Create a contact field
136
+ *
137
+ * Adds a custom field to every contact, after the existing ones. A name already in use, in any case, answers `409 conflict`.
138
+ *
139
+ * Scope: `contacts:write`.
140
+ */
141
+ createContactField(options) {
142
+ return (options.client ?? this.client).post({
143
+ responseStyle: 'data',
144
+ security: [{ scheme: 'bearer', type: 'http' }],
145
+ url: '/contact-fields',
146
+ ...options,
147
+ headers: {
148
+ 'Content-Type': 'application/json',
149
+ ...options.headers
150
+ }
151
+ });
152
+ }
134
153
  /**
135
154
  * List conversations
136
155
  *
@@ -347,7 +366,7 @@ class RickyApi extends HeyApiClient {
347
366
  *
348
367
  * Creates a contact tag. Apply it with `tag_ids` on a contact. A name already in use, in any case, answers `409 conflict`.
349
368
  *
350
- * Scope: `contacts:write`.
369
+ * Scope: `tags:write` or, on older keys, `contacts:write`.
351
370
  */
352
371
  createTag(options) {
353
372
  return (options.client ?? this.client).post({
@@ -361,21 +380,6 @@ class RickyApi extends HeyApiClient {
361
380
  }
362
381
  });
363
382
  }
364
- /**
365
- * List templates
366
- *
367
- * WhatsApp templates of every connected business account, read live from Meta.
368
- *
369
- * Scope: `templates:read`.
370
- */
371
- listTemplates(options) {
372
- return (options?.client ?? this.client).get({
373
- responseStyle: 'data',
374
- security: [{ scheme: 'bearer', type: 'http' }],
375
- url: '/templates',
376
- ...options
377
- });
378
- }
379
383
  /**
380
384
  * List webhooks
381
385
  *
@@ -1122,5 +1126,352 @@ class RickyApi extends HeyApiClient {
1122
1126
  }
1123
1127
  });
1124
1128
  }
1129
+ /**
1130
+ * Change tags on many contacts
1131
+ *
1132
+ * Adds and removes the same tags on up to 100 contacts and answers one result per contact, in order. A tag ID the organization does not have refuses the whole request before any contact changes.
1133
+ *
1134
+ * Scope: `contacts:write`.
1135
+ */
1136
+ changeContactsTags(options) {
1137
+ return (options.client ?? this.client).post({
1138
+ responseStyle: 'data',
1139
+ security: [{ scheme: 'bearer', type: 'http' }],
1140
+ url: '/contacts/tags',
1141
+ ...options,
1142
+ headers: {
1143
+ 'Content-Type': 'application/json',
1144
+ ...options.headers
1145
+ }
1146
+ });
1147
+ }
1148
+ /**
1149
+ * Delete a contact field
1150
+ *
1151
+ * Deletes the field and its value on every contact, and answers the field as it was. It cannot be undone.
1152
+ *
1153
+ * Scope: `contacts:write`.
1154
+ */
1155
+ deleteContactField(options) {
1156
+ return (options.client ?? this.client).delete({
1157
+ responseStyle: 'data',
1158
+ security: [{ scheme: 'bearer', type: 'http' }],
1159
+ url: '/contact-fields/{field_id}',
1160
+ ...options
1161
+ });
1162
+ }
1163
+ /**
1164
+ * Delete a tag
1165
+ *
1166
+ * Deletes the tag and removes it from every contact, and answers the tag as it was. It cannot be undone.
1167
+ *
1168
+ * Scope: `tags:write`.
1169
+ */
1170
+ deleteTag(options) {
1171
+ return (options.client ?? this.client).delete({
1172
+ responseStyle: 'data',
1173
+ security: [{ scheme: 'bearer', type: 'http' }],
1174
+ url: '/tags/{tag_id}',
1175
+ ...options
1176
+ });
1177
+ }
1178
+ /**
1179
+ * Update a tag
1180
+ *
1181
+ * Renames or recolors a tag on every contact that has it. A name already in use, in any case, answers `409 conflict`.
1182
+ *
1183
+ * Scope: `tags:write`.
1184
+ */
1185
+ updateTag(options) {
1186
+ return (options.client ?? this.client).patch({
1187
+ responseStyle: 'data',
1188
+ security: [{ scheme: 'bearer', type: 'http' }],
1189
+ url: '/tags/{tag_id}',
1190
+ ...options,
1191
+ headers: {
1192
+ 'Content-Type': 'application/json',
1193
+ ...options.headers
1194
+ }
1195
+ });
1196
+ }
1197
+ /**
1198
+ * Search conversations
1199
+ *
1200
+ * Conversations whose contact or messages contain the text, latest activity first. Answers one page of at most `limit`; `next_cursor` is always null.
1201
+ *
1202
+ * Scope: `conversations:read`.
1203
+ */
1204
+ searchConversations(options) {
1205
+ return (options.client ?? this.client).get({
1206
+ responseStyle: 'data',
1207
+ security: [{ scheme: 'bearer', type: 'http' }],
1208
+ url: '/conversations/search',
1209
+ ...options
1210
+ });
1211
+ }
1212
+ /**
1213
+ * Change a conversation's tags
1214
+ *
1215
+ * Tags belong to the conversation's contact: this adds and removes tags on it and answers the contact.
1216
+ *
1217
+ * Scope: `contacts:write`.
1218
+ */
1219
+ changeConversationTags(options) {
1220
+ return (options.client ?? this.client).patch({
1221
+ responseStyle: 'data',
1222
+ security: [{ scheme: 'bearer', type: 'http' }],
1223
+ url: '/conversations/{conversation_id}/tags',
1224
+ ...options,
1225
+ headers: {
1226
+ 'Content-Type': 'application/json',
1227
+ ...options.headers
1228
+ }
1229
+ });
1230
+ }
1231
+ /**
1232
+ * Mark a conversation read
1233
+ *
1234
+ * Marks it read for the whole team through its latest message, as opening it in the inbox does. On WhatsApp the contact sees the read receipt. Send no body.
1235
+ *
1236
+ * Scope: `conversations:write`.
1237
+ */
1238
+ markConversationRead(options) {
1239
+ return (options.client ?? this.client).post({
1240
+ responseStyle: 'data',
1241
+ security: [{ scheme: 'bearer', type: 'http' }],
1242
+ url: '/conversations/{conversation_id}/read',
1243
+ ...options
1244
+ });
1245
+ }
1246
+ /**
1247
+ * Search messages
1248
+ *
1249
+ * Messages of every conversation that contain the words, newest first. Answers one page of at most `limit`; `next_cursor` is always null.
1250
+ *
1251
+ * Scope: `conversations:read`.
1252
+ */
1253
+ searchMessages(options) {
1254
+ return (options.client ?? this.client).get({
1255
+ responseStyle: 'data',
1256
+ security: [{ scheme: 'bearer', type: 'http' }],
1257
+ url: '/messages/search',
1258
+ ...options
1259
+ });
1260
+ }
1261
+ /**
1262
+ * List quick replies
1263
+ *
1264
+ * Every quick reply of the organization, by title.
1265
+ *
1266
+ * Scope: `quick_replies:read`.
1267
+ */
1268
+ listQuickReplies(options) {
1269
+ return (options?.client ?? this.client).get({
1270
+ responseStyle: 'data',
1271
+ security: [{ scheme: 'bearer', type: 'http' }],
1272
+ url: '/quick-replies',
1273
+ ...options
1274
+ });
1275
+ }
1276
+ /**
1277
+ * Create a quick reply
1278
+ *
1279
+ * Saves an answer operators can insert in the inbox. A title already in use, in any case, answers `409 conflict`.
1280
+ *
1281
+ * Scope: `quick_replies:write`.
1282
+ */
1283
+ createQuickReply(options) {
1284
+ return (options.client ?? this.client).post({
1285
+ responseStyle: 'data',
1286
+ security: [{ scheme: 'bearer', type: 'http' }],
1287
+ url: '/quick-replies',
1288
+ ...options,
1289
+ headers: {
1290
+ 'Content-Type': 'application/json',
1291
+ ...options.headers
1292
+ }
1293
+ });
1294
+ }
1295
+ /**
1296
+ * Delete a quick reply
1297
+ *
1298
+ * Deletes it and answers it as it was. It cannot be undone.
1299
+ *
1300
+ * Scope: `quick_replies:write`.
1301
+ */
1302
+ deleteQuickReply(options) {
1303
+ return (options.client ?? this.client).delete({
1304
+ responseStyle: 'data',
1305
+ security: [{ scheme: 'bearer', type: 'http' }],
1306
+ url: '/quick-replies/{quick_reply_id}',
1307
+ ...options
1308
+ });
1309
+ }
1310
+ /**
1311
+ * Get a quick reply
1312
+ *
1313
+ * One quick reply.
1314
+ *
1315
+ * Scope: `quick_replies:read`.
1316
+ */
1317
+ getQuickReply(options) {
1318
+ return (options.client ?? this.client).get({
1319
+ responseStyle: 'data',
1320
+ security: [{ scheme: 'bearer', type: 'http' }],
1321
+ url: '/quick-replies/{quick_reply_id}',
1322
+ ...options
1323
+ });
1324
+ }
1325
+ /**
1326
+ * Update a quick reply
1327
+ *
1328
+ * Changes only the fields in the body. A title already in use, in any case, answers `409 conflict`.
1329
+ *
1330
+ * Scope: `quick_replies:write`.
1331
+ */
1332
+ updateQuickReply(options) {
1333
+ return (options.client ?? this.client).patch({
1334
+ responseStyle: 'data',
1335
+ security: [{ scheme: 'bearer', type: 'http' }],
1336
+ url: '/quick-replies/{quick_reply_id}',
1337
+ ...options,
1338
+ headers: {
1339
+ 'Content-Type': 'application/json',
1340
+ ...options.headers
1341
+ }
1342
+ });
1343
+ }
1344
+ /**
1345
+ * List templates
1346
+ *
1347
+ * WhatsApp templates of every connected business account, read live from Meta.
1348
+ *
1349
+ * Scope: `templates:read`.
1350
+ */
1351
+ listTemplates(options) {
1352
+ return (options?.client ?? this.client).get({
1353
+ responseStyle: 'data',
1354
+ security: [{ scheme: 'bearer', type: 'http' }],
1355
+ url: '/templates',
1356
+ ...options
1357
+ });
1358
+ }
1359
+ /**
1360
+ * Create a template
1361
+ *
1362
+ * Submits a template to Meta for review from the business account of `channel_id`. It answers the template as Meta has it, usually `PENDING`; follow it with `GET /templates/{template_id}`. A draft that breaks a rule answers `400` with the first problem; Meta refusing it answers `422 rule_violation` with its reason.
1363
+ *
1364
+ * Scope: `templates:write`.
1365
+ */
1366
+ createTemplate(options) {
1367
+ return (options.client ?? this.client).post({
1368
+ responseStyle: 'data',
1369
+ security: [{ scheme: 'bearer', type: 'http' }],
1370
+ url: '/templates',
1371
+ ...options,
1372
+ headers: {
1373
+ 'Content-Type': 'application/json',
1374
+ ...options.headers
1375
+ }
1376
+ });
1377
+ }
1378
+ /**
1379
+ * Delete a template
1380
+ *
1381
+ * Deletes the template at Meta. Meta deletes it in every language that shares its name, and the name cannot be used again for 30 days.
1382
+ *
1383
+ * Scope: `templates:write`.
1384
+ */
1385
+ deleteTemplate(options) {
1386
+ return (options.client ?? this.client).delete({
1387
+ responseStyle: 'data',
1388
+ security: [{ scheme: 'bearer', type: 'http' }],
1389
+ url: '/templates/{template_id}',
1390
+ ...options
1391
+ });
1392
+ }
1393
+ /**
1394
+ * Get a template
1395
+ *
1396
+ * One template, read live from Meta, with its review `status`: `PENDING` while Meta reviews it, then `APPROVED`, `REJECTED` or `PAUSED`. Read it again to follow Meta's review.
1397
+ *
1398
+ * Scope: `templates:read`.
1399
+ */
1400
+ getTemplate(options) {
1401
+ return (options.client ?? this.client).get({
1402
+ responseStyle: 'data',
1403
+ security: [{ scheme: 'bearer', type: 'http' }],
1404
+ url: '/templates/{template_id}',
1405
+ ...options
1406
+ });
1407
+ }
1408
+ /**
1409
+ * Edit a template
1410
+ *
1411
+ * Changes the category or content of a template and sends it to Meta for review again. Meta allows it only for `APPROVED`, `REJECTED` and `PAUSED` templates, and limits how often an approved one can change; otherwise it answers `422 rule_violation`. Templates with a media header, or with buttons and components Ricky’s editor does not build, cannot be edited here.
1412
+ *
1413
+ * Scope: `templates:write`.
1414
+ */
1415
+ updateTemplate(options) {
1416
+ return (options.client ?? this.client).patch({
1417
+ responseStyle: 'data',
1418
+ security: [{ scheme: 'bearer', type: 'http' }],
1419
+ url: '/templates/{template_id}',
1420
+ ...options,
1421
+ headers: {
1422
+ 'Content-Type': 'application/json',
1423
+ ...options.headers
1424
+ }
1425
+ });
1426
+ }
1427
+ /**
1428
+ * Validate a template draft
1429
+ *
1430
+ * Checks a draft with the rules of Ricky’s template editor and answers every problem found, without submitting anything to Meta. A body that is not a draft answers `400`; a draft that breaks a rule answers `200` with `valid: false`. Meta can still reject a valid draft in its review.
1431
+ *
1432
+ * Scope: `templates:read`.
1433
+ */
1434
+ validateTemplate(options) {
1435
+ return (options.client ?? this.client).post({
1436
+ responseStyle: 'data',
1437
+ security: [{ scheme: 'bearer', type: 'http' }],
1438
+ url: '/templates/validate',
1439
+ ...options,
1440
+ headers: {
1441
+ 'Content-Type': 'application/json',
1442
+ ...options.headers
1443
+ }
1444
+ });
1445
+ }
1446
+ /**
1447
+ * List WhatsApp numbers
1448
+ *
1449
+ * Every WhatsApp number of the organization, also disconnected ones, with its status, quality rating and messaging limit as Ricky last read them from Meta.
1450
+ *
1451
+ * Scope: `conversations:read`.
1452
+ */
1453
+ listWhatsAppNumbers(options) {
1454
+ return (options?.client ?? this.client).get({
1455
+ responseStyle: 'data',
1456
+ security: [{ scheme: 'bearer', type: 'http' }],
1457
+ url: '/whatsapp-numbers',
1458
+ ...options
1459
+ });
1460
+ }
1461
+ /**
1462
+ * Get a WhatsApp number
1463
+ *
1464
+ * One WhatsApp number by its channel ID.
1465
+ *
1466
+ * Scope: `conversations:read`.
1467
+ */
1468
+ getWhatsAppNumber(options) {
1469
+ return (options.client ?? this.client).get({
1470
+ responseStyle: 'data',
1471
+ security: [{ scheme: 'bearer', type: 'http' }],
1472
+ url: '/whatsapp-numbers/{channel_id}',
1473
+ ...options
1474
+ });
1475
+ }
1125
1476
  }
1126
1477
  exports.RickyApi = RickyApi;