Skip to content

Commit

Permalink
feat: distributions API updates (#145)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-bodnar authored Aug 2, 2023
1 parent 00f06fa commit b851532
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 101 deletions.
102 changes: 25 additions & 77 deletions src/CrowdinApiClient/Model/Distribution.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,18 @@ class Distribution extends BaseModel
protected $fileIds;

/**
* @var string
* @var int[]
*/
protected $format;
protected $bundleIds;

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

/**
* @var string[]
* @var string
*/
protected $labelIds;

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

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

public function __construct(array $data = [])
Expand All @@ -58,9 +52,7 @@ public function __construct(array $data = [])
$this->exportMode = (string)$this->getDataProperty('exportMode');
$this->name = (string)$this->getDataProperty('name');
$this->fileIds = (array)$this->getDataProperty('fileIds');
$this->format = (string)$this->getDataProperty('format');
$this->exportPattern = (string)$this->getDataProperty('exportPattern');
$this->labelIds = (array)$this->getDataProperty('labelIds');
$this->bundleIds = (array)$this->getDataProperty('bundleIds');
$this->createdAt = (string)$this->getDataProperty('createdAt');
$this->updatedAt = (string)$this->getDataProperty('updatedAt');
}
Expand All @@ -75,6 +67,16 @@ public function setHash(string $hash): void
$this->hash = $hash;
}

public function getExportMode(): string
{
return $this->exportMode;
}

public function setExportMode(string $exportMode): void
{
$this->exportMode = $exportMode;
}

public function getName(): string
{
return $this->name;
Expand All @@ -95,6 +97,16 @@ public function setFileIds(array $fileIds): void
$this->fileIds = $fileIds;
}

public function getBundleIds(): array
{
return $this->bundleIds;
}

public function setBundleIds(array $bundleIds): void
{
$this->bundleIds = $bundleIds;
}

public function getCreatedAt(): string
{
return $this->createdAt;
Expand All @@ -114,68 +126,4 @@ public function setUpdatedAt(string $updatedAt): void
{
$this->updatedAt = $updatedAt;
}

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

/**
* @param string $exportMode
*/
public function setExportMode(string $exportMode): void
{
$this->exportMode = $exportMode;
}

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

/**
* @param string $format
*/
public function setFormat(string $format): void
{
$this->format = $format;
}

/**
* @return array|string
*/
public function getExportPattern()
{
return $this->exportPattern;
}

/**
* @param array|string $exportPattern
*/
public function setExportPattern($exportPattern): void
{
$this->exportPattern = $exportPattern;
}

/**
* @return array|string[]
*/
public function getLabelIds(): array
{
return $this->labelIds;
}

/**
* @param array|string[] $labelIds
*/
public function setLabelIds(array $labelIds): void
{
$this->labelIds = $labelIds;
}
}
16 changes: 4 additions & 12 deletions tests/CrowdinApiClient/Api/DistributionApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ public function testList()
"data": {
"hash": "e-4326c06be14321dd967b161a",
"exportMode": "bundle",
"format": "crowdin-resx",
"exportPattern": "strings-%two_letters_code%.resx",
"name": "Test Distribution",
"fileIds": [
1
],
"labelIds": [
"bundleIds": [
1
],
"createdAt": "2019-09-23T09:04:29+00:00",
Expand Down Expand Up @@ -70,12 +68,10 @@ public function testCreate()
"hash": "e-4326c06be14321dd967b161a",
"name": "Test Distribution",
"exportMode": "bundle",
"format": "crowdin-resx",
"exportPattern": "strings-%two_letters_code%.resx",
"fileIds": [
1
],
"labelIds": [
"bundleIds": [
1
],
"createdAt": "2019-09-23T09:04:29+00:00",
Expand All @@ -98,12 +94,10 @@ public function testGetAndUpdate()
"hash": "e-4326c06be14321dd967b161a",
"name": "Test Distribution",
"exportMode": "bundle",
"format": "crowdin-resx",
"exportPattern": "strings-%two_letters_code%.resx",
"fileIds": [
1
],
"labelIds": [
"bundleIds": [
1
],
"createdAt": "2019-09-23T09:04:29+00:00",
Expand All @@ -120,12 +114,10 @@ public function testGetAndUpdate()
"hash": "e-4326c06be14321dd967b161a",
"name": "test edit",
"exportMode": "bundle",
"format": "crowdin-resx",
"exportPattern": "strings-%two_letters_code%.resx",
"fileIds": [
1
],
"labelIds": [
"bundleIds": [
1
],
"createdAt": "2019-09-23T09:04:29+00:00",
Expand Down
16 changes: 4 additions & 12 deletions tests/CrowdinApiClient/Model/DistributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@ class DistributionTest extends TestCase
'hash' => 'e-4326c06be14321dd967b161a',
'exportMode' => 'bundle',
'name' => 'Test Distribution',
'format' => 'crowdin-resx',
'exportPattern' => 'strings-%two_letters_code%.resx',
'fileIds' => [1, 2, 3],
'labelIds' => [1, 2, 3],
'bundleIds' => [1],
'createdAt' => '2019-09-19T14:14:00+00:00',
'updatedAt' => '2019-09-19T14:14:00+00:00',
];
Expand All @@ -42,17 +40,13 @@ public function testSetData()
$this->distribution->setName($this->data['name']);
$this->distribution->setFileIds($this->data['fileIds']);
$this->distribution->setExportMode($this->data['exportMode']);
$this->distribution->setExportPattern($this->data['exportPattern']);
$this->distribution->setLabelIds($this->data['labelIds']);
$this->distribution->setFormat($this->data['format']);
$this->distribution->setBundleIds($this->data['bundleIds']);

$this->assertEquals($this->data['hash'], $this->distribution->getHash());
$this->assertEquals($this->data['name'], $this->distribution->getName());
$this->assertEquals($this->data['fileIds'], $this->distribution->getFileIds());
$this->assertEquals($this->data['exportMode'], $this->distribution->getExportMode());
$this->assertEquals($this->data['exportPattern'], $this->distribution->getExportPattern());
$this->assertEquals($this->data['labelIds'], $this->distribution->getLabelIds());
$this->assertEquals($this->data['format'], $this->distribution->getFormat());
$this->assertEquals($this->data['bundleIds'], $this->distribution->getBundleIds());
}

public function checkData()
Expand All @@ -61,9 +55,7 @@ public function checkData()
$this->assertEquals($this->data['name'], $this->distribution->getName());
$this->assertEquals($this->data['fileIds'], $this->distribution->getFileIds());
$this->assertEquals($this->data['exportMode'], $this->distribution->getExportMode());
$this->assertEquals($this->data['exportPattern'], $this->distribution->getExportPattern());
$this->assertEquals($this->data['labelIds'], $this->distribution->getLabelIds());
$this->assertEquals($this->data['format'], $this->distribution->getFormat());
$this->assertEquals($this->data['bundleIds'], $this->distribution->getBundleIds());
$this->assertEquals($this->data['createdAt'], $this->distribution->getCreatedAt());
$this->assertEquals($this->data['updatedAt'], $this->distribution->getUpdatedAt());
}
Expand Down

0 comments on commit b851532

Please sign in to comment.