@@ -161,7 +161,7 @@ public function get_growth_stats(\DateTime $starting = null, \DateTime $ending =
161161 *
162162 * @see https://developers.convertkit.com/v4.html#convertkit-api-forms
163163 *
164- * @return false |array<int,\stdClass>
164+ * @return mixed |array<int,\stdClass>
165165 */
166166 public function get_forms (
167167 string $ status = 'active ' ,
@@ -198,7 +198,7 @@ public function get_forms(
198198 *
199199 * @see https://developers.convertkit.com/v4.html#convertkit-api-forms
200200 *
201- * @return false |array<int,\stdClass>
201+ * @return mixed |array<int,\stdClass>
202202 */
203203 public function get_landing_pages (
204204 string $ status = 'active ' ,
@@ -222,21 +222,57 @@ public function get_landing_pages(
222222 );
223223 }
224224
225+ /**
226+ * Adds subscribers to forms in bulk.
227+ *
228+ * @param array<array<string,string>> $forms_subscribers_ids Array of arrays comprising of `form_id`, `subscriber_id` and optional `referrer` URL.
229+ * @param string $callback_url URL to notify for large batch size when async processing complete.
230+ *
231+ * @since 2.1.0
232+ *
233+ * @see https://developers.kit.com/v4.html#bulk-add-subscribers-to-forms
234+ *
235+ * @return false|object
236+ */
237+ public function add_subscribers_to_forms (array $ forms_subscribers_ids , string $ callback_url = '' )
238+ {
239+ // Build parameters.
240+ $ options = ['additions ' => $ forms_subscribers_ids ];
241+ if (!empty ($ callback_url )) {
242+ $ options ['callback_url ' ] = $ callback_url ;
243+ }
244+
245+ // Send request.
246+ return $ this ->post (
247+ 'bulk/forms/subscribers ' ,
248+ $ options
249+ );
250+ }
251+
225252 /**
226253 * Adds a subscriber to a form by email address
227254 *
228255 * @param integer $form_id Form ID.
229256 * @param string $email_address Email Address.
257+ * @param string $referrer Referrer.
230258 *
231259 * @see https://developers.convertkit.com/v4.html#add-subscriber-to-form-by-email-address
232260 *
233261 * @return false|mixed
234262 */
235- public function add_subscriber_to_form_by_email (int $ form_id , string $ email_address )
263+ public function add_subscriber_to_form_by_email (int $ form_id , string $ email_address, string $ referrer = '' )
236264 {
265+ // Build parameters.
266+ $ options = ['email_address ' => $ email_address ];
267+
268+ if (!empty ($ referrer )) {
269+ $ options ['referrer ' ] = $ referrer ;
270+ }
271+
272+ // Send request.
237273 return $ this ->post (
238274 sprintf ('forms/%s/subscribers ' , $ form_id ),
239- [ ' email_address ' => $ email_address ]
275+ $ options
240276 );
241277 }
242278
@@ -245,16 +281,28 @@ public function add_subscriber_to_form_by_email(int $form_id, string $email_addr
245281 *
246282 * @param integer $form_id Form ID.
247283 * @param integer $subscriber_id Subscriber ID.
284+ * @param string $referrer Referrer URL.
248285 *
249286 * @see https://developers.convertkit.com/v4.html#add-subscriber-to-form
250287 *
251288 * @since 2.0.0
252289 *
253290 * @return false|mixed
254291 */
255- public function add_subscriber_to_form (int $ form_id , int $ subscriber_id )
292+ public function add_subscriber_to_form (int $ form_id , int $ subscriber_id, string $ referrer = '' )
256293 {
257- return $ this ->post (sprintf ('forms/%s/subscribers/%s ' , $ form_id , $ subscriber_id ));
294+ // Build parameters.
295+ $ options = [];
296+
297+ if (!empty ($ referrer )) {
298+ $ options ['referrer ' ] = $ referrer ;
299+ }
300+
301+ // Send request.
302+ return $ this ->post (
303+ sprintf ('forms/%s/subscribers/%s ' , $ form_id , $ subscriber_id ),
304+ $ options
305+ );
258306 }
259307
260308 /**
@@ -456,7 +504,7 @@ public function get_sequence_subscriptions(
456504 *
457505 * @see https://developers.convertkit.com/v4.html#list-tags
458506 *
459- * @return false |array<int,\stdClass>
507+ * @return mixed |array<int,\stdClass>
460508 */
461509 public function get_tags (
462510 bool $ include_total_count = false ,
@@ -863,10 +911,26 @@ public function get_subscriber_id(string $email_address)
863911 ['email_address ' => $ email_address ]
864912 );
865913
914+ if (!$ subscribers instanceof \stdClass) {
915+ return false ;
916+ }
917+
918+ if (!is_array ($ subscribers ->subscribers )) {
919+ return false ;
920+ }
921+
866922 if (!count ($ subscribers ->subscribers )) {
867923 return false ;
868924 }
869925
926+ if (!$ subscribers ->subscribers [0 ] instanceof \stdClass) {
927+ return false ;
928+ }
929+
930+ if (!is_int ($ subscribers ->subscribers [0 ]->id )) {
931+ return false ;
932+ }
933+
870934 // Return the subscriber's ID.
871935 return $ subscribers ->subscribers [0 ]->id ;
872936 }
@@ -878,7 +942,7 @@ public function get_subscriber_id(string $email_address)
878942 *
879943 * @see https://developers.convertkit.com/v4.html#get-a-subscriber
880944 *
881- * @return false |integer
945+ * @return mixed |integer
882946 */
883947 public function get_subscriber (int $ subscriber_id )
884948 {
@@ -895,7 +959,7 @@ public function get_subscriber(int $subscriber_id)
895959 *
896960 * @see https://developers.convertkit.com/v4.html#update-a-subscriber
897961 *
898- * @return false| mixed
962+ * @return mixed
899963 */
900964 public function update_subscriber (
901965 int $ subscriber_id ,
@@ -930,7 +994,7 @@ public function update_subscriber(
930994 *
931995 * @see https://developers.convertkit.com/v4.html#unsubscribe-subscriber
932996 *
933- * @return false |object
997+ * @return mixed |object
934998 */
935999 public function unsubscribe_by_email (string $ email_address )
9361000 {
@@ -949,7 +1013,7 @@ public function unsubscribe_by_email(string $email_address)
9491013 *
9501014 * @see https://developers.convertkit.com/v4.html#unsubscribe-subscriber
9511015 *
952- * @return false |object
1016+ * @return mixed |object
9531017 */
9541018 public function unsubscribe (int $ subscriber_id )
9551019 {
@@ -967,7 +1031,7 @@ public function unsubscribe(int $subscriber_id)
9671031 *
9681032 * @see https://developers.convertkit.com/v4.html#list-tags-for-a-subscriber
9691033 *
970- * @return false |array<int,\stdClass>
1034+ * @return mixed |array<int,\stdClass>
9711035 */
9721036 public function get_subscriber_tags (
9731037 int $ subscriber_id ,
@@ -1044,7 +1108,7 @@ public function get_broadcasts(
10441108 *
10451109 * @see https://developers.convertkit.com/v4.html#create-a-broadcast
10461110 *
1047- * @return false |object
1111+ * @return mixed |object
10481112 */
10491113 public function create_broadcast (
10501114 string $ subject = '' ,
@@ -1103,7 +1167,7 @@ public function create_broadcast(
11031167 *
11041168 * @see https://developers.convertkit.com/v4.html#get-a-broadcast
11051169 *
1106- * @return false |object
1170+ * @return mixed |object
11071171 */
11081172 public function get_broadcast (int $ id )
11091173 {
@@ -1118,7 +1182,7 @@ public function get_broadcast(int $id)
11181182 *
11191183 * @see https://developers.convertkit.com/v4.html#get-stats
11201184 *
1121- * @return false |object
1185+ * @return mixed |object
11221186 */
11231187 public function get_broadcast_stats (int $ id )
11241188 {
@@ -1151,7 +1215,7 @@ public function get_broadcast_stats(int $id)
11511215 *
11521216 * @see https://developers.convertkit.com/#create-a-broadcast
11531217 *
1154- * @return false |object
1218+ * @return mixed |object
11551219 */
11561220 public function update_broadcast (
11571221 int $ id ,
@@ -1213,7 +1277,7 @@ public function update_broadcast(
12131277 *
12141278 * @see https://developers.convertkit.com/v4.html#delete-a-broadcast
12151279 *
1216- * @return false |object
1280+ * @return mixed |object
12171281 */
12181282 public function delete_broadcast (int $ id )
12191283 {
@@ -1266,7 +1330,7 @@ public function get_webhooks(
12661330 *
12671331 * @throws \InvalidArgumentException If the event is not supported.
12681332 *
1269- * @return false |object
1333+ * @return mixed |object
12701334 */
12711335 public function create_webhook (string $ url , string $ event , string $ parameter = '' )
12721336 {
@@ -1340,7 +1404,7 @@ public function create_webhook(string $url, string $event, string $parameter = '
13401404 *
13411405 * @see https://developers.convertkit.com/v4.html#delete-a-webhook
13421406 *
1343- * @return false |object
1407+ * @return mixed |object
13441408 */
13451409 public function delete_webhook (int $ id )
13461410 {
@@ -1389,7 +1453,7 @@ public function get_custom_fields(
13891453 *
13901454 * @see https://developers.convertkit.com/v4.html#create-a-custom-field
13911455 *
1392- * @return false |object
1456+ * @return mixed |object
13931457 */
13941458 public function create_custom_field (string $ label )
13951459 {
@@ -1409,7 +1473,7 @@ public function create_custom_field(string $label)
14091473 *
14101474 * @see https://developers.convertkit.com/v4.html#bulk-create-custom-fields
14111475 *
1412- * @return false |object
1476+ * @return mixed |object
14131477 */
14141478 public function create_custom_fields (array $ labels , string $ callback_url = '' )
14151479 {
@@ -1444,7 +1508,7 @@ public function create_custom_fields(array $labels, string $callback_url = '')
14441508 *
14451509 * @see https://developers.convertkit.com/v4.html#update-a-custom-field
14461510 *
1447- * @return false |object
1511+ * @return mixed |object
14481512 */
14491513 public function update_custom_field (int $ id , string $ label )
14501514 {
@@ -1463,7 +1527,7 @@ public function update_custom_field(int $id, string $label)
14631527 *
14641528 * @see https://developers.convertkit.com/#destroy-field
14651529 *
1466- * @return false |object
1530+ * @return mixed |object
14671531 */
14681532 public function delete_custom_field (int $ id )
14691533 {
@@ -1510,7 +1574,7 @@ public function get_purchases(
15101574 *
15111575 * @see https://developers.convertkit.com/v4.html#get-a-purchase
15121576 *
1513- * @return false |object
1577+ * @return mixed |object
15141578 */
15151579 public function get_purchase (int $ purchase_id )
15161580 {
@@ -1535,7 +1599,7 @@ public function get_purchase(int $purchase_id)
15351599 *
15361600 * @see https://developers.convertkit.com/v4.html#create-a-purchase
15371601 *
1538- * @return false |object
1602+ * @return mixed |object
15391603 */
15401604 public function create_purchase (
15411605 string $ email_address ,
0 commit comments