diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index d3c991b..a930031 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -42,6 +42,7 @@ docs/Api/OrganizationJobTemplatesApi.md docs/Api/ProjectsApi.md docs/Api/QualityPerformanceScoreApi.md docs/Api/ReleasesApi.md +docs/Api/RepoSyncsApi.md docs/Api/ReportsApi.md docs/Api/ScreenshotMarkersApi.md docs/Api/ScreenshotsApi.md @@ -208,6 +209,11 @@ docs/Model/ReleaseCreateParameters.md docs/Model/ReleasePreview.md docs/Model/ReleaseUpdateParameters.md docs/Model/RepliesListParameters.md +docs/Model/RepoSync.md +docs/Model/RepoSyncEvent.md +docs/Model/RepoSyncEventErrorsInner.md +docs/Model/RepoSyncExport.md +docs/Model/RepoSyncImport.md docs/Model/Screenshot.md docs/Model/ScreenshotMarker.md docs/Model/ScreenshotMarkerCreateParameters.md @@ -308,6 +314,7 @@ lib/Api/OrganizationJobTemplatesApi.php lib/Api/ProjectsApi.php lib/Api/QualityPerformanceScoreApi.php lib/Api/ReleasesApi.php +lib/Api/RepoSyncsApi.php lib/Api/ReportsApi.php lib/Api/ScreenshotMarkersApi.php lib/Api/ScreenshotsApi.php @@ -478,6 +485,11 @@ lib/Model/ReleaseCreateParameters.php lib/Model/ReleasePreview.php lib/Model/ReleaseUpdateParameters.php lib/Model/RepliesListParameters.php +lib/Model/RepoSync.php +lib/Model/RepoSyncEvent.php +lib/Model/RepoSyncEventErrorsInner.php +lib/Model/RepoSyncExport.php +lib/Model/RepoSyncImport.php lib/Model/Screenshot.php lib/Model/ScreenshotMarker.php lib/Model/ScreenshotMarkerCreateParameters.php @@ -578,6 +590,7 @@ test/Api/OrganizationJobTemplatesApiTest.php test/Api/ProjectsApiTest.php test/Api/QualityPerformanceScoreApiTest.php test/Api/ReleasesApiTest.php +test/Api/RepoSyncsApiTest.php test/Api/ReportsApiTest.php test/Api/ScreenshotMarkersApiTest.php test/Api/ScreenshotsApiTest.php @@ -743,6 +756,11 @@ test/Model/ReleasePreviewTest.php test/Model/ReleaseTest.php test/Model/ReleaseUpdateParametersTest.php test/Model/RepliesListParametersTest.php +test/Model/RepoSyncEventErrorsInnerTest.php +test/Model/RepoSyncEventTest.php +test/Model/RepoSyncExportTest.php +test/Model/RepoSyncImportTest.php +test/Model/RepoSyncTest.php test/Model/ScreenshotMarkerCreateParametersTest.php test/Model/ScreenshotMarkerTest.php test/Model/ScreenshotMarkerUpdateParametersTest.php diff --git a/README.md b/README.md index fb6fccb..badc67d 100644 --- a/README.md +++ b/README.md @@ -333,6 +333,13 @@ Class | Method | HTTP request | Description *ReleasesApi* | [**releaseShow**](docs/Api/ReleasesApi.md#releaseshow) | **GET** /accounts/{account_id}/distributions/{distribution_id}/releases/{id} | Get a single release *ReleasesApi* | [**releaseUpdate**](docs/Api/ReleasesApi.md#releaseupdate) | **PATCH** /accounts/{account_id}/distributions/{distribution_id}/releases/{id} | Update a release *ReleasesApi* | [**releasesList**](docs/Api/ReleasesApi.md#releaseslist) | **GET** /accounts/{account_id}/distributions/{distribution_id}/releases | List releases +*RepoSyncsApi* | [**repoSyncActivate**](docs/Api/RepoSyncsApi.md#reposyncactivate) | **POST** /accounts/{account_id}/repo_syncs/{repo_sync_id}/activate | Activate a Repo Sync +*RepoSyncsApi* | [**repoSyncDeactivate**](docs/Api/RepoSyncsApi.md#reposyncdeactivate) | **POST** /accounts/{account_id}/repo_syncs/{repo_sync_id}/deactivate | Deactivate a Repo Sync +*RepoSyncsApi* | [**repoSyncEvents**](docs/Api/RepoSyncsApi.md#reposyncevents) | **GET** /accounts/{account_id}/repo_syncs/{repo_sync_id}/events | Repository Syncs History +*RepoSyncsApi* | [**repoSyncExport**](docs/Api/RepoSyncsApi.md#reposyncexport) | **POST** /accounts/{account_id}/repo_syncs/{repo_sync_id}/export | Export to code repository +*RepoSyncsApi* | [**repoSyncImport**](docs/Api/RepoSyncsApi.md#reposyncimport) | **POST** /accounts/{account_id}/repo_syncs/{repo_sync_id}/import | Import from code repository +*RepoSyncsApi* | [**repoSyncList**](docs/Api/RepoSyncsApi.md#reposynclist) | **GET** /accounts/{account_id}/repo_syncs | Get Repo Syncs +*RepoSyncsApi* | [**repoSyncShow**](docs/Api/RepoSyncsApi.md#reposyncshow) | **GET** /accounts/{account_id}/repo_syncs/{repo_sync_id} | Get a single Repo Sync *ReportsApi* | [**reportLocalesList**](docs/Api/ReportsApi.md#reportlocaleslist) | **GET** /projects/{project_id}/report/locales | List Locale Reports *ReportsApi* | [**reportShow**](docs/Api/ReportsApi.md#reportshow) | **GET** /projects/{project_id}/report | Get Project Report *ScreenshotMarkersApi* | [**screenshotMarkerCreate**](docs/Api/ScreenshotMarkersApi.md#screenshotmarkercreate) | **POST** /projects/{project_id}/screenshots/{screenshot_id}/markers | Create a screenshot marker @@ -566,6 +573,11 @@ Class | Method | HTTP request | Description - [ReleasePreview](docs/Model/ReleasePreview.md) - [ReleaseUpdateParameters](docs/Model/ReleaseUpdateParameters.md) - [RepliesListParameters](docs/Model/RepliesListParameters.md) + - [RepoSync](docs/Model/RepoSync.md) + - [RepoSyncEvent](docs/Model/RepoSyncEvent.md) + - [RepoSyncEventErrorsInner](docs/Model/RepoSyncEventErrorsInner.md) + - [RepoSyncExport](docs/Model/RepoSyncExport.md) + - [RepoSyncImport](docs/Model/RepoSyncImport.md) - [Screenshot](docs/Model/Screenshot.md) - [ScreenshotMarker](docs/Model/ScreenshotMarker.md) - [ScreenshotMarkerCreateParameters](docs/Model/ScreenshotMarkerCreateParameters.md) diff --git a/docs/Api/RepoSyncsApi.md b/docs/Api/RepoSyncsApi.md new file mode 100644 index 0000000..796a312 --- /dev/null +++ b/docs/Api/RepoSyncsApi.md @@ -0,0 +1,454 @@ +# Phrase\RepoSyncsApi + +All URIs are relative to *https://api.phrase.com/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**repoSyncActivate**](RepoSyncsApi.md#repoSyncActivate) | **POST** /accounts/{account_id}/repo_syncs/{repo_sync_id}/activate | Activate a Repo Sync +[**repoSyncDeactivate**](RepoSyncsApi.md#repoSyncDeactivate) | **POST** /accounts/{account_id}/repo_syncs/{repo_sync_id}/deactivate | Deactivate a Repo Sync +[**repoSyncEvents**](RepoSyncsApi.md#repoSyncEvents) | **GET** /accounts/{account_id}/repo_syncs/{repo_sync_id}/events | Repository Syncs History +[**repoSyncExport**](RepoSyncsApi.md#repoSyncExport) | **POST** /accounts/{account_id}/repo_syncs/{repo_sync_id}/export | Export to code repository +[**repoSyncImport**](RepoSyncsApi.md#repoSyncImport) | **POST** /accounts/{account_id}/repo_syncs/{repo_sync_id}/import | Import from code repository +[**repoSyncList**](RepoSyncsApi.md#repoSyncList) | **GET** /accounts/{account_id}/repo_syncs | Get Repo Syncs +[**repoSyncShow**](RepoSyncsApi.md#repoSyncShow) | **GET** /accounts/{account_id}/repo_syncs/{repo_sync_id} | Get a single Repo Sync + + + +## repoSyncActivate + +> \Phrase\Model\RepoSync repoSyncActivate($account_id, $repo_sync_id, $x_phrase_app_otp) + +Activate a Repo Sync + +Activate a deactivated Repo Sync. Active syncs can be used to import and export translations, and imports to Phrase are automatically triggered by pushes to the repository, if configured. + +### Example + +```php +setApiKey('Authorization', 'YOUR_API_KEY'); +$config = Phrase\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'token'); + +$apiInstance = new Phrase\Api\RepoSyncsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$account_id = 'account_id_example'; // string | Account ID +$repo_sync_id = 'repo_sync_id_example'; // string | Repo Sync ID +$x_phrase_app_otp = 'x_phrase_app_otp_example'; // string | Two-Factor-Authentication token (optional) + +try { + $result = $apiInstance->repoSyncActivate($account_id, $repo_sync_id, $x_phrase_app_otp); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling RepoSyncsApi->repoSyncActivate: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **account_id** | **string**| Account ID | + **repo_sync_id** | **string**| Repo Sync ID | + **x_phrase_app_otp** | **string**| Two-Factor-Authentication token (optional) | [optional] + +### Return type + +[**\Phrase\Model\RepoSync**](../Model/RepoSync.md) + +### Authorization + +[Basic](../../README.md#Basic), [Token](../../README.md#Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../../README.md#documentation-for-models) +[[Back to README]](../../README.md) + + +## repoSyncDeactivate + +> \Phrase\Model\RepoSync repoSyncDeactivate($account_id, $repo_sync_id, $x_phrase_app_otp) + +Deactivate a Repo Sync + +Deactivate an active Repo Sync. Import and export can't be performed on deactivated syncs and the pushes to the repository won't trigger the import to Phrase. + +### Example + +```php +setApiKey('Authorization', 'YOUR_API_KEY'); +$config = Phrase\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'token'); + +$apiInstance = new Phrase\Api\RepoSyncsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$account_id = 'account_id_example'; // string | Account ID +$repo_sync_id = 'repo_sync_id_example'; // string | Repo Sync ID +$x_phrase_app_otp = 'x_phrase_app_otp_example'; // string | Two-Factor-Authentication token (optional) + +try { + $result = $apiInstance->repoSyncDeactivate($account_id, $repo_sync_id, $x_phrase_app_otp); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling RepoSyncsApi->repoSyncDeactivate: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **account_id** | **string**| Account ID | + **repo_sync_id** | **string**| Repo Sync ID | + **x_phrase_app_otp** | **string**| Two-Factor-Authentication token (optional) | [optional] + +### Return type + +[**\Phrase\Model\RepoSync**](../Model/RepoSync.md) + +### Authorization + +[Basic](../../README.md#Basic), [Token](../../README.md#Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../../README.md#documentation-for-models) +[[Back to README]](../../README.md) + + +## repoSyncEvents + +> \Phrase\Model\RepoSyncEvent[] repoSyncEvents($account_id, $repo_sync_id, $x_phrase_app_otp) + +Repository Syncs History + +Get the history of a single Repo Sync. The history includes all imports and exports performed by the Repo Sync. + +### Example + +```php +setApiKey('Authorization', 'YOUR_API_KEY'); +$config = Phrase\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'token'); + +$apiInstance = new Phrase\Api\RepoSyncsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$account_id = 'account_id_example'; // string | Account ID +$repo_sync_id = 'repo_sync_id_example'; // string | Repo Sync ID +$x_phrase_app_otp = 'x_phrase_app_otp_example'; // string | Two-Factor-Authentication token (optional) + +try { + $result = $apiInstance->repoSyncEvents($account_id, $repo_sync_id, $x_phrase_app_otp); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling RepoSyncsApi->repoSyncEvents: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **account_id** | **string**| Account ID | + **repo_sync_id** | **string**| Repo Sync ID | + **x_phrase_app_otp** | **string**| Two-Factor-Authentication token (optional) | [optional] + +### Return type + +[**\Phrase\Model\RepoSyncEvent[]**](../Model/RepoSyncEvent.md) + +### Authorization + +[Basic](../../README.md#Basic), [Token](../../README.md#Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../../README.md#documentation-for-models) +[[Back to README]](../../README.md) + + +## repoSyncExport + +> \Phrase\Model\RepoSyncExport repoSyncExport($account_id, $repo_sync_id, $x_phrase_app_otp) + +Export to code repository + +> Beta: this feature will change in the future. Export translations from Phrase Strings to repository provider according to the .phrase.yml file within the code repository. *Export is done asynchronously and may take several seconds depending on the project size.* + +### Example + +```php +setApiKey('Authorization', 'YOUR_API_KEY'); +$config = Phrase\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'token'); + +$apiInstance = new Phrase\Api\RepoSyncsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$account_id = 'account_id_example'; // string | Account ID +$repo_sync_id = 'repo_sync_id_example'; // string | Repo Sync ID +$x_phrase_app_otp = 'x_phrase_app_otp_example'; // string | Two-Factor-Authentication token (optional) + +try { + $result = $apiInstance->repoSyncExport($account_id, $repo_sync_id, $x_phrase_app_otp); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling RepoSyncsApi->repoSyncExport: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **account_id** | **string**| Account ID | + **repo_sync_id** | **string**| Repo Sync ID | + **x_phrase_app_otp** | **string**| Two-Factor-Authentication token (optional) | [optional] + +### Return type + +[**\Phrase\Model\RepoSyncExport**](../Model/RepoSyncExport.md) + +### Authorization + +[Basic](../../README.md#Basic), [Token](../../README.md#Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../../README.md#documentation-for-models) +[[Back to README]](../../README.md) + + +## repoSyncImport + +> \Phrase\Model\RepoSyncImport repoSyncImport($account_id, $repo_sync_id, $x_phrase_app_otp) + +Import from code repository + +> Beta: this feature will change in the future. Import translations from repository provider to Phrase Strings according to the .phrase.yml file within the code repository. _Import is done asynchronously and may take several seconds depending on the project size._ + +### Example + +```php +setApiKey('Authorization', 'YOUR_API_KEY'); +$config = Phrase\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'token'); + +$apiInstance = new Phrase\Api\RepoSyncsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$account_id = 'account_id_example'; // string | Account ID +$repo_sync_id = 'repo_sync_id_example'; // string | Repo Sync ID +$x_phrase_app_otp = 'x_phrase_app_otp_example'; // string | Two-Factor-Authentication token (optional) + +try { + $result = $apiInstance->repoSyncImport($account_id, $repo_sync_id, $x_phrase_app_otp); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling RepoSyncsApi->repoSyncImport: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **account_id** | **string**| Account ID | + **repo_sync_id** | **string**| Repo Sync ID | + **x_phrase_app_otp** | **string**| Two-Factor-Authentication token (optional) | [optional] + +### Return type + +[**\Phrase\Model\RepoSyncImport**](../Model/RepoSyncImport.md) + +### Authorization + +[Basic](../../README.md#Basic), [Token](../../README.md#Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../../README.md#documentation-for-models) +[[Back to README]](../../README.md) + + +## repoSyncList + +> \Phrase\Model\RepoSync[] repoSyncList($account_id, $x_phrase_app_otp) + +Get Repo Syncs + +Lists all Repo Syncs from an account + +### Example + +```php +setApiKey('Authorization', 'YOUR_API_KEY'); +$config = Phrase\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'token'); + +$apiInstance = new Phrase\Api\RepoSyncsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$account_id = 'account_id_example'; // string | Account ID +$x_phrase_app_otp = 'x_phrase_app_otp_example'; // string | Two-Factor-Authentication token (optional) + +try { + $result = $apiInstance->repoSyncList($account_id, $x_phrase_app_otp); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling RepoSyncsApi->repoSyncList: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **account_id** | **string**| Account ID | + **x_phrase_app_otp** | **string**| Two-Factor-Authentication token (optional) | [optional] + +### Return type + +[**\Phrase\Model\RepoSync[]**](../Model/RepoSync.md) + +### Authorization + +[Basic](../../README.md#Basic), [Token](../../README.md#Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../../README.md#documentation-for-models) +[[Back to README]](../../README.md) + + +## repoSyncShow + +> \Phrase\Model\RepoSync repoSyncShow($account_id, $repo_sync_id, $x_phrase_app_otp) + +Get a single Repo Sync + +Shows a single Repo Sync setting. + +### Example + +```php +setApiKey('Authorization', 'YOUR_API_KEY'); +$config = Phrase\Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'token'); + +$apiInstance = new Phrase\Api\RepoSyncsApi( + // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`. + // This is optional, `GuzzleHttp\Client` will be used as default. + new GuzzleHttp\Client(), + $config +); +$account_id = 'account_id_example'; // string | Account ID +$repo_sync_id = 'repo_sync_id_example'; // string | Repo Sync ID +$x_phrase_app_otp = 'x_phrase_app_otp_example'; // string | Two-Factor-Authentication token (optional) + +try { + $result = $apiInstance->repoSyncShow($account_id, $repo_sync_id, $x_phrase_app_otp); + print_r($result); +} catch (Exception $e) { + echo 'Exception when calling RepoSyncsApi->repoSyncShow: ', $e->getMessage(), PHP_EOL; +} +?> +``` + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **account_id** | **string**| Account ID | + **repo_sync_id** | **string**| Repo Sync ID | + **x_phrase_app_otp** | **string**| Two-Factor-Authentication token (optional) | [optional] + +### Return type + +[**\Phrase\Model\RepoSync**](../Model/RepoSync.md) + +### Authorization + +[Basic](../../README.md#Basic), [Token](../../README.md#Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../../README.md#documentation-for-models) +[[Back to README]](../../README.md) + diff --git a/docs/Model/RepoSync.md b/docs/Model/RepoSync.md new file mode 100644 index 0000000..0840309 --- /dev/null +++ b/docs/Model/RepoSync.md @@ -0,0 +1,19 @@ +# # RepoSync + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **string** | | [optional] +**project** | [**\Phrase\Model\ProjectShort**](ProjectShort.md) | | [optional] +**provider** | **string** | | [optional] +**enabled** | **bool** | | [optional] +**auto_import** | **bool** | | [optional] +**repo_name** | **string** | | [optional] +**created_at** | **\DateTime** | | [optional] +**last_import_at** | **\DateTime** | | [optional] +**last_export_at** | **\DateTime** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + + diff --git a/docs/Model/RepoSyncEvent.md b/docs/Model/RepoSyncEvent.md new file mode 100644 index 0000000..4c31dac --- /dev/null +++ b/docs/Model/RepoSyncEvent.md @@ -0,0 +1,16 @@ +# # RepoSyncEvent + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**event_type** | **string** | | [optional] +**created_at** | **\DateTime** | | [optional] +**status** | **string** | | [optional] +**pull_request_url** | **string** | URL of the pull request created on export | [optional] +**auto_import** | **bool** | Whether the import was triggered by the repo push event | [optional] +**errors** | [**\Phrase\Model\RepoSyncEventErrorsInner[]**](RepoSyncEventErrorsInner.md) | List of error messages, in case of failure | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + + diff --git a/docs/Model/RepoSyncEventErrorsInner.md b/docs/Model/RepoSyncEventErrorsInner.md new file mode 100644 index 0000000..1155376 --- /dev/null +++ b/docs/Model/RepoSyncEventErrorsInner.md @@ -0,0 +1,10 @@ +# # RepoSyncEventErrorsInner + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + + diff --git a/docs/Model/RepoSyncExport.md b/docs/Model/RepoSyncExport.md new file mode 100644 index 0000000..3ce33a6 --- /dev/null +++ b/docs/Model/RepoSyncExport.md @@ -0,0 +1,11 @@ +# # RepoSyncExport + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**message** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + + diff --git a/docs/Model/RepoSyncImport.md b/docs/Model/RepoSyncImport.md new file mode 100644 index 0000000..21ebbce --- /dev/null +++ b/docs/Model/RepoSyncImport.md @@ -0,0 +1,11 @@ +# # RepoSyncImport + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**message** | **string** | | [optional] + +[[Back to Model list]](../../README.md#documentation-for-models) [[Back to API list]](../../README.md#documentation-for-api-endpoints) [[Back to README]](../../README.md) + + diff --git a/lib/Api/RepoSyncsApi.php b/lib/Api/RepoSyncsApi.php new file mode 100644 index 0000000..f4ae961 --- /dev/null +++ b/lib/Api/RepoSyncsApi.php @@ -0,0 +1,2300 @@ +client = $client ?: new Client(); + $this->config = $config ?: new Configuration(); + $this->headerSelector = $selector ?: new HeaderSelector(); + $this->hostIndex = $host_index; + } + + /** + * Set the host index + * + * @param int Host index (required) + */ + public function setHostIndex($host_index) + { + $this->hostIndex = $host_index; + } + + /** + * Get the host index + * + * @return Host index + */ + public function getHostIndex() + { + return $this->hostIndex; + } + + /** + * @return Configuration + */ + public function getConfig() + { + return $this->config; + } + + /** + * Operation repoSyncActivate + * + * Activate a Repo Sync + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \Phrase\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Phrase\Model\RepoSync + */ + public function repoSyncActivate($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + list($response) = $this->repoSyncActivateWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp); + return $response; + } + + /** + * Operation repoSyncActivateWithHttpInfo + * + * Activate a Repo Sync + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \Phrase\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Phrase\Model\RepoSync, HTTP status code, HTTP response headers (array of strings) + */ + public function repoSyncActivateWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + $request = $this->repoSyncActivateRequest($account_id, $repo_sync_id, $x_phrase_app_otp); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\Phrase\Model\RepoSync' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, '\Phrase\Model\RepoSync', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Phrase\Model\RepoSync'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Phrase\Model\RepoSync', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation repoSyncActivateAsync + * + * Activate a Repo Sync + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function repoSyncActivateAsync($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + return $this->repoSyncActivateAsyncWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation repoSyncActivateAsyncWithHttpInfo + * + * Activate a Repo Sync + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function repoSyncActivateAsyncWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + $returnType = '\Phrase\Model\RepoSync'; + $request = $this->repoSyncActivateRequest($account_id, $repo_sync_id, $x_phrase_app_otp); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'repoSyncActivate' + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function repoSyncActivateRequest($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + // verify the required parameter 'account_id' is set + if ($account_id === null || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $account_id when calling repoSyncActivate' + ); + } + // verify the required parameter 'repo_sync_id' is set + if ($repo_sync_id === null || (is_array($repo_sync_id) && count($repo_sync_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $repo_sync_id when calling repoSyncActivate' + ); + } + + $resourcePath = '/accounts/{account_id}/repo_syncs/{repo_sync_id}/activate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // header params + if ($x_phrase_app_otp !== null) { + $headerParams['X-PhraseApp-OTP'] = ObjectSerializer::toHeaderValue($x_phrase_app_otp); + } + + // path params + if ($account_id !== null) { + $resourcePath = str_replace( + '{' . 'account_id' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + // path params + if ($repo_sync_id !== null) { + $resourcePath = str_replace( + '{' . 'repo_sync_id' . '}', + ObjectSerializer::toPathValue($repo_sync_id), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + if ($apiKey !== null) { + $headers['Authorization'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\Query::build($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation repoSyncDeactivate + * + * Deactivate a Repo Sync + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \Phrase\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Phrase\Model\RepoSync + */ + public function repoSyncDeactivate($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + list($response) = $this->repoSyncDeactivateWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp); + return $response; + } + + /** + * Operation repoSyncDeactivateWithHttpInfo + * + * Deactivate a Repo Sync + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \Phrase\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Phrase\Model\RepoSync, HTTP status code, HTTP response headers (array of strings) + */ + public function repoSyncDeactivateWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + $request = $this->repoSyncDeactivateRequest($account_id, $repo_sync_id, $x_phrase_app_otp); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\Phrase\Model\RepoSync' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, '\Phrase\Model\RepoSync', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Phrase\Model\RepoSync'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Phrase\Model\RepoSync', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation repoSyncDeactivateAsync + * + * Deactivate a Repo Sync + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function repoSyncDeactivateAsync($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + return $this->repoSyncDeactivateAsyncWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation repoSyncDeactivateAsyncWithHttpInfo + * + * Deactivate a Repo Sync + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function repoSyncDeactivateAsyncWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + $returnType = '\Phrase\Model\RepoSync'; + $request = $this->repoSyncDeactivateRequest($account_id, $repo_sync_id, $x_phrase_app_otp); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'repoSyncDeactivate' + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function repoSyncDeactivateRequest($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + // verify the required parameter 'account_id' is set + if ($account_id === null || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $account_id when calling repoSyncDeactivate' + ); + } + // verify the required parameter 'repo_sync_id' is set + if ($repo_sync_id === null || (is_array($repo_sync_id) && count($repo_sync_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $repo_sync_id when calling repoSyncDeactivate' + ); + } + + $resourcePath = '/accounts/{account_id}/repo_syncs/{repo_sync_id}/deactivate'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // header params + if ($x_phrase_app_otp !== null) { + $headerParams['X-PhraseApp-OTP'] = ObjectSerializer::toHeaderValue($x_phrase_app_otp); + } + + // path params + if ($account_id !== null) { + $resourcePath = str_replace( + '{' . 'account_id' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + // path params + if ($repo_sync_id !== null) { + $resourcePath = str_replace( + '{' . 'repo_sync_id' . '}', + ObjectSerializer::toPathValue($repo_sync_id), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + if ($apiKey !== null) { + $headers['Authorization'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\Query::build($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation repoSyncEvents + * + * Repository Syncs History + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \Phrase\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Phrase\Model\RepoSyncEvent[] + */ + public function repoSyncEvents($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + list($response) = $this->repoSyncEventsWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp); + return $response; + } + + /** + * Operation repoSyncEventsWithHttpInfo + * + * Repository Syncs History + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \Phrase\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Phrase\Model\RepoSyncEvent[], HTTP status code, HTTP response headers (array of strings) + */ + public function repoSyncEventsWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + $request = $this->repoSyncEventsRequest($account_id, $repo_sync_id, $x_phrase_app_otp); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\Phrase\Model\RepoSyncEvent[]' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, '\Phrase\Model\RepoSyncEvent[]', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Phrase\Model\RepoSyncEvent[]'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Phrase\Model\RepoSyncEvent[]', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation repoSyncEventsAsync + * + * Repository Syncs History + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function repoSyncEventsAsync($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + return $this->repoSyncEventsAsyncWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation repoSyncEventsAsyncWithHttpInfo + * + * Repository Syncs History + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function repoSyncEventsAsyncWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + $returnType = '\Phrase\Model\RepoSyncEvent[]'; + $request = $this->repoSyncEventsRequest($account_id, $repo_sync_id, $x_phrase_app_otp); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'repoSyncEvents' + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function repoSyncEventsRequest($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + // verify the required parameter 'account_id' is set + if ($account_id === null || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $account_id when calling repoSyncEvents' + ); + } + // verify the required parameter 'repo_sync_id' is set + if ($repo_sync_id === null || (is_array($repo_sync_id) && count($repo_sync_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $repo_sync_id when calling repoSyncEvents' + ); + } + + $resourcePath = '/accounts/{account_id}/repo_syncs/{repo_sync_id}/events'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // header params + if ($x_phrase_app_otp !== null) { + $headerParams['X-PhraseApp-OTP'] = ObjectSerializer::toHeaderValue($x_phrase_app_otp); + } + + // path params + if ($account_id !== null) { + $resourcePath = str_replace( + '{' . 'account_id' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + // path params + if ($repo_sync_id !== null) { + $resourcePath = str_replace( + '{' . 'repo_sync_id' . '}', + ObjectSerializer::toPathValue($repo_sync_id), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + if ($apiKey !== null) { + $headers['Authorization'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\Query::build($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation repoSyncExport + * + * Export to code repository + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \Phrase\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Phrase\Model\RepoSyncExport + */ + public function repoSyncExport($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + list($response) = $this->repoSyncExportWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp); + return $response; + } + + /** + * Operation repoSyncExportWithHttpInfo + * + * Export to code repository + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \Phrase\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Phrase\Model\RepoSyncExport, HTTP status code, HTTP response headers (array of strings) + */ + public function repoSyncExportWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + $request = $this->repoSyncExportRequest($account_id, $repo_sync_id, $x_phrase_app_otp); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\Phrase\Model\RepoSyncExport' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, '\Phrase\Model\RepoSyncExport', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Phrase\Model\RepoSyncExport'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Phrase\Model\RepoSyncExport', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation repoSyncExportAsync + * + * Export to code repository + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function repoSyncExportAsync($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + return $this->repoSyncExportAsyncWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation repoSyncExportAsyncWithHttpInfo + * + * Export to code repository + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function repoSyncExportAsyncWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + $returnType = '\Phrase\Model\RepoSyncExport'; + $request = $this->repoSyncExportRequest($account_id, $repo_sync_id, $x_phrase_app_otp); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'repoSyncExport' + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function repoSyncExportRequest($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + // verify the required parameter 'account_id' is set + if ($account_id === null || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $account_id when calling repoSyncExport' + ); + } + // verify the required parameter 'repo_sync_id' is set + if ($repo_sync_id === null || (is_array($repo_sync_id) && count($repo_sync_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $repo_sync_id when calling repoSyncExport' + ); + } + + $resourcePath = '/accounts/{account_id}/repo_syncs/{repo_sync_id}/export'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // header params + if ($x_phrase_app_otp !== null) { + $headerParams['X-PhraseApp-OTP'] = ObjectSerializer::toHeaderValue($x_phrase_app_otp); + } + + // path params + if ($account_id !== null) { + $resourcePath = str_replace( + '{' . 'account_id' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + // path params + if ($repo_sync_id !== null) { + $resourcePath = str_replace( + '{' . 'repo_sync_id' . '}', + ObjectSerializer::toPathValue($repo_sync_id), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + if ($apiKey !== null) { + $headers['Authorization'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\Query::build($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation repoSyncImport + * + * Import from code repository + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \Phrase\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Phrase\Model\RepoSyncImport + */ + public function repoSyncImport($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + list($response) = $this->repoSyncImportWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp); + return $response; + } + + /** + * Operation repoSyncImportWithHttpInfo + * + * Import from code repository + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \Phrase\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Phrase\Model\RepoSyncImport, HTTP status code, HTTP response headers (array of strings) + */ + public function repoSyncImportWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + $request = $this->repoSyncImportRequest($account_id, $repo_sync_id, $x_phrase_app_otp); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\Phrase\Model\RepoSyncImport' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, '\Phrase\Model\RepoSyncImport', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Phrase\Model\RepoSyncImport'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Phrase\Model\RepoSyncImport', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation repoSyncImportAsync + * + * Import from code repository + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function repoSyncImportAsync($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + return $this->repoSyncImportAsyncWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation repoSyncImportAsyncWithHttpInfo + * + * Import from code repository + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function repoSyncImportAsyncWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + $returnType = '\Phrase\Model\RepoSyncImport'; + $request = $this->repoSyncImportRequest($account_id, $repo_sync_id, $x_phrase_app_otp); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'repoSyncImport' + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function repoSyncImportRequest($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + // verify the required parameter 'account_id' is set + if ($account_id === null || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $account_id when calling repoSyncImport' + ); + } + // verify the required parameter 'repo_sync_id' is set + if ($repo_sync_id === null || (is_array($repo_sync_id) && count($repo_sync_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $repo_sync_id when calling repoSyncImport' + ); + } + + $resourcePath = '/accounts/{account_id}/repo_syncs/{repo_sync_id}/import'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // header params + if ($x_phrase_app_otp !== null) { + $headerParams['X-PhraseApp-OTP'] = ObjectSerializer::toHeaderValue($x_phrase_app_otp); + } + + // path params + if ($account_id !== null) { + $resourcePath = str_replace( + '{' . 'account_id' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + // path params + if ($repo_sync_id !== null) { + $resourcePath = str_replace( + '{' . 'repo_sync_id' . '}', + ObjectSerializer::toPathValue($repo_sync_id), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + if ($apiKey !== null) { + $headers['Authorization'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\Query::build($queryParams); + return new Request( + 'POST', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation repoSyncList + * + * Get Repo Syncs + * + * @param string $account_id Account ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \Phrase\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Phrase\Model\RepoSync[] + */ + public function repoSyncList($account_id, $x_phrase_app_otp = null) + { + list($response) = $this->repoSyncListWithHttpInfo($account_id, $x_phrase_app_otp); + return $response; + } + + /** + * Operation repoSyncListWithHttpInfo + * + * Get Repo Syncs + * + * @param string $account_id Account ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \Phrase\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Phrase\Model\RepoSync[], HTTP status code, HTTP response headers (array of strings) + */ + public function repoSyncListWithHttpInfo($account_id, $x_phrase_app_otp = null) + { + $request = $this->repoSyncListRequest($account_id, $x_phrase_app_otp); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\Phrase\Model\RepoSync[]' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, '\Phrase\Model\RepoSync[]', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Phrase\Model\RepoSync[]'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Phrase\Model\RepoSync[]', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation repoSyncListAsync + * + * Get Repo Syncs + * + * @param string $account_id Account ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function repoSyncListAsync($account_id, $x_phrase_app_otp = null) + { + return $this->repoSyncListAsyncWithHttpInfo($account_id, $x_phrase_app_otp) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation repoSyncListAsyncWithHttpInfo + * + * Get Repo Syncs + * + * @param string $account_id Account ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function repoSyncListAsyncWithHttpInfo($account_id, $x_phrase_app_otp = null) + { + $returnType = '\Phrase\Model\RepoSync[]'; + $request = $this->repoSyncListRequest($account_id, $x_phrase_app_otp); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'repoSyncList' + * + * @param string $account_id Account ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function repoSyncListRequest($account_id, $x_phrase_app_otp = null) + { + // verify the required parameter 'account_id' is set + if ($account_id === null || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $account_id when calling repoSyncList' + ); + } + + $resourcePath = '/accounts/{account_id}/repo_syncs'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // header params + if ($x_phrase_app_otp !== null) { + $headerParams['X-PhraseApp-OTP'] = ObjectSerializer::toHeaderValue($x_phrase_app_otp); + } + + // path params + if ($account_id !== null) { + $resourcePath = str_replace( + '{' . 'account_id' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + if ($apiKey !== null) { + $headers['Authorization'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\Query::build($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Operation repoSyncShow + * + * Get a single Repo Sync + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \Phrase\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \Phrase\Model\RepoSync + */ + public function repoSyncShow($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + list($response) = $this->repoSyncShowWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp); + return $response; + } + + /** + * Operation repoSyncShowWithHttpInfo + * + * Get a single Repo Sync + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \Phrase\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \Phrase\Model\RepoSync, HTTP status code, HTTP response headers (array of strings) + */ + public function repoSyncShowWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + $request = $this->repoSyncShowRequest($account_id, $repo_sync_id, $x_phrase_app_otp); + + try { + $options = $this->createHttpClientOption(); + try { + $response = $this->client->send($request, $options); + } catch (RequestException $e) { + throw new ApiException( + "[{$e->getCode()}] {$e->getMessage()}", + $e->getCode(), + $e->getResponse() ? $e->getResponse()->getHeaders() : null, + $e->getResponse() ? (string) $e->getResponse()->getBody() : null + ); + } + + $statusCode = $response->getStatusCode(); + + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $request->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + + $responseBody = $response->getBody(); + switch($statusCode) { + case 200: + if ('\Phrase\Model\RepoSync' === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, '\Phrase\Model\RepoSync', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\Phrase\Model\RepoSync'; + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\Phrase\Model\RepoSync', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation repoSyncShowAsync + * + * Get a single Repo Sync + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function repoSyncShowAsync($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + return $this->repoSyncShowAsyncWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation repoSyncShowAsyncWithHttpInfo + * + * Get a single Repo Sync + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function repoSyncShowAsyncWithHttpInfo($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + $returnType = '\Phrase\Model\RepoSync'; + $request = $this->repoSyncShowRequest($account_id, $repo_sync_id, $x_phrase_app_otp); + + return $this->client + ->sendAsync($request, $this->createHttpClientOption()) + ->then( + function ($response) use ($returnType) { + $responseBody = $response->getBody(); + if ($returnType === '\SplFileObject') { + $content = $responseBody; //stream goes to serializer + } else { + $content = (string) $responseBody; + } + + return [ + ObjectSerializer::deserialize($content, $returnType, []), + $response->getStatusCode(), + $response->getHeaders() + ]; + }, + function ($exception) { + $response = $exception->getResponse(); + $statusCode = $response->getStatusCode(); + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + $exception->getRequest()->getUri() + ), + $statusCode, + $response->getHeaders(), + $response->getBody() + ); + } + ); + } + + /** + * Create request for operation 'repoSyncShow' + * + * @param string $account_id Account ID (required) + * @param string $repo_sync_id Repo Sync ID (required) + * @param string $x_phrase_app_otp Two-Factor-Authentication token (optional) (optional) + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + protected function repoSyncShowRequest($account_id, $repo_sync_id, $x_phrase_app_otp = null) + { + // verify the required parameter 'account_id' is set + if ($account_id === null || (is_array($account_id) && count($account_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $account_id when calling repoSyncShow' + ); + } + // verify the required parameter 'repo_sync_id' is set + if ($repo_sync_id === null || (is_array($repo_sync_id) && count($repo_sync_id) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $repo_sync_id when calling repoSyncShow' + ); + } + + $resourcePath = '/accounts/{account_id}/repo_syncs/{repo_sync_id}'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + // header params + if ($x_phrase_app_otp !== null) { + $headerParams['X-PhraseApp-OTP'] = ObjectSerializer::toHeaderValue($x_phrase_app_otp); + } + + // path params + if ($account_id !== null) { + $resourcePath = str_replace( + '{' . 'account_id' . '}', + ObjectSerializer::toPathValue($account_id), + $resourcePath + ); + } + // path params + if ($repo_sync_id !== null) { + $resourcePath = str_replace( + '{' . 'repo_sync_id' . '}', + ObjectSerializer::toPathValue($repo_sync_id), + $resourcePath + ); + } + + // body params + $_tempBody = null; + + if ($multipart) { + $headers = $this->headerSelector->selectHeadersForMultipart( + ['application/json'] + ); + } else { + $headers = $this->headerSelector->selectHeaders( + ['application/json'], + [] + ); + } + + // for model (json/xml) + if (isset($_tempBody)) { + // $_tempBody is the method argument, if present + if ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($_tempBody)); + } else { + $httpBody = $_tempBody; + } + } elseif (count($formParams) > 0) { + if ($multipart) { + $multipartContents = []; + foreach ($formParams as $formParamName => $formParamValue) { + $multipartContents[] = [ + 'name' => $formParamName, + 'contents' => $formParamValue + ]; + } + // for HTTP post (form) + $httpBody = new MultipartStream($multipartContents); + + } elseif ($headers['Content-Type'] === 'application/json') { + $httpBody = \GuzzleHttp\json_encode($formParams); + + } else { + // for HTTP post (form) + $httpBody = \GuzzleHttp\Psr7\Query::build($formParams); + } + } + + // this endpoint requires HTTP basic authentication + if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { + $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); + } + // this endpoint requires API key authentication + $apiKey = $this->config->getApiKeyWithPrefix('Authorization'); + if ($apiKey !== null) { + $headers['Authorization'] = $apiKey; + } + + $defaultHeaders = []; + if ($this->config->getUserAgent()) { + $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); + } + + $headers = array_merge( + $defaultHeaders, + $headerParams, + $headers + ); + + $query = \GuzzleHttp\Psr7\Query::build($queryParams); + return new Request( + 'GET', + $this->config->getHost() . $resourcePath . ($query ? "?{$query}" : ''), + $headers, + $httpBody + ); + } + + /** + * Create http client option + * + * @throws \RuntimeException on file opening failure + * @return array of http client options + */ + protected function createHttpClientOption() + { + $options = []; + if ($this->config->getDebug()) { + $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); + if (!$options[RequestOptions::DEBUG]) { + throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); + } + } + + return $options; + } + /** + * Append to form params, handle object params + */ + protected function formParamsAppend(&$formParams, $name, $value) + { + if (is_object($value)) { + foreach ((array) $value as $k => $v) { + $formParams[$name.'['.$k.']'] = ObjectSerializer::toFormValue($v); + } + + return; + } + + $formParams[$name] = ObjectSerializer::toFormValue($value); + } +} diff --git a/lib/Model/RepoSync.php b/lib/Model/RepoSync.php new file mode 100644 index 0000000..518169d --- /dev/null +++ b/lib/Model/RepoSync.php @@ -0,0 +1,549 @@ + 'string', + 'project' => '\Phrase\Model\ProjectShort', + 'provider' => 'string', + 'enabled' => 'bool', + 'auto_import' => 'bool', + 'repo_name' => 'string', + 'created_at' => '\DateTime', + 'last_import_at' => '\DateTime', + 'last_export_at' => '\DateTime' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'id' => null, + 'project' => null, + 'provider' => null, + 'enabled' => null, + 'auto_import' => null, + 'repo_name' => null, + 'created_at' => 'date-time', + 'last_import_at' => 'date-time', + 'last_export_at' => 'date-time' + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'id' => 'id', + 'project' => 'project', + 'provider' => 'provider', + 'enabled' => 'enabled', + 'auto_import' => 'auto_import', + 'repo_name' => 'repo_name', + 'created_at' => 'created_at', + 'last_import_at' => 'last_import_at', + 'last_export_at' => 'last_export_at' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'id' => 'setId', + 'project' => 'setProject', + 'provider' => 'setProvider', + 'enabled' => 'setEnabled', + 'auto_import' => 'setAutoImport', + 'repo_name' => 'setRepoName', + 'created_at' => 'setCreatedAt', + 'last_import_at' => 'setLastImportAt', + 'last_export_at' => 'setLastExportAt' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'id' => 'getId', + 'project' => 'getProject', + 'provider' => 'getProvider', + 'enabled' => 'getEnabled', + 'auto_import' => 'getAutoImport', + 'repo_name' => 'getRepoName', + 'created_at' => 'getCreatedAt', + 'last_import_at' => 'getLastImportAt', + 'last_export_at' => 'getLastExportAt' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['id'] = isset($data['id']) ? $data['id'] : null; + $this->container['project'] = isset($data['project']) ? $data['project'] : null; + $this->container['provider'] = isset($data['provider']) ? $data['provider'] : null; + $this->container['enabled'] = isset($data['enabled']) ? $data['enabled'] : null; + $this->container['auto_import'] = isset($data['auto_import']) ? $data['auto_import'] : null; + $this->container['repo_name'] = isset($data['repo_name']) ? $data['repo_name'] : null; + $this->container['created_at'] = isset($data['created_at']) ? $data['created_at'] : null; + $this->container['last_import_at'] = isset($data['last_import_at']) ? $data['last_import_at'] : null; + $this->container['last_export_at'] = isset($data['last_export_at']) ? $data['last_export_at'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets id + * + * @return string|null + */ + public function getId() + { + return $this->container['id']; + } + + /** + * Sets id + * + * @param string|null $id id + * + * @return $this + */ + public function setId($id) + { + $this->container['id'] = $id; + + return $this; + } + + /** + * Gets project + * + * @return \Phrase\Model\ProjectShort|null + */ + public function getProject() + { + return $this->container['project']; + } + + /** + * Sets project + * + * @param \Phrase\Model\ProjectShort|null $project project + * + * @return $this + */ + public function setProject($project) + { + $this->container['project'] = $project; + + return $this; + } + + /** + * Gets provider + * + * @return string|null + */ + public function getProvider() + { + return $this->container['provider']; + } + + /** + * Sets provider + * + * @param string|null $provider provider + * + * @return $this + */ + public function setProvider($provider) + { + $this->container['provider'] = $provider; + + return $this; + } + + /** + * Gets enabled + * + * @return bool|null + */ + public function getEnabled() + { + return $this->container['enabled']; + } + + /** + * Sets enabled + * + * @param bool|null $enabled enabled + * + * @return $this + */ + public function setEnabled($enabled) + { + $this->container['enabled'] = $enabled; + + return $this; + } + + /** + * Gets auto_import + * + * @return bool|null + */ + public function getAutoImport() + { + return $this->container['auto_import']; + } + + /** + * Sets auto_import + * + * @param bool|null $auto_import auto_import + * + * @return $this + */ + public function setAutoImport($auto_import) + { + $this->container['auto_import'] = $auto_import; + + return $this; + } + + /** + * Gets repo_name + * + * @return string|null + */ + public function getRepoName() + { + return $this->container['repo_name']; + } + + /** + * Sets repo_name + * + * @param string|null $repo_name repo_name + * + * @return $this + */ + public function setRepoName($repo_name) + { + $this->container['repo_name'] = $repo_name; + + return $this; + } + + /** + * Gets created_at + * + * @return \DateTime|null + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime|null $created_at created_at + * + * @return $this + */ + public function setCreatedAt($created_at) + { + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets last_import_at + * + * @return \DateTime|null + */ + public function getLastImportAt() + { + return $this->container['last_import_at']; + } + + /** + * Sets last_import_at + * + * @param \DateTime|null $last_import_at last_import_at + * + * @return $this + */ + public function setLastImportAt($last_import_at) + { + $this->container['last_import_at'] = $last_import_at; + + return $this; + } + + /** + * Gets last_export_at + * + * @return \DateTime|null + */ + public function getLastExportAt() + { + return $this->container['last_export_at']; + } + + /** + * Sets last_export_at + * + * @param \DateTime|null $last_export_at last_export_at + * + * @return $this + */ + public function setLastExportAt($last_export_at) + { + $this->container['last_export_at'] = $last_export_at; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + #[\ReturnTypeWillChange] + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/RepoSyncEvent.php b/lib/Model/RepoSyncEvent.php new file mode 100644 index 0000000..633063a --- /dev/null +++ b/lib/Model/RepoSyncEvent.php @@ -0,0 +1,525 @@ + 'string', + 'created_at' => '\DateTime', + 'status' => 'string', + 'pull_request_url' => 'string', + 'auto_import' => 'bool', + 'errors' => '\Phrase\Model\RepoSyncEventErrorsInner[]' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'event_type' => null, + 'created_at' => 'date-time', + 'status' => null, + 'pull_request_url' => null, + 'auto_import' => null, + 'errors' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'event_type' => 'event_type', + 'created_at' => 'created_at', + 'status' => 'status', + 'pull_request_url' => 'pull_request_url', + 'auto_import' => 'auto_import', + 'errors' => 'errors' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'event_type' => 'setEventType', + 'created_at' => 'setCreatedAt', + 'status' => 'setStatus', + 'pull_request_url' => 'setPullRequestUrl', + 'auto_import' => 'setAutoImport', + 'errors' => 'setErrors' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'event_type' => 'getEventType', + 'created_at' => 'getCreatedAt', + 'status' => 'getStatus', + 'pull_request_url' => 'getPullRequestUrl', + 'auto_import' => 'getAutoImport', + 'errors' => 'getErrors' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + const EVENT_TYPE_IMPORT = 'import'; + const EVENT_TYPE_EXPORT = 'export'; + const STATUS_RUNNING = 'running'; + const STATUS_SUCCESS = 'success'; + const STATUS_FAILURE = 'failure'; + + + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getEventTypeAllowableValues() + { + return [ + self::EVENT_TYPE_IMPORT, + self::EVENT_TYPE_EXPORT, + ]; + } + + /** + * Gets allowable values of the enum + * + * @return string[] + */ + public function getStatusAllowableValues() + { + return [ + self::STATUS_RUNNING, + self::STATUS_SUCCESS, + self::STATUS_FAILURE, + ]; + } + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['event_type'] = isset($data['event_type']) ? $data['event_type'] : null; + $this->container['created_at'] = isset($data['created_at']) ? $data['created_at'] : null; + $this->container['status'] = isset($data['status']) ? $data['status'] : null; + $this->container['pull_request_url'] = isset($data['pull_request_url']) ? $data['pull_request_url'] : null; + $this->container['auto_import'] = isset($data['auto_import']) ? $data['auto_import'] : null; + $this->container['errors'] = isset($data['errors']) ? $data['errors'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + $allowedValues = $this->getEventTypeAllowableValues(); + if (!is_null($this->container['event_type']) && !in_array($this->container['event_type'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value for 'event_type', must be one of '%s'", + implode("', '", $allowedValues) + ); + } + + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($this->container['status']) && !in_array($this->container['status'], $allowedValues, true)) { + $invalidProperties[] = sprintf( + "invalid value for 'status', must be one of '%s'", + implode("', '", $allowedValues) + ); + } + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets event_type + * + * @return string|null + */ + public function getEventType() + { + return $this->container['event_type']; + } + + /** + * Sets event_type + * + * @param string|null $event_type event_type + * + * @return $this + */ + public function setEventType($event_type) + { + $allowedValues = $this->getEventTypeAllowableValues(); + if (!is_null($event_type) && !in_array($event_type, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'event_type', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['event_type'] = $event_type; + + return $this; + } + + /** + * Gets created_at + * + * @return \DateTime|null + */ + public function getCreatedAt() + { + return $this->container['created_at']; + } + + /** + * Sets created_at + * + * @param \DateTime|null $created_at created_at + * + * @return $this + */ + public function setCreatedAt($created_at) + { + $this->container['created_at'] = $created_at; + + return $this; + } + + /** + * Gets status + * + * @return string|null + */ + public function getStatus() + { + return $this->container['status']; + } + + /** + * Sets status + * + * @param string|null $status status + * + * @return $this + */ + public function setStatus($status) + { + $allowedValues = $this->getStatusAllowableValues(); + if (!is_null($status) && !in_array($status, $allowedValues, true)) { + throw new \InvalidArgumentException( + sprintf( + "Invalid value for 'status', must be one of '%s'", + implode("', '", $allowedValues) + ) + ); + } + $this->container['status'] = $status; + + return $this; + } + + /** + * Gets pull_request_url + * + * @return string|null + */ + public function getPullRequestUrl() + { + return $this->container['pull_request_url']; + } + + /** + * Sets pull_request_url + * + * @param string|null $pull_request_url URL of the pull request created on export + * + * @return $this + */ + public function setPullRequestUrl($pull_request_url) + { + $this->container['pull_request_url'] = $pull_request_url; + + return $this; + } + + /** + * Gets auto_import + * + * @return bool|null + */ + public function getAutoImport() + { + return $this->container['auto_import']; + } + + /** + * Sets auto_import + * + * @param bool|null $auto_import Whether the import was triggered by the repo push event + * + * @return $this + */ + public function setAutoImport($auto_import) + { + $this->container['auto_import'] = $auto_import; + + return $this; + } + + /** + * Gets errors + * + * @return \Phrase\Model\RepoSyncEventErrorsInner[]|null + */ + public function getErrors() + { + return $this->container['errors']; + } + + /** + * Sets errors + * + * @param \Phrase\Model\RepoSyncEventErrorsInner[]|null $errors List of error messages, in case of failure + * + * @return $this + */ + public function setErrors($errors) + { + $this->container['errors'] = $errors; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + #[\ReturnTypeWillChange] + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/RepoSyncEventErrorsInner.php b/lib/Model/RepoSyncEventErrorsInner.php new file mode 100644 index 0000000..3f1ba8a --- /dev/null +++ b/lib/Model/RepoSyncEventErrorsInner.php @@ -0,0 +1,284 @@ +listInvalidProperties()) === 0; + } + + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + #[\ReturnTypeWillChange] + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/RepoSyncExport.php b/lib/Model/RepoSyncExport.php new file mode 100644 index 0000000..d354cd6 --- /dev/null +++ b/lib/Model/RepoSyncExport.php @@ -0,0 +1,309 @@ + 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'message' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'message' => 'message' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'message' => 'setMessage' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'message' => 'getMessage' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['message'] = isset($data['message']) ? $data['message'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message message + * + * @return $this + */ + public function setMessage($message) + { + $this->container['message'] = $message; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + #[\ReturnTypeWillChange] + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/lib/Model/RepoSyncImport.php b/lib/Model/RepoSyncImport.php new file mode 100644 index 0000000..bdb31a8 --- /dev/null +++ b/lib/Model/RepoSyncImport.php @@ -0,0 +1,309 @@ + 'string' + ]; + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + */ + protected static $openAPIFormats = [ + 'message' => null + ]; + + /** + * Array of property to type mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPITypes() + { + return self::$openAPITypes; + } + + /** + * Array of property to format mappings. Used for (de)serialization + * + * @return array + */ + public static function openAPIFormats() + { + return self::$openAPIFormats; + } + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @var string[] + */ + protected static $attributeMap = [ + 'message' => 'message' + ]; + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @var string[] + */ + protected static $setters = [ + 'message' => 'setMessage' + ]; + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @var string[] + */ + protected static $getters = [ + 'message' => 'getMessage' + ]; + + /** + * Array of attributes where the key is the local name, + * and the value is the original name + * + * @return array + */ + public static function attributeMap() + { + return self::$attributeMap; + } + + /** + * Array of attributes to setter functions (for deserialization of responses) + * + * @return array + */ + public static function setters() + { + return self::$setters; + } + + /** + * Array of attributes to getter functions (for serialization of requests) + * + * @return array + */ + public static function getters() + { + return self::$getters; + } + + /** + * The original name of the model. + * + * @return string + */ + public function getModelName() + { + return self::$openAPIModelName; + } + + + + + + /** + * Associative array for storing property values + * + * @var mixed[] + */ + protected $container = []; + + /** + * Constructor + * + * @param mixed[] $data Associated array of property values + * initializing the model + */ + public function __construct(array $data = null) + { + $this->container['message'] = isset($data['message']) ? $data['message'] : null; + } + + /** + * Show all the invalid properties with reasons. + * + * @return array invalid properties with reasons + */ + public function listInvalidProperties() + { + $invalidProperties = []; + + return $invalidProperties; + } + + /** + * Validate all the properties in the model + * return true if all passed + * + * @return bool True if all properties are valid + */ + public function valid() + { + return count($this->listInvalidProperties()) === 0; + } + + + /** + * Gets message + * + * @return string|null + */ + public function getMessage() + { + return $this->container['message']; + } + + /** + * Sets message + * + * @param string|null $message message + * + * @return $this + */ + public function setMessage($message) + { + $this->container['message'] = $message; + + return $this; + } + /** + * Returns true if offset exists. False otherwise. + * + * @param integer $offset Offset + * + * @return boolean + */ + #[\ReturnTypeWillChange] + public function offsetExists($offset) + { + return isset($this->container[$offset]); + } + + /** + * Gets offset. + * + * @param integer $offset Offset + * + * @return mixed + */ + #[\ReturnTypeWillChange] + public function offsetGet($offset) + { + return isset($this->container[$offset]) ? $this->container[$offset] : null; + } + + /** + * Sets value based on offset. + * + * @param integer $offset Offset + * @param mixed $value Value to be set + * + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetSet($offset, $value) + { + if (is_null($offset)) { + $this->container[] = $value; + } else { + $this->container[$offset] = $value; + } + } + + /** + * Unsets offset. + * + * @param integer $offset Offset + * + * @return void + */ + #[\ReturnTypeWillChange] + public function offsetUnset($offset) + { + unset($this->container[$offset]); + } + + /** + * Gets the string presentation of the object + * + * @return string + */ + public function __toString() + { + return json_encode( + ObjectSerializer::sanitizeForSerialization($this), + JSON_PRETTY_PRINT + ); + } + + /** + * Gets a header-safe presentation of the object + * + * @return string + */ + public function toHeaderValue() + { + return json_encode(ObjectSerializer::sanitizeForSerialization($this)); + } +} + + diff --git a/test/Api/RepoSyncsApiTest.php b/test/Api/RepoSyncsApiTest.php new file mode 100644 index 0000000..88cc0b2 --- /dev/null +++ b/test/Api/RepoSyncsApiTest.php @@ -0,0 +1,142 @@ +