<?php
/**
 * Configuration API
 *
 * The version of the OpenAPI document: 2
 * Generated by: https://openapi-generator.tech
 * OpenAPI Generator version: 6.0.1
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

namespace Adyen\Service\BalancePlatform;

use Adyen\AdyenException;
use Adyen\Client;
use Adyen\Service;
use Adyen\Model\BalancePlatform\ObjectSerializer;

class TransferLimitsBalancePlatformLevelApi extends Service
{
    /**
     * @var array|string|string[]
     */
    private $baseURL;

    /**
     * TransferLimitsBalancePlatformLevelApi 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("https://balanceplatform-api-test.adyen.com/bcl/v2");
    }

    /**
    * Create a transfer limit
    *
    * @param string $id
    * @param \Adyen\Model\BalancePlatform\CreateTransferLimitRequest $createTransferLimitRequest
    * @param array|null $requestOptions
    * @return \Adyen\Model\BalancePlatform\TransferLimit
    * @throws AdyenException
    */
    public function createTransferLimit(string $id, \Adyen\Model\BalancePlatform\CreateTransferLimitRequest $createTransferLimitRequest, ?array $requestOptions = null): \Adyen\Model\BalancePlatform\TransferLimit
    {
        $endpoint = $this->baseURL . str_replace(['{id}'], [$id], "/balancePlatforms/{id}/transferLimits");
        $response = $this->requestHttp($endpoint, strtolower('POST'), (array) $createTransferLimitRequest->jsonSerialize(), $requestOptions);
        return ObjectSerializer::deserialize($response, \Adyen\Model\BalancePlatform\TransferLimit::class);
    }

    /**
    * Delete a scheduled or pending transfer limit
    *
    * @param string $id
    * @param string $transferLimitId
    * @param array|null $requestOptions

    * @throws AdyenException
    */
    public function deletePendingTransferLimit(string $id, string $transferLimitId, ?array $requestOptions = null)
    {
        $endpoint = $this->baseURL . str_replace(['{id}', '{transferLimitId}'], [$id, $transferLimitId], "/balancePlatforms/{id}/transferLimits/{transferLimitId}");
        $this->requestHttp($endpoint, strtolower('DELETE'), null, $requestOptions);
    }

    /**
    * Get the details of a transfer limit
    *
    * @param string $id
    * @param string $transferLimitId
    * @param array|null $requestOptions
    * @return \Adyen\Model\BalancePlatform\TransferLimit
    * @throws AdyenException
    */
    public function getSpecificTransferLimit(string $id, string $transferLimitId, ?array $requestOptions = null): \Adyen\Model\BalancePlatform\TransferLimit
    {
        $endpoint = $this->baseURL . str_replace(['{id}', '{transferLimitId}'], [$id, $transferLimitId], "/balancePlatforms/{id}/transferLimits/{transferLimitId}");
        $response = $this->requestHttp($endpoint, strtolower('GET'), null, $requestOptions);
        return ObjectSerializer::deserialize($response, \Adyen\Model\BalancePlatform\TransferLimit::class);
    }

    /**
    * Filter and view the transfer limits
    *
    * @param string $id
    * @param array|null $requestOptions ['queryParams' => ['scope'=> Scope, 'transferType'=> TransferType, 'status'=> LimitStatus]]
    * @return \Adyen\Model\BalancePlatform\TransferLimitListResponse
    * @throws AdyenException
    */
    public function getTransferLimits(string $id, ?array $requestOptions = null): \Adyen\Model\BalancePlatform\TransferLimitListResponse
    {
        $endpoint = $this->baseURL . str_replace(['{id}'], [$id], "/balancePlatforms/{id}/transferLimits");
        $response = $this->requestHttp($endpoint, strtolower('GET'), null, $requestOptions);
        return ObjectSerializer::deserialize($response, \Adyen\Model\BalancePlatform\TransferLimitListResponse::class);
    }
}
