Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/CrowdinApiClient/Api/Enterprise/FileApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public function listReviewedSourceFilesBuilds(int $projectId, array $params = []
* @param int $projectId
* @param array $data
* integer $data[branchId]
* @return ReviewedSourceFileBuild
* @return ReviewedSourceFileBuild|null
*/
public function buildReviewedSourceFiles(int $projectId, array $data = []): ReviewedSourceFileBuild
public function buildReviewedSourceFiles(int $projectId, array $data = []): ?ReviewedSourceFileBuild
{
$path = sprintf('projects/%d/strings/reviewed-builds', $projectId);
return $this->_create($path, ReviewedSourceFileBuild::class, $data);
Expand All @@ -51,18 +51,18 @@ public function buildReviewedSourceFiles(int $projectId, array $data = []): Revi
/**
* Check Reviewed Source Files Build Status
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.strings.reviewed-builds.get API Documentation Enterprise
*
* @param int $projectId
* @param int $buildId
* @return ReviewedSourceFileBuild
*/
public function checkReviewedSourceFilesBuildStatus(int $projectId, int $buildId): ReviewedSourceFileBuild
public function checkReviewedSourceFilesBuildStatus(int $projectId, int $buildId): ?ReviewedSourceFileBuild
{
$path = sprintf('projects/%d/strings/reviewed-builds/%d', $projectId, $buildId);
return $this->_get($path, ReviewedSourceFileBuild::class);
}

public function downloadReviewedSourceFiles(int $projectId, int $buildId): DownloadFile
/**
* Download Reviewed Source Files
* @link https://support.crowdin.com/developer/enterprise/api/v2/#tag/Source-Files/operation/api.projects.strings.reviewed-builds.download.download API Documentation Enterprise
*/
public function downloadReviewedSourceFiles(int $projectId, int $buildId): ?DownloadFile
{
$path = sprintf('projects/%d/strings/reviewed-builds/%d/download', $projectId, $buildId);
return $this->_get($path, DownloadFile::class);
Expand Down
30 changes: 4 additions & 26 deletions src/CrowdinApiClient/Api/FileApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class FileApi extends AbstractApi
* List Files
* @link https://developer.crowdin.com/api/v2/#operation/api.projects.files.getMany API Documentation
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.getMany API Documentation Enterprise
*
* @param int $projectId
* @param array $params
* integer $params[branchId] Can't be used with directoryId in the same request<br>
Expand Down Expand Up @@ -62,9 +63,6 @@ public function create(int $projectId, array $data): File
* Get File Info
* @link https://developer.crowdin.com/api/v2/#operation/api.projects.files.get API Documentation
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.get API Documentation Enterprise
* @param int $projectId
* @param int $fileId
* @return File|null
*/
public function get(int $projectId, int $fileId): ?File
{
Expand All @@ -76,6 +74,7 @@ public function get(int $projectId, int $fileId): ?File
* Update File
* @link https://developer.crowdin.com/api/v2/#operation/api.projects.files.put API Documentation
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.put API Documentation Enterprise
*
* @param int $projectId
* @param int $fileId
* @param array $data
Expand All @@ -95,6 +94,7 @@ public function update(int $projectId, int $fileId, array $data): File
* Restore file to revision
* @link https://developer.crowdin.com/api/v2/#operation/api.projects.files.put API Documentation
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.put API Documentation Enterprise
*
* @param int $projectId
* @param int $fileId
* @param array $data
Expand All @@ -111,10 +111,6 @@ public function restore(int $projectId, int $fileId, array $data): File
* Download Preview File
* @link https://developer.crowdin.com/api/v2/#operation/api.projects.files.preview.get API Documentation
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.preview.get API Documentation Enterprise
*
* @param int $projectId
* @param int $fileId
* @return DownloadFilePreview|null
*/
public function downloadPreview(int $projectId, int $fileId): ?DownloadFilePreview
{
Expand All @@ -126,10 +122,6 @@ public function downloadPreview(int $projectId, int $fileId): ?DownloadFilePrevi
* Download File
* @link https://developer.crowdin.com/api/v2/#operation/api.projects.files.download.get API Documentation
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.download.get API Documentation Enterprise
*
* @param int $projectId
* @param int $fileId
* @return DownloadFile|null
*/
public function download(int $projectId, int $fileId): ?DownloadFile
{
Expand All @@ -141,9 +133,6 @@ public function download(int $projectId, int $fileId): ?DownloadFile
* Edit File
* @link https://developer.crowdin.com/api/v2/#operation/api.projects.files.patch API Documentation
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.patch API Documentation Enterprise
*
* @param File $file
* @return File|null
*/
public function edit(File $file): ?File
{
Expand All @@ -156,9 +145,7 @@ public function edit(File $file): ?File
* @link https://developer.crowdin.com/api/v2/#operation/api.projects.files.delete API Documentation
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.delete API Documentation Enterprise
*
* @param int $projectId
* @param int $fileId
* @return mixed
* @return null
*/
public function delete(int $projectId, int $fileId)
{
Expand All @@ -170,10 +157,6 @@ public function delete(int $projectId, int $fileId)
* List File Revisions
* @link https://developer.crowdin.com/api/v2/#operation/api.projects.files.revisions.getMany API Documentation
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.revisions.getMany API Documentation Enterprise
*
* @param int $projectId
* @param int $fileId
* @return ModelCollection
*/
public function revisions(int $projectId, int $fileId): ModelCollection
{
Expand All @@ -185,11 +168,6 @@ public function revisions(int $projectId, int $fileId): ModelCollection
* Get File Revision
* @link https://developer.crowdin.com/api/v2/#operation/api.projects.files.revisions.get API Documentation
* @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.revisions.get API Documentation Enterprise
*
* @param int $projectId
* @param int $fileId
* @param int $revision
* @return FileRevision|null
*/
public function getRevision(int $projectId, int $fileId, int $revision): ?FileRevision
{
Expand Down
69 changes: 17 additions & 52 deletions src/CrowdinApiClient/Model/FileRevision.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
class FileRevision extends BaseModel
{
/**
* @var integer
* @var int
*/
protected $id;

/**
* @var integer
* @var int
*/
protected $projectId;

/**
* @var integer
* @var int
*/
protected $fileId;

/**
* @var integer
* @var int|null
*/
protected $restoreToRevision;

Expand All @@ -37,82 +37,47 @@
*/
protected $date;

/**
* FileRevision constructor.
* @param array $data
*/
public function __construct(array $data = [])
{
parent::__construct($data);
$this->id = (integer)$this->getDataProperty('id');
$this->projectId = (integer)$this->getDataProperty('projectId');
$this->restoreToRevision = (integer)$this->getDataProperty('restoreToRevision');
$this->fileId = (integer)$this->getDataProperty('fileId');

$this->id = (int)$this->getDataProperty('id');
$this->projectId = (int)$this->getDataProperty('projectId');
$this->fileId = (int)$this->getDataProperty('fileId');
$this->restoreToRevision = $this->getDataProperty('restoreToRevision')
? (int)$this->getDataProperty('restoreToRevision')

Check warning on line 48 in src/CrowdinApiClient/Model/FileRevision.php

View check run for this annotation

Codecov / codecov/patch

src/CrowdinApiClient/Model/FileRevision.php#L48

Added line #L48 was not covered by tests
: null;
$this->info = (array)$this->getDataProperty('info');
$this->date = (string)$this->getDataProperty('date');
}

/**
* @return int
*/
public function getId(): int
{
return $this->id;
}

/**
* @return int
*/
public function getProjectId(): int
{
return $this->projectId;
}

/**
* @param int $projectId
*/
public function setProjectId(int $projectId): void
public function getFileId(): int
{
$this->projectId = $projectId;
return $this->fileId;
}

/**
* @return array
*/
public function getInfo(): array
public function getRestoreToRevision(): ?int
{
return $this->info;
return $this->restoreToRevision;
}

/**
* @param array $info
*/
public function setInfo(array $info): void
public function getInfo(): array
{
$this->info = $info;
return $this->info;
}

/**
* @return string
*/
public function getDate(): string
{
return $this->date;
}

/**
* @return int
*/
public function getFileId(): int
{
return $this->fileId;
}

/**
* @return int
*/
public function getRestoreToRevision(): int
{
return $this->restoreToRevision;
}
}
Loading