-
Notifications
You must be signed in to change notification settings - Fork 37
feat: added User Report Settings Templates support #265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,40 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace CrowdinApiClient\Model; | ||
|
|
||
| /** | ||
| * @package Crowdin\Model | ||
| */ | ||
| class HourlyBaseRates extends BaseModel | ||
| { | ||
| /** | ||
| * @var float | ||
| */ | ||
| protected $hourly; | ||
|
|
||
| public function __construct(array $data = []) | ||
| { | ||
| parent::__construct($data); | ||
|
|
||
| $this->hourly = (float)$this->getDataProperty('hourly'); | ||
| } | ||
|
|
||
| public function getHourly(): float | ||
| { | ||
| return $this->hourly; | ||
| } | ||
|
|
||
| public function setHourly(float $hourly): void | ||
| { | ||
| $this->hourly = $hourly; | ||
| } | ||
|
|
||
| public function toArray(): array | ||
| { | ||
| return [ | ||
| 'hourly' => $this->hourly, | ||
| ]; | ||
| } | ||
| } |
This file contains hidden or 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,112 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace CrowdinApiClient\Model; | ||
|
|
||
| use InvalidArgumentException; | ||
|
|
||
| /** | ||
| * @package Crowdin\Model | ||
| */ | ||
| class HourlyIndividualRates extends BaseModel | ||
| { | ||
| /** | ||
| * @var string[] | ||
| */ | ||
| protected $languageIds; | ||
|
|
||
| /** | ||
| * @var int[] | ||
| */ | ||
| protected $userIds; | ||
|
|
||
| /** | ||
| * @var float | ||
| */ | ||
| protected $hourly; | ||
|
|
||
| public function __construct(array $data = []) | ||
| { | ||
| parent::__construct($data); | ||
|
|
||
| $this->languageIds = array_map(static function ($languageId): string { | ||
| return (string)$languageId; | ||
| }, $this->getDataProperty('languageIds') ?? []); | ||
| $this->userIds = array_map(static function ($userId): int { | ||
| return (int)$userId; | ||
| }, $this->getDataProperty('userIds') ?? []); | ||
| $this->hourly = (float)$this->getDataProperty('hourly'); | ||
| } | ||
|
|
||
| /** | ||
| * @return string[] | ||
| */ | ||
| public function getLanguageIds(): array | ||
| { | ||
| return $this->languageIds; | ||
| } | ||
|
|
||
| /** | ||
| * @param string[] $languageIds | ||
| */ | ||
| public function setLanguageIds(array $languageIds): void | ||
| { | ||
| if ($languageIds === []) { | ||
| throw new InvalidArgumentException('Argument "languageIds" cannot be empty'); | ||
| } | ||
|
|
||
| foreach ($languageIds as $languageId) { | ||
| if (!is_string($languageId)) { | ||
| throw new InvalidArgumentException('Argument "languageIds" must be an array of strings'); | ||
| } | ||
| } | ||
|
|
||
| $this->languageIds = $languageIds; | ||
| } | ||
|
|
||
| /** | ||
| * @return int[] | ||
| */ | ||
| public function getUserIds(): array | ||
| { | ||
| return $this->userIds; | ||
| } | ||
|
|
||
| /** | ||
| * @param int[] $userIds | ||
| */ | ||
| public function setUserIds(array $userIds): void | ||
| { | ||
| if ($userIds === []) { | ||
| throw new InvalidArgumentException('Argument "userIds" cannot be empty'); | ||
| } | ||
|
|
||
| foreach ($userIds as $userId) { | ||
| if (!is_int($userId)) { | ||
| throw new InvalidArgumentException('Argument "userIds" must be an array of integers'); | ||
| } | ||
| } | ||
|
|
||
| $this->userIds = $userIds; | ||
| } | ||
|
|
||
| public function getHourly(): float | ||
| { | ||
| return $this->hourly; | ||
| } | ||
|
|
||
| public function setHourly(float $hourly): void | ||
| { | ||
| $this->hourly = $hourly; | ||
| } | ||
|
|
||
| public function toArray(): array | ||
| { | ||
| return [ | ||
| 'languageIds' => $this->languageIds, | ||
| 'userIds' => $this->userIds, | ||
| 'hourly' => $this->hourly, | ||
| ]; | ||
| } | ||
| } |
81 changes: 81 additions & 0 deletions
81
src/CrowdinApiClient/Model/HourlyReportSettingsTemplateConfig.php
This file contains hidden or 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,81 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace CrowdinApiClient\Model; | ||
|
|
||
| use InvalidArgumentException; | ||
|
|
||
| /** | ||
| * @package Crowdin\Model | ||
| */ | ||
| class HourlyReportSettingsTemplateConfig extends BaseModel | ||
| { | ||
| /** | ||
| * @var HourlyBaseRates | ||
| */ | ||
| protected $baseRates; | ||
|
|
||
| /** | ||
| * @var HourlyIndividualRates[] | ||
| */ | ||
| protected $individualRates; | ||
|
|
||
| public function __construct(array $data = []) | ||
| { | ||
| parent::__construct($data); | ||
|
|
||
| $this->baseRates = new HourlyBaseRates($this->getDataProperty('baseRates') ?? []); | ||
| $this->individualRates = array_map(static function (array $individualRates): HourlyIndividualRates { | ||
| return new HourlyIndividualRates($individualRates); | ||
| }, $this->getDataProperty('individualRates') ?? []); | ||
| } | ||
|
|
||
| public function getBaseRates(): HourlyBaseRates | ||
| { | ||
| return $this->baseRates; | ||
| } | ||
|
|
||
| public function setBaseRates(HourlyBaseRates $baseRates): void | ||
| { | ||
| $this->baseRates = $baseRates; | ||
| } | ||
|
|
||
| /** | ||
| * @return HourlyIndividualRates[] | ||
| */ | ||
| public function getIndividualRates(): array | ||
| { | ||
| return $this->individualRates; | ||
| } | ||
|
|
||
| /** | ||
| * @param HourlyIndividualRates[] $individualRates | ||
| */ | ||
| public function setIndividualRates(array $individualRates): void | ||
| { | ||
| if ($individualRates === []) { | ||
| throw new InvalidArgumentException('Argument "individualRates" cannot be empty'); | ||
| } | ||
|
|
||
| foreach ($individualRates as $individualRate) { | ||
| if (!$individualRate instanceof HourlyIndividualRates) { | ||
| throw new InvalidArgumentException( | ||
| 'Argument "individualRates" must contain only IndividualRates objects' | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| $this->individualRates = $individualRates; | ||
| } | ||
|
|
||
| public function toArray(): array | ||
| { | ||
| return [ | ||
| 'baseRates' => $this->baseRates->toArray(), | ||
| 'individualRates' => array_map(static function (HourlyIndividualRates $individualRate): array { | ||
| return $individualRate->toArray(); | ||
| }, $this->individualRates), | ||
| ]; | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.