From ae28e62b1a0488457fd0f08058c920dfb71b7ba5 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Mon, 27 Mar 2023 12:06:39 -0300 Subject: [PATCH] Add documentation for the unsubscribe() MP API method [MAILPOET-5152] --- doc/Readme.md | 1 + doc/api_methods/UnsubscribeGlobally.md | 29 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 doc/api_methods/UnsubscribeGlobally.md diff --git a/doc/Readme.md b/doc/Readme.md index 05e4eb1b62..426ad31ce3 100644 --- a/doc/Readme.md +++ b/doc/Readme.md @@ -37,6 +37,7 @@ Class `\MailPoet\API\API` becomes available once MailPoet plugin is loaded by Wo - [Is Setup Complete (isSetupComplete)](api_methods/IsSetupComplete.md) - [Subscribe to List (subscribeToList)](api_methods/SubscribeToList.md) - [Subscribe to Lists (subscribeToLists)](api_methods/SubscribeToLists.md) +- [Unsubscribe globally](api_methods/UnsubscribeGlobally.md) - [Unsubscribe from List (unsubscribeFromList)](api_methods/UnsubscribeFromList.md) - [Unsubscribe from Lists (unsubscribeFromLists)](api_methods/UnsubscribeFromLists.md) - [Update List (updateList)](api_methods/UpdateList.md) diff --git a/doc/api_methods/UnsubscribeGlobally.md b/doc/api_methods/UnsubscribeGlobally.md new file mode 100644 index 0000000000..2159277ba1 --- /dev/null +++ b/doc/api_methods/UnsubscribeGlobally.md @@ -0,0 +1,29 @@ +[back to list](../Readme.md) + +# Unsubscribe from all lists and change subscriber status + +## `array unsubscribe(string $subscriber_id)` + +This method removes a subscriber from all lists and updates its status to 'unsubscribed'. + +It returns a subscriber. See [Get Subscriber](GetSubscriber.md) for returned data structure. + +## Arguments + +### string `$subscriber_id` (required) + +An id or email of an existing subscriber. An `\Exception` is thrown when an id or email doesn't match any subscriber. + +## Error handling + +All expected errors from the API are exceptions of class `\MailPoet\API\MP\v1\APIException`. +Code of the exception is populated to distinguish between different errors. + +An exception of base class `\Exception` can be thrown when something unexpected happens. + +Codes description: + +| Code | Description | +| ---- | -------------------------------------------- | +| 4 | Invalid subscriber that does not exist | +| 24 | Subscriber already has 'unsubscribed' status |