forked from oprimus/PHP-Zoho
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZohoCreatorApplication.php
45 lines (37 loc) · 1.38 KB
/
ZohoCreatorApplication.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
<?php
class ZohoCreatorApplication {
public $name;
protected $zohoCreator;
protected $views = array();
public function __construct($name, ZohoCreator $zohoCreator) {
$this->name = $name;
$this->zohoCreator = $zohoCreator;
}
public function call($path, $params=array(), $options=array()) {
return $this->zohoCreator->call("{$this->name}/$path", $params, $options);
}
/**
* @see https://api.creator.zoho.com/REST-API-View-Records-in-View.html
*/
public function viewRecords($viewName) {
return $this->call("view/{$viewName}", array('raw' => 'true'));
}
/**
* @see https://api.creator.zoho.com/REST-API-List-Forms-and-Views.html
*/
public function formsAndViews() {
return $this->call("formsandviews");
}
/**
* @see https://api.creator.zoho.com/REST-API-Add-Records.html
* @param array $data An associative array of key => value pairs to set
*/
public function add($formName, $data) {
$result = $this->call("{$formName}/add/", array(), array("PostData" => $data));
if ($result->formname[1]->operation[1]->values[1]->status[0] == 'Success') {
return $result->formname[1]->operation[1]->values[0];
} else {
throw new Exception(sprintf("Zoho error: %s", $result->formname[1]->operation[1]->values[1]->status[0]));
}
}
}