<?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}}