<?php
/**
 * FacilityApi
 * PHP version 5
 *
 * @category Class
 * @package  Fifa\ConnectId\Sdk\Api
 * @author   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */

/**
 * FIFA Connect ID - ID Directory V6
 *
 * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
 *
 * OpenAPI spec version: v6
 * 
 * Generated by: https://github.com/swagger-api/swagger-codegen.git
 *
 */

/**
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen
 * Do not edit the class manually.
 */

namespace Fifa\ConnectId\Sdk\Api\Resource;

use \Fifa\ConnectId\Sdk\Api\ApiClient;
use \Fifa\ConnectId\Sdk\Api\ApiException;
use \Fifa\ConnectId\Sdk\Api\Configuration;
use \Fifa\ConnectId\Sdk\Api\ObjectSerializer;

/**
 * FacilityApi Class Doc Comment
 *
 * @category Class
 * @package  Fifa\ConnectId\Sdk\Api
 * @author   Swagger Codegen team
 * @link     https://github.com/swagger-api/swagger-codegen
 */
class FacilityApi
{
    /**
     * API Client
     *
     * @var \Fifa\ConnectId\Sdk\Api\ApiClient instance of the ApiClient
     */
    protected $apiClient;

    /**
     * Constructor
     *
     * @param \Fifa\ConnectId\Sdk\Api\ApiClient|null $apiClient The api client to use
     */
    public function __construct(\Fifa\ConnectId\Sdk\Api\ApiClient $apiClient = null)
    {
        if ($apiClient === null) {
            $apiClient = new ApiClient();
        }

        $this->apiClient = $apiClient;
    }

    /**
     * Get API client
     *
     * @return \Fifa\ConnectId\Sdk\Api\ApiClient get the API client
     */
    public function getApiClient()
    {
        return $this->apiClient;
    }

    /**
     * Set the API client
     *
     * @param \Fifa\ConnectId\Sdk\Api\ApiClient $apiClient set the API client
     *
     * @return FacilityApi
     */
    public function setApiClient(\Fifa\ConnectId\Sdk\Api\ApiClient $apiClient)
    {
        $this->apiClient = $apiClient;
        return $this;
    }

    /**
     * Operation facilityFind
     *
     * Finds facilities matching provided data
     *
     * @param \Fifa\ConnectId\Sdk\Api\Model\FindFacilitiesRequestType $body Request object (required)
     * @param string $x_actor_details Name or identifier of a user invoking the method on API (optional)
     * @throws \Fifa\ConnectId\Sdk\Api\ApiException on non-2xx response
     * @return \Fifa\ConnectId\Sdk\Api\Model\FindFacilitiesResponseType
     */
    public function facilityFind($body, $x_actor_details = null)
    {
        list($response) = $this->facilityFindWithHttpInfo($body, $x_actor_details);
        return $response;
    }

    /**
     * Operation facilityFindWithHttpInfo
     *
     * Finds facilities matching provided data
     *
     * @param \Fifa\ConnectId\Sdk\Api\Model\FindFacilitiesRequestType $body Request object (required)
     * @param string $x_actor_details Name or identifier of a user invoking the method on API (optional)
     * @throws \Fifa\ConnectId\Sdk\Api\ApiException on non-2xx response
     * @return array of \Fifa\ConnectId\Sdk\Api\Model\FindFacilitiesResponseType, HTTP status code, HTTP response headers (array of strings)
     */
    public function facilityFindWithHttpInfo($body, $x_actor_details = null)
    {
        // verify the required parameter 'body' is set
        if ($body === null) {
            throw new \InvalidArgumentException('Missing the required parameter $body when calling facilityFind');
        }
        // parse inputs
        $resourcePath = "/api/v6/facility/find";
        $httpBody = '';
        $queryParams = [];
        $headerParams = [];
        $formParams = [];
        $_header_accept = $this->apiClient->selectHeaderAccept(['application/json', 'text/json']);
        if (!is_null($_header_accept)) {
            $headerParams['Accept'] = $_header_accept;
        }
        $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json', 'text/json', 'application/_*+json']);

        // header params
        if ($x_actor_details !== null) {
            $headerParams['X-ActorDetails'] = $this->apiClient->getSerializer()->toHeaderValue($x_actor_details);
        }
        // default format to json
        $resourcePath = str_replace("{format}", "json", $resourcePath);

        // body params
        $_tempBody = null;
        if (isset($body)) {
            $_tempBody = $body;
        }

        // for model (json/xml)
        if (isset($_tempBody)) {
            $httpBody = $_tempBody; // $_tempBody is the method argument, if present
        } elseif (count($formParams) > 0) {
            $httpBody = $formParams; // for HTTP post (form)
        }
        // this endpoint requires OAuth (access token)
        if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
            $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
        }
        // make the API Call
        try {
            list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
                $resourcePath,
                'POST',
                $queryParams,
                $httpBody,
                $headerParams,
                '\Fifa\ConnectId\Sdk\Api\Model\FindFacilitiesResponseType',
                '/api/v6/facility/find'
            );

            return [$this->apiClient->getSerializer()->deserialize($response, '\Fifa\ConnectId\Sdk\Api\Model\FindFacilitiesResponseType', $httpHeader), $statusCode, $httpHeader];
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\FindFacilitiesResponseType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\BadRequestResponseType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\TooManyRequestsResponseType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
            }

            throw $e;
        }
    }

    /**
     * Operation facilityGetByFacilityfifaid
     *
     * Gets facility data associated with the specified FIFA Unique Identifier.
     *
     * @param string $facility_fifa_id FIFA Unique Identifier (required)
     * @throws \Fifa\ConnectId\Sdk\Api\ApiException on non-2xx response
     * @return \Fifa\ConnectId\Sdk\Api\Model\FacilityLocalType
     */
    public function facilityGetByFacilityfifaid($facility_fifa_id)
    {
        list($response) = $this->facilityGetByFacilityfifaidWithHttpInfo($facility_fifa_id);
        return $response;
    }

    /**
     * Operation facilityGetByFacilityfifaidWithHttpInfo
     *
     * Gets facility data associated with the specified FIFA Unique Identifier.
     *
     * @param string $facility_fifa_id FIFA Unique Identifier (required)
     * @throws \Fifa\ConnectId\Sdk\Api\ApiException on non-2xx response
     * @return array of \Fifa\ConnectId\Sdk\Api\Model\FacilityLocalType, HTTP status code, HTTP response headers (array of strings)
     */
    public function facilityGetByFacilityfifaidWithHttpInfo($facility_fifa_id)
    {
        // verify the required parameter 'facility_fifa_id' is set
        if ($facility_fifa_id === null) {
            throw new \InvalidArgumentException('Missing the required parameter $facility_fifa_id when calling facilityGetByFacilityfifaid');
        }
        // parse inputs
        $resourcePath = "/api/v6/facility/get";
        $httpBody = '';
        $queryParams = [];
        $headerParams = [];
        $formParams = [];
        $_header_accept = $this->apiClient->selectHeaderAccept(['application/json', 'text/json']);
        if (!is_null($_header_accept)) {
            $headerParams['Accept'] = $_header_accept;
        }
        $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType([]);

        // query params
        if ($facility_fifa_id !== null) {
            $queryParams['facilityFifaId'] = $this->apiClient->getSerializer()->toQueryValue($facility_fifa_id);
        }
        // default format to json
        $resourcePath = str_replace("{format}", "json", $resourcePath);

        // for model (json/xml)
        if (isset($_tempBody)) {
            $httpBody = $_tempBody; // $_tempBody is the method argument, if present
        } elseif (count($formParams) > 0) {
            $httpBody = $formParams; // for HTTP post (form)
        }
        // this endpoint requires OAuth (access token)
        if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
            $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
        }
        // make the API Call
        try {
            list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
                $resourcePath,
                'GET',
                $queryParams,
                $httpBody,
                $headerParams,
                '\Fifa\ConnectId\Sdk\Api\Model\FacilityLocalType',
                '/api/v6/facility/get'
            );

            return [$this->apiClient->getSerializer()->deserialize($response, '\Fifa\ConnectId\Sdk\Api\Model\FacilityLocalType', $httpHeader), $statusCode, $httpHeader];
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\FacilityLocalType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\BadRequestResponseType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\TooManyRequestsResponseType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
            }

            throw $e;
        }
    }

    /**
     * Operation facilityGetDuplicates
     *
     * Gets a list of facilities this facility may be duplicated with.
     *
     * @param \Fifa\ConnectId\Sdk\Api\Model\FacilityLocalType $body Facility data (required)
     * @param string $x_actor_details Name or identifier of a user invoking the method on API (optional)
     * @throws \Fifa\ConnectId\Sdk\Api\ApiException on non-2xx response
     * @return \Fifa\ConnectId\Sdk\Api\Model\GetFacilityDuplicatesResponseType
     */
    public function facilityGetDuplicates($body, $x_actor_details = null)
    {
        list($response) = $this->facilityGetDuplicatesWithHttpInfo($body, $x_actor_details);
        return $response;
    }

    /**
     * Operation facilityGetDuplicatesWithHttpInfo
     *
     * Gets a list of facilities this facility may be duplicated with.
     *
     * @param \Fifa\ConnectId\Sdk\Api\Model\FacilityLocalType $body Facility data (required)
     * @param string $x_actor_details Name or identifier of a user invoking the method on API (optional)
     * @throws \Fifa\ConnectId\Sdk\Api\ApiException on non-2xx response
     * @return array of \Fifa\ConnectId\Sdk\Api\Model\GetFacilityDuplicatesResponseType, HTTP status code, HTTP response headers (array of strings)
     */
    public function facilityGetDuplicatesWithHttpInfo($body, $x_actor_details = null)
    {
        // verify the required parameter 'body' is set
        if ($body === null) {
            throw new \InvalidArgumentException('Missing the required parameter $body when calling facilityGetDuplicates');
        }
        // parse inputs
        $resourcePath = "/api/v6/facility/getduplicates";
        $httpBody = '';
        $queryParams = [];
        $headerParams = [];
        $formParams = [];
        $_header_accept = $this->apiClient->selectHeaderAccept(['application/json', 'text/json']);
        if (!is_null($_header_accept)) {
            $headerParams['Accept'] = $_header_accept;
        }
        $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json', 'text/json', 'application/_*+json']);

        // header params
        if ($x_actor_details !== null) {
            $headerParams['X-ActorDetails'] = $this->apiClient->getSerializer()->toHeaderValue($x_actor_details);
        }
        // default format to json
        $resourcePath = str_replace("{format}", "json", $resourcePath);

        // body params
        $_tempBody = null;
        if (isset($body)) {
            $_tempBody = $body;
        }

        // for model (json/xml)
        if (isset($_tempBody)) {
            $httpBody = $_tempBody; // $_tempBody is the method argument, if present
        } elseif (count($formParams) > 0) {
            $httpBody = $formParams; // for HTTP post (form)
        }
        // this endpoint requires OAuth (access token)
        if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
            $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
        }
        // make the API Call
        try {
            list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
                $resourcePath,
                'POST',
                $queryParams,
                $httpBody,
                $headerParams,
                '\Fifa\ConnectId\Sdk\Api\Model\GetFacilityDuplicatesResponseType',
                '/api/v6/facility/getduplicates'
            );

            return [$this->apiClient->getSerializer()->deserialize($response, '\Fifa\ConnectId\Sdk\Api\Model\GetFacilityDuplicatesResponseType', $httpHeader), $statusCode, $httpHeader];
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\GetFacilityDuplicatesResponseType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\BadRequestResponseType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\TooManyRequestsResponseType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
            }

            throw $e;
        }
    }

    /**
     * Operation facilityRegisterByForce
     *
     * Registers a new facility and assigns FIFA Unique Identifier.
     *
     * @param \Fifa\ConnectId\Sdk\Api\Model\FacilityLocalType $body Facility data. (required)
     * @param bool $force Ignores FIFA registration rules violation check (optional, default to false)
     * @param string $x_actor_details Name or identifier of a user invoking the method on API (optional)
     * @throws \Fifa\ConnectId\Sdk\Api\ApiException on non-2xx response
     * @return \Fifa\ConnectId\Sdk\Api\Model\RegisterResponseType
     */
    public function facilityRegisterByForce($body, $force = null, $x_actor_details = null)
    {
        list($response) = $this->facilityRegisterByForceWithHttpInfo($body, $force, $x_actor_details);
        return $response;
    }

    /**
     * Operation facilityRegisterByForceWithHttpInfo
     *
     * Registers a new facility and assigns FIFA Unique Identifier.
     *
     * @param \Fifa\ConnectId\Sdk\Api\Model\FacilityLocalType $body Facility data. (required)
     * @param bool $force Ignores FIFA registration rules violation check (optional, default to false)
     * @param string $x_actor_details Name or identifier of a user invoking the method on API (optional)
     * @throws \Fifa\ConnectId\Sdk\Api\ApiException on non-2xx response
     * @return array of \Fifa\ConnectId\Sdk\Api\Model\RegisterResponseType, HTTP status code, HTTP response headers (array of strings)
     */
    public function facilityRegisterByForceWithHttpInfo($body, $force = null, $x_actor_details = null)
    {
        // verify the required parameter 'body' is set
        if ($body === null) {
            throw new \InvalidArgumentException('Missing the required parameter $body when calling facilityRegisterByForce');
        }
        // parse inputs
        $resourcePath = "/api/v6/facility/register";
        $httpBody = '';
        $queryParams = [];
        $headerParams = [];
        $formParams = [];
        $_header_accept = $this->apiClient->selectHeaderAccept(['application/json', 'text/json']);
        if (!is_null($_header_accept)) {
            $headerParams['Accept'] = $_header_accept;
        }
        $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json', 'text/json', 'application/_*+json']);

        // query params
        if ($force !== null) {
            $queryParams['force'] = $this->apiClient->getSerializer()->toQueryValue($force);
        }
        // header params
        if ($x_actor_details !== null) {
            $headerParams['X-ActorDetails'] = $this->apiClient->getSerializer()->toHeaderValue($x_actor_details);
        }
        // default format to json
        $resourcePath = str_replace("{format}", "json", $resourcePath);

        // body params
        $_tempBody = null;
        if (isset($body)) {
            $_tempBody = $body;
        }

        // for model (json/xml)
        if (isset($_tempBody)) {
            $httpBody = $_tempBody; // $_tempBody is the method argument, if present
        } elseif (count($formParams) > 0) {
            $httpBody = $formParams; // for HTTP post (form)
        }
        // this endpoint requires OAuth (access token)
        if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
            $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
        }
        // make the API Call
        try {
            list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
                $resourcePath,
                'POST',
                $queryParams,
                $httpBody,
                $headerParams,
                '\Fifa\ConnectId\Sdk\Api\Model\RegisterResponseType',
                '/api/v6/facility/register'
            );

            return [$this->apiClient->getSerializer()->deserialize($response, '\Fifa\ConnectId\Sdk\Api\Model\RegisterResponseType', $httpHeader), $statusCode, $httpHeader];
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 201:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\RegisterResponseType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\BadRequestResponseType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
                case 409:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\GetFacilityDuplicatesResponseType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\TooManyRequestsResponseType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
            }

            throw $e;
        }
    }

    /**
     * Operation facilityUpdateByForce
     *
     * Updates facility data.
     *
     * @param \Fifa\ConnectId\Sdk\Api\Model\FacilityLocalType $body Facility data to be updated. (required)
     * @param bool $force Ignores FIFA registration rules violation check (optional, default to false)
     * @param string $x_actor_details Name or identifier of a user invoking the method on API (optional)
     * @throws \Fifa\ConnectId\Sdk\Api\ApiException on non-2xx response
     * @return \Fifa\ConnectId\Sdk\Api\Model\FacilityLocalType
     */
    public function facilityUpdateByForce($body, $force = null, $x_actor_details = null)
    {
        list($response) = $this->facilityUpdateByForceWithHttpInfo($body, $force, $x_actor_details);
        return $response;
    }

    /**
     * Operation facilityUpdateByForceWithHttpInfo
     *
     * Updates facility data.
     *
     * @param \Fifa\ConnectId\Sdk\Api\Model\FacilityLocalType $body Facility data to be updated. (required)
     * @param bool $force Ignores FIFA registration rules violation check (optional, default to false)
     * @param string $x_actor_details Name or identifier of a user invoking the method on API (optional)
     * @throws \Fifa\ConnectId\Sdk\Api\ApiException on non-2xx response
     * @return array of \Fifa\ConnectId\Sdk\Api\Model\FacilityLocalType, HTTP status code, HTTP response headers (array of strings)
     */
    public function facilityUpdateByForceWithHttpInfo($body, $force = null, $x_actor_details = null)
    {
        // verify the required parameter 'body' is set
        if ($body === null) {
            throw new \InvalidArgumentException('Missing the required parameter $body when calling facilityUpdateByForce');
        }
        // parse inputs
        $resourcePath = "/api/v6/facility/update";
        $httpBody = '';
        $queryParams = [];
        $headerParams = [];
        $formParams = [];
        $_header_accept = $this->apiClient->selectHeaderAccept(['application/json', 'text/json']);
        if (!is_null($_header_accept)) {
            $headerParams['Accept'] = $_header_accept;
        }
        $headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(['application/json', 'text/json', 'application/_*+json']);

        // query params
        if ($force !== null) {
            $queryParams['force'] = $this->apiClient->getSerializer()->toQueryValue($force);
        }
        // header params
        if ($x_actor_details !== null) {
            $headerParams['X-ActorDetails'] = $this->apiClient->getSerializer()->toHeaderValue($x_actor_details);
        }
        // default format to json
        $resourcePath = str_replace("{format}", "json", $resourcePath);

        // body params
        $_tempBody = null;
        if (isset($body)) {
            $_tempBody = $body;
        }

        // for model (json/xml)
        if (isset($_tempBody)) {
            $httpBody = $_tempBody; // $_tempBody is the method argument, if present
        } elseif (count($formParams) > 0) {
            $httpBody = $formParams; // for HTTP post (form)
        }
        // this endpoint requires OAuth (access token)
        if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
            $headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
        }
        // make the API Call
        try {
            list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
                $resourcePath,
                'POST',
                $queryParams,
                $httpBody,
                $headerParams,
                '\Fifa\ConnectId\Sdk\Api\Model\FacilityLocalType',
                '/api/v6/facility/update'
            );

            return [$this->apiClient->getSerializer()->deserialize($response, '\Fifa\ConnectId\Sdk\Api\Model\FacilityLocalType', $httpHeader), $statusCode, $httpHeader];
        } catch (ApiException $e) {
            switch ($e->getCode()) {
                case 200:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\FacilityLocalType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
                case 400:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\BadRequestResponseType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
                case 409:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\GetFacilityDuplicatesResponseType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
                case 429:
                    $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Fifa\ConnectId\Sdk\Api\Model\TooManyRequestsResponseType', $e->getResponseHeaders());
                    $e->setResponseObject($data);
                    break;
            }

            throw $e;
        }
    }
}

