-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added Report Archives API endpoints (#181)
- Loading branch information
1 parent
5199cf7
commit efe1805
Showing
7 changed files
with
794 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php | ||
|
||
namespace CrowdinApiClient\Api\Enterprise; | ||
|
||
use CrowdinApiClient\Api\AbstractApi; | ||
use CrowdinApiClient\Model\DownloadFile; | ||
use CrowdinApiClient\Model\ReportArchive; | ||
use CrowdinApiClient\Model\ReportArchiveExport; | ||
use CrowdinApiClient\ModelCollection; | ||
|
||
class ReportArchiveApi extends AbstractApi | ||
{ | ||
/** | ||
* List Report Archives | ||
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.reports.archives.getMany | ||
* | ||
* @param array $params | ||
* string $params[scopeType] | ||
* integer $params[scopeId] | ||
* integer $params[limit] | ||
* integer $params[offset] | ||
* @return ModelCollection | ||
*/ | ||
public function list(array $params = []): ModelCollection | ||
{ | ||
$path = 'reports/archives'; | ||
return $this->_list($path, ReportArchive::class, $params); | ||
} | ||
|
||
/** | ||
* Get Report Archive | ||
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.reports.archives.get | ||
* | ||
* @param int $archiveId | ||
* @return ReportArchive|null | ||
*/ | ||
public function get(int $archiveId): ?ReportArchive | ||
{ | ||
$path = sprintf('reports/archives/%d', $archiveId); | ||
return $this->_get($path, ReportArchive::class); | ||
} | ||
|
||
/** | ||
* Delete Report Archive | ||
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.reports.archives.delete | ||
* | ||
* @param int $archiveId | ||
* @return void | ||
*/ | ||
public function delete(int $archiveId): void | ||
{ | ||
$path = sprintf('reports/archives/%d', $archiveId); | ||
$this->_delete($path); | ||
} | ||
|
||
/** | ||
* Export Report Archive | ||
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.reports.archives.exports.post | ||
* | ||
* @param int $archiveId | ||
* @param array $params | ||
* string $params[format] Enum: "xlsx" "csv" "json" | ||
* @return ReportArchiveExport|null | ||
*/ | ||
public function export(int $archiveId, array $params = []): ?ReportArchiveExport | ||
{ | ||
$path = sprintf('reports/archives/%d/exports', $archiveId); | ||
return $this->_post($path, ReportArchiveExport::class, $params); | ||
} | ||
|
||
/** | ||
* Check Report Archive Export Status | ||
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.reports.archives.exports.get | ||
* | ||
* @param int $archiveId | ||
* @param string $exportId | ||
* @return ReportArchiveExport|null | ||
*/ | ||
public function checkExportStatus(int $archiveId, string $exportId): ?ReportArchiveExport | ||
{ | ||
$path = sprintf('reports/archives/%d/exports/%s', $archiveId, $exportId); | ||
return $this->_get($path, ReportArchiveExport::class); | ||
} | ||
|
||
/** | ||
* Download Report Archive | ||
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.reports.archives.exports.download.get | ||
* | ||
* @param int $archiveId | ||
* @param string $exportId | ||
* @return DownloadFile|null | ||
*/ | ||
public function downloadReportArchive(int $archiveId, string $exportId): ?DownloadFile | ||
{ | ||
$path = sprintf('reports/archives/%d/exports/%s/download', $archiveId, $exportId); | ||
return $this->_get($path, DownloadFile::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<?php | ||
|
||
namespace CrowdinApiClient\Api; | ||
|
||
use CrowdinApiClient\Model\DownloadFile; | ||
use CrowdinApiClient\Model\ReportArchive; | ||
use CrowdinApiClient\Model\ReportArchiveExport; | ||
use CrowdinApiClient\ModelCollection; | ||
|
||
/** | ||
* @package Crowdin\Api | ||
*/ | ||
class ReportArchiveApi extends AbstractApi | ||
{ | ||
/** | ||
* List Report Archives | ||
* @link https://developer.crowdin.com/api/v2/#operation/api.reports.archives.getMany | ||
* | ||
* @param int $userId | ||
* @param array $params | ||
* string $params[scopeType] | ||
* integer $params[scopeId] | ||
* integer $params[limit] | ||
* integer $params[offset] | ||
* @return ModelCollection | ||
*/ | ||
public function list(int $userId, array $params = []): ModelCollection | ||
{ | ||
$path = sprintf('users/%d/reports/archives', $userId); | ||
return $this->_list($path, ReportArchive::class, $params); | ||
} | ||
|
||
/** | ||
* Get Report Archive | ||
* @link https://developer.crowdin.com/api/v2/#operation/api.users.reports.archives.get | ||
* | ||
* @param int $userId | ||
* @param int $archiveId | ||
* @return ReportArchive|null | ||
*/ | ||
public function get(int $userId, int $archiveId): ?ReportArchive | ||
{ | ||
$path = sprintf('users/%d/reports/archives/%d', $userId, $archiveId); | ||
return $this->_get($path, ReportArchive::class); | ||
} | ||
|
||
/** | ||
* Delete Report Archive | ||
* @link https://developer.crowdin.com/api/v2/#operation/api.users.reports.archives.delete | ||
* | ||
* @param int $userId | ||
* @param int $archiveId | ||
* @return void | ||
*/ | ||
public function delete(int $userId, int $archiveId): void | ||
{ | ||
$path = sprintf('users/%d/reports/archives/%d', $userId, $archiveId); | ||
$this->_delete($path); | ||
} | ||
|
||
/** | ||
* Export Report Archive | ||
* @link https://developer.crowdin.com/api/v2/#operation/api.reports.archives.exports.post | ||
* | ||
* @param int $userId | ||
* @param int $archiveId | ||
* @param array $params | ||
* string $params[format] Enum: "xlsx" "csv" "json" | ||
* @return ReportArchiveExport|null | ||
*/ | ||
public function export(int $userId, int $archiveId, array $params = []): ?ReportArchiveExport | ||
{ | ||
$path = sprintf('users/%d/reports/archives/%d/exports', $userId, $archiveId); | ||
return $this->_post($path, ReportArchiveExport::class, $params); | ||
} | ||
|
||
/** | ||
* Check Report Archive Export Status | ||
* @link https://developer.crowdin.com/api/v2/#operation/api.users.reports.archives.exports.get | ||
* | ||
* @param int $userId | ||
* @param int $archiveId | ||
* @param string $exportId | ||
* @return ReportArchiveExport|null | ||
*/ | ||
public function checkExportStatus(int $userId, int $archiveId, string $exportId): ?ReportArchiveExport | ||
{ | ||
$path = sprintf('users/%d/reports/archives/%d/exports/%s', $userId, $archiveId, $exportId); | ||
return $this->_get($path, ReportArchiveExport::class); | ||
} | ||
|
||
/** | ||
* Download Report Archive | ||
* @link https://developer.crowdin.com/api/v2/#operation/api.users.reports.archives.exports.download.get | ||
* | ||
* @param int $userId | ||
* @param int $archiveId | ||
* @param string $exportId | ||
* @return DownloadFile|null | ||
*/ | ||
public function downloadReportArchive(int $userId, int $archiveId, string $exportId): ?DownloadFile | ||
{ | ||
$path = sprintf('users/%d/reports/archives/%d/exports/%s/download', $userId, $archiveId, $exportId); | ||
return $this->_get($path, DownloadFile::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
<?php | ||
|
||
namespace CrowdinApiClient\Model; | ||
|
||
class ReportArchive extends BaseModel | ||
{ | ||
/** | ||
* @var integer | ||
*/ | ||
protected $id; | ||
/** | ||
* @var string | ||
*/ | ||
protected $scopeType; | ||
/** | ||
* @var integer | ||
*/ | ||
protected $scopeId; | ||
/** | ||
* @var integer | ||
*/ | ||
protected $userId; | ||
/** | ||
* @var string | ||
*/ | ||
protected $name; | ||
/** | ||
* @var string | ||
*/ | ||
protected $webUrl; | ||
/** | ||
* @var array | ||
*/ | ||
protected $scheme; | ||
/** | ||
* @var string | ||
*/ | ||
protected $createdAt; | ||
|
||
public function __construct(array $data = []) | ||
{ | ||
parent::__construct($data); | ||
$this->id = (integer)$this->getDataProperty('id'); | ||
$this->scopeType = (string)$this->getDataProperty('scopeType'); | ||
$this->scopeId = (integer)$this->getDataProperty('scopeId'); | ||
$this->userId = (integer)$this->getDataProperty('userId'); | ||
$this->name = (string)$this->getDataProperty('name'); | ||
$this->webUrl = (string)$this->getDataProperty('webUrl'); | ||
$this->scheme = (array)$this->getDataProperty('scheme'); | ||
$this->createdAt = (string)$this->getDataProperty('createdAt'); | ||
} | ||
|
||
public function getId(): int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getScopeType(): string | ||
{ | ||
return $this->scopeType; | ||
} | ||
|
||
public function setScopeType(string $scopeType): void | ||
{ | ||
$this->scopeType = $scopeType; | ||
} | ||
|
||
public function getScopeId(): int | ||
{ | ||
return $this->scopeId; | ||
} | ||
|
||
public function setScopeId(int $scopeId): void | ||
{ | ||
$this->scopeId = $scopeId; | ||
} | ||
|
||
public function getUserId(): int | ||
{ | ||
return $this->userId; | ||
} | ||
|
||
public function setUserId(int $userId): void | ||
{ | ||
$this->userId = $userId; | ||
} | ||
|
||
public function getName(): string | ||
{ | ||
return $this->name; | ||
} | ||
|
||
public function setName(string $name): void | ||
{ | ||
$this->name = $name; | ||
} | ||
|
||
public function getWebUrl(): string | ||
{ | ||
return $this->webUrl; | ||
} | ||
|
||
public function setWebUrl(string $webUrl): void | ||
{ | ||
$this->webUrl = $webUrl; | ||
} | ||
|
||
public function getScheme(): array | ||
{ | ||
return $this->scheme; | ||
} | ||
|
||
public function setScheme(array $scheme): void | ||
{ | ||
$this->scheme = $scheme; | ||
} | ||
|
||
public function getCreatedAt(): string | ||
{ | ||
return $this->createdAt; | ||
} | ||
|
||
public function setCreatedAt(string $createdAt): void | ||
{ | ||
$this->createdAt = $createdAt; | ||
} | ||
} |
Oops, something went wrong.