Skip to content

kevinpurwito/laravel-mailcoach-api

Repository files navigation

About Laravel Mailcoach API

Tests Code Style Psalm Latest Version on Packagist Total Downloads

Laravel Mailcoach API is a package to make it easier to integrate your own Mailcoach API for your other Laravel projects.

Refer to this docs

Installation

You can install the package via composer:

composer require kevinpurwito/laravel-mailcoach-api

Configuration

The vendor:publish command will publish a file named kp_mailcoach.php within your laravel project config folder config/kp_mailcoach.php.

Published Config File Contents

[
    'url' => strtolower(env('KP_MAILCOACH_API_URL')),
    
    'token' => env('KP_MAILCOACH_API_TOKEN'),

    'list_id' => intval(env('KP_MAILCOACH_LIST_ID', 1)),
];

Alternatively you can ignore the above publish command and add this following variables to your .env file.

KP_MAILCOACH_API_URL=your_mailcoach_api_url
KP_MAILCOACH_API_TOKEN=your_mailcoach_api_token

Auto Discovery

If you're using Laravel 5.5+ you don't need to manually add the service provider or facade. This will be Auto-Discovered. For all versions of Laravel below 5.5, you must manually add the ServiceProvider & Facade to the appropriate arrays within your Laravel project config/app.php

Provider

[
    Kevinpurwito\LaravelMailcoachApi\MailcoachApiServiceProvider::class,
];

Alias / Facade

[
    'MailcoachApi' => Kevinpurwito\LaravelMailcoachApi\Facades\MailcoachApi::class,
];

Usage

Using Facade

use Kevinpurwito\LaravelMailcoachApi\Facades\MailcoachApi;

MailcoachApi::getSubscribers();

Using Class

use Kevinpurwito\LaravelMailcoachApi\MailcoachApi;
use Kevinpurwito\LaravelMailcoachApi\Data\InputSubscriberData;

$mcApi = (new MailcoachApi(url: '', token: ''));

$data = new InputSubscriberData(email: '', first_name: '', last_name: '');

$subscriber = $mcApi->addSubscriber(listId: 0, data: $data);

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

Laravel Package Boilerplate

This package was generated using the PHP Package Boilerplate by Beyond Code with some modifications inspired from PHP Package Skeleton by spatie.

About

Mailcoach API package for Laravel

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published