public static function findById($id) { $call = Request::call(Requests::getDocumentRevision($id)); if (isset($call->number)) { throw new Exception($call->description); } return self::create($call); }
public function fetchRelation(array $fields = array()) { $requestAction = Requests::getRelationships($this->module->getModuleName(), $this->module->id, $this->relation->getDbName(), $this->relation->getModuleName(), $fields); $results = Request::call($requestAction); if ($this->relation->isCollection()) { return Converter::toModules($results, $this->relationModule); } return Converter::toModule($results->entry_list[0], $this->relationModule); }
public static function connect($url, $login, $password) { self::$url = $url; $result = Request::call(Requests::login($login, $password)); if (isset($result->number) && $result->number == 10) { throw new LoginException($result->name); } self::$sessionId = $result->id; return true; }
public static function forModule($moduleName) { return new self(Request::call(Requests::getModuleFields($moduleName))); }
public static function getId() { return Request::call(Requests::getUserId()); }
public function count() { $call = Request::call(Requests::getEntriesCount($this->module->getModuleName(), $this->prepareWhere())); return $call->result_count; }
public function into($moduleName) { Request::call(Requests::setEntry($moduleName, $this->attributes)); }
protected function tearDown() { Request::$requestHandler = new RequestHandler(); parent::tearDown(); }
public function into($moduleName) { $call = Request::call(Requests::setEntry($moduleName, $this->attributes)); return $call->id; }
/** * @return File * @throws Exception */ public function getFile() { $call = Request::call(Requests::getDocumentRevision($this->document_revision_id)); return File::create($call); }
<?php namespace SugarClient\Http; use SugarClient\Http\ApiAction\RequestAction; /** * Class Request * @package SugarClient\Http * @author Piotr Olaszewski <piotroo89 [%] gmail dot com> */ class Request { public static $requestHandler = null; public static function call(RequestAction $requestAction) { $post = array("method" => $requestAction->getMethod(), "input_type" => "JSON", "response_type" => "JSON", "rest_data" => $requestAction->getRestData()); return self::doRequest($post); } public static function callMethod($method, $parameters) { $post = array("method" => $method, "input_type" => "JSON", "response_type" => "JSON", "rest_data" => json_encode($parameters)); return self::doRequest($post); } private static function doRequest($post) { return self::$requestHandler->handle($post); } } Request::$requestHandler = new RequestHandler();
public function relatedWith(Module $module) { $result = Request::call(Requests::setRelationship($this->getModuleName(), $this->id, $module->getModuleDbName(), $module->id)); if ($result->failed) { throw new Exception("Creating relationship failed"); } return $result->created == 1; }