/** * @param array|null $params * * @return Printfection_Order The placed order. */ public function place() { $requestor = new Printfection_ApiRequestor($this->_apiKey); $url = $this->instanceUrl() . '/place'; list($response, $apiKey) = $requestor->request('post', $url); $this->refreshFrom($response, $apiKey); return $this; }
public function next() { list($url, $params) = $this->extractPathAndUpdateParams($params); $requestor = new Printfection_ApiRequestor($this->_apiKey); $id = Printfection_ApiRequestor::utf8($id); $extn = urlencode($id); $params['limit'] = isset($params['limit']) ? $params['limit'] : 100; $params['offset'] = isset($params['offset']) ? $params['offset'] + $params['limit'] : $params['limit']; list($response, $apiKey) = $requestor->request('get', "{$url}/{$extn}", $params); return Printfection_Util::convertToPrintfectionObject($response, $apiKey); }
/** * @return string The instance URL for this resource. It needs to be special * cased because it doesn't fit into the standard resource pattern. */ public function instanceUrl() { $id = $this['id']; if (!$id) { $class = get_class($this); $msg = "Could not determine which URL to request: {$class} instance has invalid ID: {$id}"; throw new Printfection_InvalidRequestError($msg, null); } $parent = $this['order_id']; $base = self::classUrl('Printfection_Order'); $parent = Printfection_ApiRequestor::utf8($parent); $id = Printfection_ApiRequestor::utf8($id); $parentExtn = urlencode($parent); $extn = urlencode($id); $class = get_class($this); $self = self::_scopedLsb($class, 'className', $class); return $base . "/" . $parentExtn . "/" . $self . "s/" . $extn; }
protected function _scopedDelete($class, $params = null) { self::_validateCall('delete'); $requestor = new Printfection_ApiRequestor($this->_apiKey); $url = $this->instanceUrl(); list($response, $apiKey) = $requestor->request('delete', $url, $params); $this->refreshFrom($response, $apiKey); return $this; }