From 3498464099bcde694317ef97d79a414f34c9abe8 Mon Sep 17 00:00:00 2001 From: Phrase Date: Tue, 2 Jan 2024 10:03:04 +0000 Subject: [PATCH] Deploying from phrase/openapi@ce2ed948 --- .openapi-generator/FILES | 6 + README.md | 2 + docs/CustomMetadataApi.md | 38 +-- ...ustomMetadataPropertiesCreateParameters.md | 25 ++ ...ustomMetadataPropertiesUpdateParameters.md | 23 ++ docs/KeyCreateParameters.md | 2 +- docs/KeyUpdateParameters.md | 2 +- docs/ProjectCreateParameters.md | 2 +- docs/ProjectUpdateParameters.md | 2 +- docs/ScreenshotUpdateParameters.md | 2 +- lib/phrase.rb | 2 + lib/phrase/api/custom_metadata_api.rb | 65 ++--- ...m_metadata_properties_create_parameters.rb | 272 ++++++++++++++++++ ...m_metadata_properties_update_parameters.rb | 231 +++++++++++++++ spec/api/custom_metadata_api_spec.rb | 11 +- ...adata_properties_create_parameters_spec.rb | 53 ++++ ...adata_properties_update_parameters_spec.rb | 47 +++ 17 files changed, 703 insertions(+), 82 deletions(-) create mode 100644 docs/CustomMetadataPropertiesCreateParameters.md create mode 100644 docs/CustomMetadataPropertiesUpdateParameters.md create mode 100644 lib/phrase/models/custom_metadata_properties_create_parameters.rb create mode 100644 lib/phrase/models/custom_metadata_properties_update_parameters.rb create mode 100644 spec/models/custom_metadata_properties_create_parameters_spec.rb create mode 100644 spec/models/custom_metadata_properties_update_parameters_spec.rb diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index db440f8..1b180ec 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -45,6 +45,8 @@ docs/CommentsListParameters.md docs/CurrentUser.md docs/CustomMetadataApi.md docs/CustomMetadataDataType.md +docs/CustomMetadataPropertiesCreateParameters.md +docs/CustomMetadataPropertiesUpdateParameters.md docs/CustomMetadataProperty.md docs/CustomMetadataPropertyCreate422Response.md docs/CustomMetadataPropertyCreate422ResponseErrorsInner.md @@ -341,6 +343,8 @@ lib/phrase/models/comment_update_parameters.rb lib/phrase/models/comments_list_parameters.rb lib/phrase/models/current_user.rb lib/phrase/models/custom_metadata_data_type.rb +lib/phrase/models/custom_metadata_properties_create_parameters.rb +lib/phrase/models/custom_metadata_properties_update_parameters.rb lib/phrase/models/custom_metadata_property.rb lib/phrase/models/custom_metadata_property_create422_response.rb lib/phrase/models/custom_metadata_property_create422_response_errors_inner.rb @@ -592,6 +596,8 @@ spec/models/comment_update_parameters_spec.rb spec/models/comments_list_parameters_spec.rb spec/models/current_user_spec.rb spec/models/custom_metadata_data_type_spec.rb +spec/models/custom_metadata_properties_create_parameters_spec.rb +spec/models/custom_metadata_properties_update_parameters_spec.rb spec/models/custom_metadata_property_create422_response_errors_inner_spec.rb spec/models/custom_metadata_property_create422_response_spec.rb spec/models/custom_metadata_property_spec.rb diff --git a/README.md b/README.md index 2416f24..e18befc 100644 --- a/README.md +++ b/README.md @@ -422,6 +422,8 @@ Class | Method | HTTP request | Description - [Phrase::CommentsListParameters](docs/CommentsListParameters.md) - [Phrase::CurrentUser](docs/CurrentUser.md) - [Phrase::CustomMetadataDataType](docs/CustomMetadataDataType.md) + - [Phrase::CustomMetadataPropertiesCreateParameters](docs/CustomMetadataPropertiesCreateParameters.md) + - [Phrase::CustomMetadataPropertiesUpdateParameters](docs/CustomMetadataPropertiesUpdateParameters.md) - [Phrase::CustomMetadataProperty](docs/CustomMetadataProperty.md) - [Phrase::CustomMetadataPropertyCreate422Response](docs/CustomMetadataPropertyCreate422Response.md) - [Phrase::CustomMetadataPropertyCreate422ResponseErrorsInner](docs/CustomMetadataPropertyCreate422ResponseErrorsInner.md) diff --git a/docs/CustomMetadataApi.md b/docs/CustomMetadataApi.md index 764b401..d2feff9 100644 --- a/docs/CustomMetadataApi.md +++ b/docs/CustomMetadataApi.md @@ -149,7 +149,7 @@ Response<([**Array<CustomMetadataProperty>**](CustomMetadataProperty.md))> ## custom_metadata_property_create -> CustomMetadataProperty custom_metadata_property_create(account_id, name, data_type, opts) +> CustomMetadataProperty custom_metadata_property_create(account_id, custom_metadata_properties_create_parameters, opts) Create a property @@ -173,18 +173,14 @@ end api_instance = Phrase::CustomMetadataApi.new account_id = 'account_id_example' # String | Account ID -name = '["Fruit"]' # String | name of the property -data_type = Phrase::CustomMetadataDataType::BOOLEAN # CustomMetadataDataType | Data Type of Custom Metadata Property +custom_metadata_properties_create_parameters = Phrase::CustomMetadataPropertiesCreateParameters.new({name: 'Fruit', data_type: Phrase::CustomMetadataDataType::BOOLEAN}) # CustomMetadataPropertiesCreateParameters | opts = { - x_phrase_app_otp: 'x_phrase_app_otp_example', # String | Two-Factor-Authentication token (optional) - description: '["A healthy snack for all ages"]', # String | description of property - project_ids: ['inner_example'], # Array | ids of projects that the property belongs to - value_options: ['inner_example'] # Array | value options of property (only applies to single or multi select properties) + x_phrase_app_otp: 'x_phrase_app_otp_example' # String | Two-Factor-Authentication token (optional) } begin #Create a property - result = api_instance.custom_metadata_property_create(account_id, name, data_type, opts) + result = api_instance.custom_metadata_property_create(account_id, custom_metadata_properties_create_parameters, opts) pp result rescue Phrase::ApiError => e puts "Exception when calling CustomMetadataApi->custom_metadata_property_create: #{e}" @@ -197,12 +193,8 @@ end Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **account_id** | **String**| Account ID | - **name** | **String**| name of the property | - **data_type** | [**CustomMetadataDataType**](.md)| Data Type of Custom Metadata Property | + **custom_metadata_properties_create_parameters** | [**CustomMetadataPropertiesCreateParameters**](CustomMetadataPropertiesCreateParameters.md)| | **x_phrase_app_otp** | **String**| Two-Factor-Authentication token (optional) | [optional] - **description** | **String**| description of property | [optional] - **project_ids** | [**Array<String>**](String.md)| ids of projects that the property belongs to | [optional] - **value_options** | [**Array<String>**](String.md)| value options of property (only applies to single or multi select properties) | [optional] ### Return type @@ -214,7 +206,7 @@ Response<([**CustomMetadataProperty**](CustomMetadataProperty.md))> ### HTTP request headers -- **Content-Type**: Not defined +- **Content-Type**: application/json - **Accept**: application/json @@ -283,7 +275,7 @@ Response<([**CustomMetadataProperty**](CustomMetadataProperty.md))> ## custom_metadata_property_update -> CustomMetadataProperty custom_metadata_property_update(account_id, id, opts) +> CustomMetadataProperty custom_metadata_property_update(account_id, id, custom_metadata_properties_update_parameters, opts) Update a property @@ -308,17 +300,14 @@ end api_instance = Phrase::CustomMetadataApi.new account_id = 'account_id_example' # String | Account ID id = 'id_example' # String | ID +custom_metadata_properties_update_parameters = Phrase::CustomMetadataPropertiesUpdateParameters.new # CustomMetadataPropertiesUpdateParameters | opts = { - x_phrase_app_otp: 'x_phrase_app_otp_example', # String | Two-Factor-Authentication token (optional) - name: '["Fruit"]', # String | name of the property - description: '["A healthy snack for all ages"]', # String | description of property - project_ids: ['inner_example'], # Array | ids of projects that the property belongs to - value_options: ['inner_example'] # Array | value options of property (only applies to single or multi select properties) + x_phrase_app_otp: 'x_phrase_app_otp_example' # String | Two-Factor-Authentication token (optional) } begin #Update a property - result = api_instance.custom_metadata_property_update(account_id, id, opts) + result = api_instance.custom_metadata_property_update(account_id, id, custom_metadata_properties_update_parameters, opts) pp result rescue Phrase::ApiError => e puts "Exception when calling CustomMetadataApi->custom_metadata_property_update: #{e}" @@ -332,11 +321,8 @@ Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- **account_id** | **String**| Account ID | **id** | **String**| ID | + **custom_metadata_properties_update_parameters** | [**CustomMetadataPropertiesUpdateParameters**](CustomMetadataPropertiesUpdateParameters.md)| | **x_phrase_app_otp** | **String**| Two-Factor-Authentication token (optional) | [optional] - **name** | **String**| name of the property | [optional] - **description** | **String**| description of property | [optional] - **project_ids** | [**Array<String>**](String.md)| ids of projects that the property belongs to | [optional] - **value_options** | [**Array<String>**](String.md)| value options of property (only applies to single or multi select properties) | [optional] ### Return type @@ -348,6 +334,6 @@ Response<([**CustomMetadataProperty**](CustomMetadataProperty.md))> ### HTTP request headers -- **Content-Type**: Not defined +- **Content-Type**: application/json - **Accept**: application/json diff --git a/docs/CustomMetadataPropertiesCreateParameters.md b/docs/CustomMetadataPropertiesCreateParameters.md new file mode 100644 index 0000000..02b514b --- /dev/null +++ b/docs/CustomMetadataPropertiesCreateParameters.md @@ -0,0 +1,25 @@ +# Phrase::CustomMetadataPropertiesCreateParameters + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **String** | name of the property | +**data_type** | [**CustomMetadataDataType**](CustomMetadataDataType.md) | | +**project_ids** | **Array<String>** | ids of projects that the property belongs to | [optional] +**description** | **String** | description of property | [optional] +**value_options** | **Array<String>** | value options of property (only applies to single or multi select properties) | [optional] + +## Code Sample + +```ruby +require 'Phrase' + +instance = Phrase::CustomMetadataPropertiesCreateParameters.new(name: Fruit, + data_type: null, + project_ids: ["abcd1234cdef1234abcd1234cdef1234","abcd1234cdef1234abcd1234cdef4321"], + description: A healthy snack for all ages, + value_options: ["Apple","Banana","Coconut"]) +``` + + diff --git a/docs/CustomMetadataPropertiesUpdateParameters.md b/docs/CustomMetadataPropertiesUpdateParameters.md new file mode 100644 index 0000000..fe724f5 --- /dev/null +++ b/docs/CustomMetadataPropertiesUpdateParameters.md @@ -0,0 +1,23 @@ +# Phrase::CustomMetadataPropertiesUpdateParameters + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **String** | name of the property | [optional] +**project_ids** | **Array<String>** | ids of projects that the property belongs to | [optional] +**description** | **String** | description of property | [optional] +**value_options** | **Array<String>** | value options of property (only applies to single or multi select properties) | [optional] + +## Code Sample + +```ruby +require 'Phrase' + +instance = Phrase::CustomMetadataPropertiesUpdateParameters.new(name: Fruit, + project_ids: ["abcd1234cdef1234abcd1234cdef1234","abcd1234cdef1234abcd1234cdef4321"], + description: A healthy snack for all ages, + value_options: ["Apple","Banana","Coconut"]) +``` + + diff --git a/docs/KeyCreateParameters.md b/docs/KeyCreateParameters.md index 9611d96..e42a24e 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@20865ff2, + screenshot: [B@73dbb666, remove_screenshot: null, unformatted: null, default_translation_content: Default translation content, diff --git a/docs/KeyUpdateParameters.md b/docs/KeyUpdateParameters.md index 16c9f21..591b5d8 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@1a7c593b, + screenshot: [B@1bf5745, remove_screenshot: null, unformatted: null, xml_space_preserve: null, diff --git a/docs/ProjectCreateParameters.md b/docs/ProjectCreateParameters.md index cd98eb6..4225663 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@5c96d290, + project_image: [B@2cf065e9, remove_project_image: null, account_id: abcd1234, point_of_contact: abcd1234, diff --git a/docs/ProjectUpdateParameters.md b/docs/ProjectUpdateParameters.md index 4b9f1c0..525a2e9 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@3e908a0b, + project_image: [B@d9fe131, remove_project_image: false, workflow: review, machine_translation_enabled: true, diff --git a/docs/ScreenshotUpdateParameters.md b/docs/ScreenshotUpdateParameters.md index 31fe4d1..55606be 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@4aee166d) + filename: [B@5c2b5f27) ``` diff --git a/lib/phrase.rb b/lib/phrase.rb index 7d757ec..f6e060f 100644 --- a/lib/phrase.rb +++ b/lib/phrase.rb @@ -37,6 +37,8 @@ require 'phrase/models/comments_list_parameters' require 'phrase/models/current_user' require 'phrase/models/custom_metadata_data_type' +require 'phrase/models/custom_metadata_properties_create_parameters' +require 'phrase/models/custom_metadata_properties_update_parameters' require 'phrase/models/custom_metadata_property' require 'phrase/models/custom_metadata_property_create422_response' require 'phrase/models/custom_metadata_property_create422_response_errors_inner' diff --git a/lib/phrase/api/custom_metadata_api.rb b/lib/phrase/api/custom_metadata_api.rb index 39f59f7..38a85d1 100644 --- a/lib/phrase/api/custom_metadata_api.rb +++ b/lib/phrase/api/custom_metadata_api.rb @@ -164,31 +164,23 @@ def custom_metadata_properties_list_with_http_info(account_id, opts = {}) # Create a property # Create a new custom metadata property. # @param account_id [String] Account ID - # @param name [String] name of the property - # @param data_type [CustomMetadataDataType] Data Type of Custom Metadata Property + # @param custom_metadata_properties_create_parameters [CustomMetadataPropertiesCreateParameters] # @param [Hash] opts the optional parameters # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) - # @option opts [String] :description description of property - # @option opts [Array] :project_ids ids of projects that the property belongs to - # @option opts [Array] :value_options value options of property (only applies to single or multi select properties) # @return [CustomMetadataProperty] - def custom_metadata_property_create(account_id, name, data_type, opts = {}) - data, _status_code, _headers = custom_metadata_property_create_with_http_info(account_id, name, data_type, opts) + def custom_metadata_property_create(account_id, custom_metadata_properties_create_parameters, opts = {}) + data, _status_code, _headers = custom_metadata_property_create_with_http_info(account_id, custom_metadata_properties_create_parameters, opts) data end # Create a property # Create a new custom metadata property. # @param account_id [String] Account ID - # @param name [String] name of the property - # @param data_type [CustomMetadataDataType] Data Type of Custom Metadata Property + # @param custom_metadata_properties_create_parameters [CustomMetadataPropertiesCreateParameters] # @param [Hash] opts the optional parameters # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) - # @option opts [String] :description description of property - # @option opts [Array] :project_ids ids of projects that the property belongs to - # @option opts [Array] :value_options value options of property (only applies to single or multi select properties) # @return [Array<(Response<(CustomMetadataProperty)>, Integer, Hash)>] Response<(CustomMetadataProperty)> data, response status code and response headers - def custom_metadata_property_create_with_http_info(account_id, name, data_type, opts = {}) + def custom_metadata_property_create_with_http_info(account_id, custom_metadata_properties_create_parameters, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CustomMetadataApi.custom_metadata_property_create ...' end @@ -196,36 +188,29 @@ def custom_metadata_property_create_with_http_info(account_id, name, data_type, if @api_client.config.client_side_validation && account_id.nil? fail ArgumentError, "Missing the required parameter 'account_id' when calling CustomMetadataApi.custom_metadata_property_create" end - # verify the required parameter 'name' is set - if @api_client.config.client_side_validation && name.nil? - fail ArgumentError, "Missing the required parameter 'name' when calling CustomMetadataApi.custom_metadata_property_create" - end - # verify the required parameter 'data_type' is set - if @api_client.config.client_side_validation && data_type.nil? - fail ArgumentError, "Missing the required parameter 'data_type' when calling CustomMetadataApi.custom_metadata_property_create" + # verify the required parameter 'custom_metadata_properties_create_parameters' is set + if @api_client.config.client_side_validation && custom_metadata_properties_create_parameters.nil? + fail ArgumentError, "Missing the required parameter 'custom_metadata_properties_create_parameters' when calling CustomMetadataApi.custom_metadata_property_create" end # resource path local_var_path = '/accounts/{account_id}/custom_metadata/properties'.sub('{' + 'account_id' + '}', CGI.escape(account_id.to_s)) # query parameters query_params = opts[:query_params] || {} - query_params[:'name'] = name - query_params[:'data_type'] = data_type - query_params[:'description'] = opts[:'description'] if !opts[:'description'].nil? - query_params[:'project_ids'] = @api_client.build_collection_param(opts[:'project_ids'], :multi) if !opts[:'project_ids'].nil? - query_params[:'value_options'] = @api_client.build_collection_param(opts[:'value_options'], :multi) if !opts[:'value_options'].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] + post_body = opts[:body] || @api_client.object_to_http_body(custom_metadata_properties_create_parameters) # return_type return_type = opts[:return_type] || 'CustomMetadataProperty' @@ -326,15 +311,12 @@ def custom_metadata_property_show_with_http_info(account_id, id, opts = {}) # Update an existing custom metadata property. # @param account_id [String] Account ID # @param id [String] ID + # @param custom_metadata_properties_update_parameters [CustomMetadataPropertiesUpdateParameters] # @param [Hash] opts the optional parameters # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) - # @option opts [String] :name name of the property - # @option opts [String] :description description of property - # @option opts [Array] :project_ids ids of projects that the property belongs to - # @option opts [Array] :value_options value options of property (only applies to single or multi select properties) # @return [CustomMetadataProperty] - def custom_metadata_property_update(account_id, id, opts = {}) - data, _status_code, _headers = custom_metadata_property_update_with_http_info(account_id, id, opts) + def custom_metadata_property_update(account_id, id, custom_metadata_properties_update_parameters, opts = {}) + data, _status_code, _headers = custom_metadata_property_update_with_http_info(account_id, id, custom_metadata_properties_update_parameters, opts) data end @@ -342,14 +324,11 @@ def custom_metadata_property_update(account_id, id, opts = {}) # Update an existing custom metadata property. # @param account_id [String] Account ID # @param id [String] ID + # @param custom_metadata_properties_update_parameters [CustomMetadataPropertiesUpdateParameters] # @param [Hash] opts the optional parameters # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) - # @option opts [String] :name name of the property - # @option opts [String] :description description of property - # @option opts [Array] :project_ids ids of projects that the property belongs to - # @option opts [Array] :value_options value options of property (only applies to single or multi select properties) # @return [Array<(Response<(CustomMetadataProperty)>, Integer, Hash)>] Response<(CustomMetadataProperty)> data, response status code and response headers - def custom_metadata_property_update_with_http_info(account_id, id, opts = {}) + def custom_metadata_property_update_with_http_info(account_id, id, custom_metadata_properties_update_parameters, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CustomMetadataApi.custom_metadata_property_update ...' end @@ -361,27 +340,29 @@ def custom_metadata_property_update_with_http_info(account_id, id, opts = {}) if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling CustomMetadataApi.custom_metadata_property_update" end + # verify the required parameter 'custom_metadata_properties_update_parameters' is set + if @api_client.config.client_side_validation && custom_metadata_properties_update_parameters.nil? + fail ArgumentError, "Missing the required parameter 'custom_metadata_properties_update_parameters' when calling CustomMetadataApi.custom_metadata_property_update" + end # resource path local_var_path = '/accounts/{account_id}/custom_metadata/properties/{id}'.sub('{' + 'account_id' + '}', CGI.escape(account_id.to_s)).sub('{' + 'id' + '}', CGI.escape(id.to_s)) # query parameters query_params = opts[:query_params] || {} - query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil? - query_params[:'description'] = opts[:'description'] if !opts[:'description'].nil? - query_params[:'project_ids'] = @api_client.build_collection_param(opts[:'project_ids'], :multi) if !opts[:'project_ids'].nil? - query_params[:'value_options'] = @api_client.build_collection_param(opts[:'value_options'], :multi) if !opts[:'value_options'].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] + post_body = opts[:body] || @api_client.object_to_http_body(custom_metadata_properties_update_parameters) # return_type return_type = opts[:return_type] || 'CustomMetadataProperty' diff --git a/lib/phrase/models/custom_metadata_properties_create_parameters.rb b/lib/phrase/models/custom_metadata_properties_create_parameters.rb new file mode 100644 index 0000000..5d0d17d --- /dev/null +++ b/lib/phrase/models/custom_metadata_properties_create_parameters.rb @@ -0,0 +1,272 @@ +require 'date' + +module Phrase + class CustomMetadataPropertiesCreateParameters + # name of the property + attr_accessor :name + + attr_accessor :data_type + + # ids of projects that the property belongs to + attr_accessor :project_ids + + # description of property + attr_accessor :description + + # value options of property (only applies to single or multi select properties) + attr_accessor :value_options + + class EnumAttributeValidator + attr_reader :datatype + attr_reader :allowable_values + + def initialize(datatype, allowable_values) + @allowable_values = allowable_values.map do |value| + case datatype.to_s + when /Integer/i + value.to_i + when /Float/i + value.to_f + else + value + end + end + end + + def valid?(value) + !value || allowable_values.include?(value) + end + end + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'data_type' => :'data_type', + :'project_ids' => :'project_ids', + :'description' => :'description', + :'value_options' => :'value_options' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'data_type' => :'CustomMetadataDataType', + :'project_ids' => :'Array', + :'description' => :'String', + :'value_options' => :'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::CustomMetadataPropertiesCreateParameters` 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::CustomMetadataPropertiesCreateParameters`. 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?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'data_type') + self.data_type = attributes[:'data_type'] + end + + if attributes.key?(:'project_ids') + if (value = attributes[:'project_ids']).is_a?(Array) + self.project_ids = value + end + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'value_options') + if (value = attributes[:'value_options']).is_a?(Array) + self.value_options = 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 @name.nil? + invalid_properties.push('invalid value for "name", name cannot be nil.') + end + + if @data_type.nil? + invalid_properties.push('invalid value for "data_type", data_type 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 @name.nil? + return false if @data_type.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 && + name == o.name && + data_type == o.data_type && + project_ids == o.project_ids && + description == o.description && + value_options == o.value_options + 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 + [name, data_type, project_ids, description, value_options].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/custom_metadata_properties_update_parameters.rb b/lib/phrase/models/custom_metadata_properties_update_parameters.rb new file mode 100644 index 0000000..31b75ab --- /dev/null +++ b/lib/phrase/models/custom_metadata_properties_update_parameters.rb @@ -0,0 +1,231 @@ +require 'date' + +module Phrase + class CustomMetadataPropertiesUpdateParameters + # name of the property + attr_accessor :name + + # ids of projects that the property belongs to + attr_accessor :project_ids + + # description of property + attr_accessor :description + + # value options of property (only applies to single or multi select properties) + attr_accessor :value_options + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'name' => :'name', + :'project_ids' => :'project_ids', + :'description' => :'description', + :'value_options' => :'value_options' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'name' => :'String', + :'project_ids' => :'Array', + :'description' => :'String', + :'value_options' => :'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::CustomMetadataPropertiesUpdateParameters` 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::CustomMetadataPropertiesUpdateParameters`. 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?(:'name') + self.name = attributes[:'name'] + end + + if attributes.key?(:'project_ids') + if (value = attributes[:'project_ids']).is_a?(Array) + self.project_ids = value + end + end + + if attributes.key?(:'description') + self.description = attributes[:'description'] + end + + if attributes.key?(:'value_options') + if (value = attributes[:'value_options']).is_a?(Array) + self.value_options = 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 + 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 && + name == o.name && + project_ids == o.project_ids && + description == o.description && + value_options == o.value_options + 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 + [name, project_ids, description, value_options].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/custom_metadata_api_spec.rb b/spec/api/custom_metadata_api_spec.rb index 1c40048..b2ff0a0 100644 --- a/spec/api/custom_metadata_api_spec.rb +++ b/spec/api/custom_metadata_api_spec.rb @@ -57,13 +57,9 @@ # Create a property # Create a new custom metadata property. # @param account_id Account ID - # @param name name of the property - # @param data_type Data Type of Custom Metadata Property + # @param custom_metadata_properties_create_parameters # @param [Hash] opts the optional parameters # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) - # @option opts [String] :description description of property - # @option opts [Array] :project_ids ids of projects that the property belongs to - # @option opts [Array] :value_options value options of property (only applies to single or multi select properties) # @return [CustomMetadataProperty] describe 'custom_metadata_property_create test' do it 'should work' do @@ -90,12 +86,9 @@ # Update an existing custom metadata property. # @param account_id Account ID # @param id ID + # @param custom_metadata_properties_update_parameters # @param [Hash] opts the optional parameters # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional) - # @option opts [String] :name name of the property - # @option opts [String] :description description of property - # @option opts [Array] :project_ids ids of projects that the property belongs to - # @option opts [Array] :value_options value options of property (only applies to single or multi select properties) # @return [CustomMetadataProperty] describe 'custom_metadata_property_update test' do it 'should work' do diff --git a/spec/models/custom_metadata_properties_create_parameters_spec.rb b/spec/models/custom_metadata_properties_create_parameters_spec.rb new file mode 100644 index 0000000..24c3616 --- /dev/null +++ b/spec/models/custom_metadata_properties_create_parameters_spec.rb @@ -0,0 +1,53 @@ +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Phrase::CustomMetadataPropertiesCreateParameters +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe 'CustomMetadataPropertiesCreateParameters' do + before do + # run before each test + @instance = Phrase::CustomMetadataPropertiesCreateParameters.new + end + + after do + # run after each test + end + + describe 'test an instance of CustomMetadataPropertiesCreateParameters' do + it 'should create an instance of CustomMetadataPropertiesCreateParameters' do + expect(@instance).to be_instance_of(Phrase::CustomMetadataPropertiesCreateParameters) + end + end + describe 'test attribute "name"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "data_type"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "project_ids"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "description"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "value_options"' 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/custom_metadata_properties_update_parameters_spec.rb b/spec/models/custom_metadata_properties_update_parameters_spec.rb new file mode 100644 index 0000000..afce88f --- /dev/null +++ b/spec/models/custom_metadata_properties_update_parameters_spec.rb @@ -0,0 +1,47 @@ +require 'spec_helper' +require 'json' +require 'date' + +# Unit tests for Phrase::CustomMetadataPropertiesUpdateParameters +# Automatically generated by openapi-generator (https://openapi-generator.tech) +# Please update as you see appropriate +describe 'CustomMetadataPropertiesUpdateParameters' do + before do + # run before each test + @instance = Phrase::CustomMetadataPropertiesUpdateParameters.new + end + + after do + # run after each test + end + + describe 'test an instance of CustomMetadataPropertiesUpdateParameters' do + it 'should create an instance of CustomMetadataPropertiesUpdateParameters' do + expect(@instance).to be_instance_of(Phrase::CustomMetadataPropertiesUpdateParameters) + end + end + describe 'test attribute "name"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "project_ids"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "description"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + + describe 'test attribute "value_options"' do + it 'should work' do + # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers + end + end + +end