-
Notifications
You must be signed in to change notification settings - Fork 109
/
Copy pathapi.mustache
64 lines (59 loc) · 2.58 KB
/
api.mustache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
{{>partial_header}}
namespace {{apiPackage}};
use Adyen\AdyenException;
use Adyen\Client;
use Adyen\Service;
use {{modelPackage}}\ObjectSerializer;
{{#operations}}
class {{classname}} extends Service
{
/**
* @var array|string|string[]
*/
private $baseURL;
/**
* {{classname}} constructor.
*
* @param \Adyen\Client $client
* @throws AdyenException
*/
public function __construct(Client $client)
{
parent::__construct($client);
// Create the baseUrl based on live/test and optional live-url-prefix
$this->baseURL = $this->createBaseUrl("{{{basePath}}}");
}
{{#operation}}
/**
{{#summary}}
* {{.}}
{{/summary}}
*
{{#description}}
* Description: {{.}}
*
{{/description}}
{{#isDeprecated}}
* @deprecated {{^vendorExtensions.x-deprecatedInVersion}}{{/vendorExtensions.x-deprecatedInVersion}}{{#vendorExtensions.x-deprecatedInVersion}}since {{#appName}}{{{.}}}{{/appName}} v{{.}}. {{#vendorExtensions.x-deprecatedMessage}}"{{{.}}}"{{/vendorExtensions.x-deprecatedMessage}}
{{/vendorExtensions.x-deprecatedInVersion}}
{{/isDeprecated}}
{{#pathParams}}
* @param {{{dataType}}} ${{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}
{{/pathParams}}
{{#bodyParams}}
* @param {{{dataType}}} ${{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}
{{/bodyParams}}
* @param array|null $requestOptions{{#hasQueryParams}} ['queryParams' => [{{#queryParams}}'{{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}'=> {{{dataType}}}{{^-last}}, {{/-last}}{{/queryParams}}]]{{/hasQueryParams}}
{{#returnType}}* @return {{returnType}}{{/returnType}}
* @throws AdyenException
*/
public function {{#lambda.camelcase}}{{vendorExtensions.x-methodName}}{{/lambda.camelcase}}({{>api_parameters}}){{#returnType}}: {{{.}}}{{/returnType}}
{
$endpoint = $this->baseURL . {{#hasPathParams}}str_replace([{{#pathParams}}'{{>left_bracket}}{{baseName}}{{>right_bracket}}'{{^-last}}, {{/-last}}{{/pathParams}}], [{{#pathParams}}${{baseName}}{{^-last}}, {{/-last}}{{/pathParams}}], {{/hasPathParams}}"{{{path}}}"{{#hasPathParams}}){{/hasPathParams}};
{{#returnType}}$response = {{/returnType}}$this->requestHttp($endpoint, strtolower('{{httpMethod}}'), {{#bodyParam}}(array) ${{#lambda.camelcase}}{{paramName}}{{/lambda.camelcase}}->jsonSerialize(){{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}, $requestOptions);
{{#returnType}}return ObjectSerializer::deserialize($response, {{returnType}}::class);{{/returnType}}
}
{{/operation}}
}
{{/operations}}