Skip to content
Merged
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
103 changes: 102 additions & 1 deletion src/CrowdinApiClient/Api/BranchApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
namespace CrowdinApiClient\Api;

use CrowdinApiClient\Model\Branch;
use CrowdinApiClient\Model\BranchClone;
use CrowdinApiClient\Model\BranchMerge;
use CrowdinApiClient\Model\BranchMergeSummary;
use CrowdinApiClient\ModelCollection;

/**
Expand Down Expand Up @@ -57,7 +60,8 @@ public function get(int $projectId, int $branchId): ?Branch
* string $data[name] required Note: Can't contain \\ / : * ? \" < > | symbols<br>
* string $data[title]<br>
* string $data[exportPattern] Note: Can't contain \\ / : * ? \" < > | symbols<br>
* string $data[priority] Enum: "low" "normal" "high"
* string $data[priority] Enum: "low" "normal" "high"<br>
* bool $data[isProtected] String-based projects only
* @return Branch|null
*/
public function create(int $projectId, array $data): ?Branch
Expand Down Expand Up @@ -95,4 +99,101 @@ public function delete(int $projectId, int $branchId)
$path = sprintf('projects/%d/branches/%d', $projectId, $branchId);
return $this->_delete($path);
}

/**
* Clone Branch
* @link https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.branches.clones.post API Documentation
*
* @param int $projectId
* @param int $branchId
* @param array $data
* string $data[name] required Note: Can't contain \\ / : * ? \" < > | symbols<br>
* string $data[title]<br>
* bool $data[isProtected]
* @return BranchClone|null
*/
public function cloneBranch(int $projectId, int $branchId, array $data): ?BranchClone
{
$path = sprintf('projects/%d/branches/%d/clones', $projectId, $branchId);
return $this->_post($path, BranchClone::class, $data);
}

/**
* Check Branch Clone Status
* @link https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.branches.clones.get API Documentation
*
* @param int $projectId
* @param int $branchId
* @param string $cloneId
* @return BranchClone|null
*/
public function checkCloneStatus(int $projectId, int $branchId, string $cloneId): ?BranchClone
{
$path = sprintf('projects/%d/branches/%d/clones/%s', $projectId, $branchId, $cloneId);
return $this->_get($path, BranchClone::class);
}

/**
* Get Cloned Branch
* @link https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.branches.clones.branch.get API Documentation
*
* @param int $projectId
* @param int $branchId
* @param string $cloneId
* @return Branch|null
*/
public function getClonedBranch(int $projectId, int $branchId, string $cloneId): ?Branch
{
$path = sprintf('projects/%d/branches/%d/clones/%s/branch', $projectId, $branchId, $cloneId);
return $this->_get($path, Branch::class);
}

/**
* Merge Branch
* @link https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.branches.merges.post API Documentation
*
* @param int $projectId
* @param int $branchId
* @param array $data
* int $data[sourceBranchId] required<br>
* bool $data[deleteAfterMerge]<br>
* bool $data[dryRun]<br>
* bool $data[acceptSourceChanges]
* @return BranchMerge|null
*/
public function mergeBranch(int $projectId, int $branchId, array $data): ?BranchMerge
{
$path = sprintf('projects/%d/branches/%d/merges', $projectId, $branchId);
return $this->_post($path, BranchMerge::class, $data);
}

/**
* Check Branch Merge Status
* @link https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.branches.merges.get API Documentation
*
* @param int $projectId
* @param int $branchId
* @param string $mergeId
* @return BranchMerge|null
*/
public function checkMergeStatus(int $projectId, int $branchId, string $mergeId): ?BranchMerge
{
$path = sprintf('projects/%d/branches/%d/merges/%s', $projectId, $branchId, $mergeId);
return $this->_get($path, BranchMerge::class);
}

/**
* Get Branch Merge Summary
* @link https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.branches.merges.summary.get API Documentation
*
* @param int $projectId
* @param int $branchId
* @param string $mergeId
* @return BranchMergeSummary|null
*/
public function getMergeSummary(int $projectId, int $branchId, string $mergeId): ?BranchMergeSummary
{
$path = sprintf('projects/%d/branches/%d/merges/%s/summary', $projectId, $branchId, $mergeId);
return $this->_get($path, BranchMergeSummary::class);
}
}
18 changes: 18 additions & 0 deletions src/CrowdinApiClient/Api/BundleApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace CrowdinApiClient\Api;

use CrowdinApiClient\Model\Branch;
use CrowdinApiClient\Model\Bundle;
use CrowdinApiClient\Model\BundleExport;
use CrowdinApiClient\Model\DownloadFile;
Expand Down Expand Up @@ -116,6 +117,23 @@ public function listFiles(int $projectId, int $bundleId, array $params = []): Mo
return $this->_list($path, File::class, $params);
}

/**
* List Bundle Branches
* @link https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.bundles.branches.getMany API Documentation
*
* @param int $projectId
* @param int $bundleId
* @param array $params
* integer $params[limit]<br>
* integer $params[offset]
* @return ModelCollection
*/
public function listBranches(int $projectId, int $bundleId, array $params = []): ModelCollection
{
$path = sprintf('projects/%d/bundles/%d/branches', $projectId, $bundleId);
return $this->_list($path, Branch::class, $params);
}

/**
* Export Bundle
* @link https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.exports.post API Documentation
Expand Down
5 changes: 3 additions & 2 deletions src/CrowdinApiClient/Api/DistributionApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ public function get(int $projectId, string $hash): ?Distribution
*
* @param int $projectId
* @param array $data
* string $data[exportMode] Enum: "default" "bundle" Default: "default"<br>
* string $data[exportMode] Enum: "default" "bundle" Default: "default" Note: String-based projects use "bundle" only<br>
* string $data[name] required<br>
* int[] $data[fileIds] required<br>
* int[] $data[fileIds] Required for file-based projects (default export mode)<br>
* int[] $data[bundleIds] Required for string-based projects<br>
* string $data[format] required for 'bundle' export mode<br>
* string $data[exportPattern] required for 'bundle' export mode. Note: Can't contain \\ / : * ? \" < > | symbols<br>
* int[] $data[labelIds]<br>
Expand Down
43 changes: 41 additions & 2 deletions src/CrowdinApiClient/Api/SourceStringApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace CrowdinApiClient\Api;

use CrowdinApiClient\Model\SourceString;
use CrowdinApiClient\Model\StringUpload;
use CrowdinApiClient\ModelCollection;

/**
Expand Down Expand Up @@ -50,9 +51,10 @@ public function get(int $projectId, int $stringId): ?SourceString
*
* @param int $projectId
* @param array $data
* string $data[identifier] Required for strings-based projects or file-based projects if scheme of CSV file includes identifier column<br>
* string $data[identifier] Required for string-based projects or file-based projects if scheme of CSV file includes identifier column<br>
* string $data[text] required<br>
* integer $data[fileId]<br>
* integer $data[branchId] Required for string-based projects<br>
* integer $data[fileId] Required for file-based projects<br>
* string $data[context]<br>
* bool $data[isHidden]<br>
* integer $data[maxLength]
Expand Down Expand Up @@ -110,4 +112,41 @@ public function batchOperations(int $projectId, array $data)
$path = sprintf('projects/%d/strings', $projectId);
return $this->_patch($path, SourceString::class, $data);
}

/**
* Upload Strings
* @link https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.strings.uploads.post API Documentation
*
* @param int $projectId
* @param array $data
* int $data[storageId] required<br>
* int $data[branchId] required<br>
* string $data[type]<br>
* int $data[parserVersion]<br>
* int[] $data[labelIds]<br>
* bool $data[updateStrings]<br>
* bool $data[cleanupMode]<br>
* array $data[importOptions]<br>
* string $data[updateOption]
* @return StringUpload|null
*/
public function uploadStrings(int $projectId, array $data): ?StringUpload
{
$path = sprintf('projects/%d/strings/uploads', $projectId);
return $this->_post($path, StringUpload::class, $data);
}

/**
* Check Upload Strings Status
* @link https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.strings.uploads.get API Documentation
*
* @param int $projectId
* @param string $uploadId
* @return StringUpload|null
*/
public function checkUploadStatus(int $projectId, string $uploadId): ?StringUpload
{
$path = sprintf('projects/%d/strings/uploads/%s', $projectId, $uploadId);
return $this->_get($path, StringUpload::class);
}
}
3 changes: 2 additions & 1 deletion src/CrowdinApiClient/Api/TranslationApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public function listPreTranslations(int $projectId, array $params = []): ModelCo
* @param int $projectId
* @param array $params
* string[] $params[languageIds] required<br>
* int[] $params[fileIds] required<br>
* int[] $params[fileIds] Required for file-based projects<br>
* int[] $params[branchIds] String-based projects only<br>
* string $params[method]<br>
* int $params[engineId]<br>
* string $params[autoApproveOption]<br>
Expand Down
11 changes: 11 additions & 0 deletions src/CrowdinApiClient/Model/Branch.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ class Branch extends BaseModel
*/
protected $priority;

/**
* @var bool
*/
protected $isProtected;

/**
* @var string
*/
Expand All @@ -57,6 +62,7 @@ public function __construct(array $data = [])
$this->title = (string)$this->getDataProperty('title');
$this->exportPattern = (string)$this->getDataProperty('exportPattern');
$this->priority = (string)$this->getDataProperty('priority');
$this->isProtected = (bool)$this->getDataProperty('isProtected');
$this->createdAt = (string)$this->getDataProperty('createdAt');
$this->updatedAt = (string)$this->getDataProperty('updatedAt');
}
Expand Down Expand Up @@ -141,6 +147,11 @@ public function setPriority(string $priority): void
$this->priority = $priority;
}

public function isProtected(): bool
{
return $this->isProtected;
}

/**
* @return string
*/
Expand Down
103 changes: 103 additions & 0 deletions src/CrowdinApiClient/Model/BranchClone.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php

namespace CrowdinApiClient\Model;

/**
* @package Crowdin\Model
*/
class BranchClone extends BaseModel
{
/**
* @var string
*/
protected $identifier;

/**
* @var string
*/
protected $status;

/**
* @var integer
*/
protected $progress;

/**
* @var array
*/
protected $attributes;

/**
* @var string
*/
protected $createdAt;

/**
* @var string
*/
protected $updatedAt;

/**
* @var string|null
*/
protected $startedAt;

/**
* @var string|null
*/
protected $finishedAt;

public function __construct(array $data = [])
{
parent::__construct($data);

$this->identifier = (string)$this->getDataProperty('identifier');
$this->status = (string)$this->getDataProperty('status');
$this->progress = (int)$this->getDataProperty('progress');
$this->attributes = (array)$this->getDataProperty('attributes');
$this->createdAt = (string)$this->getDataProperty('createdAt');
$this->updatedAt = (string)$this->getDataProperty('updatedAt');
$this->startedAt = $this->getDataProperty('startedAt');
$this->finishedAt = $this->getDataProperty('finishedAt');
}

public function getIdentifier(): string
{
return $this->identifier;
}

public function getStatus(): string
{
return $this->status;
}

public function getProgress(): int
{
return $this->progress;
}

public function getAttributes(): array
{
return $this->attributes;
}

public function getCreatedAt(): string
{
return $this->createdAt;
}

public function getUpdatedAt(): string
{
return $this->updatedAt;
}

public function getStartedAt(): ?string
{
return $this->startedAt;
}

public function getFinishedAt(): ?string
{
return $this->finishedAt;
}
}
Loading
Loading