arky-sdk 0.3.126 → 0.3.127

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/dist/index.cjs CHANGED
@@ -795,30 +795,11 @@ var createCmsApi = (apiConfig) => {
795
795
  options
796
796
  );
797
797
  },
798
- async sendNode(params, options) {
799
- const { nodeId, scheduledAt } = params;
800
- return apiConfig.httpClient.post(
801
- `/v1/businesses/${apiConfig.businessId}/nodes/${nodeId}/send`,
802
- {
803
- businessId: apiConfig.businessId,
804
- nodeId,
805
- scheduledAt: scheduledAt ?? Math.floor(Date.now() / 1e3)
806
- },
807
- options
808
- );
809
- },
810
798
  async getVariableMetadata(params, options) {
811
799
  return apiConfig.httpClient.get(
812
800
  `/v1/businesses/${apiConfig.businessId}/nodes/types/${params.nodeType}/variables`,
813
801
  options
814
802
  );
815
- },
816
- async getNodeSubscribers(params, options) {
817
- const formattedId = formatIdOrSlug(params.id, apiConfig);
818
- return apiConfig.httpClient.get(
819
- `/v1/businesses/${apiConfig.businessId}/nodes/${formattedId}/subscribers`,
820
- options
821
- );
822
803
  }
823
804
  };
824
805
  };
@@ -1278,6 +1259,173 @@ var createLocationApi = (apiConfig) => {
1278
1259
  };
1279
1260
  };
1280
1261
 
1262
+ // src/api/newsletter.ts
1263
+ var createNewsletterApi = (apiConfig) => {
1264
+ return {
1265
+ // ===== NEWSLETTER CRUD =====
1266
+ /**
1267
+ * Create a new newsletter
1268
+ */
1269
+ async createNewsletter(params, options) {
1270
+ return apiConfig.httpClient.post(
1271
+ `/v1/newsletters`,
1272
+ { ...params, businessId: apiConfig.businessId },
1273
+ options
1274
+ );
1275
+ },
1276
+ /**
1277
+ * Get a newsletter by ID
1278
+ */
1279
+ async getNewsletter(params, options) {
1280
+ return apiConfig.httpClient.get(
1281
+ `/v1/newsletters/${params.id}`,
1282
+ options
1283
+ );
1284
+ },
1285
+ /**
1286
+ * List all newsletters for the business
1287
+ */
1288
+ async getNewsletters(params, options) {
1289
+ return apiConfig.httpClient.get(`/v1/newsletters`, {
1290
+ ...options,
1291
+ params: { ...params, businessId: apiConfig.businessId }
1292
+ });
1293
+ },
1294
+ /**
1295
+ * Update a newsletter
1296
+ */
1297
+ async updateNewsletter(params, options) {
1298
+ const { id, ...body } = params;
1299
+ return apiConfig.httpClient.put(`/v1/newsletters/${id}`, body, options);
1300
+ },
1301
+ /**
1302
+ * Delete a newsletter
1303
+ */
1304
+ async deleteNewsletter(params, options) {
1305
+ return apiConfig.httpClient.delete(
1306
+ `/v1/newsletters/${params.id}`,
1307
+ options
1308
+ );
1309
+ },
1310
+ /**
1311
+ * Get subscribers for a newsletter
1312
+ */
1313
+ async getSubscribers(params, options) {
1314
+ return apiConfig.httpClient.get(
1315
+ `/v1/newsletters/${params.id}/subscribers`,
1316
+ options
1317
+ );
1318
+ },
1319
+ // ===== POST CRUD =====
1320
+ /**
1321
+ * Create a new post for a newsletter
1322
+ */
1323
+ async createPost(params, options) {
1324
+ const { newsletterId, ...body } = params;
1325
+ return apiConfig.httpClient.post(
1326
+ `/v1/newsletters/${newsletterId}/posts`,
1327
+ { ...body, businessId: apiConfig.businessId },
1328
+ options
1329
+ );
1330
+ },
1331
+ /**
1332
+ * Get a post by ID
1333
+ */
1334
+ async getPost(params, options) {
1335
+ return apiConfig.httpClient.get(
1336
+ `/v1/newsletters/${params.newsletterId}/posts/${params.postId}`,
1337
+ options
1338
+ );
1339
+ },
1340
+ /**
1341
+ * List all posts for a newsletter
1342
+ */
1343
+ async getPosts(params, options) {
1344
+ const { newsletterId, ...queryParams } = params;
1345
+ return apiConfig.httpClient.get(
1346
+ `/v1/newsletters/${newsletterId}/posts`,
1347
+ {
1348
+ ...options,
1349
+ params: { ...queryParams, businessId: apiConfig.businessId }
1350
+ }
1351
+ );
1352
+ },
1353
+ /**
1354
+ * Update a post
1355
+ */
1356
+ async updatePost(params, options) {
1357
+ const { newsletterId, postId, ...body } = params;
1358
+ return apiConfig.httpClient.put(
1359
+ `/v1/newsletters/${newsletterId}/posts/${postId}`,
1360
+ body,
1361
+ options
1362
+ );
1363
+ },
1364
+ /**
1365
+ * Delete a post
1366
+ */
1367
+ async deletePost(params, options) {
1368
+ return apiConfig.httpClient.delete(
1369
+ `/v1/newsletters/${params.newsletterId}/posts/${params.postId}`,
1370
+ options
1371
+ );
1372
+ },
1373
+ // ===== SEND OPERATIONS =====
1374
+ /**
1375
+ * Schedule a send for a post
1376
+ */
1377
+ async scheduleSend(params, options) {
1378
+ const { newsletterId, postId, ...body } = params;
1379
+ return apiConfig.httpClient.post(
1380
+ `/v1/newsletters/${newsletterId}/posts/${postId}/send`,
1381
+ body,
1382
+ options
1383
+ );
1384
+ },
1385
+ /**
1386
+ * Cancel a scheduled send
1387
+ */
1388
+ async cancelSend(params, options) {
1389
+ const { newsletterId, postId, sendId } = params;
1390
+ return apiConfig.httpClient.post(
1391
+ `/v1/newsletters/${newsletterId}/posts/${postId}/send/${sendId}/cancel`,
1392
+ {},
1393
+ options
1394
+ );
1395
+ },
1396
+ // ===== CONVENIENCE METHODS =====
1397
+ /**
1398
+ * Publish a post (set status to PUBLISHED)
1399
+ */
1400
+ async publishPost(newsletterId, postId) {
1401
+ return this.updatePost({
1402
+ newsletterId,
1403
+ postId,
1404
+ status: "PUBLISHED"
1405
+ });
1406
+ },
1407
+ /**
1408
+ * Archive a post (set status to ARCHIVED)
1409
+ */
1410
+ async archivePost(newsletterId, postId) {
1411
+ return this.updatePost({
1412
+ newsletterId,
1413
+ postId,
1414
+ status: "ARCHIVED"
1415
+ });
1416
+ },
1417
+ /**
1418
+ * Send a post immediately
1419
+ */
1420
+ async sendNow(newsletterId, postId) {
1421
+ return this.scheduleSend({
1422
+ newsletterId,
1423
+ postId
1424
+ });
1425
+ }
1426
+ };
1427
+ };
1428
+
1281
1429
  // src/utils/currency.ts
1282
1430
  function getCurrencySymbol(currency) {
1283
1431
  const currencySymbols = {
@@ -1686,6 +1834,7 @@ async function createArkySDK(config) {
1686
1834
  database: createDatabaseApi(apiConfig),
1687
1835
  featureFlags: createFeatureFlagsApi(apiConfig),
1688
1836
  location: createLocationApi(apiConfig),
1837
+ newsletter: createNewsletterApi(apiConfig),
1689
1838
  setBusinessId: (businessId) => {
1690
1839
  apiConfig.businessId = businessId;
1691
1840
  },