<?php
/**
 * AlphaApi
 * PHP version 5
 *
 * @category Class
 * @package  HelixWebServices
 * @author   http://github.com/swagger-api/swagger-codegen
 * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
 * @link     https://github.com/swagger-api/swagger-codegen
 */
/**
 *  Copyright 2015 SmartBear Software
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

/**
 * 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 HelixWebServices\Api;

use \HelixWebServices\Configuration;
use \HelixWebServices\ApiClient;
use \HelixWebServices\ApiException;
use \HelixWebServices\ObjectSerializer;

/**
 * AlphaApi Class Doc Comment
 *
 * @category Class
 * @package  HelixWebServices
 * @author   http://github.com/swagger-api/swagger-codegen
 * @license  http://www.apache.org/licenses/LICENSE-2.0 Apache Licene v2
 * @link     https://github.com/swagger-api/swagger-codegen
 */
class AlphaApi
{

    /**
     * API Client
     * @var \HelixWebServices\ApiClient instance of the ApiClient
     */
    protected $apiClient;

    /**
     * Constructor
     * @param \HelixWebServices\ApiClient|null $apiClient The api client to use
     */
    function __construct($apiClient = null)
    {
        if ($apiClient == null) {
            $apiClient = new ApiClient();
            $apiClient->getConfig()->setHost('http://localhost/api');
        }

        $this->apiClient = $apiClient;
    }

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

    /**
     * Set the API client
     * @param \HelixWebServices\ApiClient $apiClient set the API client
     * @return AlphaApi
     */
    public function setApiClient(ApiClient $apiClient)
    {
        $this->apiClient = $apiClient;
        return $this;
    }

    
    /**
     * serverChangesPost
     *
     * 
     *
     * @param string $server The server ID that we execute this particular method against. (required)
     * @param \HelixWebServices\Model\ChangelistRequest $changelist_request Description of changes to make (required)
     * @return \HelixWebServices\Model\CommandResponse
     * @throws \HelixWebServices\ApiException on non-2xx response
     */
    public function serverChangesPost($server, $changelist_request)
    {
        list($response, $statusCode, $httpHeader) = $this->serverChangesPostWithHttpInfo ($server, $changelist_request);
        return $response;
    }


    /**
     * serverChangesPostWithHttpInfo
     *
     * 
     *
     * @param string $server The server ID that we execute this particular method against. (required)
     * @param \HelixWebServices\Model\ChangelistRequest $changelist_request Description of changes to make (required)
     * @return Array of \HelixWebServices\Model\CommandResponse, HTTP status code, HTTP response headers (array of strings)
     * @throws \HelixWebServices\ApiException on non-2xx response
     */
    public function serverChangesPostWithHttpInfo($server, $changelist_request)
    {
        
        // verify the required parameter 'server' is set
        if ($server === null) {
            throw new \InvalidArgumentException('Missing the required parameter $server when calling serverChangesPost');
        }
        // verify the required parameter 'changelist_request' is set
        if ($changelist_request === null) {
            throw new \InvalidArgumentException('Missing the required parameter $changelist_request when calling serverChangesPost');
        }

        // parse inputs
        $resourcePath = "/p4d/v16.1/{server}/changes";
        $resourcePath = str_replace("{format}", "json", $resourcePath);
        $method = "POST";
        $httpBody = '';
        $queryParams = array();
        $headerParams = array();
        $formParams = array();
        $_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
        if (!is_null($_header_accept)) {
            $headerParams['Accept'] = $_header_accept;
        }
        $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json'));

        
        
        // path params
        
        if ($server !== null) {
            $resourcePath = str_replace(
                "{" . "server" . "}",
                $this->apiClient->getSerializer()->toPathValue($server),
                $resourcePath
            );
        }
        
        // body params
        $_tempBody = null;
        if (isset($changelist_request)) {
            $_tempBody = $changelist_request;
        }

        // 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 API key authentication
        $apiKey = $this->apiClient->getApiKeyWithPrefix('Authorization');
        if (strlen($apiKey) !== 0) {
            $headerParams['Authorization'] = $apiKey;
        }
        
        
        // make the API Call
        try {
            list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
                $resourcePath, $method,
                $queryParams, $httpBody,
                $headerParams, '\HelixWebServices\Model\CommandResponse'
            );
            
            if (!$response) {
                return array(null, $statusCode, $httpHeader);
            }

            return array($this->apiClient->getSerializer()->deserialize($response, '\HelixWebServices\Model\CommandResponse', $httpHeader), $statusCode, $httpHeader);
            
        } catch (ApiException $e) {
            switch ($e->getCode()) { 
            case 200:
                $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\HelixWebServices\Model\CommandResponse', $e->getResponseHeaders());
                $e->setResponseObject($data);
                break;
            }

            throw $e;
        }
    }
    
    /**
     * serverGitFusionReposGet
     *
     * 
     *
     * @param string $server The server ID that we execute this particular method against. (required)
     * @return \HelixWebServices\Model\GitFusionRepoId[]
     * @throws \HelixWebServices\ApiException on non-2xx response
     */
    public function serverGitFusionReposGet($server)
    {
        list($response, $statusCode, $httpHeader) = $this->serverGitFusionReposGetWithHttpInfo ($server);
        return $response;
    }


    /**
     * serverGitFusionReposGetWithHttpInfo
     *
     * 
     *
     * @param string $server The server ID that we execute this particular method against. (required)
     * @return Array of \HelixWebServices\Model\GitFusionRepoId[], HTTP status code, HTTP response headers (array of strings)
     * @throws \HelixWebServices\ApiException on non-2xx response
     */
    public function serverGitFusionReposGetWithHttpInfo($server)
    {
        
        // verify the required parameter 'server' is set
        if ($server === null) {
            throw new \InvalidArgumentException('Missing the required parameter $server when calling serverGitFusionReposGet');
        }

        // parse inputs
        $resourcePath = "/p4d/v16.1/{server}/git-fusion-repos";
        $resourcePath = str_replace("{format}", "json", $resourcePath);
        $method = "GET";
        $httpBody = '';
        $queryParams = array();
        $headerParams = array();
        $formParams = array();
        $_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
        if (!is_null($_header_accept)) {
            $headerParams['Accept'] = $_header_accept;
        }
        $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json'));

        
        
        // path params
        
        if ($server !== null) {
            $resourcePath = str_replace(
                "{" . "server" . "}",
                $this->apiClient->getSerializer()->toPathValue($server),
                $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 API key authentication
        $apiKey = $this->apiClient->getApiKeyWithPrefix('Authorization');
        if (strlen($apiKey) !== 0) {
            $headerParams['Authorization'] = $apiKey;
        }
        
        
        // make the API Call
        try {
            list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
                $resourcePath, $method,
                $queryParams, $httpBody,
                $headerParams, '\HelixWebServices\Model\GitFusionRepoId[]'
            );
            
            if (!$response) {
                return array(null, $statusCode, $httpHeader);
            }

            return array($this->apiClient->getSerializer()->deserialize($response, '\HelixWebServices\Model\GitFusionRepoId[]', $httpHeader), $statusCode, $httpHeader);
            
        } catch (ApiException $e) {
            switch ($e->getCode()) { 
            case 200:
                $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\HelixWebServices\Model\GitFusionRepoId[]', $e->getResponseHeaders());
                $e->setResponseObject($data);
                break;
            }

            throw $e;
        }
    }
    
    /**
     * serverGitFusionReposPost
     *
     * 
     *
     * @param string $server The server ID that we execute this particular method against. (required)
     * @param \HelixWebServices\Model\GitFusionRepoConfig $body The new configuration (required)
     * @return \HelixWebServices\Model\CommandResponse
     * @throws \HelixWebServices\ApiException on non-2xx response
     */
    public function serverGitFusionReposPost($server, $body)
    {
        list($response, $statusCode, $httpHeader) = $this->serverGitFusionReposPostWithHttpInfo ($server, $body);
        return $response;
    }


    /**
     * serverGitFusionReposPostWithHttpInfo
     *
     * 
     *
     * @param string $server The server ID that we execute this particular method against. (required)
     * @param \HelixWebServices\Model\GitFusionRepoConfig $body The new configuration (required)
     * @return Array of \HelixWebServices\Model\CommandResponse, HTTP status code, HTTP response headers (array of strings)
     * @throws \HelixWebServices\ApiException on non-2xx response
     */
    public function serverGitFusionReposPostWithHttpInfo($server, $body)
    {
        
        // verify the required parameter 'server' is set
        if ($server === null) {
            throw new \InvalidArgumentException('Missing the required parameter $server when calling serverGitFusionReposPost');
        }
        // verify the required parameter 'body' is set
        if ($body === null) {
            throw new \InvalidArgumentException('Missing the required parameter $body when calling serverGitFusionReposPost');
        }

        // parse inputs
        $resourcePath = "/p4d/v16.1/{server}/git-fusion-repos";
        $resourcePath = str_replace("{format}", "json", $resourcePath);
        $method = "POST";
        $httpBody = '';
        $queryParams = array();
        $headerParams = array();
        $formParams = array();
        $_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
        if (!is_null($_header_accept)) {
            $headerParams['Accept'] = $_header_accept;
        }
        $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json'));

        
        
        // path params
        
        if ($server !== null) {
            $resourcePath = str_replace(
                "{" . "server" . "}",
                $this->apiClient->getSerializer()->toPathValue($server),
                $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 API key authentication
        $apiKey = $this->apiClient->getApiKeyWithPrefix('Authorization');
        if (strlen($apiKey) !== 0) {
            $headerParams['Authorization'] = $apiKey;
        }
        
        
        // make the API Call
        try {
            list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
                $resourcePath, $method,
                $queryParams, $httpBody,
                $headerParams, '\HelixWebServices\Model\CommandResponse'
            );
            
            if (!$response) {
                return array(null, $statusCode, $httpHeader);
            }

            return array($this->apiClient->getSerializer()->deserialize($response, '\HelixWebServices\Model\CommandResponse', $httpHeader), $statusCode, $httpHeader);
            
        } catch (ApiException $e) {
            switch ($e->getCode()) { 
            case 200:
                $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\HelixWebServices\Model\CommandResponse', $e->getResponseHeaders());
                $e->setResponseObject($data);
                break;
            }

            throw $e;
        }
    }
    
    /**
     * serverGitFusionReposRepoGet
     *
     * 
     *
     * @param string $server The server ID that we execute this particular method against. (required)
     * @param string $repo The Git Fusion Repo ID (required)
     * @return \HelixWebServices\Model\GitFusionRepoConfig
     * @throws \HelixWebServices\ApiException on non-2xx response
     */
    public function serverGitFusionReposRepoGet($server, $repo)
    {
        list($response, $statusCode, $httpHeader) = $this->serverGitFusionReposRepoGetWithHttpInfo ($server, $repo);
        return $response;
    }


    /**
     * serverGitFusionReposRepoGetWithHttpInfo
     *
     * 
     *
     * @param string $server The server ID that we execute this particular method against. (required)
     * @param string $repo The Git Fusion Repo ID (required)
     * @return Array of \HelixWebServices\Model\GitFusionRepoConfig, HTTP status code, HTTP response headers (array of strings)
     * @throws \HelixWebServices\ApiException on non-2xx response
     */
    public function serverGitFusionReposRepoGetWithHttpInfo($server, $repo)
    {
        
        // verify the required parameter 'server' is set
        if ($server === null) {
            throw new \InvalidArgumentException('Missing the required parameter $server when calling serverGitFusionReposRepoGet');
        }
        // verify the required parameter 'repo' is set
        if ($repo === null) {
            throw new \InvalidArgumentException('Missing the required parameter $repo when calling serverGitFusionReposRepoGet');
        }

        // parse inputs
        $resourcePath = "/p4d/v16.1/{server}/git-fusion-repos/{repo}";
        $resourcePath = str_replace("{format}", "json", $resourcePath);
        $method = "GET";
        $httpBody = '';
        $queryParams = array();
        $headerParams = array();
        $formParams = array();
        $_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
        if (!is_null($_header_accept)) {
            $headerParams['Accept'] = $_header_accept;
        }
        $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json'));

        
        
        // path params
        
        if ($server !== null) {
            $resourcePath = str_replace(
                "{" . "server" . "}",
                $this->apiClient->getSerializer()->toPathValue($server),
                $resourcePath
            );
        }// path params
        
        if ($repo !== null) {
            $resourcePath = str_replace(
                "{" . "repo" . "}",
                $this->apiClient->getSerializer()->toPathValue($repo),
                $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 API key authentication
        $apiKey = $this->apiClient->getApiKeyWithPrefix('Authorization');
        if (strlen($apiKey) !== 0) {
            $headerParams['Authorization'] = $apiKey;
        }
        
        
        // make the API Call
        try {
            list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
                $resourcePath, $method,
                $queryParams, $httpBody,
                $headerParams, '\HelixWebServices\Model\GitFusionRepoConfig'
            );
            
            if (!$response) {
                return array(null, $statusCode, $httpHeader);
            }

            return array($this->apiClient->getSerializer()->deserialize($response, '\HelixWebServices\Model\GitFusionRepoConfig', $httpHeader), $statusCode, $httpHeader);
            
        } catch (ApiException $e) {
            switch ($e->getCode()) { 
            case 200:
                $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\HelixWebServices\Model\GitFusionRepoConfig', $e->getResponseHeaders());
                $e->setResponseObject($data);
                break;
            }

            throw $e;
        }
    }
    
    /**
     * serverGitFusionReposRepoDelete
     *
     * 
     *
     * @param string $server The server ID that we execute this particular method against. (required)
     * @param string $repo The Git Fusion Repo ID (required)
     * @return \HelixWebServices\Model\CommandResponse
     * @throws \HelixWebServices\ApiException on non-2xx response
     */
    public function serverGitFusionReposRepoDelete($server, $repo)
    {
        list($response, $statusCode, $httpHeader) = $this->serverGitFusionReposRepoDeleteWithHttpInfo ($server, $repo);
        return $response;
    }


    /**
     * serverGitFusionReposRepoDeleteWithHttpInfo
     *
     * 
     *
     * @param string $server The server ID that we execute this particular method against. (required)
     * @param string $repo The Git Fusion Repo ID (required)
     * @return Array of \HelixWebServices\Model\CommandResponse, HTTP status code, HTTP response headers (array of strings)
     * @throws \HelixWebServices\ApiException on non-2xx response
     */
    public function serverGitFusionReposRepoDeleteWithHttpInfo($server, $repo)
    {
        
        // verify the required parameter 'server' is set
        if ($server === null) {
            throw new \InvalidArgumentException('Missing the required parameter $server when calling serverGitFusionReposRepoDelete');
        }
        // verify the required parameter 'repo' is set
        if ($repo === null) {
            throw new \InvalidArgumentException('Missing the required parameter $repo when calling serverGitFusionReposRepoDelete');
        }

        // parse inputs
        $resourcePath = "/p4d/v16.1/{server}/git-fusion-repos/{repo}";
        $resourcePath = str_replace("{format}", "json", $resourcePath);
        $method = "DELETE";
        $httpBody = '';
        $queryParams = array();
        $headerParams = array();
        $formParams = array();
        $_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
        if (!is_null($_header_accept)) {
            $headerParams['Accept'] = $_header_accept;
        }
        $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json'));

        
        
        // path params
        
        if ($server !== null) {
            $resourcePath = str_replace(
                "{" . "server" . "}",
                $this->apiClient->getSerializer()->toPathValue($server),
                $resourcePath
            );
        }// path params
        
        if ($repo !== null) {
            $resourcePath = str_replace(
                "{" . "repo" . "}",
                $this->apiClient->getSerializer()->toPathValue($repo),
                $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 API key authentication
        $apiKey = $this->apiClient->getApiKeyWithPrefix('Authorization');
        if (strlen($apiKey) !== 0) {
            $headerParams['Authorization'] = $apiKey;
        }
        
        
        // make the API Call
        try {
            list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
                $resourcePath, $method,
                $queryParams, $httpBody,
                $headerParams, '\HelixWebServices\Model\CommandResponse'
            );
            
            if (!$response) {
                return array(null, $statusCode, $httpHeader);
            }

            return array($this->apiClient->getSerializer()->deserialize($response, '\HelixWebServices\Model\CommandResponse', $httpHeader), $statusCode, $httpHeader);
            
        } catch (ApiException $e) {
            switch ($e->getCode()) { 
            case 200:
                $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\HelixWebServices\Model\CommandResponse', $e->getResponseHeaders());
                $e->setResponseObject($data);
                break;
            }

            throw $e;
        }
    }
    
    /**
     * serverGitFusionReposRepoPatch
     *
     * 
     *
     * @param string $server The server ID that we execute this particular method against. (required)
     * @param string $repo The Git Fusion Repo ID (required)
     * @param \HelixWebServices\Model\GitFusionRepoConfig $body The new configuration (required)
     * @return \HelixWebServices\Model\CommandResponse
     * @throws \HelixWebServices\ApiException on non-2xx response
     */
    public function serverGitFusionReposRepoPatch($server, $repo, $body)
    {
        list($response, $statusCode, $httpHeader) = $this->serverGitFusionReposRepoPatchWithHttpInfo ($server, $repo, $body);
        return $response;
    }


    /**
     * serverGitFusionReposRepoPatchWithHttpInfo
     *
     * 
     *
     * @param string $server The server ID that we execute this particular method against. (required)
     * @param string $repo The Git Fusion Repo ID (required)
     * @param \HelixWebServices\Model\GitFusionRepoConfig $body The new configuration (required)
     * @return Array of \HelixWebServices\Model\CommandResponse, HTTP status code, HTTP response headers (array of strings)
     * @throws \HelixWebServices\ApiException on non-2xx response
     */
    public function serverGitFusionReposRepoPatchWithHttpInfo($server, $repo, $body)
    {
        
        // verify the required parameter 'server' is set
        if ($server === null) {
            throw new \InvalidArgumentException('Missing the required parameter $server when calling serverGitFusionReposRepoPatch');
        }
        // verify the required parameter 'repo' is set
        if ($repo === null) {
            throw new \InvalidArgumentException('Missing the required parameter $repo when calling serverGitFusionReposRepoPatch');
        }
        // verify the required parameter 'body' is set
        if ($body === null) {
            throw new \InvalidArgumentException('Missing the required parameter $body when calling serverGitFusionReposRepoPatch');
        }

        // parse inputs
        $resourcePath = "/p4d/v16.1/{server}/git-fusion-repos/{repo}";
        $resourcePath = str_replace("{format}", "json", $resourcePath);
        $method = "PATCH";
        $httpBody = '';
        $queryParams = array();
        $headerParams = array();
        $formParams = array();
        $_header_accept = ApiClient::selectHeaderAccept(array('application/json'));
        if (!is_null($_header_accept)) {
            $headerParams['Accept'] = $_header_accept;
        }
        $headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json'));

        
        
        // path params
        
        if ($server !== null) {
            $resourcePath = str_replace(
                "{" . "server" . "}",
                $this->apiClient->getSerializer()->toPathValue($server),
                $resourcePath
            );
        }// path params
        
        if ($repo !== null) {
            $resourcePath = str_replace(
                "{" . "repo" . "}",
                $this->apiClient->getSerializer()->toPathValue($repo),
                $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 API key authentication
        $apiKey = $this->apiClient->getApiKeyWithPrefix('Authorization');
        if (strlen($apiKey) !== 0) {
            $headerParams['Authorization'] = $apiKey;
        }
        
        
        // make the API Call
        try {
            list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
                $resourcePath, $method,
                $queryParams, $httpBody,
                $headerParams, '\HelixWebServices\Model\CommandResponse'
            );
            
            if (!$response) {
                return array(null, $statusCode, $httpHeader);
            }

            return array($this->apiClient->getSerializer()->deserialize($response, '\HelixWebServices\Model\CommandResponse', $httpHeader), $statusCode, $httpHeader);
            
        } catch (ApiException $e) {
            switch ($e->getCode()) { 
            case 200:
                $data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\HelixWebServices\Model\CommandResponse', $e->getResponseHeaders());
                $e->setResponseObject($data);
                break;
            }

            throw $e;
        }
    }
    
}