phrase 2.20.0 → 2.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/README.md +27 -5
  4. data/docs/CustomMetadataApi.md +339 -0
  5. data/docs/CustomMetadataDataType.md +16 -0
  6. data/docs/CustomMetadataPropertiesCreateParameters.md +25 -0
  7. data/docs/CustomMetadataPropertiesUpdateParameters.md +23 -0
  8. data/docs/CustomMetadataProperty.md +33 -0
  9. data/docs/CustomMetadataPropertyCreate422Response.md +19 -0
  10. data/docs/{InvitationCreate422ResponseErrorsInner.md → CustomMetadataPropertyCreate422ResponseErrorsInner.md} +2 -2
  11. data/docs/Error.md +17 -0
  12. data/docs/ErrorError.md +19 -0
  13. data/docs/KeyCreateParameters.md +4 -2
  14. data/docs/KeyUpdateParameters.md +4 -2
  15. data/docs/KeysApi.md +2 -2
  16. data/docs/KeysSearchParameters.md +1 -1
  17. data/docs/LocaleReport.md +43 -0
  18. data/docs/LocalesApi.md +3 -1
  19. data/docs/ProjectCreateParameters.md +1 -1
  20. data/docs/ProjectReport.md +31 -0
  21. data/docs/ProjectUpdateParameters.md +1 -1
  22. data/docs/ProjectsQualityPerformanceScore200Response.md +21 -0
  23. data/docs/ProjectsQualityPerformanceScore200ResponseAnyOf.md +19 -0
  24. data/docs/ProjectsQualityPerformanceScore200ResponseAnyOfData.md +17 -0
  25. data/docs/ProjectsQualityPerformanceScore200ResponseAnyOfDataTranslationsInner.md +21 -0
  26. data/docs/ProjectsQualityPerformanceScore200ResponseAnyOfErrorsInner.md +21 -0
  27. data/docs/ProjectsQualityPerformanceScoreRequest.md +17 -0
  28. data/docs/QualityPerformanceScoreApi.md +72 -0
  29. data/docs/ReportsApi.md +144 -0
  30. data/docs/ScreenshotUpdateParameters.md +1 -1
  31. data/docs/TranslationKeyDetails.md +3 -1
  32. data/docs/Upload.md +2 -0
  33. data/lib/phrase/api/custom_metadata_api.rb +390 -0
  34. data/lib/phrase/api/keys_api.rb +2 -2
  35. data/lib/phrase/api/locales_api.rb +3 -0
  36. data/lib/phrase/api/quality_performance_score_api.rb +84 -0
  37. data/lib/phrase/api/reports_api.rb +160 -0
  38. data/lib/phrase/models/custom_metadata_data_type.rb +30 -0
  39. data/lib/phrase/models/custom_metadata_properties_create_parameters.rb +272 -0
  40. data/lib/phrase/models/custom_metadata_properties_update_parameters.rb +231 -0
  41. data/lib/phrase/models/custom_metadata_property.rb +294 -0
  42. data/lib/phrase/models/{invitation_create422_response.rb → custom_metadata_property_create422_response.rb} +4 -4
  43. data/lib/phrase/models/{invitation_create422_response_errors_inner.rb → custom_metadata_property_create422_response_errors_inner.rb} +3 -3
  44. data/lib/phrase/models/error.rb +197 -0
  45. data/lib/phrase/models/error_error.rb +205 -0
  46. data/lib/phrase/models/key_create_parameters.rb +14 -4
  47. data/lib/phrase/models/key_update_parameters.rb +14 -4
  48. data/lib/phrase/models/keys_search_parameters.rb +1 -1
  49. data/lib/phrase/models/locale_report.rb +313 -0
  50. data/lib/phrase/models/project_report.rb +259 -0
  51. data/lib/phrase/models/projects_quality_performance_score200_response.rb +237 -0
  52. data/lib/phrase/models/projects_quality_performance_score200_response_any_of.rb +208 -0
  53. data/lib/phrase/models/projects_quality_performance_score200_response_any_of_data.rb +198 -0
  54. data/lib/phrase/models/projects_quality_performance_score200_response_any_of_data_translations_inner.rb +217 -0
  55. data/lib/phrase/models/projects_quality_performance_score200_response_any_of_errors_inner.rb +215 -0
  56. data/lib/phrase/models/projects_quality_performance_score_request.rb +199 -0
  57. data/lib/phrase/models/translation_key_details.rb +15 -4
  58. data/lib/phrase/models/upload.rb +11 -1
  59. data/lib/phrase/version.rb +1 -1
  60. data/lib/phrase.rb +19 -2
  61. data/spec/api/custom_metadata_api_spec.rb +99 -0
  62. data/spec/api/keys_api_spec.rb +1 -1
  63. data/spec/api/quality_performance_score_api_spec.rb +37 -0
  64. data/spec/api/reports_api_spec.rb +55 -0
  65. data/spec/models/custom_metadata_data_type_spec.rb +23 -0
  66. data/spec/models/custom_metadata_properties_create_parameters_spec.rb +53 -0
  67. data/spec/models/custom_metadata_properties_update_parameters_spec.rb +47 -0
  68. data/spec/models/{invitation_create422_response_errors_inner_spec.rb → custom_metadata_property_create422_response_errors_inner_spec.rb} +6 -6
  69. data/spec/models/custom_metadata_property_create422_response_spec.rb +35 -0
  70. data/spec/models/custom_metadata_property_spec.rb +77 -0
  71. data/spec/models/{invitation_create422_response_spec.rb → error_error_spec.rb} +7 -7
  72. data/spec/models/error_spec.rb +29 -0
  73. data/spec/models/key_create_parameters_spec.rb +6 -0
  74. data/spec/models/key_update_parameters_spec.rb +6 -0
  75. data/spec/models/locale_report_spec.rb +107 -0
  76. data/spec/models/project_report_spec.rb +71 -0
  77. data/spec/models/projects_quality_performance_score200_response_any_of_data_spec.rb +29 -0
  78. data/spec/models/projects_quality_performance_score200_response_any_of_data_translations_inner_spec.rb +41 -0
  79. data/spec/models/projects_quality_performance_score200_response_any_of_errors_inner_spec.rb +41 -0
  80. data/spec/models/projects_quality_performance_score200_response_any_of_spec.rb +35 -0
  81. data/spec/models/projects_quality_performance_score200_response_spec.rb +41 -0
  82. data/spec/models/projects_quality_performance_score_request_spec.rb +29 -0
  83. data/spec/models/translation_key_details_spec.rb +6 -0
  84. data/spec/models/upload_spec.rb +6 -0
  85. metadata +285 -217
  86. data/docs/InvitationCreate422Response.md +0 -19
@@ -0,0 +1,160 @@
1
+ require 'cgi'
2
+
3
+ module Phrase
4
+ class ReportsApi
5
+ attr_accessor :api_client
6
+
7
+ def initialize(api_client = ApiClient.default)
8
+ @api_client = api_client
9
+ end
10
+ # List Locale Reports
11
+ # List all locale reports for the given project
12
+ # @param project_id [String] Project ID
13
+ # @param [Hash] opts the optional parameters
14
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
15
+ # @option opts [Integer] :page Page number
16
+ # @option opts [Integer] :per_page Limit on the number of objects to be returned, between 1 and 100. 25 by default
17
+ # @option opts [String] :locale_codes Locale Code
18
+ # @option opts [String] :tag tag
19
+ # @option opts [String] :branch specify the branch to use
20
+ # @return [Array<LocaleReport>]
21
+ def report_locales_list(project_id, opts = {})
22
+ data, _status_code, _headers = report_locales_list_with_http_info(project_id, opts)
23
+ data
24
+ end
25
+
26
+ # List Locale Reports
27
+ # List all locale reports for the given project
28
+ # @param project_id [String] Project ID
29
+ # @param [Hash] opts the optional parameters
30
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
31
+ # @option opts [Integer] :page Page number
32
+ # @option opts [Integer] :per_page Limit on the number of objects to be returned, between 1 and 100. 25 by default
33
+ # @option opts [String] :locale_codes Locale Code
34
+ # @option opts [String] :tag tag
35
+ # @option opts [String] :branch specify the branch to use
36
+ # @return [Array<(Response<(Array<LocaleReport>)>, Integer, Hash)>] Response<(Array<LocaleReport>)> data, response status code and response headers
37
+ def report_locales_list_with_http_info(project_id, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: ReportsApi.report_locales_list ...'
40
+ end
41
+ # verify the required parameter 'project_id' is set
42
+ if @api_client.config.client_side_validation && project_id.nil?
43
+ fail ArgumentError, "Missing the required parameter 'project_id' when calling ReportsApi.report_locales_list"
44
+ end
45
+ # resource path
46
+ local_var_path = '/projects/{project_id}/report/locales'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s))
47
+
48
+ # query parameters
49
+ query_params = opts[:query_params] || {}
50
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
51
+ query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?
52
+ query_params[:'locale_codes'] = opts[:'locale_codes'] if !opts[:'locale_codes'].nil?
53
+ query_params[:'tag'] = opts[:'tag'] if !opts[:'tag'].nil?
54
+ query_params[:'branch'] = opts[:'branch'] if !opts[:'branch'].nil?
55
+
56
+ # header parameters
57
+ header_params = opts[:header_params] || {}
58
+ # HTTP header 'Accept' (if needed)
59
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
60
+ header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
61
+
62
+ # form parameters
63
+ form_params = opts[:form_params] || {}
64
+
65
+ # http body (model)
66
+ post_body = opts[:body]
67
+
68
+ # return_type
69
+ return_type = opts[:return_type] || 'Array<LocaleReport>'
70
+
71
+ # auth_names
72
+ auth_names = opts[:auth_names] || ['Basic', 'Token']
73
+
74
+ new_options = opts.merge(
75
+ :header_params => header_params,
76
+ :query_params => query_params,
77
+ :form_params => form_params,
78
+ :body => post_body,
79
+ :auth_names => auth_names,
80
+ :return_type => return_type
81
+ )
82
+
83
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
84
+ if @api_client.config.debugging
85
+ @api_client.config.logger.debug "API called: ReportsApi#report_locales_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
86
+ end
87
+ response = ::Phrase::Response.new(data, headers)
88
+ return response, status_code, headers
89
+ end
90
+
91
+ # Get Project Report
92
+ # Get report of a single project.
93
+ # @param project_id [String] Project ID
94
+ # @param [Hash] opts the optional parameters
95
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
96
+ # @option opts [String] :branch specify the branch to use
97
+ # @return [ProjectReport]
98
+ def report_show(project_id, opts = {})
99
+ data, _status_code, _headers = report_show_with_http_info(project_id, opts)
100
+ data
101
+ end
102
+
103
+ # Get Project Report
104
+ # Get report of a single project.
105
+ # @param project_id [String] Project ID
106
+ # @param [Hash] opts the optional parameters
107
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
108
+ # @option opts [String] :branch specify the branch to use
109
+ # @return [Array<(Response<(ProjectReport)>, Integer, Hash)>] Response<(ProjectReport)> data, response status code and response headers
110
+ def report_show_with_http_info(project_id, opts = {})
111
+ if @api_client.config.debugging
112
+ @api_client.config.logger.debug 'Calling API: ReportsApi.report_show ...'
113
+ end
114
+ # verify the required parameter 'project_id' is set
115
+ if @api_client.config.client_side_validation && project_id.nil?
116
+ fail ArgumentError, "Missing the required parameter 'project_id' when calling ReportsApi.report_show"
117
+ end
118
+ # resource path
119
+ local_var_path = '/projects/{project_id}/report'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s))
120
+
121
+ # query parameters
122
+ query_params = opts[:query_params] || {}
123
+ query_params[:'branch'] = opts[:'branch'] if !opts[:'branch'].nil?
124
+
125
+ # header parameters
126
+ header_params = opts[:header_params] || {}
127
+ # HTTP header 'Accept' (if needed)
128
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
129
+ header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
130
+
131
+ # form parameters
132
+ form_params = opts[:form_params] || {}
133
+
134
+ # http body (model)
135
+ post_body = opts[:body]
136
+
137
+ # return_type
138
+ return_type = opts[:return_type] || 'ProjectReport'
139
+
140
+ # auth_names
141
+ auth_names = opts[:auth_names] || ['Basic', 'Token']
142
+
143
+ new_options = opts.merge(
144
+ :header_params => header_params,
145
+ :query_params => query_params,
146
+ :form_params => form_params,
147
+ :body => post_body,
148
+ :auth_names => auth_names,
149
+ :return_type => return_type
150
+ )
151
+
152
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
153
+ if @api_client.config.debugging
154
+ @api_client.config.logger.debug "API called: ReportsApi#report_show\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
155
+ end
156
+ response = ::Phrase::Response.new(data, headers)
157
+ return response, status_code, headers
158
+ end
159
+ end
160
+ end
@@ -0,0 +1,30 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class CustomMetadataDataType
5
+ BOOLEAN = "boolean".freeze
6
+ DATE = "date".freeze
7
+ LINK = "link".freeze
8
+ MULTI_SELECT = "multi_select".freeze
9
+ NUMBER = "number".freeze
10
+ SINGLE_SELECT = "single_select".freeze
11
+ STRING = "string".freeze
12
+ TEXT = "text".freeze
13
+
14
+ # Builds the enum from string
15
+ # @param [String] The enum value in the form of the string
16
+ # @return [String] The enum value
17
+ def self.build_from_hash(value)
18
+ new.build_from_hash(value)
19
+ end
20
+
21
+ # Builds the enum from string
22
+ # @param [String] The enum value in the form of the string
23
+ # @return [String] The enum value
24
+ def build_from_hash(value)
25
+ constantValues = CustomMetadataDataType.constants.select { |c| CustomMetadataDataType::const_get(c) == value }
26
+ raise "Invalid ENUM value #{value} for class #CustomMetadataDataType" if constantValues.empty?
27
+ value
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,272 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class CustomMetadataPropertiesCreateParameters
5
+ # name of the property
6
+ attr_accessor :name
7
+
8
+ attr_accessor :data_type
9
+
10
+ # ids of projects that the property belongs to
11
+ attr_accessor :project_ids
12
+
13
+ # description of property
14
+ attr_accessor :description
15
+
16
+ # value options of property (only applies to single or multi select properties)
17
+ attr_accessor :value_options
18
+
19
+ class EnumAttributeValidator
20
+ attr_reader :datatype
21
+ attr_reader :allowable_values
22
+
23
+ def initialize(datatype, allowable_values)
24
+ @allowable_values = allowable_values.map do |value|
25
+ case datatype.to_s
26
+ when /Integer/i
27
+ value.to_i
28
+ when /Float/i
29
+ value.to_f
30
+ else
31
+ value
32
+ end
33
+ end
34
+ end
35
+
36
+ def valid?(value)
37
+ !value || allowable_values.include?(value)
38
+ end
39
+ end
40
+
41
+ # Attribute mapping from ruby-style variable name to JSON key.
42
+ def self.attribute_map
43
+ {
44
+ :'name' => :'name',
45
+ :'data_type' => :'data_type',
46
+ :'project_ids' => :'project_ids',
47
+ :'description' => :'description',
48
+ :'value_options' => :'value_options'
49
+ }
50
+ end
51
+
52
+ # Attribute type mapping.
53
+ def self.openapi_types
54
+ {
55
+ :'name' => :'String',
56
+ :'data_type' => :'CustomMetadataDataType',
57
+ :'project_ids' => :'Array<String>',
58
+ :'description' => :'String',
59
+ :'value_options' => :'Array<String>'
60
+ }
61
+ end
62
+
63
+ # List of attributes with nullable: true
64
+ def self.openapi_nullable
65
+ Set.new([
66
+ ])
67
+ end
68
+
69
+ # Initializes the object
70
+ # @param [Hash] attributes Model attributes in the form of hash
71
+ def initialize(attributes = {})
72
+ if (!attributes.is_a?(Hash))
73
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::CustomMetadataPropertiesCreateParameters` initialize method"
74
+ end
75
+
76
+ # check to see if the attribute exists and convert string to symbol for hash key
77
+ attributes = attributes.each_with_object({}) { |(k, v), h|
78
+ if (!self.class.attribute_map.key?(k.to_sym))
79
+ 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
80
+ end
81
+ h[k.to_sym] = v
82
+ }
83
+
84
+ if attributes.key?(:'name')
85
+ self.name = attributes[:'name']
86
+ end
87
+
88
+ if attributes.key?(:'data_type')
89
+ self.data_type = attributes[:'data_type']
90
+ end
91
+
92
+ if attributes.key?(:'project_ids')
93
+ if (value = attributes[:'project_ids']).is_a?(Array)
94
+ self.project_ids = value
95
+ end
96
+ end
97
+
98
+ if attributes.key?(:'description')
99
+ self.description = attributes[:'description']
100
+ end
101
+
102
+ if attributes.key?(:'value_options')
103
+ if (value = attributes[:'value_options']).is_a?(Array)
104
+ self.value_options = value
105
+ end
106
+ end
107
+ end
108
+
109
+ # Show invalid properties with the reasons. Usually used together with valid?
110
+ # @return Array for valid properties with the reasons
111
+ def list_invalid_properties
112
+ invalid_properties = Array.new
113
+ if @name.nil?
114
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
115
+ end
116
+
117
+ if @data_type.nil?
118
+ invalid_properties.push('invalid value for "data_type", data_type cannot be nil.')
119
+ end
120
+
121
+ invalid_properties
122
+ end
123
+
124
+ # Check to see if the all the properties in the model are valid
125
+ # @return true if the model is valid
126
+ def valid?
127
+ return false if @name.nil?
128
+ return false if @data_type.nil?
129
+ true
130
+ end
131
+
132
+ # Checks equality by comparing each attribute.
133
+ # @param [Object] Object to be compared
134
+ def ==(o)
135
+ return true if self.equal?(o)
136
+ self.class == o.class &&
137
+ name == o.name &&
138
+ data_type == o.data_type &&
139
+ project_ids == o.project_ids &&
140
+ description == o.description &&
141
+ value_options == o.value_options
142
+ end
143
+
144
+ # @see the `==` method
145
+ # @param [Object] Object to be compared
146
+ def eql?(o)
147
+ self == o
148
+ end
149
+
150
+ # Calculates hash code according to all attributes.
151
+ # @return [Integer] Hash code
152
+ def hash
153
+ [name, data_type, project_ids, description, value_options].hash
154
+ end
155
+
156
+ # Builds the object from hash
157
+ # @param [Hash] attributes Model attributes in the form of hash
158
+ # @return [Object] Returns the model itself
159
+ def self.build_from_hash(attributes)
160
+ new.build_from_hash(attributes)
161
+ end
162
+
163
+ # Builds the object from hash
164
+ # @param [Hash] attributes Model attributes in the form of hash
165
+ # @return [Object] Returns the model itself
166
+ def build_from_hash(attributes)
167
+ return nil unless attributes.is_a?(Hash)
168
+ self.class.openapi_types.each_pair do |key, type|
169
+ if type =~ /\AArray<(.*)>/i
170
+ # check to ensure the input is an array given that the attribute
171
+ # is documented as an array but the input is not
172
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
173
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
174
+ end
175
+ elsif !attributes[self.class.attribute_map[key]].nil?
176
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
177
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
178
+ end
179
+
180
+ self
181
+ end
182
+
183
+ # Deserializes the data based on type
184
+ # @param string type Data type
185
+ # @param string value Value to be deserialized
186
+ # @return [Object] Deserialized data
187
+ def _deserialize(type, value)
188
+ case type.to_sym
189
+ when :DateTime
190
+ DateTime.parse(value)
191
+ when :Date
192
+ Date.parse(value)
193
+ when :Time
194
+ Time.parse(value)
195
+ when :String
196
+ value.to_s
197
+ when :Integer
198
+ value.to_i
199
+ when :Float
200
+ value.to_f
201
+ when :Boolean
202
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
203
+ true
204
+ else
205
+ false
206
+ end
207
+ when :Object
208
+ # generic object (usually a Hash), return directly
209
+ value
210
+ when /\AArray<(?<inner_type>.+)>\z/
211
+ inner_type = Regexp.last_match[:inner_type]
212
+ value.map { |v| _deserialize(inner_type, v) }
213
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
214
+ k_type = Regexp.last_match[:k_type]
215
+ v_type = Regexp.last_match[:v_type]
216
+ {}.tap do |hash|
217
+ value.each do |k, v|
218
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
219
+ end
220
+ end
221
+ else # model
222
+ Phrase.const_get(type).build_from_hash(value)
223
+ end
224
+ end
225
+
226
+ # Returns the string representation of the object
227
+ # @return [String] String presentation of the object
228
+ def to_s
229
+ to_hash.to_s
230
+ end
231
+
232
+ # to_body is an alias to to_hash (backward compatibility)
233
+ # @return [Hash] Returns the object in the form of hash
234
+ def to_body
235
+ to_hash
236
+ end
237
+
238
+ # Returns the object in the form of hash
239
+ # @return [Hash] Returns the object in the form of hash
240
+ def to_hash
241
+ hash = {}
242
+ self.class.attribute_map.each_pair do |attr, param|
243
+ value = self.send(attr)
244
+ if value.nil?
245
+ is_nullable = self.class.openapi_nullable.include?(attr)
246
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
247
+ end
248
+
249
+ hash[param] = _to_hash(value)
250
+ end
251
+ hash
252
+ end
253
+
254
+ # Outputs non-array value in the form of hash
255
+ # For object, use to_hash. Otherwise, just return the value
256
+ # @param [Object] value Any valid value
257
+ # @return [Hash] Returns the value in the form of hash
258
+ def _to_hash(value)
259
+ if value.is_a?(Array)
260
+ value.compact.map { |v| _to_hash(v) }
261
+ elsif value.is_a?(Hash)
262
+ {}.tap do |hash|
263
+ value.each { |k, v| hash[k] = _to_hash(v) }
264
+ end
265
+ elsif value.respond_to? :to_hash
266
+ value.to_hash
267
+ else
268
+ value
269
+ end
270
+ end
271
+ end
272
+ end
@@ -0,0 +1,231 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class CustomMetadataPropertiesUpdateParameters
5
+ # name of the property
6
+ attr_accessor :name
7
+
8
+ # ids of projects that the property belongs to
9
+ attr_accessor :project_ids
10
+
11
+ # description of property
12
+ attr_accessor :description
13
+
14
+ # value options of property (only applies to single or multi select properties)
15
+ attr_accessor :value_options
16
+
17
+ # Attribute mapping from ruby-style variable name to JSON key.
18
+ def self.attribute_map
19
+ {
20
+ :'name' => :'name',
21
+ :'project_ids' => :'project_ids',
22
+ :'description' => :'description',
23
+ :'value_options' => :'value_options'
24
+ }
25
+ end
26
+
27
+ # Attribute type mapping.
28
+ def self.openapi_types
29
+ {
30
+ :'name' => :'String',
31
+ :'project_ids' => :'Array<String>',
32
+ :'description' => :'String',
33
+ :'value_options' => :'Array<String>'
34
+ }
35
+ end
36
+
37
+ # List of attributes with nullable: true
38
+ def self.openapi_nullable
39
+ Set.new([
40
+ ])
41
+ end
42
+
43
+ # Initializes the object
44
+ # @param [Hash] attributes Model attributes in the form of hash
45
+ def initialize(attributes = {})
46
+ if (!attributes.is_a?(Hash))
47
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::CustomMetadataPropertiesUpdateParameters` initialize method"
48
+ end
49
+
50
+ # check to see if the attribute exists and convert string to symbol for hash key
51
+ attributes = attributes.each_with_object({}) { |(k, v), h|
52
+ if (!self.class.attribute_map.key?(k.to_sym))
53
+ 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
54
+ end
55
+ h[k.to_sym] = v
56
+ }
57
+
58
+ if attributes.key?(:'name')
59
+ self.name = attributes[:'name']
60
+ end
61
+
62
+ if attributes.key?(:'project_ids')
63
+ if (value = attributes[:'project_ids']).is_a?(Array)
64
+ self.project_ids = value
65
+ end
66
+ end
67
+
68
+ if attributes.key?(:'description')
69
+ self.description = attributes[:'description']
70
+ end
71
+
72
+ if attributes.key?(:'value_options')
73
+ if (value = attributes[:'value_options']).is_a?(Array)
74
+ self.value_options = value
75
+ end
76
+ end
77
+ end
78
+
79
+ # Show invalid properties with the reasons. Usually used together with valid?
80
+ # @return Array for valid properties with the reasons
81
+ def list_invalid_properties
82
+ invalid_properties = Array.new
83
+ invalid_properties
84
+ end
85
+
86
+ # Check to see if the all the properties in the model are valid
87
+ # @return true if the model is valid
88
+ def valid?
89
+ true
90
+ end
91
+
92
+ # Checks equality by comparing each attribute.
93
+ # @param [Object] Object to be compared
94
+ def ==(o)
95
+ return true if self.equal?(o)
96
+ self.class == o.class &&
97
+ name == o.name &&
98
+ project_ids == o.project_ids &&
99
+ description == o.description &&
100
+ value_options == o.value_options
101
+ end
102
+
103
+ # @see the `==` method
104
+ # @param [Object] Object to be compared
105
+ def eql?(o)
106
+ self == o
107
+ end
108
+
109
+ # Calculates hash code according to all attributes.
110
+ # @return [Integer] Hash code
111
+ def hash
112
+ [name, project_ids, description, value_options].hash
113
+ end
114
+
115
+ # Builds the object from hash
116
+ # @param [Hash] attributes Model attributes in the form of hash
117
+ # @return [Object] Returns the model itself
118
+ def self.build_from_hash(attributes)
119
+ new.build_from_hash(attributes)
120
+ end
121
+
122
+ # Builds the object from hash
123
+ # @param [Hash] attributes Model attributes in the form of hash
124
+ # @return [Object] Returns the model itself
125
+ def build_from_hash(attributes)
126
+ return nil unless attributes.is_a?(Hash)
127
+ self.class.openapi_types.each_pair do |key, type|
128
+ if type =~ /\AArray<(.*)>/i
129
+ # check to ensure the input is an array given that the attribute
130
+ # is documented as an array but the input is not
131
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
132
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
133
+ end
134
+ elsif !attributes[self.class.attribute_map[key]].nil?
135
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
136
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
137
+ end
138
+
139
+ self
140
+ end
141
+
142
+ # Deserializes the data based on type
143
+ # @param string type Data type
144
+ # @param string value Value to be deserialized
145
+ # @return [Object] Deserialized data
146
+ def _deserialize(type, value)
147
+ case type.to_sym
148
+ when :DateTime
149
+ DateTime.parse(value)
150
+ when :Date
151
+ Date.parse(value)
152
+ when :Time
153
+ Time.parse(value)
154
+ when :String
155
+ value.to_s
156
+ when :Integer
157
+ value.to_i
158
+ when :Float
159
+ value.to_f
160
+ when :Boolean
161
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
162
+ true
163
+ else
164
+ false
165
+ end
166
+ when :Object
167
+ # generic object (usually a Hash), return directly
168
+ value
169
+ when /\AArray<(?<inner_type>.+)>\z/
170
+ inner_type = Regexp.last_match[:inner_type]
171
+ value.map { |v| _deserialize(inner_type, v) }
172
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
173
+ k_type = Regexp.last_match[:k_type]
174
+ v_type = Regexp.last_match[:v_type]
175
+ {}.tap do |hash|
176
+ value.each do |k, v|
177
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
178
+ end
179
+ end
180
+ else # model
181
+ Phrase.const_get(type).build_from_hash(value)
182
+ end
183
+ end
184
+
185
+ # Returns the string representation of the object
186
+ # @return [String] String presentation of the object
187
+ def to_s
188
+ to_hash.to_s
189
+ end
190
+
191
+ # to_body is an alias to to_hash (backward compatibility)
192
+ # @return [Hash] Returns the object in the form of hash
193
+ def to_body
194
+ to_hash
195
+ end
196
+
197
+ # Returns the object in the form of hash
198
+ # @return [Hash] Returns the object in the form of hash
199
+ def to_hash
200
+ hash = {}
201
+ self.class.attribute_map.each_pair do |attr, param|
202
+ value = self.send(attr)
203
+ if value.nil?
204
+ is_nullable = self.class.openapi_nullable.include?(attr)
205
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
206
+ end
207
+
208
+ hash[param] = _to_hash(value)
209
+ end
210
+ hash
211
+ end
212
+
213
+ # Outputs non-array value in the form of hash
214
+ # For object, use to_hash. Otherwise, just return the value
215
+ # @param [Object] value Any valid value
216
+ # @return [Hash] Returns the value in the form of hash
217
+ def _to_hash(value)
218
+ if value.is_a?(Array)
219
+ value.compact.map { |v| _to_hash(v) }
220
+ elsif value.is_a?(Hash)
221
+ {}.tap do |hash|
222
+ value.each { |k, v| hash[k] = _to_hash(v) }
223
+ end
224
+ elsif value.respond_to? :to_hash
225
+ value.to_hash
226
+ else
227
+ value
228
+ end
229
+ end
230
+ end
231
+ end