<?php
/**
 * Adyen Checkout API
 *
 * The version of the OpenAPI document: 71
 * 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\Checkout;

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

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

    /**
     * DonationsApi 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://checkout-test.adyen.com/v71");
    }

    /**
    * Get a list of donation campaigns.
    *
    * @param \Adyen\Model\Checkout\DonationCampaignsRequest $donationCampaignsRequest
    * @param array|null $requestOptions
    * @return \Adyen\Model\Checkout\DonationCampaignsResponse
    * @throws AdyenException
    */
    public function donationCampaigns(\Adyen\Model\Checkout\DonationCampaignsRequest $donationCampaignsRequest, ?array $requestOptions = null): \Adyen\Model\Checkout\DonationCampaignsResponse
    {
        $endpoint = $this->baseURL . "/donationCampaigns";
        $response = $this->requestHttp($endpoint, strtolower('POST'), (array) $donationCampaignsRequest->jsonSerialize(), $requestOptions);
        return ObjectSerializer::deserialize($response, \Adyen\Model\Checkout\DonationCampaignsResponse::class);
    }

    /**
    * Start a transaction for donations
    *
    * @param \Adyen\Model\Checkout\DonationPaymentRequest $donationPaymentRequest
    * @param array|null $requestOptions
    * @return \Adyen\Model\Checkout\DonationPaymentResponse
    * @throws AdyenException
    */
    public function donations(\Adyen\Model\Checkout\DonationPaymentRequest $donationPaymentRequest, ?array $requestOptions = null): \Adyen\Model\Checkout\DonationPaymentResponse
    {
        $endpoint = $this->baseURL . "/donations";
        $response = $this->requestHttp($endpoint, strtolower('POST'), (array) $donationPaymentRequest->jsonSerialize(), $requestOptions);
        return ObjectSerializer::deserialize($response, \Adyen\Model\Checkout\DonationPaymentResponse::class);
    }
}
