hocza / sendy-laravel

A service provider for Sendy API in Laravel 5
https://hocza.com/packages/sendy/
MIT License
71 stars 21 forks source link

Add the ability to store multiple list_id in the config file #2

Closed michellaurent closed 8 years ago

michellaurent commented 9 years ago

It would be nice if we can have multiple list_id in the config file. installation_url and api_key can be the same or different.

vinkla/hashids is a Laravel package that have this kind of features in his configuration. This package use graham-campbell/manager to enable different "connections".

hocza commented 9 years ago

So it is should be working like the $connection with the Eloquent?

michellaurent commented 8 years ago

I think so

alisonmonteiro commented 8 years ago

@michellaurent I hope this helps you

hocza commented 8 years ago

I think he was thinking about doing the following:

instead of

return [
    'listId' => '',
    'installationUrl' => '',
    'apiKey' => '',
];

it could be like this

return [
    'default' => [
        'listId' => 'AAA',
        'installationUrl' => 'aaa.com',
        'apiKey' => 'AA123456',
    ],
    'other' => [
        'listId' => 'BBB',
        'installationUrl' => 'bbb.com',
        'apiKey' => 'BB234567',
    ],
];

However, I do not think that many of us have multiple installations, so the setListId() should be enough for now.

But @michellaurent you can also use setApiKey($apiKey) and setInstallationUrl($installationUrl) if you ever need to change it for that request only. :)

alisonmonteiro commented 8 years ago

@hocza This is a good point, but I can't test this. I don't have 2 installations :-1:

hocza commented 8 years ago

@alisonmonteiro well I can access plenty, because I encourage my clients to use Sendy instead of mail chimp or other kind of expensive services. :)

However I only needed to connect with 1 Sendy / Laravel App so thats why it is left out. I think it is really rare if someone has multiple and wants to use multiple within 1 Laravel app :)

(By the way you can make multiple installations with subdomains with the same license)

But lets just close this for now. If someone really needs this in the future, it may be added

michellaurent commented 8 years ago

@hocza @alisonmonteiro I only have one Sendy install but I use two lists: a first one for members and second one for the newsletter. So when a user creates an account, I will add it to the member list. If someone wants to subscribe to the newsletter, I will add it on the other.

Instead of having to specify the list id, I think it would be nice to use a friendly name and have something like Sendy::setList($list_name)->subscribe($data);

alisonmonteiro commented 8 years ago

@michellaurent ok. Can you create a new issue for this feature?