Add new exception to API documentation

[MAILPOET-2107]
This commit is contained in:
Pavel Dohnal
2019-06-04 14:09:01 +02:00
committed by M. Shull
parent f130c8d17b
commit 8ee1ead0a6
6 changed files with 104 additions and 1 deletions

View File

@@ -17,3 +17,18 @@ An associative array which contains list data.
| --- | --- | --- | --- | | --- | --- | --- | --- |
| name (required) | string | 90 chars | A name of the list. | | name (required) | string | 90 chars | A name of the list. |
| description (optional) | string\|null| 250 chars | A description 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 couldnt be created in the database |

View File

@@ -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`. | | 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.| | 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.| | 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 couldnt be created in the database |
| 17 | Welcome email failed to send |

View File

@@ -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 | | 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 | | 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 couldnt 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 |

View File

@@ -87,3 +87,16 @@ This method throws an `\Exception` in the event a subscriber with a given email
'cf_2' => 'New York', '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. |

View File

@@ -12,7 +12,6 @@ This method allows adding an existing subscriber into lists and handles confirma
All these emails can be disabled using `$options`. All these emails can be disabled using `$options`.
It returns a subscriber. See [Get Subscriber](GetSubscriber.md) for a subscriber data structure. It returns a subscriber. See [Get Subscriber](GetSubscriber.md) for a subscriber data structure.
## Arguments ## 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.| | 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.| | 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.| | 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 doesnt support that |
| 10 | Confirmation email failed to send |
| 17 | Welcome email failed to send |

View File

@@ -14,3 +14,21 @@ An id or email of an existing subscriber. An `\Exception` is thrown when an id o
### array `$list_ids` (required) ### 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. 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 |