juanparati / inmobile
inMobile client for Laravel
1.0
2024-02-22 13:02 UTC
Requires
- php: >=8.1
- ext-json: *
- guzzlehttp/guzzle: ^7.8
- illuminate/support: >=10.3
Requires (Dev)
- laravel/pint: ^1.13
- orchestra/testbench: >=8.2
- phpunit/phpunit: >=9.5
This package is auto-updated.
Last update: 2024-04-22 13:21:45 UTC
README
inMobile library for Laravel.
Note: Do not use this library on production. It's still under development
Installation
composer require juanparati/inmobile
Facade registration (optional)
'aliases' => [
...
'InMobile' => \Juanparati\Inmobile\Facades\InmobileFacade::class,
...
]
Configuration
Publish configuration file:
artisan vendor:publish --tag="inmobile"
Usage examples
List service
Create list
InMobile::lists()->create('My list');
Get all lists
// Return a paginated results instance. $lists = InMobile::lists()->all(); // Will automatically transverse all the pages automatically. // Rewind is not allowed. foreach ($lists as $list) var_dump($list->toArray());
Get a list
InMobile::lists()->find($myListId);
Create a list
InMobile::lists()->create('My new list');
Recipient service
Create recipient
$recipient = InMobile::recipients()->create( 'listId', \Juanparati\Inmobile\Models\Recipient::make('45', '12345678') ->addField('firstname', 'John') ->addField('lastname', 'Random') ->addField('custom1', 'foobar') ->setCreatedAt(now()->subMinute() ) ); echo 'Recipient id: ' . $recipient->getId();
Find recipient by Id
if ($recipient = InMobile::recipients()->findById('listid', 'recipientId')) { echo 'Recipient ' . $recipient->getId() . ' has phone +' . $recipient->getCode() . ' ' . $recipient->getPhone(); var_dump($recipient->toArray()); } else { echo 'Recipient not found'; }
Find recipient by Phone
$recipient = InMobile::recipients()->findByNumber('listid', '45', '12345678');