@@ -4853,17 +4853,19 @@ public function testCreateWebhookWithEventParameter()
48534853 $ url = 'https://webhook.site/ ' . str_shuffle ('wfervdrtgsdewrafvwefds ' );
48544854 $ result = $ this ->api ->create_webhook (
48554855 url: $ url ,
4856- event: 'subscriber.form_subscribe ' ,
4857- parameter: $ _ENV ['CONVERTKIT_API_FORM_ID ' ]
4856+ event: 'custom_field.field_value_updated ' ,
4857+ parameter: $ _ENV ['CONVERTKIT_API_CUSTOM_FIELD_ID ' ]
48584858 );
48594859
48604860 // Confirm webhook created with correct data.
48614861 $ this ->assertArrayHasKey ('webhook ' , get_object_vars ($ result ));
48624862 $ this ->assertArrayHasKey ('id ' , get_object_vars ($ result ->webhook ));
4863+ $ this ->assertArrayHasKey ('account_id ' , get_object_vars ($ result ->webhook ));
4864+ $ this ->assertArrayHasKey ('event ' , get_object_vars ($ result ->webhook ));
48634865 $ this ->assertArrayHasKey ('target_url ' , get_object_vars ($ result ->webhook ));
48644866 $ this ->assertEquals ($ result ->webhook ->target_url , $ url );
4865- $ this ->assertEquals ($ result ->webhook ->event ->name , 'form_subscribe ' );
4866- $ this ->assertEquals ($ result ->webhook ->event ->form_id , $ _ENV ['CONVERTKIT_API_FORM_ID ' ]);
4867+ $ this ->assertEquals ($ result ->webhook ->event ->name , 'field_value_updated ' );
4868+ $ this ->assertEquals ($ result ->webhook ->event ->custom_field_id , $ _ENV ['CONVERTKIT_API_CUSTOM_FIELD_ID ' ]);
48674869
48684870 // Delete the webhook.
48694871 $ result = $ this ->api ->delete_webhook ($ result ->webhook ->id );
@@ -5059,6 +5061,55 @@ public function testCreateCustomFields()
50595061 $ this ->assertIsArray ($ result ->custom_fields );
50605062 }
50615063
5064+ /**
5065+ * Test that update_subscriber_custom_field_values() works.
5066+ *
5067+ * @since 2.4.0
5068+ *
5069+ * @return void
5070+ */
5071+ public function testUpdateSubscriberCustomFieldValues ()
5072+ {
5073+ // Create subscribers.
5074+ $ subscribers = [
5075+ [
5076+ 'email_address ' => str_replace ('@kit.com ' , '-1@kit.com ' , $ this ->generateEmailAddress ()),
5077+ ],
5078+ [
5079+ 'email_address ' => str_replace ('@kit.com ' , '-2@kit.com ' , $ this ->generateEmailAddress ()),
5080+ ],
5081+ ];
5082+ $ result = $ this ->api ->create_subscribers ($ subscribers );
5083+
5084+ // Set subscriber_id to ensure subscriber is unsubscribed after test.
5085+ foreach ($ result ->subscribers as $ i => $ subscriber ) {
5086+ $ this ->subscriber_ids [] = $ subscriber ->id ;
5087+ }
5088+
5089+ // Bulk update subscriber custom field values.
5090+ $ result = $ this ->api ->update_subscriber_custom_field_values (
5091+ [
5092+ [
5093+ 'subscriber_id ' => $ this ->subscriber_ids [0 ],
5094+ 'subscriber_custom_field_id ' => (int ) $ _ENV ['CONVERTKIT_API_CUSTOM_FIELD_ID ' ],
5095+ 'value ' => '100 ' ,
5096+ ],
5097+ [
5098+ 'subscriber_id ' => $ this ->subscriber_ids [1 ],
5099+ 'subscriber_custom_field_id ' => (int ) $ _ENV ['CONVERTKIT_API_CUSTOM_FIELD_ID ' ],
5100+ 'value ' => '200 ' ,
5101+ ],
5102+ ]
5103+ );
5104+
5105+ // Assert no failures.
5106+ $ this ->assertCount (0 , $ result ->failures );
5107+
5108+ // Confirm result is an array comprising of each custom field value that was updated.
5109+ $ this ->assertIsArray ($ result ->custom_field_values );
5110+ $ this ->assertCount (2 , $ result ->custom_field_values );
5111+ }
5112+
50625113 /**
50635114 * Test that update_custom_field() works.
50645115 *
0 commit comments