@@ -1292,39 +1292,59 @@ public function get_subscriber_tags(
1292
1292
}
1293
1293
1294
1294
/**
1295
- * Gets a list of broadcasts.
1295
+ * List broadcasts.
1296
1296
*
1297
- * @see https://developers.convertkit.com/#list-broadcasts
1297
+ * @param boolean $include_total_count To include the total count of records in the response, use true.
1298
+ * @param string $after_cursor Return results after the given pagination cursor.
1299
+ * @param string $before_cursor Return results before the given pagination cursor.
1300
+ * @param integer $per_page Number of results to return.
1298
1301
*
1299
- * @return false|array<int,\stdClass>
1302
+ * @see https://developers.convertkit.com/v4.html#list-broadcasts
1303
+ *
1304
+ * @return false|mixed
1300
1305
*/
1301
- public function get_broadcasts ()
1302
- {
1303
- return $ this ->get ('broadcasts ' );
1306
+ public function get_broadcasts (
1307
+ bool $ include_total_count = false ,
1308
+ string $ after_cursor = '' ,
1309
+ string $ before_cursor = '' ,
1310
+ int $ per_page = 100
1311
+ ) {
1312
+ // Send request.
1313
+ return $ this ->get (
1314
+ endpoint: 'broadcasts ' ,
1315
+ args: $ this ->build_total_count_and_pagination_params (
1316
+ include_total_count: $ include_total_count ,
1317
+ after_cursor: $ after_cursor ,
1318
+ before_cursor: $ before_cursor ,
1319
+ per_page: $ per_page
1320
+ )
1321
+ );
1304
1322
}
1305
1323
1306
1324
/**
1307
1325
* Creates a broadcast.
1308
1326
*
1309
- * @param string $subject The broadcast email's subject.
1310
- * @param string $content The broadcast's email HTML content.
1311
- * @param string $description An internal description of this broadcast.
1312
- * @param boolean $public Specifies whether or not this is a public post.
1313
- * @param \DateTime $published_at Specifies the time that this post was published (applicable
1314
- * only to public posts).
1315
- * @param \DateTime $send_at Time that this broadcast should be sent; leave blank to create
1316
- * a draft broadcast. If set to a future time, this is the time that
1317
- * the broadcast will be scheduled to send.
1318
- * @param string $email_address Sending email address; leave blank to use your account's
1319
- * default sending email address.
1320
- * @param string $email_layout_template Name of the email template to use; leave blank to use your
1321
- * account's default email template.
1322
- * @param string $thumbnail_alt Specify the ALT attribute of the public thumbnail image
1323
- * (applicable only to public posts).
1324
- * @param string $thumbnail_url Specify the URL of the thumbnail image to accompany the broadcast
1325
- * post (applicable only to public posts).
1326
- *
1327
- * @see https://developers.convertkit.com/#create-a-broadcast
1327
+ * @param string $subject The broadcast email's subject.
1328
+ * @param string $content The broadcast's email HTML content.
1329
+ * @param string $description An internal description of this broadcast.
1330
+ * @param boolean $public Specifies whether or not this is a public post.
1331
+ * @param \DateTime $published_at Specifies the time that this post was published (applicable
1332
+ * only to public posts).
1333
+ * @param \DateTime $send_at Time that this broadcast should be sent; leave blank to create
1334
+ * a draft broadcast. If set to a future time, this is the time that
1335
+ * the broadcast will be scheduled to send.
1336
+ * @param string $email_address Sending email address; leave blank to use your account's
1337
+ * default sending email address.
1338
+ * @param string $email_template_id ID of the email template to use; leave blank to use your
1339
+ * account's default email template.
1340
+ * @param string $thumbnail_alt Specify the ALT attribute of the public thumbnail image
1341
+ * (applicable only to public posts).
1342
+ * @param string $thumbnail_url Specify the URL of the thumbnail image to accompany the broadcast
1343
+ * post (applicable only to public posts).
1344
+ * @param string $preview_text Specify the preview text of the email.
1345
+ * @param array<string,string> $subscriber_filter Filter subscriber(s) to send the email to.
1346
+ *
1347
+ * @see https://developers.convertkit.com/v4.html#create-a-broadcast
1328
1348
*
1329
1349
* @return false|object
1330
1350
*/
@@ -1336,22 +1356,28 @@ public function create_broadcast(
1336
1356
\DateTime $ published_at = null ,
1337
1357
\DateTime $ send_at = null ,
1338
1358
string $ email_address = '' ,
1339
- string $ email_layout_template = '' ,
1359
+ string $ email_template_id = '' ,
1340
1360
string $ thumbnail_alt = '' ,
1341
- string $ thumbnail_url = ''
1361
+ string $ thumbnail_url = '' ,
1362
+ string $ preview_text = '' ,
1363
+ array $ subscriber_filter = []
1342
1364
) {
1343
1365
$ options = [
1344
- 'content ' => $ content ,
1345
- 'description ' => $ description ,
1346
- 'email_address ' => $ email_address ,
1347
- 'email_layout_template ' => $ email_layout_template ,
1348
- 'public ' => $ public ,
1349
- 'published_at ' => (!is_null ($ published_at ) ? $ published_at ->format ('Y-m-d H:i:s ' ) : '' ),
1350
- 'send_at ' => (!is_null ($ send_at ) ? $ send_at ->format ('Y-m-d H:i:s ' ) : '' ),
1351
- 'subject ' => $ subject ,
1352
- 'thumbnail_alt ' => $ thumbnail_alt ,
1353
- 'thumbnail_url ' => $ thumbnail_url ,
1366
+ 'email_template_id ' => $ email_template_id ,
1367
+ 'email_address ' => $ email_address ,
1368
+ 'content ' => $ content ,
1369
+ 'description ' => $ description ,
1370
+ 'public ' => $ public ,
1371
+ 'published_at ' => (!is_null ($ published_at ) ? $ published_at ->format ('Y-m-d H:i:s ' ) : '' ),
1372
+ 'send_at ' => (!is_null ($ send_at ) ? $ send_at ->format ('Y-m-d H:i:s ' ) : '' ),
1373
+ 'thumbnail_alt ' => $ thumbnail_alt ,
1374
+ 'thumbnail_url ' => $ thumbnail_url ,
1375
+ 'preview_text ' => $ preview_text ,
1376
+ 'subject ' => $ subject ,
1354
1377
];
1378
+ if (count ($ subscriber_filter )) {
1379
+ $ options ['subscriber_filter ' ] = $ subscriber_filter ;
1380
+ }
1355
1381
1356
1382
// Iterate through options, removing blank entries.
1357
1383
foreach ($ options as $ key => $ value ) {
@@ -1366,15 +1392,18 @@ public function create_broadcast(
1366
1392
}
1367
1393
1368
1394
// Send request.
1369
- return $ this ->post ('broadcasts ' , $ options );
1395
+ return $ this ->post (
1396
+ endpoint: 'broadcasts ' ,
1397
+ args: $ options
1398
+ );
1370
1399
}
1371
1400
1372
1401
/**
1373
1402
* Retrieve a specific broadcast.
1374
1403
*
1375
1404
* @param integer $id Broadcast ID.
1376
1405
*
1377
- * @see https://developers.convertkit.com/#retrieve-a-specific -broadcast
1406
+ * @see https://developers.convertkit.com/v4.html#get-a -broadcast
1378
1407
*
1379
1408
* @return false|object
1380
1409
*/
@@ -1389,7 +1418,7 @@ public function get_broadcast(int $id)
1389
1418
*
1390
1419
* @param integer $id Broadcast ID.
1391
1420
*
1392
- * @see https://developers.convertkit.com/#retrieve-a-specific-broadcast
1421
+ * @see https://developers.convertkit.com/v4.html#get-stats
1393
1422
*
1394
1423
* @return false|object
1395
1424
*/
@@ -1401,24 +1430,26 @@ public function get_broadcast_stats(int $id)
1401
1430
/**
1402
1431
* Updates a broadcast.
1403
1432
*
1404
- * @param integer $id Broadcast ID.
1405
- * @param string $subject The broadcast email's subject.
1406
- * @param string $content The broadcast's email HTML content.
1407
- * @param string $description An internal description of this broadcast.
1408
- * @param boolean $public Specifies whether or not this is a public post.
1409
- * @param \DateTime $published_at Specifies the time that this post was published (applicable
1410
- * only to public posts).
1411
- * @param \DateTime $send_at Time that this broadcast should be sent; leave blank to create
1412
- * a draft broadcast. If set to a future time, this is the time that
1413
- * the broadcast will be scheduled to send.
1414
- * @param string $email_address Sending email address; leave blank to use your account's
1415
- * default sending email address.
1416
- * @param string $email_layout_template Name of the email template to use; leave blank to use your
1417
- * account's default email template.
1418
- * @param string $thumbnail_alt Specify the ALT attribute of the public thumbnail image
1419
- * (applicable only to public posts).
1420
- * @param string $thumbnail_url Specify the URL of the thumbnail image to accompany the broadcast
1421
- * post (applicable only to public posts).
1433
+ * @param integer $id Broadcast ID.
1434
+ * @param string $subject The broadcast email's subject.
1435
+ * @param string $content The broadcast's email HTML content.
1436
+ * @param string $description An internal description of this broadcast.
1437
+ * @param boolean $public Specifies whether or not this is a public post.
1438
+ * @param \DateTime $published_at Specifies the time that this post was published (applicable
1439
+ * only to public posts).
1440
+ * @param \DateTime $send_at Time that this broadcast should be sent; leave blank to create
1441
+ * a draft broadcast. If set to a future time, this is the time that
1442
+ * the broadcast will be scheduled to send.
1443
+ * @param string $email_address Sending email address; leave blank to use your account's
1444
+ * default sending email address.
1445
+ * @param string $email_template_id ID of the email template to use; leave blank to use your
1446
+ * account's default email template.
1447
+ * @param string $thumbnail_alt Specify the ALT attribute of the public thumbnail image
1448
+ * (applicable only to public posts).
1449
+ * @param string $thumbnail_url Specify the URL of the thumbnail image to accompany the broadcast
1450
+ * post (applicable only to public posts).
1451
+ * @param string $preview_text Specify the preview text of the email.
1452
+ * @param array<string,string> $subscriber_filter Filter subscriber(s) to send the email to.
1422
1453
*
1423
1454
* @see https://developers.convertkit.com/#create-a-broadcast
1424
1455
*
@@ -1433,22 +1464,28 @@ public function update_broadcast(
1433
1464
\DateTime $ published_at = null ,
1434
1465
\DateTime $ send_at = null ,
1435
1466
string $ email_address = '' ,
1436
- string $ email_layout_template = '' ,
1467
+ string $ email_template_id = '' ,
1437
1468
string $ thumbnail_alt = '' ,
1438
- string $ thumbnail_url = ''
1469
+ string $ thumbnail_url = '' ,
1470
+ string $ preview_text = '' ,
1471
+ array $ subscriber_filter = []
1439
1472
) {
1440
1473
$ options = [
1441
- 'content ' => $ content ,
1442
- 'description ' => $ description ,
1443
- 'email_address ' => $ email_address ,
1444
- 'email_layout_template ' => $ email_layout_template ,
1445
- 'public ' => $ public ,
1446
- 'published_at ' => (!is_null ($ published_at ) ? $ published_at ->format ('Y-m-d H:i:s ' ) : '' ),
1447
- 'send_at ' => (!is_null ($ send_at ) ? $ send_at ->format ('Y-m-d H:i:s ' ) : '' ),
1448
- 'subject ' => $ subject ,
1449
- 'thumbnail_alt ' => $ thumbnail_alt ,
1450
- 'thumbnail_url ' => $ thumbnail_url ,
1474
+ 'email_template_id ' => $ email_template_id ,
1475
+ 'email_address ' => $ email_address ,
1476
+ 'content ' => $ content ,
1477
+ 'description ' => $ description ,
1478
+ 'public ' => $ public ,
1479
+ 'published_at ' => (!is_null ($ published_at ) ? $ published_at ->format ('Y-m-d H:i:s ' ) : '' ),
1480
+ 'send_at ' => (!is_null ($ send_at ) ? $ send_at ->format ('Y-m-d H:i:s ' ) : '' ),
1481
+ 'thumbnail_alt ' => $ thumbnail_alt ,
1482
+ 'thumbnail_url ' => $ thumbnail_url ,
1483
+ 'preview_text ' => $ preview_text ,
1484
+ 'subject ' => $ subject ,
1451
1485
];
1486
+ if (count ($ subscriber_filter )) {
1487
+ $ options ['subscriber_filter ' ] = $ subscriber_filter ;
1488
+ }
1452
1489
1453
1490
// Iterate through options, removing blank entries.
1454
1491
foreach ($ options as $ key => $ value ) {
@@ -1464,8 +1501,8 @@ public function update_broadcast(
1464
1501
1465
1502
// Send request.
1466
1503
return $ this ->put (
1467
- sprintf ('broadcasts/%s ' , $ id ),
1468
- $ options
1504
+ endpoint: sprintf ('broadcasts/%s ' , $ id ),
1505
+ args: $ options
1469
1506
);
1470
1507
}
1471
1508
@@ -1476,11 +1513,11 @@ public function update_broadcast(
1476
1513
*
1477
1514
* @since 1.0.0
1478
1515
*
1479
- * @see https://developers.convertkit.com/#destroy-webhook
1516
+ * @see https://developers.convertkit.com/v4.html#delete-a-broadcast
1480
1517
*
1481
1518
* @return false|object
1482
1519
*/
1483
- public function destroy_broadcast (int $ id )
1520
+ public function delete_broadcast (int $ id )
1484
1521
{
1485
1522
return $ this ->delete (sprintf ('broadcasts/%s ' , $ id ));
1486
1523
}
0 commit comments