<?php

// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.

namespace Algolia\AlgoliaSearch\Configuration;

use Algolia\AlgoliaSearch\Exceptions\AlgoliaException;

class IngestionConfig extends ConfigWithRegion
{
    protected $clientName = 'Ingestion';

    private $defaultWaitTaskTimeBeforeRetry = 5000; // 5 sec in milliseconds

    public static function create($appId, $apiKey, $region = null)
    {
        $allowedRegions = ['eu', 'us'];

        if (
            null === $region
            || (null !== $region && !in_array($region, $allowedRegions, true))
        ) {
            throw new AlgoliaException(
                '`region` is required and must be one of the following: '
                    .implode(', ', $allowedRegions)
            );
        }

        return parent::create($appId, $apiKey, $region);
    }

    public function setWaitTaskTimeBeforeRetry($waitTaskTimeBeforeRetry)
    {
        $this->config['waitTaskTimeBeforeRetry'] = $waitTaskTimeBeforeRetry;

        return $this;
    }

    public function getWaitTaskTimeBeforeRetry()
    {
        return $this->config['waitTaskTimeBeforeRetry'];
    }

    public function getDefaultConfiguration()
    {
        return [
            'appId' => '',
            'apiKey' => '',
            'hosts' => null,
            'hasFullHosts' => false,
            'readTimeout' => 25,
            'writeTimeout' => 25,
            'connectTimeout' => 25,
            'defaultHeaders' => [],
            'waitTaskTimeBeforeRetry' => $this->defaultWaitTaskTimeBeforeRetry,
        ];
    }
}
