Download the PHP package basecrm/basecrm-php without Composer
On this page you can find all versions of the php package basecrm/basecrm-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download basecrm/basecrm-php
More information about basecrm/basecrm-php
Files in basecrm/basecrm-php
Package basecrm-php
Short Description BaseCRM Official API V2 library client for PHP
License Apache License 2.0
Homepage http://developers.getbase.com/
Informations about the package basecrm-php
basecrm-php
BaseCRM Official API V2 library client for PHP
Installation
The recommended way to install the client is through Composer.
Next, run the Composer command to install the latest stable version :
After installing, you need to require Composer's autoloader:
Usage
Build a client
Using this api without authentication gives an error
Client Options
The following options are available while instantiating a client:
- accessToken: Personal access token
- baseUrl: Base url for the api
- userAgent: Default user-agent for all requests
- timeout: Request timeout
- verbose: Verbose/debug mode
- verifySSL: Whether to verify SSL or not. Default: true
Architecture
The library follows few architectural principles you should understand before digging deeper.
- Interactions with resources are done via service objects.
- Service objects are exposed as properties on client instances.
- Service objects expose resource-oriented actions.
- Actions return associative arrays.
For example, to interact with deals API you will use \BaseCRM\DealsService
, which you can get if you call:
To retrieve list of resources and use filtering you will call #all
method:
To find a resource by it's unique identifier use #get
method:
When you'd like to create a resource, or update it's attributes you want to use either #create
or #update
methods. For example if you want to create a new deal you will call:
To destroy a resource use #destroy
method:
There other non-CRUD operations supported as well. Please contact corresponding service files for in-depth documentation.
Full example
Create a new organization and after that change it's attributes (website).
Error handling
When you instantiate a client or make any request via service objects, exceptions can be raised for multiple of reasons e.g. a network error, an authentication error, an invalid param error etc.
Sample below shows how to properly handle exceptions:
Sync API
The following sample code shows how to perform a full synchronization flow using high-level wrapper.
First of all you need an instance of \BaseCRM\Client
. High-level \BaseCRM\Sync
wrapper uses \BaseCRM\SyncService
to interact with the Sync API.
In addition to the client instance, you must provide a device’s UUID within $deviceUUID
parameter. The device’s UUID must not change between synchronization sessions, otherwise the sync service will not recognize the device and will send all the data again.
Now all you have to do is to call fetch
method and pass a block that you might use to store fetched data to a database.
Notice that you must call either #ack
or #nack
method.
Resources and actions
Documentation for every action can be found in corresponding service files under lib/
directory.
Account
Actions:
- Retrieve account details -
client->accounts->self
AssociatedContact
Actions:
- Retrieve deal's associated contacts -
client->associatedContacts->all
- Create an associated contact -
client->associatedContacts->create
- Remove an associated contact -
client->associatedContacts->destroy
Contact
Actions:
- Retrieve all contacts -
client->contacts->all
- Create a contact -
client->contacts->create
- Retrieve a single contact -
client->contacts->get
- Update a contact -
client->contacts->update
- Delete a contact -
client->contacts->destroy
Deal
Actions:
- Retrieve all deals -
client->deals->all
- Create a deal -
client->deals->create
- Retrieve a single deal -
client->deals->get
- Update a deal -
client->deals->update
- Delete a deal -
client->deals->destroy
Note about deal value
You can use either a string or numerical deal value when modifying a deal.
Deal Source
Actions:
- Retrieve all deal sources -
client->dealSources->all
- Create a deal source -
client->dealSources->create
- Retrieve a single deal source -
client->dealSources->get
- Update a deal source -
client->dealSources->update
- Delete a deal source -
client->dealSources->destroy
Lead
Actions:
- Retrieve all leads -
client->leads->all
- Create a lead -
client->leads->create
- Retrieve a single lead -
client->leads->get
- Update a lead -
client->leads->update
- Delete a lead -
client->leads->destroy
Lead Source
Actions:
- Retrieve all lead sources -
client->leadSources->all
- Create a lead source -
client->leadSources->create
- Retrieve a single lead source -
client->leadSources->get
- Update a lead source -
client->leadSources->update
- Delete a lead source -
client->leadSources->destroy
Line Item
Actions:
- Retrieve all line items -
client->lineItems->all
- Create a line item -
client->lineItems->create
- Retrieve a single line item-
client->lineItems->get
- Update a line item -
client->lineItems->update
- Delete a line item -
client->lineItems->destroy
LossReason
Actions:
- Retrieve all reasons -
client->lossReasons->all
- Create a loss reason -
client->lossReasons->create
- Retrieve a single reason -
client->lossReasons->get
- Update a loss reason -
client->lossReasons->update
- Delete a reason -
client->lossReasons->destroy
Note
Actions:
- Retrieve all notes -
client->notes->all
- Create a note -
client->notes->create
- Retrieve a single note -
client->notes->get
- Update a note -
client->notes->update
- Delete a note -
client->notes->destroy
Order
Actions:
- Retrieve all orders -
client->orders->all
- Create an order -
client->orders->create
- Retrieve a single order -
client->orders->get
- Update an order -
client->orders->update
- Delete an order -
client->orders->destroy
Pipeline
Actions:
- Retrieve all pipelines -
client->pipelines->all
Product
Actions:
- Retrieve all products -
client->products->all
- Create a product -
client->products->create
- Retrieve a single product -
client->products->get
- Update a product -
client->products->update
- Delete a product -
client->products->destroy
Source (Deprecated! Use Lead Source, Deal Source instead)
Actions:
- Retrieve all sources -
client->sources->all
- Create a source -
client->sources->create
- Retrieve a single source -
client->sources->get
- Update a source -
client->sources->update
- Delete a source -
client->sources->destroy
Stage
Actions:
- Retrieve all stages -
client->stages->all
Tag
Actions:
- Retrieve all tags -
client->tags->all
- Create a tag -
client->tags->create
- Retrieve a single tag -
client->tags->get
- Update a tag -
client->tags->update
- Delete a tag -
client->tags->destroy
Task
Actions:
- Retrieve all tasks -
client->tasks->all
- Create a task -
client->tasks->create
- Retrieve a single task -
client->tasks->get
- Update a task -
client->tasks->update
- Delete a task -
client->tasks->destroy
TextMessage
Actions:
- Retrieve text messages -
client->textMessages->all
- Retrieve a single text message -
client->textMessages->get
User
Actions:
- Retrieve all users -
client->users->all
- Retrieve a single user -
client->users->get
- Retrieve an authenticating user -
client->users->self
Visit
Actions:
- Retrieve visits -
client->visits->all
VisitOutcome
Actions:
- Retrieve visit outcomes -
client->visitOutcomes->all
Tests
Install PHPUnit via Composer:
To run all test suites:
And to run a single suite:
Bug Reports
Report here.
Copyright and license
Copyright 2015 Zendesk
Licensed under the Apache License, Version 2.0