This package uses Get A Newsletter's API version 3.0. Read the official docs at https://api.getanewsletter.com/v3/docs/ for information about the API and possible params/arguments.
Right now, since this isn't added to Packagist yet, this can be installed by adding the following to your composer.json
:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/MartinCamen/laravel-getanewsletter"
}
],
And adding this to the require section:
"martincamen/laravel-getanewsletter": "dev-master"
Publish the config file by running:
php artisan vendor:publish --provider="MartinCamen\GetANewsletter\GetANewsletterServiceProvider" --tag="config"
Get an authentication token from Get A Newsletter and set it in the config file or in the .env
file and you're ready to go!
Almost all of the following modules' get()
methods are handled the same.
The get()
method takes two arguments:
Type | Description | Default |
---|---|---|
Array | Optional params (see the docs for all possibilities) | [] |
Boolean | Get the results as a collection, false will return the raw response (including the count, the results, etc.) |
true |
Get all results for a specific module:
GetANewsletter::contacts()->get();
GetANewsletter::lists()->get();
// ...and so on.
With params:
GetANewsletter::contacts()->get(['page' => 1], false);
GetANewsletter::lists()->get(['page' => 1], false);
// ...and so on.
The exceptions are (for example) the submethods of Reports
which takes $reportId
as its first argument and sometimes another related id
field as its second argument. The arguments mentioned above are then pushed to the second or third position and then following the same standard.
Get all contacts:
GetANewsletter::contacts()->get();
Create a new contact:
Type | Description | Default |
---|---|---|
String | The e-mail to store | - |
Array | Optional params (see the docs for all possibilities) | [] |
Boolean | Get the results as a collection, false will return the raw response (including the count, the results, etc.) |
true |
GetANewsletter::contacts()->create($email, $additionalData, false);
Update a contact:
Type | Description | Default |
---|---|---|
String | The e-mail to handle | - |
Array | Optional params to update (see the docs for all possibilities). Non-mentioned params will not be updated. | [] |
Boolean | Get the results as a collection, false will return the raw response (including the count, the results, etc.) |
true |
GetANewsletter::contacts()->update($email, $additionalData, false);
Delete a contact (pass the e-mail (string)
to delete):
GetANewsletter::contacts()->delete($email);
Get all e-mails (sent and drafts):
GetANewsletter::emails()->get();
Get all drafts/sent:
GetANewsletter::drafts()->get();
GetANewsletter::sent()->get();
To get a specific e-mail, use the find()
method with the appropriate ID (will return as a collection, pass false
as a second argument if you want the raw response):
GetANewsletter::drafts()->find($id);
GetANewsletter::sent()->find($id, false);
Delete a draft/sent (pass the item's id (int)
to delete):
GetANewsletter::drafts()->delete($id);
GetANewsletter::sent()->delete($id);
Create a new draft:
Type | Description | Default |
---|---|---|
Array | Params. Required params are subject & body . |
- |
Boolean | Get the result as a collection, false will return the raw response (including the count, the results, etc.) |
true |
GetANewsletter::drafts()->create($data, false);
Update a draft:
Type | Description | Default |
---|---|---|
String | The draft's id. | - |
Array | Params to update. Non-mentioned params will not be updated. | [] |
Boolean | Get the results as a collection, false will return the raw response (including the count, the results, etc.) |
true |
GetANewsletter::drafts()->update($id, $additionalData, false);
Copy a draft (pass the draft's id (int)
to copy, the second param is whether the result should be a collection or not):
GetANewsletter::drafts()->copy($id, false);
Get all lists:
GetANewsletter::lists()->get();
Create a new list:
Type | Description | Default |
---|---|---|
Array | Params. Required params are email , name & sender . |
- |
Boolean | Get the results as a collection, false will return the raw response (including the count, the results, etc.) |
true |
GetANewsletter::lists()->create($data, false);
Update a list:
Type | Description | Default |
---|---|---|
String | The list's hash. | - |
Array | Params to update. Non-mentioned params will not be updated. | [] |
Boolean | Get the results as a collection, false will return the raw response (including the count, the results, etc.) |
true |
GetANewsletter::lists()->update($hash, $additionalData, false);
Delete a list (pass the list's hash (string)
to delete):
GetANewsletter::lists()->delete($hash);
Get all attributes:
GetANewsletter::attributes()->get();
Create a new attribute:
Type | Description | Default |
---|---|---|
String | Name, required. | - |
Array | Params. Required params are name & sender . |
- |
Boolean | Get the results as a collection, false will return the raw response (including the count, the results, etc.) |
true |
GetANewsletter::attributes()->create($name, $data, false);
Update an attribute:
Type | Description | Default |
---|---|---|
String | The name to change to. This is the only value that can be changed. | - |
String | Code of the attribute to update. | - |
Boolean | Get the results as a collection, false will return the raw response (including the count, the results, etc.) |
true |
GetANewsletter::attributes()->update($name, $code, false);
Delete an attribute (pass the attribute's code (string)
to delete):
GetANewsletter::attributes()->delete($code);
Get all subscriptions:
GetANewsletter::subscriptions()->get();
Get all reports:
GetANewsletter::reports()->get();
To get a specific report, use the find()
method with the appropriate ID (will return as a collection, pass false
as a second param if you want the raw response):
GetANewsletter::reports()->find($id);
GetANewsletter::reports()->find($id, false);
Get all opened for a specific report:
GetANewsletter::opened()->get($reportId);
Get information regarding a specific open for a specific report (pass false
as a third param if you want the raw response):
GetANewsletter::opened()->find($reportId, $openId);
Get an aggregated report regarding a specific report:
GetANewsletter::opened()->aggregated($reportId);
Get all non-opened for a specific report:
GetANewsletter::nonOpened()->get($reportId);
Get information regarding a specific non-open for a specific report (pass false
as a third param if you want the raw response):
GetANewsletter::nonOpened()->find($reportId, $nonOpenedId);
Get all bounces for a specific report:
GetANewsletter::bounces()->get($reportId);
Get information regarding a specific bounce for a specific report (pass false
as a third param if you want the raw response):
GetANewsletter::bounces()->find($reportId, $bounceId);
Get information regarding all links and data regarding clicks for a specific report:
GetANewsletter::links()->get($reportId);
Get information regarding a specific link for a specific report (pass false
as a third param if you want the raw response):
GetANewsletter::links()->find($reportId, $linkId);
Get information regarding clicks for a specific report and link:
GetANewsletter::links()->get($reportId, $linkId);
Get information regarding a specific click for a specific report and link (pass false
as a fourth param if you want the raw response):
GetANewsletter::links()->find($reportId, $linkId, $clickId);
Get information regarding all unsubscriptions for a specific report:
GetANewsletter::unsubscriptions()->get($reportId);
Get information regarding a specific unsubscription for a specific report (pass false
as a second param if you want the raw response):
GetANewsletter::unsubscriptions()->find($reportId);
- Add all endpoints (including exports)
- Error handling
- ...and more.