Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-godfrey committed Apr 5, 2018
1 parent 8d3c67d commit e7267bc
Showing 1 changed file with 69 additions and 4 deletions.
73 changes: 69 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Use the Vtiger webservice (REST) API from within Laravel for operations Create,
See [Third Party App Integration (REST APIs)](http://community.vtiger.com/help/vtigercrm/developers/third-party-app-integration.html)

## Installation, Configuration and Usage
----

### Installing
1. In order to install the Vtiger package in your Laravel project, just run the composer require command from your terminal:
Expand Down Expand Up @@ -45,18 +44,84 @@ See [Third Party App Integration (REST APIs)](http://community.vtiger.com/help/v
|username |API |
|accesskey|irGsy9HB0YOZdEA |
> Because I've experienced problems getting the sessionid from the CRM when multiple users are accessing the CRM at the same time, the solution was to store the sessionid into a file within Laravel application.
> Instead of getting the token from the database for each request using the webservice API, a check is made against the expiry time in the file. If the expiry time has expired, a token is requested from the CRM and file is updated with the new token and updated expiry time.
### Usage
In your controller include the Vtiger package
```
use Vtiger;
```
#### Create
To insert a record into the CRM, first create an array of data to insert. Don't forget the added the id of the `assigned_user_id` (i.e. '4x12') otherwise the insert will fail as `assigned_user_id` is a mandatory field.
```
$data = array(
'assigned_user_id' => '',
);
```
To do the actual insert, pass the module name along with the json encoded array to the *create* function.
```
Vtiger::create($MODULE_NAME, json_encode($data));
```
#### Retrieve
To retrieve a record from the CRM, you need the id of the record you want to find (i.e. '4x12').
```
$id = '4x12';

$obj = Vtiger::retrieve($id);

// do someting with the result
var_dump($obj);
```
#### Update
The easiest way to update a record in the CRM is to retrieve the record first.
```
$id = '4x12';

$obj = Vtiger::retrieve($id);
```
Then update the object with updated data.
```
$obj->result->field_name = 'Your new value';

$update = Vtiger::update($obj->result);
```
#### Query
To use the [Query Operation](http://community.vtiger.com/help/vtigercrm/developers/third-party-app-integration.html#query-operation), you first need to create a SQL query.
```
$query = "SELECT * FROM ModuleName;";
```
Then run the query...
```
$obj = Vtiger::query($query);

//loop over result
foreach($obj->result as $result) {
// do something
}
```
## Contributing
----
Please report any issue you find in the issues page. Pull requests are more than welcome.
## Authors
----
* **Adam Godfrey** - [Clystnet](https://www.clystnet.com)
## License
----
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
Expand Down

0 comments on commit e7267bc

Please sign in to comment.