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