-
Notifications
You must be signed in to change notification settings - Fork 1
/
ZohoCrmModule.php
50 lines (41 loc) · 1.46 KB
/
ZohoCrmModule.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
include_once('ZohoCrmModuleIterator.php');
class ZohoCrmModule {
public $name;
protected $zohoCrm;
public $fixedParams = array(
'version' => 2,
'newFormat' => 2
);
public function __construct($name, ZohoCrm $zohoCrm) {
$this->name = $name;
$this->zohoCrm = $zohoCrm;
}
public function call($path, $params=array(), $options=array()) {
return $this->zohoCrm->call("{$this->name}/$path", $params, $options);
}
public function compileSelectColumns($selectColumns) {
if (empty($selectColumns) || $selectColumns === 'All') {
return 'All';
} else {
return $this->name . '(' . implode(',', $selectColumns) . ')';
}
}
/**
* @see http://www.zoho.com/crm/help/api/getrecords.html
*/
public function getRecords($options=array()) {
if (array_key_exists('selectColumns', $options) && is_array($options['selectColumns'])) {
$options['selectColumns'] = $this->compileSelectColumns($options['selectColumns']);
}
return new ZohoCrmModuleIterator($this, $options);
}
/**
* @see https://www.zoho.com/crm/help/api/getrelatedrecords.html
*/
public function getRelatedRecords($forRecordId, $relatedModule, $options=array()) {
$options['id'] = $forRecordId;
$options['parentModule'] = $this->name;
return new ZohoCrmModuleIterator($relatedModule, $options, 'getRelatedRecords');
}
}