feat: added async module

This commit is contained in:
Bruno F. Fontes 2022-12-23 00:24:24 -03:00
parent f14492d744
commit 1a3c690138
Signed by: brunofontes
GPG Key ID: 4DAA810052CF68B6

32
src/Async.php Normal file
View File

@ -0,0 +1,32 @@
<?php
/**
* A very compact and simple Memsource API library
*
* @author Bruno Fontes <developer@brunofontes.net>
* @link https://github.com/brunofontes
*/
namespace BrunoFontes\Memsource;
class Async extends \BrunoFontes\Memsource\BaseApi
{
private $_url = '/api2/v1/async';
/**
* Get asynchronous request
*
* @param string $queryParams An array with the Query parameters to filter projects
*
* @return string The JSON answer from Memsource
*/
public function getAsyncRequest(string $asyncRequestId, array $queryParams = []): string
{
$response = $this->fetchApi->fetch('get', "{$this->_url}/{$asyncRequestId}", $queryParams);
if ($this->hasError($response)) {
throw new \Exception("Error listing AsyncRequest: " . $this->getError($response), 1);
}
return $response;
}
}