Skip to content

Commit a0cf994

Browse files
committed
Merge branch '1.0-beta' into refactor-logging-and-api-calls
# Conflicts: # src/ConvertKit_API.php
2 parents 9361fa3 + c1b61a2 commit a0cf994

File tree

1 file changed

+9
-30
lines changed

1 file changed

+9
-30
lines changed

src/ConvertKit_API.php

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,10 @@ public function form_subscribe(int $form_id, array $options)
366366
// Add API Key to array of options.
367367
$options['api_key'] = $this->api_key;
368368

369-
return $this->post(sprintf('forms/%s/subscribe', $form_id), $options);
369+
return $this->post(
370+
sprintf('forms/%s/subscribe', $form_id),
371+
$option
372+
);
370373
}
371374

372375

@@ -422,15 +425,13 @@ public function get_subscriber_id(string $email_address)
422425
return false;
423426
}
424427

425-
$subscriber_id = $this::check_if_subscriber_in_array($email_address, $subscribers->subscribers);
426-
427-
if ($subscriber_id) {
428-
return $subscriber_id;
428+
if ($subscribers->total_subscribers === 0) {
429+
$this->create_log('No subscribers');
430+
return false;
429431
}
430432

431-
$this->create_log('Subscriber not found');
432-
433-
return false;
433+
// Return the subscriber's ID.
434+
return $subscribers->subscribers[0]->id;
434435
}
435436

436437

@@ -813,26 +814,4 @@ public function make_request(string $endpoint, string $method, array $args = [])
813814
$this->create_log('Failed to finish request.');
814815
return false;
815816
}
816-
817-
818-
/**
819-
* Looks for subscriber with email in array
820-
*
821-
* @param string $email_address Email Address.
822-
* @param array $subscribers Subscribers.
823-
*
824-
* @return false|integer false if not found, else subscriber object
825-
*/
826-
private function check_if_subscriber_in_array(string $email_address, array $subscribers)
827-
{
828-
foreach ($subscribers as $subscriber) {
829-
if ($subscriber->email_address === $email_address) {
830-
$this->create_log('Subscriber found!');
831-
return $subscriber->id;
832-
}
833-
}
834-
835-
$this->create_log('Subscriber not found on current page.');
836-
return false;
837-
}
838817
}

0 commit comments

Comments
 (0)