Included the Jobs class

This commit is contained in:
Bruno F. Fontes 2019-06-24 20:29:02 -03:00
parent 898f03fd92
commit 39c135be60
Signed by: brunofontes
GPG Key ID: EE3447CE80048495
2 changed files with 51 additions and 10 deletions

29
src/Jobs.php Normal file
View File

@ -0,0 +1,29 @@
<?php
/**
* A very compact and simple Memsource API library
*
* @author Bruno Fontes <developer@brunofontes.net>
* @link https://github.com/brunofontes
*/
namespace BrunoFontes\Memsource;
class Jobs extends \BrunoFontes\Memsource\BaseApi
{
/**
* List jobs of a project
* The API request returns a MAX of 50 Jobs.
* To get more jobs you need to make more requests for next pages
*
* @param string $projectUid The project uid on which has the jobs to be shown
* @param array $parameters List of Memsource Parameters
*
* @return string The JSON answer from Memsource
*/
public function listJobs(string $projectUid, array $parameters = []): string
{
$url = "/api2/v2/projects/{$projectUid}/jobs";
return $this->fetchApi->fetch('get', $url, $parameters);
}
}

View File

@ -18,6 +18,7 @@ class Memsource
{ {
private $_oauth; private $_oauth;
private $_bilingualFile; private $_bilingualFile;
private $_jobs;
private $_project; private $_project;
private $_fetchApi; private $_fetchApi;
@ -36,16 +37,6 @@ class Memsource
return $this->_oauth ?? $this->_oauth = new \BrunoFontes\Memsource\oauth(); return $this->_oauth ?? $this->_oauth = new \BrunoFontes\Memsource\oauth();
} }
/**
* Memsource API Project related functions
*
* @return \BrunoFontes\Memsource\Project
*/
public function project(): \BrunoFontes\Memsource\Project
{
return $this->_project ?? $this->_project = new \BrunoFontes\Memsource\Project($this->_fetchApi);
}
/** /**
* Memsource API BilingualFile related functions * Memsource API BilingualFile related functions
* *
@ -55,4 +46,25 @@ class Memsource
{ {
return $this->_bilingualFile ?? $this->_bilingualFile = new \BrunoFontes\Memsource\BilingualFile($this->_fetchApi); return $this->_bilingualFile ?? $this->_bilingualFile = new \BrunoFontes\Memsource\BilingualFile($this->_fetchApi);
} }
/**
* Memsource API Jobs related functions
*
* @return \BrunoFontes\Memsource\Jobs
*/
public function jobs(): \BrunoFontes\Memsource\Jobs
{
return $this->_jobs ?? $this->_jobs = new \BrunoFontes\Memsource\Jobs($this->_fetchApi);
}
/**
* Memsource API Project related functions
*
* @return \BrunoFontes\Memsource\Project
*/
public function project(): \BrunoFontes\Memsource\Project
{
return $this->_project ?? $this->_project = new \BrunoFontes\Memsource\Project($this->_fetchApi);
}
} }