This commit is contained in:
Tony Tam 2015-01-21 23:19:13 -08:00
commit 2f6bf95fa2

View File

@ -22,69 +22,78 @@
{{#operations}} {{#operations}}
class {{classname}} { class {{classname}} {
function __construct($apiClient) { function __construct($apiClient) {
$this->apiClient = $apiClient; $this->apiClient = $apiClient;
} }
{{#operation}} {{#operation}}
/** /**
* {{nickname}} * {{nickname}}
* {{summary}} * {{summary}}
*
{{#allParams}} {{#allParams}}
* @param {{dataType}} ${{paramName}} {{description}} ({{^optional}}required{{/optional}}{{#optional}}optional{{/optional}}) * @param {{dataType}} ${{paramName}} {{description}} ({{^optional}}required{{/optional}}{{#optional}}optional{{/optional}})
{{/allParams}} {{/allParams}}
* @return {{returnType}} * @return {{returnType}}
*/ */
public function {{nickname}}({{#allParams}}${{paramName}}{{#optional}}=null{{/optional}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) { public function {{nickname}}({{#allParams}}${{paramName}}{{#optional}}=null{{/optional}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
//parse inputs //parse inputs
$resourcePath = "{{path}}"; $resourcePath = "{{path}}";
$resourcePath = str_replace("{format}", "json", $resourcePath); $resourcePath = str_replace("{format}", "json", $resourcePath);
$method = "{{httpMethod}}"; $method = "{{httpMethod}}";
$queryParams = array(); $queryParams = array();
$headerParams = array(); $headerParams = array();
$headerParams['Accept'] = '{{#produces}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/produces}}'; $headerParams['Accept'] = '{{#produces}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/produces}}';
$headerParams['Content-Type'] = '{{#consumes}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/consumes}}'; $headerParams['Content-Type'] = '{{#consumes}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/consumes}}';
{{#queryParams}} {{#queryParams}}
if(${{paramName}} != null) { if(${{paramName}} != null) {
$queryParams['{{paramName}}'] = $this->apiClient->toQueryValue(${{paramName}}); $queryParams['{{paramName}}'] = $this->apiClient->toQueryValue(${{paramName}});
} }
{{/queryParams}} {{/queryParams}}
{{#headerParams}} {{#headerParams}}
if(${{paramName}} != null) { if(${{paramName}} != null) {
$headerParams['{{paramName}}'] = $this->apiClient->toHeaderValue(${{paramName}}); $headerParams['{{paramName}}'] = $this->apiClient->toHeaderValue(${{paramName}});
} }
{{/headerParams}} {{/headerParams}}
{{#pathParams}} {{#pathParams}}
if(${{paramName}} != null) { if(${{paramName}} != null) {
$resourcePath = str_replace("{" . "{{paramName}}" . "}", $resourcePath = str_replace("{" . "{{paramName}}" . "}",
$this->apiClient->toPathValue(${{paramName}}), $resourcePath); $this->apiClient->toPathValue(${{paramName}}), $resourcePath);
} }
{{/pathParams}} {{/pathParams}}
//make the API Call // Generate form params
if (! isset($body)) { if (! isset($body)) {
$body = array();
}
{{#formParams}}
if(${{paramName}} != null) {
$body['{{paramName}}'] = ${{paramName}};
}
{{/formParams}}
if (empty($body)) {
$body = null; $body = null;
} }
$response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body, // Make the API Call
$headerParams); $response = $this->apiClient->callAPI($resourcePath, $method,
$queryParams, $body,
$headerParams);
{{#returnType}} {{#returnType}}
if(! $response){ if(! $response){
return null; return null;
} }
$responseObject = $this->apiClient->deserialize($response, $responseObject = $this->apiClient->deserialize($response,
'{{returnType}}'); '{{returnType}}');
return $responseObject; return $responseObject;
{{/returnType}} {{/returnType}}
} }