本文整理汇总了PHP中Swagger\Client\ApiClient::selectHeaderAccept方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiClient::selectHeaderAccept方法的具体用法?PHP ApiClient::selectHeaderAccept怎么用?PHP ApiClient::selectHeaderAccept使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Swagger\Client\ApiClient
的用法示例。
在下文中一共展示了ApiClient::selectHeaderAccept方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testApiClient
public function testApiClient()
{
// test selectHeaderAccept
$api_client = new ApiClient();
$this->assertSame('application/json', $api_client->selectHeaderAccept(array('application/xml', 'application/json')));
$this->assertSame(null, $api_client->selectHeaderAccept(array()));
$this->assertSame('application/yaml,application/xml', $api_client->selectHeaderAccept(array('application/yaml', 'application/xml')));
// test selectHeaderContentType
$this->assertSame('application/json', $api_client->selectHeaderContentType(array('application/xml', 'application/json')));
$this->assertSame('application/json', $api_client->selectHeaderContentType(array()));
$this->assertSame('application/yaml,application/xml', $api_client->selectHeaderContentType(array('application/yaml', 'application/xml')));
// test addDefaultHeader and getDefaultHeader
$api_client->getConfig()->addDefaultHeader('test1', 'value1');
$api_client->getConfig()->addDefaultHeader('test2', 200);
$defaultHeader = $api_client->getConfig()->getDefaultHeaders();
$this->assertSame('value1', $defaultHeader['test1']);
$this->assertSame(200, $defaultHeader['test2']);
// test deleteDefaultHeader
$api_client->getConfig()->deleteDefaultHeader('test2');
$defaultHeader = $api_client->getConfig()->getDefaultHeaders();
$this->assertFalse(isset($defaultHeader['test2']));
$pet_api2 = new Api\PetApi();
$config3 = new Configuration();
$apiClient3 = new ApiClient($config3);
$apiClient3->getConfig()->setUserAgent('api client 3');
$config4 = new Configuration();
$apiClient4 = new ApiClient($config4);
$apiClient4->getConfig()->setUserAgent('api client 4');
$pet_api3 = new Api\PetApi($apiClient3);
// 2 different api clients are not the same
$this->assertNotEquals($apiClient3, $apiClient4);
// customied pet api not using the old pet api's api client
$this->assertNotEquals($pet_api2->getApiClient(), $pet_api3->getApiClient());
// test access token
$api_client->getConfig()->setAccessToken("testing_only");
$this->assertSame('testing_only', $api_client->getConfig()->getAccessToken());
}
示例2: syncschedule
/**
* syncschedule
*
*
*
* @param string $device_id The relay id (required)
* @param string $module_id The thermostat id (required)
* @param \Swagger\Client\Model\NAThermProgram $therm_program The thermostat program (zones, timetable and name) (required)
* @return \Swagger\Client\Model\NAOkResponse
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function syncschedule($device_id, $module_id, $therm_program)
{
// verify the required parameter 'device_id' is set
if ($device_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $device_id when calling syncschedule');
}
// verify the required parameter 'module_id' is set
if ($module_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $module_id when calling syncschedule');
}
// verify the required parameter 'therm_program' is set
if ($therm_program === null) {
throw new \InvalidArgumentException('Missing the required parameter $therm_program when calling syncschedule');
}
// parse inputs
$resourcePath = "/syncschedule";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array());
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// query params
if ($device_id !== null) {
$queryParams['device_id'] = $this->apiClient->getSerializer()->toQueryValue($device_id);
}
// query params
if ($module_id !== null) {
$queryParams['module_id'] = $this->apiClient->getSerializer()->toQueryValue($module_id);
}
// body params
$_tempBody = null;
if (isset($therm_program)) {
$_tempBody = $therm_program;
}
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody;
// $_tempBody is the method argument, if present
} else {
if (count($formParams) > 0) {
$httpBody = $formParams;
// for HTTP post (form)
}
}
//TODO support oauth
//TODO support oauth
// make the API Call
try {
list($response, $httpHeader) = $this->apiClient->callApi($resourcePath, $method, $queryParams, $httpBody, $headerParams, '\\Swagger\\Client\\Model\\NAOkResponse');
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\NAOkResponse', $httpHeader);
$e->setResponseObject($data);
break;
}
throw $e;
}
if (!$response) {
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '\\Swagger\\Client\\Model\\NAOkResponse');
}
示例3: deliveryCreate
/**
* deliveryCreate
*
* Create a delivery
*
* @param string $order_id Order to create delivery for (required)
* @param string $delivery_id Unique ID of the delivery (required)
* @param string[] $products (required)
* @param \DateTime $delivered (required)
* @param bool $send_mail Whether to send email to customer or not for this shipment (optional)
* @return \Swagger\Client\Model\Delivery
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function deliveryCreate($order_id, $delivery_id, $products, $delivered, $send_mail = null)
{
// verify the required parameter 'order_id' is set
if ($order_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $order_id when calling deliveryCreate');
}
// verify the required parameter 'delivery_id' is set
if ($delivery_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $delivery_id when calling deliveryCreate');
}
// verify the required parameter 'products' is set
if ($products === null) {
throw new \InvalidArgumentException('Missing the required parameter $products when calling deliveryCreate');
}
// verify the required parameter 'delivered' is set
if ($delivered === null) {
throw new \InvalidArgumentException('Missing the required parameter $delivered when calling deliveryCreate');
}
// parse inputs
$resourcePath = "/api/orders/{order_id}/deliveries/";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array());
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// path params
if ($order_id !== null) {
$resourcePath = str_replace("{" . "order_id" . "}", $this->apiClient->getSerializer()->toPathValue($order_id), $resourcePath);
}
// form params
if ($delivery_id !== null) {
$formParams['delivery_id'] = $this->apiClient->getSerializer()->toFormValue($delivery_id);
}
// form params
if ($products !== null) {
$formParams['products'] = $this->apiClient->getSerializer()->toFormValue($products);
}
// form params
if ($delivered !== null) {
$formParams['delivered'] = $this->apiClient->getSerializer()->toFormValue($delivered);
}
// form params
if ($send_mail !== null) {
$formParams['send_mail'] = $this->apiClient->getSerializer()->toFormValue($send_mail);
}
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody;
// $_tempBody is the method argument, if present
} else {
if (count($formParams) > 0) {
// for HTTP post (form)
$httpBody = $formParams;
}
}
$apiKey = $this->apiClient->getApiKeyWithPrefix('Authorization');
if (isset($apiKey)) {
$headerParams['Authorization'] = $apiKey;
}
// make the API Call
try {
$response = $this->apiClient->callAPI($resourcePath, $method, $queryParams, $httpBody, $headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 0:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\Delivery');
$e->setResponseObject($data);
break;
}
throw $e;
}
if (!$response) {
return null;
}
$responseObject = $this->apiClient->getSerializer()->deserialize($response, '\\Swagger\\Client\\Model\\Delivery');
return $responseObject;
}
示例4: signUpWithHttpInfo
/**
* signUpWithHttpInfo
*
* create a new user
*
* @param string $app_id ID of app (required)
* @param \Swagger\Client\Model\UserBody $body request body (required)
* @return Array of \Swagger\Client\Model\CloudUser, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function signUpWithHttpInfo($app_id, $body)
{
// verify the required parameter 'app_id' is set
if ($app_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $app_id when calling signUp');
}
// verify the required parameter 'body' is set
if ($body === null) {
throw new \InvalidArgumentException('Missing the required parameter $body when calling signUp');
}
// parse inputs
$resourcePath = "user/{app_id}/signup";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json'));
// path params
if ($app_id !== null) {
$resourcePath = str_replace("{" . "app_id" . "}", $this->apiClient->getSerializer()->toPathValue($app_id), $resourcePath);
}
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody;
// $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams;
// for HTTP post (form)
}
// make the API Call
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi($resourcePath, 'POST', $queryParams, $httpBody, $headerParams, '\\Swagger\\Client\\Model\\CloudUser');
if (!$response) {
return array(null, $statusCode, $httpHeader);
}
return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\\Swagger\\Client\\Model\\CloudUser', $httpHeader), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\CloudUser', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
}
throw $e;
}
}
示例5: getmeasure
/**
* getmeasure
*
*
*
* @param string $access_token Your access token (required)
* @param string $device_id Id of the device whose module's measurements you want to retrieve. This _id can be found in the user's devices field. (required)
* @param string $scale Defines the time interval between two measurements.\nPossible values :\nmax -> every value stored will be returned\n30min -> 1 value every 30 minutes\n1hour -> 1 value every hour\n3hours -> 1 value every 3 hours\n1day -> 1 value per day\n1week -> 1 value per week\n1month -> 1 value per month (required)
* @param string[] $type Sets the type of measurement you want to retrieve.\nThe different types of measurements must be given in a comma separated list of strings.\nExample: type=\"Temperature,Humidity\"\nDepending on the device's type and the scale, different measurements are available:\nFor Weather Station :\n\n max -> Temperature, CO2, Humidity, Pressure, Noise, Rain (if\nmodule_id is a rain sensor)\n\n 30min, 1hour, 3hours -> Temperature, CO2, Humidity, Pressure,\nNoise, min_temp, max_temp, min_hum, max_hum, min_pressure, max_pressure, min_noise, max_noise, sum_rain (if module_id is a rain sensor)\n\n 1day, 1week, 1month -> Temperature, Co2, Humidity, Pressure, Noise,\nmin_temp, date_min_temp, max_temp, date_max_temp, min_hum, date_min_hum, max_hum, date_max_hum, min_pressure, date_min_pressure, max_pressure, date_max_pressure, min_noise, date_min_noise, max_noise, date_max_noise, date_min_co2, date_max_co2, sum_rain (if module_id is a rain sensor)\nPlease note, the measurements sent in the response will be in the same order as in this list.\nAll measurements are expressed in metric units:\n\n Temperature: Celsius\n\n Humidity: %\n\n Co2: ppm\n\n Pressure: mbar\n\n Noise: db\n\n Rain: mm\n\nFor Thermostat:\n\n max -> Temperature, Sp_Temperature, BoilerOn, BoilerOff\n\n 30min, 1hour, 3hours -> Temperature, Sp_Temperature, min_temp,\nmax_temp, sum_boiler_on, sum_boiler_off\n\n 1day, 1week, 1month -> Temperature, min_temp, date_min_temp,\nmax_temp, sum_boiler_on, sum_boiler_off\n\n where\n\nTemperature: Celsius\n\n Sp_Temperature (temperature setpoint): Celsius\n\n BoilerOn: Duration, since the previous data point, during which the\nboiler has been on (in seconds)\n\n BoilerOff : Duration, since the previous data point, during which\nthe boiler has been off (in seconds).\n\n sum_boiler_on: Total duration during which the boiler has been on,\nat a specific scale (in seconds).\n\n sum_boiler_off: Total duration during which the boiler has been\noff, at a specific scale (in seconds). (required)
* @param string $module_id If you don't specify any module_id you will retrieve the device's measurements. If you specify a module_id you will retrieve the module's measurements. (optional)
* @param int $date_begin Starting timestamp (utc) of the requested measurements.\nPlease note measurement retrieving is limited to 1024 measurements. (optional)
* @param int $date_end Ending timestamp (utc) of the request measurements.\nIf you want only the last measurement, do not provide date_begin, and set date_end to \"last\". (optional)
* @param int $limit Limits the number of measurements returned (default & max is 1024) (optional)
* @param bool $optimize Allows you to choose the format of the answer.\nIf you build a mobile app and bandwith usage is an issue, use optimize = true.\nUse optimize = false, for an easier parse. In this case, values are indexed by sorted timestamp.\nExample of un-optimized response :\n{\"status\": \"ok\", \n \"body\": {\n \"1347575400\": [18.3,39],\n \"1347586200\": [20.6,48]\n },\n\"time_exec\": 0.012136936187744}\nIf optimize is set true, measurements are returned as an array of series of regularly spaced measurements. Each series is defined by a beginning time beg_time and a step between measurements, step_time:\n{\"status\": \"ok\",\n \"body\": [\n {\"beg_time\": 1347575400,\n \"step_time\": 10800,\n \"value\": \n [[18.3,39],\n [ 20.6,48]]\n }],\n\"time_exec\": 0.014238119125366}\nDefault value is true. (optional)
* @param bool $real_time In scales higher than max, since the data is aggregated, the timestamps returned are by default offset by +(scale/2).\nFor instance, if you ask for measurements at a daily scale, you will receive data timestamped at 12:00 if real_time is set to false (default case), and timestamped at 00:00 if real_time is set to true.\nNB : The servers always store data with real_time set to true and data are offset by this parameter AFTER having being time-filtered, thus you could have data after date_end if real_time is set to false. (optional)
* @return \Swagger\Client\Model\NAMeasureResponse
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getmeasure($access_token, $device_id, $scale, $type, $module_id = null, $date_begin = null, $date_end = null, $limit = null, $optimize = null, $real_time = null)
{
// verify the required parameter 'access_token' is set
if ($access_token === null) {
throw new \InvalidArgumentException('Missing the required parameter $access_token when calling getmeasure');
}
// verify the required parameter 'device_id' is set
if ($device_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $device_id when calling getmeasure');
}
// verify the required parameter 'scale' is set
if ($scale === null) {
throw new \InvalidArgumentException('Missing the required parameter $scale when calling getmeasure');
}
// verify the required parameter 'type' is set
if ($type === null) {
throw new \InvalidArgumentException('Missing the required parameter $type when calling getmeasure');
}
// parse inputs
$resourcePath = "/api/getmeasure";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array());
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// query params
if ($access_token !== null) {
$queryParams['access_token'] = $this->apiClient->getSerializer()->toQueryValue($access_token);
}
// query params
if ($device_id !== null) {
$queryParams['device_id'] = $this->apiClient->getSerializer()->toQueryValue($device_id);
}
// query params
if ($module_id !== null) {
$queryParams['module_id'] = $this->apiClient->getSerializer()->toQueryValue($module_id);
}
// query params
if ($scale !== null) {
$queryParams['scale'] = $this->apiClient->getSerializer()->toQueryValue($scale);
}
// query params
if ($type !== null) {
$queryParams['type'] = $this->apiClient->getSerializer()->toQueryValue($type);
}
// query params
if ($date_begin !== null) {
$queryParams['date_begin'] = $this->apiClient->getSerializer()->toQueryValue($date_begin);
}
// query params
if ($date_end !== null) {
$queryParams['date_end'] = $this->apiClient->getSerializer()->toQueryValue($date_end);
}
// query params
if ($limit !== null) {
$queryParams['limit'] = $this->apiClient->getSerializer()->toQueryValue($limit);
}
// query params
if ($optimize !== null) {
$queryParams['optimize'] = $this->apiClient->getSerializer()->toQueryValue($optimize);
}
// query params
if ($real_time !== null) {
$queryParams['real_time'] = $this->apiClient->getSerializer()->toQueryValue($real_time);
}
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody;
// $_tempBody is the method argument, if present
} else {
if (count($formParams) > 0) {
$httpBody = $formParams;
// for HTTP post (form)
}
}
// make the API Call
//.........这里部分代码省略.........
示例6: uploadFileWithHttpInfo
/**
* uploadFileWithHttpInfo
*
* uploads an image
*
* @param int $pet_id ID of pet to update (required)
* @param string $additional_metadata Additional data to pass to server (optional)
* @param \SplFileObject $file file to upload (optional)
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $file = null)
{
// verify the required parameter 'pet_id' is set
if ($pet_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling uploadFile');
}
// parse inputs
$resourcePath = "/pet/{petId}/uploadImage";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('multipart/form-data'));
// path params
if ($pet_id !== null) {
$resourcePath = str_replace("{" . "petId" . "}", $this->apiClient->getSerializer()->toPathValue($pet_id), $resourcePath);
}
// form params
if ($additional_metadata !== null) {
$formParams['additionalMetadata'] = $this->apiClient->getSerializer()->toFormValue($additional_metadata);
}
// form params
if ($file !== null) {
// PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax
// See: https://wiki.php.net/rfc/curl-file-upload
if (function_exists('curl_file_create')) {
$formParams['file'] = curl_file_create($this->apiClient->getSerializer()->toFormValue($file));
} else {
$formParams['file'] = '@' . $this->apiClient->getSerializer()->toFormValue($file);
}
}
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody;
// $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams;
// for HTTP post (form)
}
// this endpoint requires OAuth (access token)
if ($this->apiClient->getConfig()->getAccessToken() !== null) {
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
}
// make the API Call
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi($resourcePath, $method, $queryParams, $httpBody, $headerParams);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
示例7: updateWithHttpInfo
/**
* updateWithHttpInfo
*
* Modify a Lan
*
* @param string $datacenter_id (required)
* @param map[string,string] $lan_id (required)
* @param \Swagger\Client\Model\Lan $lan Modified Lan (required)
* @param bool $pretty_print_query_parameter Controls whether response is pretty-printed (with indentation and new lines) (optional, default to true)
* @param int $depth Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n\t- depth=0: only direct properties are included. Children (servers etc.) are not included\n\t- depth=1: direct properties and children references are included\n\t- depth=2: direct properties and children properties are included\n\t- depth=3: direct properties and children properties and children's children are included\n\t- depth=... and so on (optional, default to 0)
* @return Array of \Swagger\Client\Model\Lan, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function updateWithHttpInfo($datacenter_id, $lan_id, $lan, $pretty_print_query_parameter = null, $depth = null)
{
// verify the required parameter 'datacenter_id' is set
if ($datacenter_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $datacenter_id when calling update');
}
// verify the required parameter 'lan_id' is set
if ($lan_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $lan_id when calling update');
}
// verify the required parameter 'lan' is set
if ($lan === null) {
throw new \InvalidArgumentException('Missing the required parameter $lan when calling update');
}
// parse inputs
$resourcePath = "/datacenters/{datacenterId}/lans/{lanId}";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json'));
// query params
if ($pretty_print_query_parameter !== null) {
$queryParams['Pretty print query parameter'] = $this->apiClient->getSerializer()->toQueryValue($pretty_print_query_parameter);
}
// query params
if ($depth !== null) {
$queryParams['depth'] = $this->apiClient->getSerializer()->toQueryValue($depth);
}
// path params
if ($datacenter_id !== null) {
$resourcePath = str_replace("{" . "datacenterId" . "}", $this->apiClient->getSerializer()->toPathValue($datacenter_id), $resourcePath);
}
// path params
if ($lan_id !== null) {
$resourcePath = str_replace("{" . "lanId" . "}", $this->apiClient->getSerializer()->toPathValue($lan_id), $resourcePath);
}
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// body params
$_tempBody = null;
if (isset($lan)) {
$_tempBody = $lan;
}
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody;
// $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams;
// for HTTP post (form)
}
// this endpoint requires HTTP basic authentication
if (strlen($this->apiClient->getConfig()->getUsername()) !== 0 or strlen($this->apiClient->getConfig()->getPassword()) !== 0) {
$headerParams['Authorization'] = 'Basic ' . base64_encode($this->apiClient->getConfig()->getUsername() . ":" . $this->apiClient->getConfig()->getPassword());
}
// make the API Call
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi($resourcePath, 'PUT', $queryParams, $httpBody, $headerParams, '\\Swagger\\Client\\Model\\Lan');
if (!$response) {
return array(null, $statusCode, $httpHeader);
}
return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\\Swagger\\Client\\Model\\Lan', $httpHeader), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 202:
$data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\Lan', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
default:
$data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\Error', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
}
throw $e;
}
}
示例8: addPetUsingByteArrayWithHttpInfo
/**
* addPetUsingByteArrayWithHttpInfo
*
* Fake endpoint to test byte array in body parameter for adding a new pet to the store
*
* @param string $body Pet object in the form of byte array (optional)
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function addPetUsingByteArrayWithHttpInfo($body = null)
{
// parse inputs
$resourcePath = "/pet?testing_byte_array=true";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json', 'application/xml'));
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = $body;
}
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody;
// $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams;
// for HTTP post (form)
}
// this endpoint requires OAuth (access token)
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
}
// make the API Call
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi($resourcePath, 'POST', $queryParams, $httpBody, $headerParams);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
示例9: getToken
/**
* getToken
*
*
*
* @param string $grant_type Oauth2 grant type (required)
* @param string $client_id Application client ID (required)
* @param string $client_secret Application client secret (required)
* @param string $scope Scopes to use, separated by a space (optional)
* @param string $username User name if grant_type is password (optional)
* @param string $password User password if grant_type is password (optional)
* @param string $code Authorization code if grant_type is authorization_code (optional)
* @param string $redirect_uri Redirect URI if grant_type is authorization_code (optional)
* @param string $refresh_token Refresh token if grant_type is refresh_token (optional)
* @return \Swagger\Client\Model\AccessToken
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getToken($grant_type, $client_id, $client_secret, $scope = null, $username = null, $password = null, $code = null, $redirect_uri = null, $refresh_token = null)
{
// verify the required parameter 'grant_type' is set
if ($grant_type === null) {
throw new \InvalidArgumentException('Missing the required parameter $grant_type when calling getToken');
}
// verify the required parameter 'client_id' is set
if ($client_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $client_id when calling getToken');
}
// verify the required parameter 'client_secret' is set
if ($client_secret === null) {
throw new \InvalidArgumentException('Missing the required parameter $client_secret when calling getToken');
}
// parse inputs
$resourcePath = "/oauth2/token";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "POST";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded'));
// form params
if ($grant_type !== null) {
$formParams['grant_type'] = $this->apiClient->getSerializer()->toFormValue($grant_type);
}
// form params
if ($client_id !== null) {
$formParams['client_id'] = $this->apiClient->getSerializer()->toFormValue($client_id);
}
// form params
if ($client_secret !== null) {
$formParams['client_secret'] = $this->apiClient->getSerializer()->toFormValue($client_secret);
}
// form params
if ($scope !== null) {
$formParams['scope'] = $this->apiClient->getSerializer()->toFormValue($scope);
}
// form params
if ($username !== null) {
$formParams['username'] = $this->apiClient->getSerializer()->toFormValue($username);
}
// form params
if ($password !== null) {
$formParams['password'] = $this->apiClient->getSerializer()->toFormValue($password);
}
// form params
if ($code !== null) {
$formParams['code'] = $this->apiClient->getSerializer()->toFormValue($code);
}
// form params
if ($redirect_uri !== null) {
$formParams['redirect_uri'] = $this->apiClient->getSerializer()->toFormValue($redirect_uri);
}
// form params
if ($refresh_token !== null) {
$formParams['refresh_token'] = $this->apiClient->getSerializer()->toFormValue($refresh_token);
}
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody;
// $_tempBody is the method argument, if present
} else {
if (count($formParams) > 0) {
$httpBody = $formParams;
// for HTTP post (form)
}
}
// make the API Call
try {
list($response, $httpHeader) = $this->apiClient->callApi($resourcePath, $method, $queryParams, $httpBody, $headerParams, '\\Swagger\\Client\\Model\\AccessToken');
if (!$response) {
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '\\Swagger\\Client\\Model\\AccessToken', $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
//.........这里部分代码省略.........
示例10: partnerdevices
/**
* partnerdevices
*
*
*
* @param string $access_token Your access token (required)
* @return \Swagger\Client\Model\NAPartnerDevicesResponse
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function partnerdevices($access_token)
{
// verify the required parameter 'access_token' is set
if ($access_token === null) {
throw new \InvalidArgumentException('Missing the required parameter $access_token when calling partnerdevices');
}
// parse inputs
$resourcePath = "/api/partnerdevices";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array());
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// query params
if ($access_token !== null) {
$queryParams['access_token'] = $this->apiClient->getSerializer()->toQueryValue($access_token);
}
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody;
// $_tempBody is the method argument, if present
} else {
if (count($formParams) > 0) {
$httpBody = $formParams;
// for HTTP post (form)
}
}
// make the API Call
try {
list($response, $httpHeader) = $this->apiClient->callApi($resourcePath, $method, $queryParams, $httpBody, $headerParams, '\\Swagger\\Client\\Model\\NAPartnerDevicesResponse');
if (!$response) {
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '\\Swagger\\Client\\Model\\NAPartnerDevicesResponse', $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\NAPartnerDevicesResponse', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
}
throw $e;
}
return null;
}
示例11: articulosGet
/**
* articulosGet
*
* Articulos
*
* @param string $order_by Campo de ordenamiento. (optional)
* @param string $order_type Tipo de orden. (optional)
* @param Number $page Número de página. (optional)
* @param Number $page_size Número de página. (optional)
* @return \Swagger\Client\Model\Articulo[]
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function articulosGet($order_by = null, $order_type = null, $page = null, $page_size = null)
{
// parse inputs
$resourcePath = "/articulos";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "GET";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// query params
if ($order_by !== null) {
$queryParams['orderBy'] = $this->apiClient->getSerializer()->toQueryValue($order_by);
}
// query params
if ($order_type !== null) {
$queryParams['orderType'] = $this->apiClient->getSerializer()->toQueryValue($order_type);
}
// query params
if ($page !== null) {
$queryParams['page'] = $this->apiClient->getSerializer()->toQueryValue($page);
}
// query params
if ($page_size !== null) {
$queryParams['pageSize'] = $this->apiClient->getSerializer()->toQueryValue($page_size);
}
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody;
// $_tempBody is the method argument, if present
} else {
if (count($formParams) > 0) {
$httpBody = $formParams;
// for HTTP post (form)
}
}
// make the API Call
try {
list($response, $httpHeader) = $this->apiClient->callApi($resourcePath, $method, $queryParams, $httpBody, $headerParams, '\\Swagger\\Client\\Model\\Articulo[]');
if (!$response) {
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '\\Swagger\\Client\\Model\\Articulo[]', $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\Articulo[]', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
case 0:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\Error', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
}
throw $e;
}
return null;
}
示例12: printInfoWithHttpInfo
/**
* printInfoWithHttpInfo
*
* Display API information
*
* @param bool $pretty_print_query_parameter Controls whether response is pretty-printed (with indentation and new lines) (optional, default to true)
* @param int $depth Controls the details depth of response objects. \nEg. GET /datacenters/[ID]\n\t- depth=0: only direct properties are included. Children (servers etc.) are not included\n\t- depth=1: direct properties and children references are included\n\t- depth=2: direct properties and children properties are included\n\t- depth=3: direct properties and children properties and children's children are included\n\t- depth=... and so on (optional, default to 0)
* @return Array of \Swagger\Client\Model\Info, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function printInfoWithHttpInfo($pretty_print_query_parameter = null, $depth = null)
{
// parse inputs
$resourcePath = "/";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('*/*'));
// query params
if ($pretty_print_query_parameter !== null) {
$queryParams['Pretty print query parameter'] = $this->apiClient->getSerializer()->toQueryValue($pretty_print_query_parameter);
}
// query params
if ($depth !== null) {
$queryParams['depth'] = $this->apiClient->getSerializer()->toQueryValue($depth);
}
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody;
// $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams;
// for HTTP post (form)
}
// make the API Call
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi($resourcePath, 'GET', $queryParams, $httpBody, $headerParams, '\\Swagger\\Client\\Model\\Info');
if (!$response) {
return array(null, $statusCode, $httpHeader);
}
return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\\Swagger\\Client\\Model\\Info', $httpHeader), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\Info', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
default:
$data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\Error', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
}
throw $e;
}
}
示例13: updateUserPreference
/**
* updateUserPreference
*
* Update one user preference
*
* @param int $user_id The id of the user whose preference is to be updated/created (required)
* @param string $preference_name The preference name to update/create (required)
* @param string $updated_value the preference value (required)
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function updateUserPreference($user_id, $preference_name, $updated_value)
{
// verify the required parameter 'user_id' is set
if ($user_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $user_id when calling updateUserPreference');
}
// verify the required parameter 'preference_name' is set
if ($preference_name === null) {
throw new \InvalidArgumentException('Missing the required parameter $preference_name when calling updateUserPreference');
}
// parse inputs
$resourcePath = "/{userId}/{preferenceName}";
$resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "PUT";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// path params
if ($user_id !== null) {
$resourcePath = str_replace("{" . "userId" . "}", $this->apiClient->getSerializer()->toPathValue($user_id), $resourcePath);
}
// path params
if ($preference_name !== null) {
$resourcePath = str_replace("{" . "preferenceName" . "}", $this->apiClient->getSerializer()->toPathValue($preference_name), $resourcePath);
}
// body params
$_tempBody = null;
if (isset($updated_value)) {
$_tempBody = $updated_value;
}
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody;
// $_tempBody is the method argument, if present
} else {
if (count($formParams) > 0) {
// for HTTP post (form)
$httpBody = $formParams;
}
}
$apiKey = $this->apiClient->getApiKeyWithPrefix('X-Wikia-AccessToken');
if (isset($apiKey)) {
$headerParams['X-Wikia-AccessToken'] = $apiKey;
}
$apiKey = $this->apiClient->getApiKeyWithPrefix('X-Wikia-UserId');
if (isset($apiKey)) {
$headerParams['X-Wikia-UserId'] = $apiKey;
}
// make the API Call
try {
$response = $this->apiClient->callAPI($resourcePath, $method, $queryParams, $httpBody, $headerParams);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 400:
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\\Swagger\\Client\\User\\Preferences\\Models\\Problem');
$e->setResponseObject($data);
break;
}
throw $e;
}
}
示例14: getPetsWithHttpInfo
/**
* getPetsWithHttpInfo
*
* Get your pets
*
* @return Array of \Swagger\Client\Model\Animal, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getPetsWithHttpInfo()
{
// parse inputs
$resourcePath = "/pets";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded'));
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody;
// $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams;
// for HTTP post (form)
}
// make the API Call
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi($resourcePath, 'GET', $queryParams, $httpBody, $headerParams, '\\Swagger\\Client\\Model\\Animal');
if (!$response) {
return array(null, $statusCode, $httpHeader);
}
return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\\Swagger\\Client\\Model\\Animal', $httpHeader, 'className'), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\\Swagger\\Client\\Model\\Animal', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
}
throw $e;
}
}
示例15: deleteUserWithHttpInfo
/**
* deleteUserWithHttpInfo
*
* Delete user
*
* @param string $username The name that needs to be deleted (required)
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function deleteUserWithHttpInfo($username)
{
// verify the required parameter 'username' is set
if ($username === null) {
throw new \InvalidArgumentException('Missing the required parameter $username when calling deleteUser');
}
// parse inputs
$resourcePath = "/user/{username}";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// path params
if ($username !== null) {
$resourcePath = str_replace("{" . "username" . "}", $this->apiClient->getSerializer()->toPathValue($username), $resourcePath);
}
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody;
// $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams;
// for HTTP post (form)
}
// make the API Call
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi($resourcePath, 'DELETE', $queryParams, $httpBody, $headerParams);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}