-
Notifications
You must be signed in to change notification settings - Fork 36
feat(applications): add support for new endpoints #268
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
Open
innomaxx
wants to merge
4
commits into
master
Choose a base branch
from
feature/issue-170_add-applications-new-endpoints
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,174 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace CrowdinApiClient\Api; | ||
|
|
||
| use CrowdinApiClient\Model\ApplicationData; | ||
| use CrowdinApiClient\Model\ApplicationInstallation; | ||
| use CrowdinApiClient\ModelCollection; | ||
|
|
||
| /** | ||
| * Use API to manage custom application data. | ||
| * | ||
| * @package Crowdin\Api | ||
| */ | ||
| class ApplicationApi extends AbstractApi | ||
| { | ||
| /** | ||
| * Get Application Data | ||
| * @link https://developer.crowdin.com/api/v2/#operation/api.applications.api.get API Documentation | ||
| * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.applications.api.get API Documentation Enterprise | ||
| * | ||
| * @param string $applicationIdentifier | ||
| * @param string $path | ||
| * @param array $params | ||
| * @return ApplicationData|null | ||
| */ | ||
| public function getApplicationData(string $applicationIdentifier, string $path, array $params = []): ?ApplicationData | ||
| { | ||
| $url = sprintf('applications/%s/api/%s', $applicationIdentifier, $path); | ||
| return $this->_get($url, ApplicationData::class, $params); | ||
| } | ||
|
|
||
| /** | ||
| * Add Application Data | ||
| * @link https://developer.crowdin.com/api/v2/#operation/api.applications.api.post API Documentation | ||
| * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.applications.api.post API Documentation Enterprise | ||
| * | ||
| * @param string $applicationIdentifier | ||
| * @param string $path | ||
| * @param array $data | ||
| * @return ApplicationData|null | ||
| */ | ||
| public function addApplicationData(string $applicationIdentifier, string $path, array $data): ?ApplicationData | ||
| { | ||
| $url = sprintf('applications/%s/api/%s', $applicationIdentifier, $path); | ||
| return $this->_post($url, ApplicationData::class, $data); | ||
| } | ||
|
|
||
| /** | ||
| * Update or Restore Application Data | ||
| * @link https://developer.crowdin.com/api/v2/#operation/api.applications.api.put API Documentation | ||
| * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.applications.api.put API Documentation Enterprise | ||
| * | ||
| * @param string $applicationIdentifier | ||
| * @param string $path | ||
| * @param array $data | ||
| * @return ApplicationData|null | ||
| */ | ||
| public function updateOrRestoreApplicationData(string $applicationIdentifier, string $path, array $data): ?ApplicationData | ||
| { | ||
| $url = sprintf('applications/%s/api/%s', $applicationIdentifier, $path); | ||
| return $this->_put($url, ApplicationData::class, $data); | ||
| } | ||
|
|
||
| /** | ||
| * Delete Application Data | ||
| * @link https://developer.crowdin.com/api/v2/#operation/api.applications.api.delete API Documentation | ||
| * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.applications.api.delete API Documentation Enterprise | ||
| * | ||
| * @param string $applicationIdentifier | ||
| * @param string $path | ||
| * @return mixed | ||
| */ | ||
| public function deleteApplicationData(string $applicationIdentifier, string $path) | ||
| { | ||
| $url = sprintf('applications/%s/api/%s', $applicationIdentifier, $path); | ||
| return $this->_delete($url); | ||
| } | ||
|
|
||
| /** | ||
| * List Application Installations | ||
| * @link https://developer.crowdin.com/api/v2/#operation/api.applications.installations.getMany API Documentation | ||
| * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.applications.installations.getMany API Documentation Enterprise | ||
| * | ||
| * @param array $params | ||
| * integer $params[limit]<br> | ||
| * integer $params[offset]<br> | ||
| * integer $params[installedBy]<br> | ||
| * string $params[orderBy] | ||
| * @return ModelCollection | ||
| */ | ||
| public function listInstallations(array $params = []): ModelCollection | ||
| { | ||
| return $this->_list('applications/installations', ApplicationInstallation::class, $params); | ||
| } | ||
|
|
||
| /** | ||
| * Install Application | ||
| * @link https://developer.crowdin.com/api/v2/#operation/api.applications.installations.post API Documentation | ||
| * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.applications.installations.post API Documentation Enterprise | ||
| * | ||
| * @param array $data | ||
| * string $data[url] required<br> | ||
| * array $data[permissions]<br> | ||
| * array $data[modules]<br> | ||
| * bool $data[assignAgent] | ||
| * @return ApplicationInstallation|null | ||
| */ | ||
| public function installApplication(array $data): ?ApplicationInstallation | ||
| { | ||
| return $this->_create('applications/installations', ApplicationInstallation::class, $data); | ||
| } | ||
|
|
||
| /** | ||
| * Get Application Installation | ||
| * @link https://developer.crowdin.com/api/v2/#operation/api.applications.installations.get API Documentation | ||
| * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.applications.installations.get API Documentation Enterprise | ||
| * | ||
| * @param string $identifier | ||
| * @return ApplicationInstallation|null | ||
| */ | ||
| public function getInstallation(string $identifier): ?ApplicationInstallation | ||
| { | ||
| return $this->_get('applications/installations/' . $identifier, ApplicationInstallation::class); | ||
| } | ||
|
|
||
| /** | ||
| * Delete Application Installation | ||
| * @link https://developer.crowdin.com/api/v2/#operation/api.applications.installations.delete API Documentation | ||
| * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.applications.installations.delete API Documentation Enterprise | ||
| * | ||
| * @param string $identifier | ||
| * @param bool $force | ||
| * @return mixed | ||
| */ | ||
| public function deleteInstallation(string $identifier, bool $force = false) | ||
| { | ||
| $params = $force ? ['force' => true] : []; | ||
| return $this->_delete('applications/installations/' . $identifier, $params); | ||
| } | ||
|
|
||
| /** | ||
| * Edit Application Installation | ||
| * @link https://developer.crowdin.com/api/v2/#operation/api.applications.installations.patch API Documentation | ||
| * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.applications.installations.patch API Documentation Enterprise | ||
| * | ||
| * @param ApplicationInstallation $installation | ||
| * @return ApplicationInstallation|null | ||
| */ | ||
| public function updateInstallation(ApplicationInstallation $installation): ?ApplicationInstallation | ||
| { | ||
| return $this->_update('applications/installations/' . $installation->getIdentifier(), $installation); | ||
| } | ||
|
|
||
| /** | ||
| * Edit Application Data | ||
| * @link https://developer.crowdin.com/api/v2/#operation/api.applications.api.patch API Documentation | ||
| * @link https://developer.crowdin.com/enterprise/api/v2/#operation/api.applications.api.patch API Documentation Enterprise | ||
| * | ||
| * @param string $applicationIdentifier | ||
| * @param string $path | ||
| * @param array $data Application-specific key-value payload (free-form, not RFC 6902 patch operations) | ||
| * string $data[op] required Patch operation to perform (replace, add, remove, test)<br> | ||
| * string <json-pointer> $data[path] required<br> | ||
| * mixed $data[value] The value to be used within the operation (string, int, bool, or object) | ||
| * @return ApplicationData|null | ||
| */ | ||
| public function editApplicationData(string $applicationIdentifier, string $path, array $data): ?ApplicationData | ||
| { | ||
| $url = sprintf('applications/%s/api/%s', $applicationIdentifier, $path); | ||
| return $this->_patch($url, ApplicationData::class, $data); | ||
| } | ||
| } | ||
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,13 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace CrowdinApiClient\Model; | ||
|
|
||
| class ApplicationData extends BaseModel | ||
| { | ||
| public function __construct(array $data = []) | ||
| { | ||
| parent::__construct($data); | ||
| } | ||
| } |
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,165 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace CrowdinApiClient\Model; | ||
|
|
||
| class ApplicationInstallation extends BaseModel | ||
| { | ||
| /** @var string */ | ||
| protected $identifier; | ||
|
|
||
| /** @var string */ | ||
| protected $name; | ||
|
|
||
| /** @var array|null */ | ||
| protected $installedBy = null; | ||
|
|
||
| /** @var string|null */ | ||
| protected $description = null; | ||
|
|
||
| /** @var string */ | ||
| protected $logo; | ||
|
|
||
| /** @var array|null */ | ||
| protected $agent = null; | ||
|
|
||
| /** @var string */ | ||
| protected $baseUrl; | ||
|
|
||
| /** @var string */ | ||
| protected $manifestUrl; | ||
|
|
||
| /** @var string|null */ | ||
| protected $createdAt = null; | ||
|
|
||
| /** @var array */ | ||
| protected $modules = []; | ||
|
|
||
| /** @var array */ | ||
| protected $scopes = []; | ||
|
|
||
| /** @var array */ | ||
| protected $permissions = []; | ||
|
|
||
| /** @var array */ | ||
| protected $defaultPermissions = []; | ||
|
|
||
| /** @var bool */ | ||
| protected $limitReached; | ||
|
|
||
| /** @var bool */ | ||
| protected $stringBasedAvailable; | ||
|
|
||
| public function __construct(array $data = []) | ||
| { | ||
| parent::__construct($data); | ||
|
|
||
| $this->identifier = (string)$this->getDataProperty('identifier'); | ||
| $this->name = (string)$this->getDataProperty('name'); | ||
| $this->installedBy = $this->getDataProperty('installedBy'); | ||
| $this->description = $this->getDataProperty('description'); | ||
| $this->logo = (string)$this->getDataProperty('logo'); | ||
| $this->agent = $this->getDataProperty('agent'); | ||
| $this->baseUrl = (string)$this->getDataProperty('baseUrl'); | ||
| $this->manifestUrl = (string)$this->getDataProperty('manifestUrl'); | ||
| $this->createdAt = $this->getDataProperty('createdAt'); | ||
| $this->modules = (array)$this->getDataProperty('modules'); | ||
| $this->scopes = (array)$this->getDataProperty('scopes'); | ||
| $this->permissions = (array)$this->getDataProperty('permissions'); | ||
| $this->defaultPermissions = (array)$this->getDataProperty('defaultPermissions'); | ||
| $this->limitReached = (bool)$this->getDataProperty('limitReached'); | ||
| $this->stringBasedAvailable = (bool)$this->getDataProperty('stringBasedAvailable'); | ||
| } | ||
|
|
||
| public function getIdentifier(): string | ||
| { | ||
| return $this->identifier; | ||
| } | ||
|
|
||
| public function getName(): string | ||
| { | ||
| return $this->name; | ||
| } | ||
|
|
||
| /** | ||
| * @return array|null | ||
| */ | ||
| public function getInstalledBy(): ?array | ||
| { | ||
| return $this->installedBy; | ||
| } | ||
|
|
||
| public function getDescription(): ?string | ||
| { | ||
| return $this->description; | ||
| } | ||
|
|
||
| public function getLogo(): string | ||
| { | ||
| return $this->logo; | ||
| } | ||
|
|
||
| /** | ||
| * @return array|null | ||
| */ | ||
| public function getAgent(): ?array | ||
| { | ||
| return $this->agent; | ||
| } | ||
|
|
||
| public function getBaseUrl(): string | ||
| { | ||
| return $this->baseUrl; | ||
| } | ||
|
|
||
| public function getManifestUrl(): string | ||
| { | ||
| return $this->manifestUrl; | ||
| } | ||
|
|
||
| public function getCreatedAt(): ?string | ||
| { | ||
| return $this->createdAt; | ||
| } | ||
|
|
||
| public function getModules(): array | ||
| { | ||
| return $this->modules; | ||
| } | ||
|
|
||
| public function getScopes(): array | ||
| { | ||
| return $this->scopes; | ||
| } | ||
|
|
||
| public function getPermissions(): array | ||
| { | ||
| return $this->permissions; | ||
| } | ||
|
|
||
| public function getDefaultPermissions(): array | ||
| { | ||
| return $this->defaultPermissions; | ||
| } | ||
|
|
||
| public function isLimitReached(): bool | ||
| { | ||
| return $this->limitReached; | ||
| } | ||
|
|
||
| public function isStringBasedAvailable(): bool | ||
| { | ||
| return $this->stringBasedAvailable; | ||
| } | ||
|
|
||
| public function setPermissions(array $permissions): void | ||
| { | ||
| $this->permissions = $permissions; | ||
| } | ||
|
|
||
| public function setModules(array $modules): void | ||
| { | ||
| $this->modules = $modules; | ||
| } | ||
| } |
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.