isap-ou/laravel-agile-crm

Laravel HTTP Client for AgileCRM

1.1.0 2024-10-21 13:47 UTC

This package is auto-updated.

Last update: 2024-10-21 14:25:08 UTC


README

Please note!

We only include the endpoints necessary for the team's projects. If any endpoints are missing, feel free to create a pull request (PR) to add the required endpoints.

Installation

You can install the package via composer:

composer require isap-ou/laravel-agile-crm

You will most likely need to edit the extensive configuration, so you can publish the config file with:

php artisan vendor:publish --tag="agile-crm"

Usage

This package is based on documentation of Agile CRM REST API

Each AgileCRM entity is implemented as a lightweight DTO (Data Transfer Object), providing straightforward access to the underlying data. This design minimizes the need for redundant validation processes and ensures that data handling remains simple and efficient without adding unnecessary complexity.

Configuration

First You need to add environment variables Authentication credentials:

AGILE_CRM_DOMAIN=domain
AGILE_CRM_EMAIL=example@mail.com
AGILE_CRM_API_KEY=855*********************88

To work with multiple domains in parallel, simply add a new domain to the config/agile-crm.php file.

return [
    ...

    'domains' => [
       ...
       'custom_domain' => [
           'domain' => env('AGILE_CRM_DOMAIN'),
           'email' => env('AGILE_CRM_EMAIL'),
           'api_key' => env('AGILE_CRM_API_KEY'),
       ],
    ],
];

Examples:

Make request for default domain

$contact = AgileCrm::contacts()->index()

Make request for NON default domain

$contact = AgileCrm::domain('custom_domain')->contacts()->index()

Get contacts list

$contact = AgileCrm::contacts()->index()

Result will Collection of ContactDto

Create contact

use IsapOu\AgileCrm\Dto\ContactDto;
use IsapOu\AgileCrm\Dto\ContactPropertyDto;
use IsapOu\AgileCrm\Enums\ContactSystemPropertyName;
 
...
 
$properties = [];
$properties[] = new ContactPropertyDto(
    name: ContactSystemPropertyName::FIRST_NAME,
    value: 'John',
);
$properties[] = new ContactPropertyDto(
    name: ContactSystemPropertyName::LAST_NAME,
    value: 'Doe',
);
$properties[] = new ContactPropertyDto(
    name: ContactSystemPropertyName::EMAIL,
    value: 'mail@example.com',
);
$dto = new ContactDto(properties: $properties);

$contactDto = AgileCrm::contacts()->create($dto);

...

Result will ContactDto

Contributing

Please, submit bugs or feature requests via the Github issues. Pull requests are welcomed! Thanks!

License

The AgileCRM Client for Laravel is open-sourced software licensed under the MIT license