LaravelPackages.net
Acme Inc.
Toggle sidebar
heterodoks/laravel-sendy

Laravel package for Sendy API integration

10
0
v1.0.2
About heterodoks/laravel-sendy

heterodoks/laravel-sendy is a Laravel package for laravel package for sendy api integration. It currently has 0 GitHub stars and 10 downloads on Packagist (latest version v1.0.2). Install it with composer require heterodoks/laravel-sendy. Discover more Laravel packages by heterodoks or browse all Laravel packages to compare alternatives.

Last updated

Laravel Sendy

A Laravel package for integrating with the Sendy API.

Requirements

  • PHP 8.1 or higher
  • Laravel 10.x|11.x
  • Sendy 6.1

Installation

You can install the package via composer:

composer require heterodoks/laravel-sendy

The package will automatically register its service provider.

Configuration

Publish the configuration file:

php artisan vendor:publish --tag="sendy-config"

Add these variables to your .env file:

SENDY_URL=your-sendy-installation-url SENDY_API_KEY=your-api-key SENDY_BRAND_ID=your-brand-id SENDY_TIMEOUT=10

Usage

Subscribe a User

use Heterodoks\LaravelSendy\Facades\Sendy;

// Basic subscription
$result = Sendy::subscribe('list_id', '[email protected]');

// With additional details
$result = Sendy::subscribe(
    'list_id',
    '[email protected]',
    'John Doe',
    ['custom_field' => 'value'],
    true // GDPR consent
);

Unsubscribe a User

$result = Sendy::unsubscribe('list_id', '[email protected]');

Check Subscription Status

$status = Sendy::getSubscriptionStatus('list_id', '[email protected]');
// Returns: "Subscribed", "Unsubscribed", "Unconfirmed", "Bounced", "Soft bounced", or "Complained"

Get Active Subscriber Count

$count = Sendy::getActiveSubscriberCount('list_id');

Campaign Management

Create and Send Campaign

$result = Sendy::createCampaign(
    'John Doe',                  // From Name
    '[email protected]',         // From Email
    '[email protected]',        // Reply To
    'Campaign Title',           // Title
    'Email Subject',            // Subject
    'Plain text version',       // Plain Text
    '<p>HTML version</p>',      // HTML Text
    'list-id',                  // List ID or array of List IDs
    'brand-id',                 // Optional: Brand ID
    'utm_source=newsletter'     // Optional: Query String
);  ```

#### Create Draft Campaign

```php
$result = Sendy::createDraftCampaign(
    'John Doe',
    '[email protected]',
    '[email protected]',
    'Campaign Title',
    'Email Subject',
    'Plain text version',
    '<p>HTML version</p>',
    ['list-id-1', 'list-id-2'], // Multiple lists
    'brand-id',
    'utm_source=newsletter'
);  ```

#### Schedule Campaign

```php
$result = Sendy::scheduleCampaign(
    'John Doe',
    '[email protected]',
    '[email protected]',
    'Campaign Title',
    'Email Subject',
    'Plain text version',
    '<p>HTML version</p>',
    'list-id',
    '2024-12-31 23:59:59',     // Schedule datetime
    'brand-id',
    'utm_source=newsletter'
);  ```

### Subscriber Management

#### Delete Subscriber

```php
$result = Sendy::deleteSubscriber('list_id', '[email protected]');

Get Subscriber Count by Status

// Available statuses: active, unconfirmed, unsubscribed, bounced, complained
$count = Sendy::getSubscriberCountByStatus('list_id', 'active');

Get Total Active Subscribers

// Get total active subscribers for default brand
$total = Sendy::getTotalActiveSubscribers();

// Get total active subscribers for specific brand
$total = Sendy::getTotalActiveSubscribers('brand-id');

Update Subscriber

// Basic update
$result = Sendy::updateSubscriber('list_id', '[email protected]', 'New Name');

// Update with custom fields
$result = Sendy::updateSubscriber(
    'list_id',
    '[email protected]',
    'New Name',
    ['custom_field' => 'new_value']
);

Testing

composer test

License

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

Comments