Skip to content

cheppers/minicrm-client

Repository files navigation

MiniCrm client

PHP library implementing the MiniCRM API https://www.minicrm.hu/help/minicrm-api/

CircleCI codecov

^ codecov need to change to master once it is merged

Supported endpoints

Schema

Address

  • GET: /Address/:address_id

    Gets back an Address based on the given ID.

    $client->getAddress(int $addressId);
  • GET: /AddressList/:contact_id

    Gets back the Address(es) of a given Person/Business. By providing the second parameter 'true' or 'false' you can decide whether you want to get the data structured or not. Default value is 'false'.
    The field 'contactId' is mandatory in AddressRequest, see the Basic usage section, how to provide it.

    $client->getAddresses(AddressRequest $addressRequest, bool $structured = false);
  • PUT: /Address

    Creates a new Address in MiniCRM database based on the provided field's values Fields 'contactId' and 'name' are mandatory, see the Basic usage section, how to provide it.

    $client->createAddress(AddressRequest $addressRequest);
  • PUT: /Address/:address_id

    Updates an Address based on the given ID.
    See the basic usage section how to provide the ID.

    Keep in mind if you provide a 'contactId' already in use, the method will update that particular contact with the given field's values.

    $client->updateAddress(AddressRequest $addressRequest);

Category

  • GET: /Category

    Gets back the existing Categories (Modules) of MiniCRM. By providing the second parameter 'true' or 'false' you can decide whether you want to het the data detailed or not. Default value is 'false'.

    $client->getCategories(CategoryRequest $categoryRequest, bool $detailed = false);

Contact

  • GET: /Contact/:contact_id

    Gets back a Person based on the given ID

    $client->getPerson(int $contactId);

    Gets back a Business based on the given ID

    $client->getBusiness(int $contactId);
  • PUT: /Contact

    $client->createPerson(PersonRequest $personRequest);

    Creates a new Person in MiniCRM database based on the provided field's values Field 'firstName' is mandatory, see the Basic usage section, how to provide it.

    $client->createBusiness(BusinessRequest $businessRequest);

    Creates a new Business in MiniCRM database based on the provided field's values. Field 'name' is mandatory, see the Basic usage section, how to provide it.

  • PUT: /Contact/:contact_id

    Updates a Person based on the given ID.
    See the basic usage section how to provide the ID.

    $contact->updatePerson(PersonRequest $personRequest);

    Updates a Business based on the given ID.
    See the basic usage section how to provide the ID.

    $contact->updateBusiness(BusinessRequest $businessRequest);

Project

  • GET: /Project/:project_id

    Gets back a Project based on the given ID.

    $client->getProject(int $projectId);
  • GET: /Project?CategoryId=:category_id

    Gets back a Project based on the given CategoryID.

    $client->getProjectsByCategoryId(int $categoryId);
  • GET: /Project?StatusGroup=:status_group

    Gets back a Project based on the Status Group.
    Status group values can be: 'Lead', 'Open', 'Success', 'Failed'.

    $client->getProjectsByStatusGroup(string $statusGroup);
  • GET: /Project?UserId=:user_id

    Gets back Project based on the given UserID.

    $client->getProjectsByUserId(int $userId);
  • GET: /EmailList/:project_id

    Gets back a given Project's all emails based on the provided ID.
    See the basic usage section how to provide the ID.

    $client->getProjectEmails(ProjectRequest $projectRequest);
  • PUT: /Project

    Creates a new Project in MiniCRM database based on the provided field's values. Fields 'categoryId' and 'contactId' are mandatory, see the Basic usage section, how to provide it.

    $client->createProject(ProjectRequest $projectRequest);
  • PUT: /Project/:project_id

    Updates a Project based on the given ID. See the basic usage section how to provide the ID.

    $client->updateProject(ProjectRequest $projectRequest);

ToDo

  • GET: /ToDo

    Gets back a ToDo based on the given ID.

    $client->getTodo(int $todoId);
  • GET: /ToDoList

    Gets back a Todos of a given Project based on the given ID.

    $client->getTodoList(int $projectId);
  • PUT: /ToDo

    Creates a new ToDo in MiniCRM database based on the provided field's values.
    Field 'projectId' is mandatory, see the Basic usage section, how to provide it.

    $client->createToDo(TodoRequest $todoRequest);
  • PUT: /ToDo/:todo_id

    Updates a ToDo based on the given ID. See the basic usage section how to provide the ID.

    $client->updateTodo(TodoRequest $todoRequest);

Template

  • GET: /Template/:template_id

    Gets back a Template based on the given ID.

    $client->getTemplate(int $templateId);
  • GET: /TemplateList/:category_id

    Gets back a list of Templates according to a Category based on the given ID.
    Field 'categoryId' is mandatory, see the Basic usage section, how to provide it.

    $client->getTemplateList(TemplateRequest $templateRequest);

Basic usage

The MiniCRM client uses separate endpoints as clients, so in order to use them, you need to pass a Guzzle client, and a Psr NullLogger to the given endpoint's constructor.

You will need:

  • your systemId provided by the url of MiniCRM when logged in.
  • your apiKey from MiniCrm
  • the baseUri to decide whether you are using the client in a test environment or not
<?php

use Cheppers\MiniCrm\DataTypes\Address\AddressRequest;
use Cheppers\MiniCrm\Endpoints\AddressEndpoint;

require __DIR__ . '/vendor/autoload.php';

$systemId = 'YOUR_SYSTEM_ID';
$apiKey = 'YOUR_API_KEY';
$baseUri = 'YOUR_URL';
$client = new \GuzzleHttp\Client();
$logger = new \Psr\Log\NullLogger();

$credentials = [
    'baseUri' => $baseUri,
    'apiKey' => $apiKey,
    'systemId' => $systemId
];

$address = new AddressEndpoint($client, $logger);
$address->setCredentials($credentials);

// Printing out the Address with the ID: 1487.
print_r($address->getAddress(1487));

// Example for creating an Address.
print_r($address->createAddress(AddressRequest::__set_state([
    'contactId' => 1,
    'type' => 'Test Type', // Check the given types in MiniCRM. Use getSchema().
    'name' => 'Test Address',
    'countryId' => 'Test Country',
    'postalCode' => 1,
    'city' => 'Test City',
    'county' => 'Test County',
    'address' => 'Test Address',
    'default' => 0
])));

// Providing fields when updating an address.
print_r($address->updateAddress(AddressRequest::__set_state([
    'id' => 1,
    'name' => 'updated-name',
])));

To check available methods on endpoints, check above.

About

PHP library implementing the MiniCRM API https://minicrm.hu

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages