setLocation(self::$path . "/{$orderId}"); $this[static::ID_FIELD] = $orderId; } } /** * Creates the resource. * * @param array $data Creation data * * @throws ConnectorException When the API replies with an error response * @throws RequestException When an error is encountered * @throws \RuntimeException If the location header is missing * @throws \RuntimeException If the API replies with an unexpected response * @throws \LogicException When Guzzle cannot populate the response * * @return self */ public function create(array $data) { $url = $this->post(self::$path, $data) ->status('201') ->getLocation(); $this->setLocation($url); return $this; } /** * Updates the resource. * * @param array $data Update data * * @throws ConnectorException When the API replies with an error response * @throws RequestException When an error is encountered * @throws \RuntimeException On an unexpected API response * @throws \RuntimeException If the response content type is not JSON * @throws \InvalidArgumentException If the JSON cannot be parsed * @throws \LogicException When Guzzle cannot populate the response * * @return self */ public function update(array $data) { $data = $this->post($this->getLocation(), $data) ->status('200') ->contentType('application/json') ->getJson(); $this->exchangeArray($data); return $this; } }