diff --git a/doc/api_methods/AddList.md b/doc/api_methods/AddList.md index 6051ec765b..096d4800e3 100644 --- a/doc/api_methods/AddList.md +++ b/doc/api_methods/AddList.md @@ -17,3 +17,18 @@ An associative array which contains list data. | --- | --- | --- | --- | | name (required) | string | 90 chars | A name of the list. | | description (optional) | string\|null| 250 chars | A description of the list. | + +## 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 | +| --- | --- | +| 14 | Missing list name | +| 15 | Trying to create a list that already exists | +| 16 | The list couldn’t be created in the database | diff --git a/doc/api_methods/AddSubscriber.md b/doc/api_methods/AddSubscriber.md index 59f5da0f47..2a278ae347 100644 --- a/doc/api_methods/AddSubscriber.md +++ b/doc/api_methods/AddSubscriber.md @@ -45,3 +45,19 @@ All options are optional. If omitted a default value is used. | send_confirmation_email | boolean | true | Can be used to disable a confirmation email. Otherwise, a confirmation email is sent as described above. It is strongly recommended to keep this option set to `true` so that MailPoet settings for sign-up confirmation are respected. Turning it to `false` might lead that subscriber to be added as `unconfirmed`. | | schedule_welcome_email | boolean | true | Can be used to disable a welcome email. Otherwise, a welcome email is scheduled as described above.| | skip_subscriber_notification | boolean | false | Can be used to disable an admin notification email. Otherwise, an admin notification email is sent as described above.| + +## 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 | +| --- | --- | +| 11 | Missing email address | +| 12 | Trying to create a subscriber that already exists | +| 13 | The subscriber couldn’t be created in the database | +| 17 | Welcome email failed to send | diff --git a/doc/api_methods/AddSubscriberField.md b/doc/api_methods/AddSubscriberField.md index f0bd163c86..86390efd76 100644 --- a/doc/api_methods/AddSubscriberField.md +++ b/doc/api_methods/AddSubscriberField.md @@ -63,3 +63,25 @@ The common properties for all types: | created_at | string\|null | - | UTC time of creation in `Y-m-d H:i:s` format | | updated_at | string | - | UTC time of last update in `Y-m-d H:i:s` format | +## 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 | +| --- | --- | +| 1 | The subscriber couldn’t be created in the database | +| 1001 | Missing a mandatory field in the `$data` argument | +| 1002 | A mandatory field in the `$data` argument has wrong type | +| 1003 | `$params` is not an array | +| 1004 | Attempting to create a field with an unknown type | +| 1005 | Incorrect validate parameter for text type | +| 1006 | Passing a `values` array for the checkbox type that has incorrect number of values | +| 1007 | Incorrect `date_format` value | +| 1008 | Incorrect `date_type` value | +| 1009 | Missing `values` for select or radio types | +| 1010 | Empty `value` for select or radio types | diff --git a/doc/api_methods/GetSubscriber.md b/doc/api_methods/GetSubscriber.md index 9232e3d8f2..fde2508b47 100644 --- a/doc/api_methods/GetSubscriber.md +++ b/doc/api_methods/GetSubscriber.md @@ -87,3 +87,16 @@ This method throws an `\Exception` in the event a subscriber with a given email 'cf_2' => 'New York', ]; ``` + +## 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 | Asking for a subscriber that does not exist. | diff --git a/doc/api_methods/SubscribeToLists.md b/doc/api_methods/SubscribeToLists.md index 6431b1576c..83b41af70f 100644 --- a/doc/api_methods/SubscribeToLists.md +++ b/doc/api_methods/SubscribeToLists.md @@ -12,7 +12,6 @@ This method allows adding an existing subscriber into lists and handles confirma All these emails can be disabled using `$options`. - It returns a subscriber. See [Get Subscriber](GetSubscriber.md) for a subscriber data structure. ## Arguments @@ -30,3 +29,23 @@ All options are optional. If omitted, a default value is used. | send_confirmation_email | boolean | true | Can be used to disable confirmation email. Otherwise, a confirmation email is sent as described above.| | schedule_welcome_email | boolean | true | Can be used to disable welcome email. Otherwise, a welcome email is scheduled as described above.| | skip_subscriber_notification | boolean | false | Can be used to disable an admin notification email. Otherwise, an admin notification email is sent as described above.| + +## 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 | +| --- | --- | +| 3 | No lists provided | +| 4 | Invalid subscriber that does not exist | +| 5 | Invalid list that does not exist | +| 6 | Trying to subscribe to a WordPress Users list | +| 7 | Trying to subscribe to a WooCommerce Customers list | +| 8 | Trying to subscribe to a list that doesn’t support that | +| 10 | Confirmation email failed to send | +| 17 | Welcome email failed to send | diff --git a/doc/api_methods/UnsubscribeFromLists.md b/doc/api_methods/UnsubscribeFromLists.md index 08c79b97df..fafabf1b52 100644 --- a/doc/api_methods/UnsubscribeFromLists.md +++ b/doc/api_methods/UnsubscribeFromLists.md @@ -14,3 +14,21 @@ An id or email of an existing subscriber. An `\Exception` is thrown when an id o ### array `$list_ids` (required) An array of list ids. An `\Exception` is thrown if any of list ids are invalid. In such a case the subscriber remains subscribed to all lists. + +## 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 | +| --- | --- | +| 3 | No lists provided | +| 4 | Invalid subscriber that does not exist | +| 5 | Invalid list that does not exist | +| 6 | Trying to subscribe to a WordPress Users list | +| 7 | Trying to subscribe to a WooCommerce Customers list | +| 10 | Confirmation email failed to send |