Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4 API: Forms #76

Merged
merged 8 commits into from
Mar 22, 2024
Merged

v4 API: Forms #76

merged 8 commits into from
Mar 22, 2024

Conversation

n7studios
Copy link
Contributor

@n7studios n7studios commented Mar 20, 2024

Summary

Adds support for endpoints in the forms section of the v4 API.

Testing

  • testGetFormSubscriptionsWithBouncedSubscriberState: Test that get_form_subscriptions() returns the expected data when a valid Form ID is specified and the subscription status is cancelled.
  • testGetFormSubscriptionsWithAddedAfterParam: Test that get_form_subscriptions() returns the expected data when a valid Form ID is specified and the added_after parameter is used.
  • testGetFormSubscriptionsWithAddedBeforeParam: Test that get_form_subscriptions() returns the expected data when a valid Form ID is specified and the added_before parameter is used.
  • testGetFormSubscriptionsWithCreatedAfterParam: Test that get_form_subscriptions() returns the expected data when a valid Form ID is specified and the created_after parameter is used.
  • testGetFormSubscriptionsWithCreatedBeforeParam: Test that get_form_subscriptions() returns the expected data when a valid Form ID is specified and the created_before parameter is used.
  • testGetFormSubscriptionsPagination: Test that get_form_subscriptions() returns the expected data when a valid Form ID is specified and pagination parameters and per_page limits are specified.
  • testGetFormSubscriptionsWithInvalidFormID: Test that get_form_subscriptions() throws a ClientException when an invalid Form ID is specified.
  • testGetFormSubscriptionsWithInvalidSubscriberState: Test that get_form_subscriptions() throws a ClientException when an invalid subscriber state is specified.
  • testGetFormSubscriptionsWithInvalidPagination: Test that get_form_subscriptions() throws a ClientException when invalid pagination parameters are specified.
  • testAddSubscriberToFormByID: Test that add_subscriber_to_form_by_subscriber_id() returns the expected data.
  • testAddSubscriberToFormByIDWithInvalidFormID: Test that add_subscriber_to_form_by_subscriber_id() throws a ClientException when an invalid form ID is specified.
  • testAddSubscriberToFormByIDWithInvalidSubscriberID: Test that add_subscriber_to_form_by_subscriber_id() throws a ClientException when an invalid email address is specified.

Removed Tests:

  • testAddSubscriberToFormWithFirstName
  • testAddSubscriberToFormWithCustomFields
  • testAddSubscriberToFormWithTagID

v4 API has no concept of adding a new subscriber to a form with data; a separate PR will be added to add support for the new Create a subscriber endpoint (https://developers.convertkit.com/v4.html#create-a-subscriber), which supports this.

Checklist

@n7studios n7studios added this to the 2.0 milestone Mar 20, 2024
@n7studios n7studios self-assigned this Mar 20, 2024
@n7studios n7studios requested review from a team, noelherrick and corydhmiller and removed request for a team March 20, 2024 14:58
@n7studios n7studios marked this pull request as ready for review March 20, 2024 14:58
@n7studios n7studios marked this pull request as draft March 20, 2024 14:59
@n7studios n7studios marked this pull request as ready for review March 20, 2024 15:23
@n7studios n7studios marked this pull request as draft March 20, 2024 16:02
@n7studios n7studios marked this pull request as ready for review March 20, 2024 17:54
Copy link

@noelherrick noelherrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! What are your thoughts on passing along existing vs. new to the API consumer? The API will return a 200 if the subscriber is already subscribed vs. a 201 if it is not.

@n7studios n7studios mentioned this pull request Mar 21, 2024
5 tasks
@n7studios
Copy link
Contributor Author

Looks good! What are your thoughts on passing along existing vs. new to the API consumer? The API will return a 200 if the subscriber is already subscribed vs. a 201 if it is not.

This PR exposes the response object, allowing the consumer to inspect the HTTP status code, should they wish to determine whether a subscriber is already subscribed vs. created:

$result = $api->add_subscriber_to_form(12345, 'joe.bloggs@convertkit.com');
$code = $api->getResponseInterface()->getStatusCode(); // 200 OK if e.g. a subscriber already added to the specified form, 201 Created if the subscriber added to the specified form for the first time.

@n7studios n7studios merged commit 376fcfe into v4-api-oauth Mar 22, 2024
4 checks passed
@n7studios n7studios deleted the v4-api-forms branch June 26, 2024 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants