add test case for api client instance

This commit is contained in:
wing328
2015-05-23 10:35:19 +08:00
parent 612abf134b
commit 691838c47d
7 changed files with 129 additions and 17 deletions

View File

@@ -92,15 +92,36 @@ class APIClient {
}
/**
* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
* get the user agent of the api client
*
* @return string user agent
*/
public function getUserAgent($user_agent) {
return $this->user_agent;
}
/**
* set the HTTP timeout value
*
* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
*/
public function setTimeout($seconds) {
if (!is_numeric($seconds))
throw new \InvalidArgumentException('Timeout variable must be numeric.');
if (!is_numeric($seconds) || $seconds < 0)
throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.');
$this->curl_timeout = $seconds;
}
/**
* get the HTTP timeout value
*
* @return string HTTP timeout value
*/
public function getTimeout() {
return $this->curl_timeout;
}
/**
* Get API key (with prefix if set)
* @param string key name