diff --git a/src/Jobs.php b/src/Jobs.php new file mode 100644 index 0000000..28464db --- /dev/null +++ b/src/Jobs.php @@ -0,0 +1,29 @@ + + * @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); + } +} diff --git a/src/Memsource.php b/src/Memsource.php index b6f4e36..b994aca 100644 --- a/src/Memsource.php +++ b/src/Memsource.php @@ -18,6 +18,7 @@ class Memsource { private $_oauth; private $_bilingualFile; + private $_jobs; private $_project; private $_fetchApi; @@ -36,16 +37,6 @@ class Memsource 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 * @@ -55,4 +46,25 @@ class Memsource { 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); + } }