コード例 #1
0
 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);
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 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));
 }