star-insure/crm-client

Star Insure CRM Client

1.0.0 2023-11-02 20:12 UTC

This package is auto-updated.

Last update: 2024-04-06 21:54:42 UTC


README

A package for Laravel apps that includes a wrapper for the Star Inure CRM and scaffolds out routes, controllers and middleware for authenticating with the Star auth app.

Installation

You can install the package via composer:

composer require star-insure/crm-client

Add these values to your .env file:

# CRM
CRM_API_URL=http://crm.test
CRM_API_TOKEN=dev
CRM_API_GROUP_ID=2
CRM_API_VERSION=v1

Publish config:

php artisan vendor:publish --tag=starinsure-crm

Usage

API

Call the Star CRM API by instantiating a new client, or using the StarInsure\Api\Facades\CrmApi facade.

CrmApi::get('/account-manager-brokers');

Helper functions

Create a helpers.php file within the app directory (or edit your existing one):

if (! function_exists('crm')) {
    /**
     * Global helper to create an instance of the StarCrm client.
     */
    function crm()
    {
        return new \StarInsure\Crm\CrmApi(
            config('crm.version'),
        );
    }
}

Autoload your helpers file in composer.json:

"autoload": {
    ...
    "files": [
        "app/helpers.php"
    ]
},

After adding the helpers file to composer.json, you'll need to dump the autoloader

composer dump-autoload

You can now use the global helper functions and not worry about namespaces/imports.

crm()->get('/account-manager-brokers');