@@ -206,6 +206,8 @@ public function get_form_subscriptions(
206206 /**
207207 * Gets all sequences
208208 *
209+ * @see https://developers.convertkit.com/#list-sequences
210+ *
209211 * @return false|mixed
210212 */
211213 public function get_sequences ()
@@ -219,39 +221,73 @@ public function get_sequences()
219221 }
220222
221223 /**
222- * Gets subscribers to a sequence
224+ * Adds a subscriber to a sequence by email address
223225 *
224- * @param integer $sequence_id Sequence ID.
225- * @param string $sort_order Sort Order (asc|desc).
226+ * @param integer $sequence_id Sequence ID.
227+ * @param string $email Email Address.
228+ * @param string $first_name First Name.
229+ * @param array<string, string> $fields Custom Fields.
230+ * @param array<string, int> $tag_ids Tag ID(s) to subscribe to.
231+ *
232+ * @see https://developers.convertkit.com/#add-subscriber-to-a-sequence
226233 *
227234 * @return false|mixed
228235 */
229- public function get_sequence_subscriptions (int $ sequence_id , string $ sort_order = 'asc ' )
230- {
231- return $ this ->get (
232- sprintf ('sequences/%s/subscriptions ' , $ sequence_id ),
233- [
234- 'api_secret ' => $ this ->api_secret ,
235- 'sort_order ' => $ sort_order ,
236- ]
236+ public function add_subscriber_to_sequence (
237+ int $ sequence_id ,
238+ string $ email ,
239+ string $ first_name = '' ,
240+ array $ fields = [],
241+ array $ tag_ids = []
242+ ) {
243+ // Build parameters.
244+ $ options = [
245+ 'api_key ' => $ this ->api_key ,
246+ 'email ' => $ email ,
247+ ];
248+
249+ if (!empty ($ first_name )) {
250+ $ options ['first_name ' ] = $ first_name ;
251+ }
252+ if (!empty ($ fields )) {
253+ $ options ['fields ' ] = $ fields ;
254+ }
255+ if (!empty ($ tag_ids )) {
256+ $ options ['tags ' ] = $ tag_ids ;
257+ }
258+
259+ // Send request.
260+ return $ this ->post (
261+ sprintf ('sequences/%s/subscribe ' , $ sequence_id ),
262+ $ options
237263 );
238264 }
239265
240266 /**
241- * Adds a subscriber to a sequence by email address
267+ * Gets subscribers to a sequence
268+ *
269+ * @param integer $sequence_id Sequence ID.
270+ * @param string $sort_order Sort Order (asc|desc).
271+ * @param string $subscriber_state Subscriber State (active,cancelled).
272+ * @param integer $page Page.
242273 *
243- * @param integer $sequence_id Sequence ID.
244- * @param string $email Email Address.
274+ * @see https://developers.convertkit.com/#list-subscriptions-to-a-sequence
245275 *
246276 * @return false|mixed
247277 */
248- public function add_subscriber_to_sequence (int $ sequence_id , string $ email )
249- {
250- return $ this ->post (
251- sprintf ('courses/%s/subscribe ' , $ sequence_id ),
278+ public function get_sequence_subscriptions (
279+ int $ sequence_id ,
280+ string $ sort_order = 'asc ' ,
281+ string $ subscriber_state = 'active ' ,
282+ int $ page = 1
283+ ) {
284+ return $ this ->get (
285+ sprintf ('sequences/%s/subscriptions ' , $ sequence_id ),
252286 [
253- 'api_key ' => $ this ->api_key ,
254- 'email ' => $ email ,
287+ 'api_secret ' => $ this ->api_secret ,
288+ 'sort_order ' => $ sort_order ,
289+ 'subscriber_state ' => $ subscriber_state ,
290+ 'page ' => $ page ,
255291 ]
256292 );
257293 }
@@ -747,8 +783,8 @@ private function strip_html_head_body_tags(string $markup)
747783 /**
748784 * Performs a GET request to the API.
749785 *
750- * @param string $endpoint API Endpoint.
751- * @param array<string, int|string> $args Request arguments.
786+ * @param string $endpoint API Endpoint.
787+ * @param array<string, int|string|array<string, int|string>|string > $args Request arguments.
752788 *
753789 * @throws \InvalidArgumentException If the provided arguments are not of the expected type.
754790 *
@@ -766,8 +802,8 @@ public function get(string $endpoint, array $args = [])
766802 /**
767803 * Performs a POST request to the API.
768804 *
769- * @param string $endpoint API Endpoint.
770- * @param array<string, int|string> $args Request arguments.
805+ * @param string $endpoint API Endpoint.
806+ * @param array<string, int|string|array<string, int|string>|string > $args Request arguments.
771807 *
772808 * @throws \InvalidArgumentException If the provided arguments are not of the expected type.
773809 *
@@ -785,8 +821,8 @@ public function post(string $endpoint, array $args = [])
785821 /**
786822 * Performs a PUT request to the API.
787823 *
788- * @param string $endpoint API Endpoint.
789- * @param array<string, int|string> $args Request arguments.
824+ * @param string $endpoint API Endpoint.
825+ * @param array<string, int|string|array<string, int|string>|string > $args Request arguments.
790826 *
791827 * @throws \InvalidArgumentException If the provided arguments are not of the expected type.
792828 *
@@ -804,8 +840,8 @@ public function put(string $endpoint, array $args = [])
804840 /**
805841 * Performs a DELETE request to the API.
806842 *
807- * @param string $endpoint API Endpoint.
808- * @param array<string, int|string> $args Request arguments.
843+ * @param string $endpoint API Endpoint.
844+ * @param array<string, int|string|array<string, int|string>|string > $args Request arguments.
809845 *
810846 * @throws \InvalidArgumentException If the provided arguments are not of the expected type.
811847 *
@@ -823,9 +859,9 @@ public function delete(string $endpoint, array $args = [])
823859 /**
824860 * Performs an API request using Guzzle.
825861 *
826- * @param string $endpoint API Endpoint.
827- * @param string $method Request method (POST, GET, PUT, PATCH, DELETE) .
828- * @param array<string, int|string> $args Request arguments.
862+ * @param string $endpoint API Endpoint.
863+ * @param string $method Request method .
864+ * @param array<string, int|string|array<string, int|string>|string > $args Request arguments.
829865 *
830866 * @throws \InvalidArgumentException If the provided arguments are not of the expected type.
831867 * @throws \Exception If JSON encoding arguments failed.
0 commit comments