Skip to content
This repository was archived by the owner on Jan 6, 2021. It is now read-only.

Commit f7d3f46

Browse files
authored
Merge pull request #21 from SPOORT/readme-improvements
Readme improvements
2 parents a9a8e83 + dd0310e commit f7d3f46

File tree

1 file changed

+70
-6
lines changed

1 file changed

+70
-6
lines changed

README.md

Lines changed: 70 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,16 @@ You can enable logging by adding the following line after instantiating the clie
2626
```php
2727
$client->setLogger($myPsrLogger);
2828
```
29-
3029
The logger should implement the PSR `LoggerInterface`. If the transport being used implements `LoggerAwareInterface`, this call will chaing to set the logger for the transport as well. The build in transport supports this.
3130

31+
### Choosing a different Zoho realm
32+
33+
ZohoCRMClient will by default connect to the API at `crm.zoho.com`. If you wish to connect to a different one, you can supply the TLD as the third parameter to the constructor. For example, customer on the EU realm should instantiate the client like this:
34+
35+
``` php
36+
$client = new ZohoCRMClient('Leads', 'yourAuthKey', 'eu');
37+
```
38+
3239
### Using custom transport
3340

3441
If we wish, you can supply a custom transport class to ZohoCRMClient, as shown here:
@@ -52,11 +59,68 @@ $client = new ZohoCRMClient('Leads', $transport);
5259

5360
## Implemented Calls
5461
At the moment only the following calls are supported
55-
- getRecords
56-
- getRecordById
57-
- insertRecords
58-
- updateRecords
59-
- getFields
62+
- [getRecords](https://www.zoho.eu/crm/help/api/getrecords.html)
63+
- [getRecordById](https://www.zoho.eu/crm/help/api/getrecordbyid.html)
64+
- [insertRecords](https://www.zoho.eu/crm/help/api/insertrecords.html)
65+
- [updateRecords](https://www.zoho.eu/crm/help/api/updaterecords.html)
66+
- [getFields](https://www.zoho.eu/crm/help/api/getfields.html)
67+
- [searchResults](https://www.zoho.eu/crm/help/api/searchrecords.html)
6068

6169
It is rather easy to add new calls, look at one of the classes in the Request dir for examples.
6270
After the Request class is made it might be necessary to alter the parsing of the response XML in the XmlDataTransportDecorator class.
71+
72+
## More examples
73+
74+
### insertRecords()
75+
76+
```php
77+
use Christiaan\ZohoCRMClient\ZohoCRMClient;
78+
79+
$client = new ZohoCRMClient('Contacts', 'yourAuthKey');
80+
81+
$records = $client
82+
->insertRecords()
83+
->addRecord([
84+
'Email' => '[email protected]',
85+
'First Name' => 'John'
86+
])
87+
->request();
88+
```
89+
90+
Optionally, you can add `onDuplicateUpdate()` or `onDuplicateError()` to the chain, before `request()`, to instruct Zoho to either update or fail on duplicated records.
91+
Duplicate checking depends on the module being targeted, see the list in the [Zoho documentation](https://www.zoho.eu/crm/help/api/insertrecords.html#Duplicate_Check_Fields).
92+
93+
The `$records` array will contain an entry for each record you have tried to create, which on success will contain the ID of the new (or updated) record.
94+
95+
### updateRecords()
96+
97+
```php
98+
use Christiaan\ZohoCRMClient\ZohoCRMClient;
99+
100+
$client = new ZohoCRMClient('Contacts', 'yourAuthKey');
101+
102+
$records = $client
103+
->updateRecords()
104+
->addRecord([
105+
'Id' => '(ID returned from insert, search, ...)'
106+
'Last Name' => 'Smith'
107+
])
108+
->request();
109+
```
110+
111+
Specifying the ID per record is necessary when updating multiple records. Alternatively, you may call `id()` to set the ID if you are only updating a single record. Setting the ID per record works in either case.
112+
113+
### searchResults()
114+
115+
```php
116+
use Christiaan\ZohoCRMClient\ZohoCRMClient;
117+
118+
$client = new ZohoCRMClient('Contacts', 'yourAuthKey');
119+
120+
$records = $client
121+
->searchRecords()
122+
->criteria('Email:[email protected]')
123+
->request();
124+
```
125+
126+
See the [Zoho documentation](https://www.zoho.eu/crm/help/api/searchrecords.html) for the full explanation of how to write the criteria.

0 commit comments

Comments
 (0)