diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index eb40829..fb1351f 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -127,6 +127,10 @@ docs/JobTemplatesApi.md docs/JobUpdateParameters.md docs/JobsApi.md docs/KeyCreateParameters.md +docs/KeyLink.md +docs/KeyLinksBatchDestroyParameters.md +docs/KeyLinksCreateParameters.md +docs/KeyLinksIndex400Response.md docs/KeyPreview.md docs/KeyUpdateParameters.md docs/KeysApi.md @@ -136,6 +140,7 @@ docs/KeysIncludeParameters.md docs/KeysSearchParameters.md docs/KeysTagParameters.md docs/KeysUntagParameters.md +docs/LinkedKeysApi.md docs/Locale.md docs/LocaleCreateParameters.md docs/LocaleDetails.md @@ -296,6 +301,7 @@ lib/phrase/api/job_templates_api.rb lib/phrase/api/jobs_api.rb lib/phrase/api/keys_api.rb lib/phrase/api/keys_figma_attachments_api.rb +lib/phrase/api/linked_keys_api.rb lib/phrase/api/locales_api.rb lib/phrase/api/members_api.rb lib/phrase/api/notification_groups_api.rb @@ -419,6 +425,10 @@ lib/phrase/models/job_template_preview.rb lib/phrase/models/job_template_update_parameters.rb lib/phrase/models/job_update_parameters.rb lib/phrase/models/key_create_parameters.rb +lib/phrase/models/key_link.rb +lib/phrase/models/key_links_batch_destroy_parameters.rb +lib/phrase/models/key_links_create_parameters.rb +lib/phrase/models/key_links_index400_response.rb lib/phrase/models/key_preview.rb lib/phrase/models/key_update_parameters.rb lib/phrase/models/keys_exclude_parameters.rb @@ -561,6 +571,7 @@ spec/api/job_templates_api_spec.rb spec/api/jobs_api_spec.rb spec/api/keys_api_spec.rb spec/api/keys_figma_attachments_api_spec.rb +spec/api/linked_keys_api_spec.rb spec/api/members_api_spec.rb spec/api/notification_groups_api_spec.rb spec/api/notifications_api_spec.rb @@ -681,6 +692,10 @@ spec/models/job_template_spec.rb spec/models/job_template_update_parameters_spec.rb spec/models/job_update_parameters_spec.rb spec/models/key_create_parameters_spec.rb +spec/models/key_link_spec.rb +spec/models/key_links_batch_destroy_parameters_spec.rb +spec/models/key_links_create_parameters_spec.rb +spec/models/key_links_index400_response_spec.rb spec/models/key_preview_spec.rb spec/models/key_update_parameters_spec.rb spec/models/keys_exclude_parameters_spec.rb diff --git a/README.md b/README.md index 3211c68..5393a3f 100644 --- a/README.md +++ b/README.md @@ -267,6 +267,10 @@ Class | Method | HTTP request | Description *Phrase::KeysApi* | [**keys_untag**](docs/KeysApi.md#keys_untag) | **PATCH** /projects/{project_id}/keys/untag | Remove tags from collection of keys *Phrase::KeysFigmaAttachmentsApi* | [**figma_attachment_attach_to_key**](docs/KeysFigmaAttachmentsApi.md#figma_attachment_attach_to_key) | **POST** /projects/{project_id}/figma_attachments/{figma_attachment_id}/keys | Attach the Figma attachment to a key *Phrase::KeysFigmaAttachmentsApi* | [**figma_attachment_detach_from_key**](docs/KeysFigmaAttachmentsApi.md#figma_attachment_detach_from_key) | **DELETE** /projects/{project_id}/figma_attachments/{figma_attachment_id}/keys/{id} | Detach the Figma attachment from a key +*Phrase::LinkedKeysApi* | [**key_links_batch_destroy**](docs/LinkedKeysApi.md#key_links_batch_destroy) | **DELETE** /projects/{project_id}/keys/{id}/key_links | Batch unlink child keys from a parent key +*Phrase::LinkedKeysApi* | [**key_links_create**](docs/LinkedKeysApi.md#key_links_create) | **POST** /projects/{project_id}/keys/{id}/key_links | Link child keys to a parent key +*Phrase::LinkedKeysApi* | [**key_links_destroy**](docs/LinkedKeysApi.md#key_links_destroy) | **DELETE** /projects/{project_id}/keys/{id}/key_links/{child_key_id} | Unlink a child key from a parent key +*Phrase::LinkedKeysApi* | [**key_links_index**](docs/LinkedKeysApi.md#key_links_index) | **GET** /projects/{project_id}/keys/{id}/key_links | Retrieve all child keys linked to a specific parent key *Phrase::LocalesApi* | [**account_locales**](docs/LocalesApi.md#account_locales) | **GET** /accounts/{id}/locales | List locales used in account *Phrase::LocalesApi* | [**locale_create**](docs/LocalesApi.md#locale_create) | **POST** /projects/{project_id}/locales | Create a locale *Phrase::LocalesApi* | [**locale_delete**](docs/LocalesApi.md#locale_delete) | **DELETE** /projects/{project_id}/locales/{id} | Delete a locale @@ -489,6 +493,10 @@ Class | Method | HTTP request | Description - [Phrase::JobTemplateUpdateParameters](docs/JobTemplateUpdateParameters.md) - [Phrase::JobUpdateParameters](docs/JobUpdateParameters.md) - [Phrase::KeyCreateParameters](docs/KeyCreateParameters.md) + - [Phrase::KeyLink](docs/KeyLink.md) + - [Phrase::KeyLinksBatchDestroyParameters](docs/KeyLinksBatchDestroyParameters.md) + - [Phrase::KeyLinksCreateParameters](docs/KeyLinksCreateParameters.md) + - [Phrase::KeyLinksIndex400Response](docs/KeyLinksIndex400Response.md) - [Phrase::KeyPreview](docs/KeyPreview.md) - [Phrase::KeyUpdateParameters](docs/KeyUpdateParameters.md) - [Phrase::KeysExcludeParameters](docs/KeysExcludeParameters.md) diff --git a/docs/KeyCreateParameters.md b/docs/KeyCreateParameters.md index 055d7ae..7d02ee8 100644 --- a/docs/KeyCreateParameters.md +++ b/docs/KeyCreateParameters.md @@ -35,7 +35,7 @@ instance = Phrase::KeyCreateParameters.new(branch: my-feature-branch, data_type: number, tags: awesome-feature,needs-proofreading, max_characters_allowed: 140, - screenshot: [B@38dd5c3a, + screenshot: [B@4b0e0dd5, remove_screenshot: null, unformatted: null, default_translation_content: Default translation content, diff --git a/docs/KeyLink.md b/docs/KeyLink.md new file mode 100644 index 0000000..2d48238 --- /dev/null +++ b/docs/KeyLink.md @@ -0,0 +1,29 @@ +# Phrase::KeyLink + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**created_at** | **Time** | The timestamp when the link was created. | +**updated_at** | **Time** | The timestamp when the link was last updated. | +**created_by** | [**UserPreview**](UserPreview.md) | | +**updated_by** | [**UserPreview**](UserPreview.md) | | +**account** | [**Account**](Account.md) | | +**parent** | [**KeyPreview**](KeyPreview.md) | | +**children** | [**Array<KeyPreview>**](KeyPreview.md) | The child translation keys linked to the parent. | + +## Code Sample + +```ruby +require 'Phrase' + +instance = Phrase::KeyLink.new(created_at: null, + updated_at: null, + created_by: null, + updated_by: null, + account: null, + parent: null, + children: null) +``` + + diff --git a/docs/KeyLinksBatchDestroyParameters.md b/docs/KeyLinksBatchDestroyParameters.md new file mode 100644 index 0000000..21f283d --- /dev/null +++ b/docs/KeyLinksBatchDestroyParameters.md @@ -0,0 +1,17 @@ +# Phrase::KeyLinksBatchDestroyParameters + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**child_key_ids** | **Array<String>** | The IDs of the child keys to unlink from the parent key. | + +## Code Sample + +```ruby +require 'Phrase' + +instance = Phrase::KeyLinksBatchDestroyParameters.new(child_key_ids: ["child_key_id1","child_key_id2"]) +``` + + diff --git a/docs/KeyLinksCreateParameters.md b/docs/KeyLinksCreateParameters.md new file mode 100644 index 0000000..84d287f --- /dev/null +++ b/docs/KeyLinksCreateParameters.md @@ -0,0 +1,17 @@ +# Phrase::KeyLinksCreateParameters + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**child_key_ids** | **Array<String>** | The IDs of the child keys to link to the parent key. Can be left empty, to only mark the given translation-key as parent | + +## Code Sample + +```ruby +require 'Phrase' + +instance = Phrase::KeyLinksCreateParameters.new(child_key_ids: ["child_key_id1","child_key_id2"]) +``` + + diff --git a/docs/KeyLinksIndex400Response.md b/docs/KeyLinksIndex400Response.md new file mode 100644 index 0000000..1987e29 --- /dev/null +++ b/docs/KeyLinksIndex400Response.md @@ -0,0 +1,17 @@ +# Phrase::KeyLinksIndex400Response + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**message** | **String** | | [optional] + +## Code Sample + +```ruby +require 'Phrase' + +instance = Phrase::KeyLinksIndex400Response.new(message: null) +``` + + diff --git a/docs/KeyUpdateParameters.md b/docs/KeyUpdateParameters.md index b5978db..f762291 100644 --- a/docs/KeyUpdateParameters.md +++ b/docs/KeyUpdateParameters.md @@ -34,7 +34,7 @@ instance = Phrase::KeyUpdateParameters.new(branch: my-feature-branch, data_type: number, tags: awesome-feature,needs-proofreading, max_characters_allowed: 140, - screenshot: [B@533c7a52, + screenshot: [B@608c36a6, remove_screenshot: null, unformatted: null, xml_space_preserve: null, diff --git a/docs/LinkedKeysApi.md b/docs/LinkedKeysApi.md new file mode 100644 index 0000000..fd649b4 --- /dev/null +++ b/docs/LinkedKeysApi.md @@ -0,0 +1,262 @@ +# Phrase::LinkedKeysApi + +All URIs are relative to *https://api.phrase.com/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**key_links_batch_destroy**](LinkedKeysApi.md#key_links_batch_destroy) | **DELETE** /projects/{project_id}/keys/{id}/key_links | Batch unlink child keys from a parent key +[**key_links_create**](LinkedKeysApi.md#key_links_create) | **POST** /projects/{project_id}/keys/{id}/key_links | Link child keys to a parent key +[**key_links_destroy**](LinkedKeysApi.md#key_links_destroy) | **DELETE** /projects/{project_id}/keys/{id}/key_links/{child_key_id} | Unlink a child key from a parent key +[**key_links_index**](LinkedKeysApi.md#key_links_index) | **GET** /projects/{project_id}/keys/{id}/key_links | Retrieve all child keys linked to a specific parent key + + + +## key_links_batch_destroy + +> key_links_batch_destroy(account_id, key_links_batch_destroy_parameters, opts) + +Batch unlink child keys from a parent key + +Unlinks multiple child keys from a given parent key in a single operation. + +### Example + +```ruby +# load the gem +require 'phrase' +# setup authorization +Phrase.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' + + # Configure API key authorization: Token + config.api_key['Authorization'] = 'YOUR API KEY' + config.api_key_prefix['Authorization'] = 'token' +end + +api_instance = Phrase::LinkedKeysApi.new +account_id = 'account_id_example' # String | Account ID +key_links_batch_destroy_parameters = Phrase::KeyLinksBatchDestroyParameters.new({child_key_ids: ["child_key_id1", "child_key_id2"]}) # KeyLinksBatchDestroyParameters | +opts = { + x_phrase_app_otp: 'x_phrase_app_otp_example', # String | Two-Factor-Authentication token (optional) + unlink_parent: true # Boolean | Whether to unlink the parent key as well and unmark it as linked-key. +} + +begin + #Batch unlink child keys from a parent key + api_instance.key_links_batch_destroy(account_id, key_links_batch_destroy_parameters, opts) +rescue Phrase::ApiError => e + puts "Exception when calling LinkedKeysApi->key_links_batch_destroy: #{e}" +end +``` + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **account_id** | **String**| Account ID | + **key_links_batch_destroy_parameters** | [**KeyLinksBatchDestroyParameters**](KeyLinksBatchDestroyParameters.md)| | + **x_phrase_app_otp** | **String**| Two-Factor-Authentication token (optional) | [optional] + **unlink_parent** | **Boolean**| Whether to unlink the parent key as well and unmark it as linked-key. | [optional] + +### Return type + +Response<(nil (empty response body))> + +### Authorization + +[Basic](../README.md#Basic), [Token](../README.md#Token) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## key_links_create + +> KeyLink key_links_create(account_id, key_links_create_parameters, opts) + +Link child keys to a parent key + +Creates links between a given parent key and one or more child keys. + +### Example + +```ruby +# load the gem +require 'phrase' +# setup authorization +Phrase.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' + + # Configure API key authorization: Token + config.api_key['Authorization'] = 'YOUR API KEY' + config.api_key_prefix['Authorization'] = 'token' +end + +api_instance = Phrase::LinkedKeysApi.new +account_id = 'account_id_example' # String | Account ID +key_links_create_parameters = Phrase::KeyLinksCreateParameters.new({child_key_ids: ["child_key_id1", "child_key_id2"]}) # KeyLinksCreateParameters | +opts = { + x_phrase_app_otp: 'x_phrase_app_otp_example' # String | Two-Factor-Authentication token (optional) +} + +begin + #Link child keys to a parent key + result = api_instance.key_links_create(account_id, key_links_create_parameters, opts) + pp result +rescue Phrase::ApiError => e + puts "Exception when calling LinkedKeysApi->key_links_create: #{e}" +end +``` + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **account_id** | **String**| Account ID | + **key_links_create_parameters** | [**KeyLinksCreateParameters**](KeyLinksCreateParameters.md)| | + **x_phrase_app_otp** | **String**| Two-Factor-Authentication token (optional) | [optional] + +### Return type + +Response<([**KeyLink**](KeyLink.md))> + +### Authorization + +[Basic](../README.md#Basic), [Token](../README.md#Token) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + + +## key_links_destroy + +> key_links_destroy(account_id, child_key_id, opts) + +Unlink a child key from a parent key + +Unlinks a single child key from a given parent key. + +### Example + +```ruby +# load the gem +require 'phrase' +# setup authorization +Phrase.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' + + # Configure API key authorization: Token + config.api_key['Authorization'] = 'YOUR API KEY' + config.api_key_prefix['Authorization'] = 'token' +end + +api_instance = Phrase::LinkedKeysApi.new +account_id = 'account_id_example' # String | Account ID +child_key_id = 'child_key_id_example' # String | The ID of the child key to unlink. +opts = { + x_phrase_app_otp: 'x_phrase_app_otp_example' # String | Two-Factor-Authentication token (optional) +} + +begin + #Unlink a child key from a parent key + api_instance.key_links_destroy(account_id, child_key_id, opts) +rescue Phrase::ApiError => e + puts "Exception when calling LinkedKeysApi->key_links_destroy: #{e}" +end +``` + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **account_id** | **String**| Account ID | + **child_key_id** | **String**| The ID of the child key to unlink. | + **x_phrase_app_otp** | **String**| Two-Factor-Authentication token (optional) | [optional] + +### Return type + +Response<(nil (empty response body))> + +### Authorization + +[Basic](../README.md#Basic), [Token](../README.md#Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + + +## key_links_index + +> KeyLink key_links_index(account_id, opts) + +Retrieve all child keys linked to a specific parent key + +Returns detailed information about a parent key, including its linked child keys. + +### Example + +```ruby +# load the gem +require 'phrase' +# setup authorization +Phrase.configure do |config| + # Configure HTTP basic authorization: Basic + config.username = 'YOUR USERNAME' + config.password = 'YOUR PASSWORD' + + # Configure API key authorization: Token + config.api_key['Authorization'] = 'YOUR API KEY' + config.api_key_prefix['Authorization'] = 'token' +end + +api_instance = Phrase::LinkedKeysApi.new +account_id = 'account_id_example' # String | Account ID +opts = { + x_phrase_app_otp: 'x_phrase_app_otp_example' # String | Two-Factor-Authentication token (optional) +} + +begin + #Retrieve all child keys linked to a specific parent key + result = api_instance.key_links_index(account_id, opts) + pp result +rescue Phrase::ApiError => e + puts "Exception when calling LinkedKeysApi->key_links_index: #{e}" +end +``` + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **account_id** | **String**| Account ID | + **x_phrase_app_otp** | **String**| Two-Factor-Authentication token (optional) | [optional] + +### Return type + +Response<([**KeyLink**](KeyLink.md))> + +### Authorization + +[Basic](../README.md#Basic), [Token](../README.md#Token) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + diff --git a/docs/ProjectCreateParameters.md b/docs/ProjectCreateParameters.md index 7bd386e..c835da0 100644 --- a/docs/ProjectCreateParameters.md +++ b/docs/ProjectCreateParameters.md @@ -40,7 +40,7 @@ instance = Phrase::ProjectCreateParameters.new(name: My Android Project, main_format: yml, media: Python, shares_translation_memory: true, - project_image: [B@95504a0, + project_image: [B@7d80f543, remove_project_image: null, account_id: abcd1234, point_of_contact: abcd1234, diff --git a/docs/ProjectUpdateParameters.md b/docs/ProjectUpdateParameters.md index 1a58fd7..897fef2 100644 --- a/docs/ProjectUpdateParameters.md +++ b/docs/ProjectUpdateParameters.md @@ -41,7 +41,7 @@ instance = Phrase::ProjectUpdateParameters.new(account_id: abcd1234, main_format: yml, media: Python, shares_translation_memory: true, - project_image: [B@68d07b48, + project_image: [B@2531c319, remove_project_image: false, workflow: review, machine_translation_enabled: true, diff --git a/docs/ScreenshotUpdateParameters.md b/docs/ScreenshotUpdateParameters.md index 036d36c..26b055e 100644 --- a/docs/ScreenshotUpdateParameters.md +++ b/docs/ScreenshotUpdateParameters.md @@ -17,7 +17,7 @@ require 'Phrase' instance = Phrase::ScreenshotUpdateParameters.new(branch: my-feature-branch, name: A screenshot name, description: A screenshot description, - filename: [B@190c2bbf) + filename: [B@315edc50) ``` diff --git a/lib/phrase.rb b/lib/phrase.rb index 7c9da98..65ea620 100644 --- a/lib/phrase.rb +++ b/lib/phrase.rb @@ -103,6 +103,10 @@ require 'phrase/models/job_template_update_parameters' require 'phrase/models/job_update_parameters' require 'phrase/models/key_create_parameters' +require 'phrase/models/key_link' +require 'phrase/models/key_links_batch_destroy_parameters' +require 'phrase/models/key_links_create_parameters' +require 'phrase/models/key_links_index400_response' require 'phrase/models/key_preview' require 'phrase/models/key_update_parameters' require 'phrase/models/keys_exclude_parameters' @@ -245,6 +249,7 @@ require 'phrase/api/jobs_api' require 'phrase/api/keys_api' require 'phrase/api/keys_figma_attachments_api' +require 'phrase/api/linked_keys_api' require 'phrase/api/locales_api' require 'phrase/api/members_api' require 'phrase/api/notification_groups_api' diff --git a/lib/phrase/api/linked_keys_api.rb b/lib/phrase/api/linked_keys_api.rb new file mode 100644 index 0000000..814bd7d --- /dev/null +++ b/lib/phrase/api/linked_keys_api.rb @@ -0,0 +1,299 @@ +require 'cgi' + +module Phrase + class LinkedKeysApi + attr_accessor :api_client + + def initialize(api_client = ApiClient.default) + @api_client = api_client + end + # Batch unlink child keys from a parent key + # Unlinks multiple child keys from a given parent key in a single operation. + # @param account_id [String] Account ID + # @param key_links_batch_destroy_parameters [KeyLinksBatchDestroyParameters] + # @param [Hash] opts the optional parameters + # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) + # @option opts [Boolean] :unlink_parent Whether to unlink the parent key as well and unmark it as linked-key. + # @return [nil] + def key_links_batch_destroy(account_id, key_links_batch_destroy_parameters, opts = {}) + data, _status_code, _headers = key_links_batch_destroy_with_http_info(account_id, key_links_batch_destroy_parameters, opts) + data + end + + # Batch unlink child keys from a parent key + # Unlinks multiple child keys from a given parent key in a single operation. + # @param account_id [String] Account ID + # @param key_links_batch_destroy_parameters [KeyLinksBatchDestroyParameters] + # @param [Hash] opts the optional parameters + # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) + # @option opts [Boolean] :unlink_parent Whether to unlink the parent key as well and unmark it as linked-key. + # @return [Array<(Response, Integer, Hash)>] Response<(nil, response status code and response headers + def key_links_batch_destroy_with_http_info(account_id, key_links_batch_destroy_parameters, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LinkedKeysApi.key_links_batch_destroy ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling LinkedKeysApi.key_links_batch_destroy" + end + # verify the required parameter 'key_links_batch_destroy_parameters' is set + if @api_client.config.client_side_validation && key_links_batch_destroy_parameters.nil? + fail ArgumentError, "Missing the required parameter 'key_links_batch_destroy_parameters' when calling LinkedKeysApi.key_links_batch_destroy" + end + # resource path + local_var_path = '/projects/{project_id}/keys/{id}/key_links'.sub('{' + 'account_id' + '}', CGI.escape(account_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'unlink_parent'] = opts[:'unlink_parent'] if !opts[:'unlink_parent'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil? + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:body] || @api_client.object_to_http_body(key_links_batch_destroy_parameters) + + # return_type + return_type = opts[:return_type] + + # auth_names + auth_names = opts[:auth_names] || ['Basic', 'Token'] + + new_options = opts.merge( + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LinkedKeysApi#key_links_batch_destroy\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + response = ::Phrase::Response.new(data, headers) + return response, status_code, headers + end + + # Link child keys to a parent key + # Creates links between a given parent key and one or more child keys. + # @param account_id [String] Account ID + # @param key_links_create_parameters [KeyLinksCreateParameters] + # @param [Hash] opts the optional parameters + # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) + # @return [KeyLink] + def key_links_create(account_id, key_links_create_parameters, opts = {}) + data, _status_code, _headers = key_links_create_with_http_info(account_id, key_links_create_parameters, opts) + data + end + + # Link child keys to a parent key + # Creates links between a given parent key and one or more child keys. + # @param account_id [String] Account ID + # @param key_links_create_parameters [KeyLinksCreateParameters] + # @param [Hash] opts the optional parameters + # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) + # @return [Array<(Response<(KeyLink)>, Integer, Hash)>] Response<(KeyLink)> data, response status code and response headers + def key_links_create_with_http_info(account_id, key_links_create_parameters, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LinkedKeysApi.key_links_create ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling LinkedKeysApi.key_links_create" + end + # verify the required parameter 'key_links_create_parameters' is set + if @api_client.config.client_side_validation && key_links_create_parameters.nil? + fail ArgumentError, "Missing the required parameter 'key_links_create_parameters' when calling LinkedKeysApi.key_links_create" + end + # resource path + local_var_path = '/projects/{project_id}/keys/{id}/key_links'.sub('{' + 'account_id' + '}', CGI.escape(account_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + # HTTP header 'Content-Type' + header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) + header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil? + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:body] || @api_client.object_to_http_body(key_links_create_parameters) + + # return_type + return_type = opts[:return_type] || 'KeyLink' + + # auth_names + auth_names = opts[:auth_names] || ['Basic', 'Token'] + + new_options = opts.merge( + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LinkedKeysApi#key_links_create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + response = ::Phrase::Response.new(data, headers) + return response, status_code, headers + end + + # Unlink a child key from a parent key + # Unlinks a single child key from a given parent key. + # @param account_id [String] Account ID + # @param child_key_id [String] The ID of the child key to unlink. + # @param [Hash] opts the optional parameters + # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) + # @return [nil] + def key_links_destroy(account_id, child_key_id, opts = {}) + data, _status_code, _headers = key_links_destroy_with_http_info(account_id, child_key_id, opts) + data + end + + # Unlink a child key from a parent key + # Unlinks a single child key from a given parent key. + # @param account_id [String] Account ID + # @param child_key_id [String] The ID of the child key to unlink. + # @param [Hash] opts the optional parameters + # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) + # @return [Array<(Response, Integer, Hash)>] Response<(nil, response status code and response headers + def key_links_destroy_with_http_info(account_id, child_key_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LinkedKeysApi.key_links_destroy ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling LinkedKeysApi.key_links_destroy" + end + # verify the required parameter 'child_key_id' is set + if @api_client.config.client_side_validation && child_key_id.nil? + fail ArgumentError, "Missing the required parameter 'child_key_id' when calling LinkedKeysApi.key_links_destroy" + end + # resource path + local_var_path = '/projects/{project_id}/keys/{id}/key_links/{child_key_id}'.sub('{' + 'account_id' + '}', CGI.escape(account_id.to_s)).sub('{' + 'child_key_id' + '}', CGI.escape(child_key_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil? + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:body] + + # return_type + return_type = opts[:return_type] + + # auth_names + auth_names = opts[:auth_names] || ['Basic', 'Token'] + + new_options = opts.merge( + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LinkedKeysApi#key_links_destroy\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + response = ::Phrase::Response.new(data, headers) + return response, status_code, headers + end + + # Retrieve all child keys linked to a specific parent key + # Returns detailed information about a parent key, including its linked child keys. + # @param account_id [String] Account ID + # @param [Hash] opts the optional parameters + # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) + # @return [KeyLink] + def key_links_index(account_id, opts = {}) + data, _status_code, _headers = key_links_index_with_http_info(account_id, opts) + data + end + + # Retrieve all child keys linked to a specific parent key + # Returns detailed information about a parent key, including its linked child keys. + # @param account_id [String] Account ID + # @param [Hash] opts the optional parameters + # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) + # @return [Array<(Response<(KeyLink)>, Integer, Hash)>] Response<(KeyLink)> data, response status code and response headers + def key_links_index_with_http_info(account_id, opts = {}) + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: LinkedKeysApi.key_links_index ...' + end + # verify the required parameter 'account_id' is set + if @api_client.config.client_side_validation && account_id.nil? + fail ArgumentError, "Missing the required parameter 'account_id' when calling LinkedKeysApi.key_links_index" + end + # resource path + local_var_path = '/projects/{project_id}/keys/{id}/key_links'.sub('{' + 'account_id' + '}', CGI.escape(account_id.to_s)) + + # query parameters + query_params = opts[:query_params] || {} + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json']) + header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil? + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:body] + + # return_type + return_type = opts[:return_type] || 'KeyLink' + + # auth_names + auth_names = opts[:auth_names] || ['Basic', 'Token'] + + new_options = opts.merge( + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: LinkedKeysApi#key_links_index\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + response = ::Phrase::Response.new(data, headers) + return response, status_code, headers + end + end +end diff --git a/lib/phrase/models/key_link.rb b/lib/phrase/models/key_link.rb new file mode 100644 index 0000000..1346c07 --- /dev/null +++ b/lib/phrase/models/key_link.rb @@ -0,0 +1,290 @@ +require 'date' + +module Phrase + class KeyLink + # The timestamp when the link was created. + attr_accessor :created_at + + # The timestamp when the link was last updated. + attr_accessor :updated_at + + attr_accessor :created_by + + attr_accessor :updated_by + + attr_accessor :account + + attr_accessor :parent + + # The child translation keys linked to the parent. + attr_accessor :children + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'created_at' => :'created_at', + :'updated_at' => :'updated_at', + :'created_by' => :'created_by', + :'updated_by' => :'updated_by', + :'account' => :'account', + :'parent' => :'parent', + :'children' => :'children' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'created_at' => :'DateTime', + :'updated_at' => :'DateTime', + :'created_by' => :'UserPreview', + :'updated_by' => :'UserPreview', + :'account' => :'Account', + :'parent' => :'KeyPreview', + :'children' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::KeyLink` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::KeyLink`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'created_at') + self.created_at = attributes[:'created_at'] + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'created_by') + self.created_by = attributes[:'created_by'] + end + + if attributes.key?(:'updated_by') + self.updated_by = attributes[:'updated_by'] + end + + if attributes.key?(:'account') + self.account = attributes[:'account'] + end + + if attributes.key?(:'parent') + self.parent = attributes[:'parent'] + end + + if attributes.key?(:'children') + if (value = attributes[:'children']).is_a?(Array) + self.children = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + if @created_at.nil? + invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') + end + + if @updated_at.nil? + invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.') + end + + if @created_by.nil? + invalid_properties.push('invalid value for "created_by", created_by cannot be nil.') + end + + if @updated_by.nil? + invalid_properties.push('invalid value for "updated_by", updated_by cannot be nil.') + end + + if @account.nil? + invalid_properties.push('invalid value for "account", account cannot be nil.') + end + + if @parent.nil? + invalid_properties.push('invalid value for "parent", parent cannot be nil.') + end + + if @children.nil? + invalid_properties.push('invalid value for "children", children cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @created_at.nil? + return false if @updated_at.nil? + return false if @created_by.nil? + return false if @updated_by.nil? + return false if @account.nil? + return false if @parent.nil? + return false if @children.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + created_at == o.created_at && + updated_at == o.updated_at && + created_by == o.created_by && + updated_by == o.updated_by && + account == o.account && + parent == o.parent && + children == o.children + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [created_at, updated_at, created_by, updated_by, account, parent, children].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :Time + Time.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + Phrase.const_get(type).build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/phrase/models/key_links_batch_destroy_parameters.rb b/lib/phrase/models/key_links_batch_destroy_parameters.rb new file mode 100644 index 0000000..90d51ff --- /dev/null +++ b/lib/phrase/models/key_links_batch_destroy_parameters.rb @@ -0,0 +1,204 @@ +require 'date' + +module Phrase + class KeyLinksBatchDestroyParameters + # The IDs of the child keys to unlink from the parent key. + attr_accessor :child_key_ids + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'child_key_ids' => :'child_key_ids' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'child_key_ids' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::KeyLinksBatchDestroyParameters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::KeyLinksBatchDestroyParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'child_key_ids') + if (value = attributes[:'child_key_ids']).is_a?(Array) + self.child_key_ids = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + if @child_key_ids.nil? + invalid_properties.push('invalid value for "child_key_ids", child_key_ids cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @child_key_ids.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + child_key_ids == o.child_key_ids + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [child_key_ids].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :Time + Time.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + Phrase.const_get(type).build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/phrase/models/key_links_create_parameters.rb b/lib/phrase/models/key_links_create_parameters.rb new file mode 100644 index 0000000..5ae786a --- /dev/null +++ b/lib/phrase/models/key_links_create_parameters.rb @@ -0,0 +1,204 @@ +require 'date' + +module Phrase + class KeyLinksCreateParameters + # The IDs of the child keys to link to the parent key. Can be left empty, to only mark the given translation-key as parent + attr_accessor :child_key_ids + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'child_key_ids' => :'child_key_ids' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'child_key_ids' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::KeyLinksCreateParameters` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::KeyLinksCreateParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'child_key_ids') + if (value = attributes[:'child_key_ids']).is_a?(Array) + self.child_key_ids = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + if @child_key_ids.nil? + invalid_properties.push('invalid value for "child_key_ids", child_key_ids cannot be nil.') + end + + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + return false if @child_key_ids.nil? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + child_key_ids == o.child_key_ids + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [child_key_ids].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :Time + Time.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + Phrase.const_get(type).build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/lib/phrase/models/key_links_index400_response.rb b/lib/phrase/models/key_links_index400_response.rb new file mode 100644 index 0000000..286b767 --- /dev/null +++ b/lib/phrase/models/key_links_index400_response.rb @@ -0,0 +1,196 @@ +require 'date' + +module Phrase + class KeyLinksIndex400Response + attr_accessor :message + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'message' => :'message' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'message' => :'String' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::KeyLinksIndex400Response` initialize method" + end + + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::KeyLinksIndex400Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'message') + self.message = attributes[:'message'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + message == o.message + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [message].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end # or else data not found in attributes(hash), not an issue as the data can be optional + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :DateTime + DateTime.parse(value) + when :Date + Date.parse(value) + when :Time + Time.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + Phrase.const_get(type).build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + end +end diff --git a/spec/api/linked_keys_api_spec.rb b/spec/api/linked_keys_api_spec.rb new file mode 100644 index 0000000..da64ea7 --- /dev/null +++ b/spec/api/linked_keys_api_spec.rb @@ -0,0 +1,79 @@ +require 'spec_helper' +require 'json' + +# Unit tests for Phrase::LinkedKeysApi +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe 'LinkedKeysApi' do + before do + # run before each test + @api_instance = Phrase::LinkedKeysApi.new + end + + after do + # run after each test + end + + describe 'test an instance of LinkedKeysApi' do + it 'should create an instance of LinkedKeysApi' do + expect(@api_instance).to be_instance_of(Phrase::LinkedKeysApi) + end + end + + # unit tests for key_links_batch_destroy + # Batch unlink child keys from a parent key + # Unlinks multiple child keys from a given parent key in a single operation. + # @param account_id Account ID + # @param key_links_batch_destroy_parameters + # @param [Hash] opts the optional parameters + # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) + # @option opts [Boolean] :unlink_parent Whether to unlink the parent key as well and unmark it as linked-key. + # @return [nil] + describe 'key_links_batch_destroy test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for key_links_create + # Link child keys to a parent key + # Creates links between a given parent key and one or more child keys. + # @param account_id Account ID + # @param key_links_create_parameters + # @param [Hash] opts the optional parameters + # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) + # @return [KeyLink] + describe 'key_links_create test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for key_links_destroy + # Unlink a child key from a parent key + # Unlinks a single child key from a given parent key. + # @param account_id Account ID + # @param child_key_id The ID of the child key to unlink. + # @param [Hash] opts the optional parameters + # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) + # @return [nil] + describe 'key_links_destroy test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + # unit tests for key_links_index + # Retrieve all child keys linked to a specific parent key + # Returns detailed information about a parent key, including its linked child keys. + # @param account_id Account ID + # @param [Hash] opts the optional parameters + # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) + # @return [KeyLink] + describe 'key_links_index test' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/spec/models/key_link_spec.rb b/spec/models/key_link_spec.rb new file mode 100644 index 0000000..7a6c359 --- /dev/null +++ b/spec/models/key_link_spec.rb @@ -0,0 +1,65 @@ +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Phrase::KeyLink +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe 'KeyLink' do + before do + # run before each test + @instance = Phrase::KeyLink.new + end + + after do + # run after each test + end + + describe 'test an instance of KeyLink' do + it 'should create an instance of KeyLink' do + expect(@instance).to be_instance_of(Phrase::KeyLink) + end + end + describe 'test attribute "created_at"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "updated_at"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "created_by"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "updated_by"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "account"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "parent"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "children"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/spec/models/key_links_batch_destroy_parameters_spec.rb b/spec/models/key_links_batch_destroy_parameters_spec.rb new file mode 100644 index 0000000..caf3306 --- /dev/null +++ b/spec/models/key_links_batch_destroy_parameters_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Phrase::KeyLinksBatchDestroyParameters +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe 'KeyLinksBatchDestroyParameters' do + before do + # run before each test + @instance = Phrase::KeyLinksBatchDestroyParameters.new + end + + after do + # run after each test + end + + describe 'test an instance of KeyLinksBatchDestroyParameters' do + it 'should create an instance of KeyLinksBatchDestroyParameters' do + expect(@instance).to be_instance_of(Phrase::KeyLinksBatchDestroyParameters) + end + end + describe 'test attribute "child_key_ids"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/spec/models/key_links_create_parameters_spec.rb b/spec/models/key_links_create_parameters_spec.rb new file mode 100644 index 0000000..1d2ad2a --- /dev/null +++ b/spec/models/key_links_create_parameters_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Phrase::KeyLinksCreateParameters +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe 'KeyLinksCreateParameters' do + before do + # run before each test + @instance = Phrase::KeyLinksCreateParameters.new + end + + after do + # run after each test + end + + describe 'test an instance of KeyLinksCreateParameters' do + it 'should create an instance of KeyLinksCreateParameters' do + expect(@instance).to be_instance_of(Phrase::KeyLinksCreateParameters) + end + end + describe 'test attribute "child_key_ids"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end diff --git a/spec/models/key_links_index400_response_spec.rb b/spec/models/key_links_index400_response_spec.rb new file mode 100644 index 0000000..4d995ad --- /dev/null +++ b/spec/models/key_links_index400_response_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Phrase::KeyLinksIndex400Response +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe 'KeyLinksIndex400Response' do + before do + # run before each test + @instance = Phrase::KeyLinksIndex400Response.new + end + + after do + # run after each test + end + + describe 'test an instance of KeyLinksIndex400Response' do + it 'should create an instance of KeyLinksIndex400Response' do + expect(@instance).to be_instance_of(Phrase::KeyLinksIndex400Response) + end + end + describe 'test attribute "message"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end