public function __construct($method, $path, $params, $headers, $object) { $this->apiBase = $this->apiBase ? $this->apiBase : Rainforest::getApiBase(); $this->method = $method; $this->path = PathBuilder::build($path, $object, $params); $this->params = ParamsBuilder::build($params); $this->headers = HeadersBuilder::build($headers); }
public static function defaultHeaders() { $apiVersion = Rainforest::getApiVersion(); $version = Rainforest::VERSION; $headers = array_merge(["user_agent" => "Rainforest/" . $apiVersion . " Rainforest/" . $version], ["Content-Type" => "application/json", "CLIENT_TOKEN" => Rainforest::$apiKey]); try { $headers["x_rainforest_client_user_agent"] = json_encode(self::userAgent()); } catch (Exception $e) { $headers["x_rainforest_client_raw_user_agent"] = var_dump(self::userAgent()); $headers["error"] = "{$e}"; } return $headers; }
public function testShouldSetTheUserAgent() { $this->assertNotEmpty($this->builtHeaders['user_agent']); $this->assertNotEmpty(strpos($this->builtHeaders['user_agent'], Rainforest::getApiVersion())); $this->assertNotEmpty(strpos($this->builtHeaders['user_agent'], Rainforest::VERSION)); }