|
22 | 22 | {{#operations}}
|
23 | 23 | class {{classname}} {
|
24 | 24 |
|
25 |
| - function __construct($apiClient) { |
26 |
| - $this->apiClient = $apiClient; |
27 |
| - } |
| 25 | + function __construct($apiClient) { |
| 26 | + $this->apiClient = $apiClient; |
| 27 | + } |
28 | 28 |
|
29 | 29 | {{#operation}}
|
30 | 30 | /**
|
31 | 31 | * {{nickname}}
|
32 | 32 | * {{summary}}
|
33 |
| - * |
34 | 33 | {{#allParams}}
|
35 | 34 | * @param {{dataType}} ${{paramName}} {{description}} ({{^optional}}required{{/optional}}{{#optional}}optional{{/optional}})
|
36 | 35 | {{/allParams}}
|
37 |
| - * @return {{returnType}} |
38 |
| - */ |
| 36 | + * @return {{returnType}} |
| 37 | + */ |
39 | 38 |
|
40 | 39 | public function {{nickname}}({{#allParams}}${{paramName}}{{#optional}}=null{{/optional}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
41 | 40 |
|
42 |
| - //parse inputs |
43 |
| - $resourcePath = "{{path}}"; |
44 |
| - $resourcePath = str_replace("{format}", "json", $resourcePath); |
45 |
| - $method = "{{httpMethod}}"; |
| 41 | + //parse inputs |
| 42 | + $resourcePath = "{{path}}"; |
| 43 | + $resourcePath = str_replace("{format}", "json", $resourcePath); |
| 44 | + $method = "{{httpMethod}}"; |
46 | 45 | $queryParams = array();
|
47 | 46 | $headerParams = array();
|
48 | 47 | $headerParams['Accept'] = '{{#produces}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/produces}}';
|
49 | 48 | $headerParams['Content-Type'] = '{{#consumes}}{{mediaType}}{{#hasMore}},{{/hasMore}}{{/consumes}}';
|
50 | 49 |
|
51 | 50 | {{#queryParams}}
|
52 |
| - if(${{paramName}} != null) { |
53 |
| - $queryParams['{{paramName}}'] = $this->apiClient->toQueryValue(${{paramName}}); |
54 |
| - } |
55 |
| - {{/queryParams}} |
| 51 | + if(${{paramName}} != null) { |
| 52 | + $queryParams['{{paramName}}'] = $this->apiClient->toQueryValue(${{paramName}}); |
| 53 | + } |
| 54 | + {{/queryParams}} |
56 | 55 |
|
57 | 56 | {{#headerParams}}
|
58 |
| - if(${{paramName}} != null) { |
59 |
| - $headerParams['{{paramName}}'] = $this->apiClient->toHeaderValue(${{paramName}}); |
60 |
| - } |
| 57 | + if(${{paramName}} != null) { |
| 58 | + $headerParams['{{paramName}}'] = $this->apiClient->toHeaderValue(${{paramName}}); |
| 59 | + } |
61 | 60 | {{/headerParams}}
|
62 | 61 |
|
63 | 62 | {{#pathParams}}
|
64 |
| - if(${{paramName}} != null) { |
65 |
| - $resourcePath = str_replace("{" . "{{paramName}}" . "}", |
66 |
| - $this->apiClient->toPathValue(${{paramName}}), $resourcePath); |
67 |
| - } |
68 |
| - {{/pathParams}} |
| 63 | + if(${{paramName}} != null) { |
| 64 | + $resourcePath = str_replace("{" . "{{paramName}}" . "}", |
| 65 | + $this->apiClient->toPathValue(${{paramName}}), $resourcePath); |
| 66 | + } |
| 67 | + {{/pathParams}} |
69 | 68 |
|
70 |
| - //make the API Call |
| 69 | + // Generate form params |
71 | 70 | if (! isset($body)) {
|
| 71 | + $body = array(); |
| 72 | + } |
| 73 | + {{#formParams}} |
| 74 | + if(${{paramName}} != null) { |
| 75 | + $body['{{paramName}}'] = ${{paramName}}; |
| 76 | + } |
| 77 | + {{/formParams}} |
| 78 | + if (empty($body)) { |
72 | 79 | $body = null;
|
73 | 80 | }
|
74 |
| - $response = $this->apiClient->callAPI($resourcePath, $method, |
75 |
| - $queryParams, $body, |
76 |
| - $headerParams); |
| 81 | + |
| 82 | + // Make the API Call |
| 83 | + $response = $this->apiClient->callAPI($resourcePath, $method, |
| 84 | + $queryParams, $body, |
| 85 | + $headerParams); |
77 | 86 |
|
78 | 87 |
|
79 | 88 | {{#returnType}}
|
80 | 89 |
|
81 | 90 | if(! $response){
|
82 | 91 | return null;
|
83 |
| - } |
| 92 | + } |
84 | 93 |
|
85 |
| - $responseObject = $this->apiClient->deserialize($response, |
86 |
| - '{{returnType}}'); |
87 |
| - return $responseObject; |
| 94 | + $responseObject = $this->apiClient->deserialize($response, |
| 95 | + '{{returnType}}'); |
| 96 | + return $responseObject; |
88 | 97 |
|
89 | 98 | {{/returnType}}
|
90 | 99 | }
|
|
0 commit comments