Download the PHP package inetprocess/sugarcrm-apiwrapper without Composer
On this page you can find all versions of the php package inetprocess/sugarcrm-apiwrapper. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download inetprocess/sugarcrm-apiwrapper
More information about inetprocess/sugarcrm-apiwrapper
Files in inetprocess/sugarcrm-apiwrapper
Package sugarcrm-apiwrapper
Short Description A very simple API Wrapper for SugarCRM 7
License GPL-2.0
Informations about the package sugarcrm-apiwrapper
SugarCRM Api Wrapper
Install
Usage
BaseRequest
A basic class that initiate the Guzzle HTTP Client and provides the main methods for other class to do SugarCRM API Calls. You can use it directly but it's not recommanded. You can also build your own class based on that one.
Example Usage:
Other useful methods
The following methods allows you to take more control of the SugarAPIWrapper:
getBaseUrl()
: returns the BaseURLgetClient()
: returns the GuzzleClientgetToken()
: get the token sent by SugarCRMgetTokenExpiration()
: get the Token Expiration sent by SugarsetToken(string $token)
andsetTokenExpiration(\DateTime $date)
: must be used together to avoid a LoginsetLogger(\Psr\Log\LoggerInterface $logger)
set a PSR LoggersetPlatform(string $platform)
: defines the platform (inetprocess by default)
SugarClient
An extension of BaseRequest
with wrappers for GET, POST, PUT and DELETE. It does an autologin and sends the right headers with the token automatically.
Init the client
POST To any Endpoint
PUT To any Endpoint
After doing the POST, do the following:
GET To any Endpoint
DELETE To any Endpoint
Use a Bulk request to send multiple requests in a single HTTP call
Get a new BulkRequest object
Send multiple requests
You can use the same functions as the SugarClient class to prepare your requests
Module
Wrappers for specific modules actions. It does an autologin and sends the right headers with the tokens automatically.
Init the client and the module classes
Count Records
Count Records by applying filters
$module
: Module Name such as Contacts$filters
: An Array of filters as defined in SugarCRM Doc
Example of a count of notes with name = Test
Search records
Search Records by applying filters (the structure of filters is the same than for Count).
$module
: Module Name such as Contacts$filters
: An Array of filters as defined in SugarCRM Doc$fields
: list of fields to get back, all by default$offset
: 0 by default$maxNum
: 20 by default$orderBy
: null by default
Example of a search that should retrieve a max of 10 notes with name = Test, ordered by name:
Retrieve one or multiple records
$module
: Module Name such as Contacts$record
: Record ID, null by default$offset
: 0 by default$maxNum
: 20 by default
Retrieve a max of 10 records:
Retrieve a single record (throws a SugarAPIException if it does not Exists)
Create a record
Parameters:
$module
: Module Name such as Contacts$data
: Array of fields => values
Update a record
Parameters:
$module
: Module Name such as Contacts$record
: ID of the record$data
: Array of fields => values
Delete a record
Parameters:
$module
: Module Name such as Contacts$record
: ID of the record
Set all related ids to a record
Parameters:
$module
: Module Name such as Contacts$record
: ID of the record$linkName
: Relationship name$relatedIds
: Array of ids from the related module. This array is the full set of related ids, it will remove existing related links if they are not sent here.
Download a file
Parameters:
$module
: Module Name such as Contacts$record
: ID of the record$field
: Field Name$targetFile
: Local File to write the content. If empty, returns directly the data$originalName
: Name of the file displayed in Sugar
The following example downloads a file and put its content to the $targetFile
file
Upload a file
Parameters:
$module
: Module Name such as Contacts$record
: ID of the record$field
: Field Name$filePath
: Local File Path$originalName
: Name of the file displayed in Sugar
Dropdown
Retrieves the keys / values of a dropdown, in the current user (the one defined in setUserName) language.
Parameters:
$module
: Module Name such as Contacts$field
: Field for which we needs the values
All versions of sugarcrm-apiwrapper with dependencies
guzzlehttp/guzzle Version ^6
webmozart/assert Version ^1.2
psr/log Version @stable