phrase 4.33.0 → 4.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +14 -0
  3. data/README.md +11 -3
  4. data/docs/KeysApi.md +6 -2
  5. data/docs/RepoSync.md +7 -1
  6. data/docs/RepoSyncCreateParameters.md +7 -1
  7. data/docs/RepoSyncCreateParametersExportSchedule.md +27 -0
  8. data/docs/RepoSyncExportSchedule.md +23 -0
  9. data/docs/RepoSyncUpdateParameters.md +23 -0
  10. data/docs/RepoSyncUpdateParametersExportSchedule.md +27 -0
  11. data/docs/RepoSyncsApi.md +66 -0
  12. data/docs/TranslationKey.md +3 -1
  13. data/docs/TranslationKeyDetails.md +2 -0
  14. data/docs/TranslationKeyLinkedKey.md +21 -0
  15. data/docs/TranslationKeyLinkedKeyParent.md +19 -0
  16. data/docs/UserShort.md +23 -0
  17. data/lib/phrase/api/keys_api.rb +6 -0
  18. data/lib/phrase/api/repo_syncs_api.rb +80 -0
  19. data/lib/phrase/models/repo_sync.rb +58 -5
  20. data/lib/phrase/models/repo_sync_create_parameters.rb +35 -4
  21. data/lib/phrase/models/repo_sync_create_parameters_export_schedule.rb +281 -0
  22. data/lib/phrase/models/repo_sync_export_schedule.rb +263 -0
  23. data/lib/phrase/models/repo_sync_update_parameters.rb +250 -0
  24. data/lib/phrase/models/repo_sync_update_parameters_export_schedule.rb +276 -0
  25. data/lib/phrase/models/translation_key.rb +14 -4
  26. data/lib/phrase/models/translation_key_details.rb +11 -1
  27. data/lib/phrase/models/translation_key_linked_key.rb +253 -0
  28. data/lib/phrase/models/translation_key_linked_key_parent.rb +208 -0
  29. data/lib/phrase/models/user_short.rb +223 -0
  30. data/lib/phrase/version.rb +1 -1
  31. data/lib/phrase.rb +7 -0
  32. data/spec/api/keys_api_spec.rb +2 -0
  33. data/spec/api/repo_syncs_api_spec.rb +15 -0
  34. data/spec/models/repo_sync_create_parameters_export_schedule_spec.rb +63 -0
  35. data/spec/models/repo_sync_create_parameters_spec.rb +22 -0
  36. data/spec/models/repo_sync_export_schedule_spec.rb +51 -0
  37. data/spec/models/repo_sync_spec.rb +22 -0
  38. data/spec/models/repo_sync_update_parameters_export_schedule_spec.rb +63 -0
  39. data/spec/models/repo_sync_update_parameters_spec.rb +51 -0
  40. data/spec/models/translation_key_details_spec.rb +6 -0
  41. data/spec/models/translation_key_linked_key_parent_spec.rb +35 -0
  42. data/spec/models/translation_key_linked_key_spec.rb +45 -0
  43. data/spec/models/translation_key_spec.rb +6 -0
  44. data/spec/models/user_short_spec.rb +47 -0
  45. metadata +295 -267
@@ -0,0 +1,276 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ # Updates the schedule for automatic exports. Only applied when `export_triggers` includes `schedule`. Requires `manage_github_sync?` permission and the automatic export feature to be enabled.
5
+ class RepoSyncUpdateParametersExportSchedule
6
+ attr_accessor :frequency
7
+
8
+ attr_accessor :time
9
+
10
+ attr_accessor :time_zone
11
+
12
+ attr_accessor :days_of_week
13
+
14
+ attr_accessor :day_of_month
15
+
16
+ attr_accessor :cron_schedule
17
+
18
+ class EnumAttributeValidator
19
+ attr_reader :datatype
20
+ attr_reader :allowable_values
21
+
22
+ def initialize(datatype, allowable_values)
23
+ @allowable_values = allowable_values.map do |value|
24
+ case datatype.to_s
25
+ when /Integer/i
26
+ value.to_i
27
+ when /Float/i
28
+ value.to_f
29
+ else
30
+ value
31
+ end
32
+ end
33
+ end
34
+
35
+ def valid?(value)
36
+ !value || allowable_values.include?(value)
37
+ end
38
+ end
39
+
40
+ # Attribute mapping from ruby-style variable name to JSON key.
41
+ def self.attribute_map
42
+ {
43
+ :'frequency' => :'frequency',
44
+ :'time' => :'time',
45
+ :'time_zone' => :'time_zone',
46
+ :'days_of_week' => :'days_of_week',
47
+ :'day_of_month' => :'day_of_month',
48
+ :'cron_schedule' => :'cron_schedule'
49
+ }
50
+ end
51
+
52
+ # Attribute type mapping.
53
+ def self.openapi_types
54
+ {
55
+ :'frequency' => :'String',
56
+ :'time' => :'String',
57
+ :'time_zone' => :'String',
58
+ :'days_of_week' => :'String',
59
+ :'day_of_month' => :'Integer',
60
+ :'cron_schedule' => :'String'
61
+ }
62
+ end
63
+
64
+ # List of attributes with nullable: true
65
+ def self.openapi_nullable
66
+ Set.new([
67
+ ])
68
+ end
69
+
70
+ # Initializes the object
71
+ # @param [Hash] attributes Model attributes in the form of hash
72
+ def initialize(attributes = {})
73
+ if (!attributes.is_a?(Hash))
74
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::RepoSyncUpdateParametersExportSchedule` initialize method"
75
+ end
76
+
77
+ # check to see if the attribute exists and convert string to symbol for hash key
78
+ attributes = attributes.each_with_object({}) { |(k, v), h|
79
+ if (!self.class.attribute_map.key?(k.to_sym))
80
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::RepoSyncUpdateParametersExportSchedule`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
81
+ end
82
+ h[k.to_sym] = v
83
+ }
84
+
85
+ if attributes.key?(:'frequency')
86
+ self.frequency = attributes[:'frequency']
87
+ end
88
+
89
+ if attributes.key?(:'time')
90
+ self.time = attributes[:'time']
91
+ end
92
+
93
+ if attributes.key?(:'time_zone')
94
+ self.time_zone = attributes[:'time_zone']
95
+ end
96
+
97
+ if attributes.key?(:'days_of_week')
98
+ self.days_of_week = attributes[:'days_of_week']
99
+ end
100
+
101
+ if attributes.key?(:'day_of_month')
102
+ self.day_of_month = attributes[:'day_of_month']
103
+ end
104
+
105
+ if attributes.key?(:'cron_schedule')
106
+ self.cron_schedule = attributes[:'cron_schedule']
107
+ end
108
+ end
109
+
110
+ # Show invalid properties with the reasons. Usually used together with valid?
111
+ # @return Array for valid properties with the reasons
112
+ def list_invalid_properties
113
+ invalid_properties = Array.new
114
+ invalid_properties
115
+ end
116
+
117
+ # Check to see if the all the properties in the model are valid
118
+ # @return true if the model is valid
119
+ def valid?
120
+ frequency_validator = EnumAttributeValidator.new('String', ["hour", "day", "week", "month", "cron"])
121
+ return false unless frequency_validator.valid?(@frequency)
122
+ true
123
+ end
124
+
125
+ # Custom attribute writer method checking allowed values (enum).
126
+ # @param [Object] frequency Object to be assigned
127
+ def frequency=(frequency)
128
+ validator = EnumAttributeValidator.new('String', ["hour", "day", "week", "month", "cron"])
129
+ unless validator.valid?(frequency)
130
+ fail ArgumentError, "invalid value for \"frequency\", must be one of #{validator.allowable_values}."
131
+ end
132
+ @frequency = frequency
133
+ end
134
+
135
+ # Checks equality by comparing each attribute.
136
+ # @param [Object] Object to be compared
137
+ def ==(o)
138
+ return true if self.equal?(o)
139
+ self.class == o.class &&
140
+ frequency == o.frequency &&
141
+ time == o.time &&
142
+ time_zone == o.time_zone &&
143
+ days_of_week == o.days_of_week &&
144
+ day_of_month == o.day_of_month &&
145
+ cron_schedule == o.cron_schedule
146
+ end
147
+
148
+ # @see the `==` method
149
+ # @param [Object] Object to be compared
150
+ def eql?(o)
151
+ self == o
152
+ end
153
+
154
+ # Calculates hash code according to all attributes.
155
+ # @return [Integer] Hash code
156
+ def hash
157
+ [frequency, time, time_zone, days_of_week, day_of_month, cron_schedule].hash
158
+ end
159
+
160
+ # Builds the object from hash
161
+ # @param [Hash] attributes Model attributes in the form of hash
162
+ # @return [Object] Returns the model itself
163
+ def self.build_from_hash(attributes)
164
+ new.build_from_hash(attributes)
165
+ end
166
+
167
+ # Builds the object from hash
168
+ # @param [Hash] attributes Model attributes in the form of hash
169
+ # @return [Object] Returns the model itself
170
+ def build_from_hash(attributes)
171
+ return nil unless attributes.is_a?(Hash)
172
+ self.class.openapi_types.each_pair do |key, type|
173
+ if type =~ /\AArray<(.*)>/i
174
+ # check to ensure the input is an array given that the attribute
175
+ # is documented as an array but the input is not
176
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
177
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
178
+ end
179
+ elsif !attributes[self.class.attribute_map[key]].nil?
180
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
181
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
182
+ end
183
+
184
+ self
185
+ end
186
+
187
+ # Deserializes the data based on type
188
+ # @param string type Data type
189
+ # @param string value Value to be deserialized
190
+ # @return [Object] Deserialized data
191
+ def _deserialize(type, value)
192
+ case type.to_sym
193
+ when :DateTime
194
+ DateTime.parse(value)
195
+ when :Date
196
+ Date.parse(value)
197
+ when :Time
198
+ Time.parse(value)
199
+ when :String
200
+ value.to_s
201
+ when :Integer
202
+ value.to_i
203
+ when :Float
204
+ value.to_f
205
+ when :Boolean
206
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
207
+ true
208
+ else
209
+ false
210
+ end
211
+ when :Object
212
+ # generic object (usually a Hash), return directly
213
+ value
214
+ when /\AArray<(?<inner_type>.+)>\z/
215
+ inner_type = Regexp.last_match[:inner_type]
216
+ value.map { |v| _deserialize(inner_type, v) }
217
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
218
+ k_type = Regexp.last_match[:k_type]
219
+ v_type = Regexp.last_match[:v_type]
220
+ {}.tap do |hash|
221
+ value.each do |k, v|
222
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
223
+ end
224
+ end
225
+ else # model
226
+ Phrase.const_get(type).build_from_hash(value)
227
+ end
228
+ end
229
+
230
+ # Returns the string representation of the object
231
+ # @return [String] String presentation of the object
232
+ def to_s
233
+ to_hash.to_s
234
+ end
235
+
236
+ # to_body is an alias to to_hash (backward compatibility)
237
+ # @return [Hash] Returns the object in the form of hash
238
+ def to_body
239
+ to_hash
240
+ end
241
+
242
+ # Returns the object in the form of hash
243
+ # @return [Hash] Returns the object in the form of hash
244
+ def to_hash
245
+ hash = {}
246
+ self.class.attribute_map.each_pair do |attr, param|
247
+ value = self.send(attr)
248
+ if value.nil?
249
+ is_nullable = self.class.openapi_nullable.include?(attr)
250
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
251
+ end
252
+
253
+ hash[param] = _to_hash(value)
254
+ end
255
+ hash
256
+ end
257
+
258
+ # Outputs non-array value in the form of hash
259
+ # For object, use to_hash. Otherwise, just return the value
260
+ # @param [Object] value Any valid value
261
+ # @return [Hash] Returns the value in the form of hash
262
+ def _to_hash(value)
263
+ if value.is_a?(Array)
264
+ value.compact.map { |v| _to_hash(v) }
265
+ elsif value.is_a?(Hash)
266
+ {}.tap do |hash|
267
+ value.each { |k, v| hash[k] = _to_hash(v) }
268
+ end
269
+ elsif value.respond_to? :to_hash
270
+ value.to_hash
271
+ else
272
+ value
273
+ end
274
+ end
275
+ end
276
+ end
@@ -22,6 +22,8 @@ module Phrase
22
22
 
23
23
  attr_accessor :updated_at
24
24
 
25
+ attr_accessor :linked_key
26
+
25
27
  # Attribute mapping from ruby-style variable name to JSON key.
26
28
  def self.attribute_map
27
29
  {
@@ -34,7 +36,8 @@ module Phrase
34
36
  :'tags' => :'tags',
35
37
  :'data_type' => :'data_type',
36
38
  :'created_at' => :'created_at',
37
- :'updated_at' => :'updated_at'
39
+ :'updated_at' => :'updated_at',
40
+ :'linked_key' => :'linked_key'
38
41
  }
39
42
  end
40
43
 
@@ -50,13 +53,15 @@ module Phrase
50
53
  :'tags' => :'Array<String>',
51
54
  :'data_type' => :'String',
52
55
  :'created_at' => :'DateTime',
53
- :'updated_at' => :'DateTime'
56
+ :'updated_at' => :'DateTime',
57
+ :'linked_key' => :'TranslationKeyLinkedKey'
54
58
  }
55
59
  end
56
60
 
57
61
  # List of attributes with nullable: true
58
62
  def self.openapi_nullable
59
63
  Set.new([
64
+ :'linked_key'
60
65
  ])
61
66
  end
62
67
 
@@ -116,6 +121,10 @@ module Phrase
116
121
  if attributes.key?(:'updated_at')
117
122
  self.updated_at = attributes[:'updated_at']
118
123
  end
124
+
125
+ if attributes.key?(:'linked_key')
126
+ self.linked_key = attributes[:'linked_key']
127
+ end
119
128
  end
120
129
 
121
130
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -145,7 +154,8 @@ module Phrase
145
154
  tags == o.tags &&
146
155
  data_type == o.data_type &&
147
156
  created_at == o.created_at &&
148
- updated_at == o.updated_at
157
+ updated_at == o.updated_at &&
158
+ linked_key == o.linked_key
149
159
  end
150
160
 
151
161
  # @see the `==` method
@@ -157,7 +167,7 @@ module Phrase
157
167
  # Calculates hash code according to all attributes.
158
168
  # @return [Integer] Hash code
159
169
  def hash
160
- [id, name, description, name_hash, plural, use_ordinal_rules, tags, data_type, created_at, updated_at].hash
170
+ [id, name, description, name_hash, plural, use_ordinal_rules, tags, data_type, created_at, updated_at, linked_key].hash
161
171
  end
162
172
 
163
173
  # Builds the object from hash
@@ -22,6 +22,8 @@ module Phrase
22
22
 
23
23
  attr_accessor :updated_at
24
24
 
25
+ attr_accessor :linked_key
26
+
25
27
  attr_accessor :name_plural
26
28
 
27
29
  attr_accessor :comments_count
@@ -55,6 +57,7 @@ module Phrase
55
57
  :'data_type' => :'data_type',
56
58
  :'created_at' => :'created_at',
57
59
  :'updated_at' => :'updated_at',
60
+ :'linked_key' => :'linked_key',
58
61
  :'name_plural' => :'name_plural',
59
62
  :'comments_count' => :'comments_count',
60
63
  :'max_characters_allowed' => :'max_characters_allowed',
@@ -81,6 +84,7 @@ module Phrase
81
84
  :'data_type' => :'String',
82
85
  :'created_at' => :'DateTime',
83
86
  :'updated_at' => :'DateTime',
87
+ :'linked_key' => :'TranslationKeyLinkedKey',
84
88
  :'name_plural' => :'String',
85
89
  :'comments_count' => :'Integer',
86
90
  :'max_characters_allowed' => :'Integer',
@@ -97,6 +101,7 @@ module Phrase
97
101
  # List of attributes with nullable: true
98
102
  def self.openapi_nullable
99
103
  Set.new([
104
+ :'linked_key',
100
105
  ])
101
106
  end
102
107
 
@@ -164,6 +169,10 @@ module Phrase
164
169
  self.updated_at = attributes[:'updated_at']
165
170
  end
166
171
 
172
+ if attributes.key?(:'linked_key')
173
+ self.linked_key = attributes[:'linked_key']
174
+ end
175
+
167
176
  if attributes.key?(:'name_plural')
168
177
  self.name_plural = attributes[:'name_plural']
169
178
  end
@@ -235,6 +244,7 @@ module Phrase
235
244
  data_type == o.data_type &&
236
245
  created_at == o.created_at &&
237
246
  updated_at == o.updated_at &&
247
+ linked_key == o.linked_key &&
238
248
  name_plural == o.name_plural &&
239
249
  comments_count == o.comments_count &&
240
250
  max_characters_allowed == o.max_characters_allowed &&
@@ -256,7 +266,7 @@ module Phrase
256
266
  # Calculates hash code according to all attributes.
257
267
  # @return [Integer] Hash code
258
268
  def hash
259
- [id, name, description, name_hash, plural, use_ordinal_rules, tags, data_type, created_at, updated_at, name_plural, comments_count, max_characters_allowed, screenshot_url, unformatted, xml_space_preserve, original_file, format_value_type, creator, custom_metadata].hash
269
+ [id, name, description, name_hash, plural, use_ordinal_rules, tags, data_type, created_at, updated_at, linked_key, name_plural, comments_count, max_characters_allowed, screenshot_url, unformatted, xml_space_preserve, original_file, format_value_type, creator, custom_metadata].hash
260
270
  end
261
271
 
262
272
  # Builds the object from hash
@@ -0,0 +1,253 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ # Describes a key's role in a parent–child link relationship.
5
+ class TranslationKeyLinkedKey
6
+ # Whether this key is the parent or the child in the link relationship.
7
+ attr_accessor :role
8
+
9
+ attr_accessor :parent
10
+
11
+ # The number of linked child keys. Set for parent keys.
12
+ attr_accessor :children_count
13
+
14
+ class EnumAttributeValidator
15
+ attr_reader :datatype
16
+ attr_reader :allowable_values
17
+
18
+ def initialize(datatype, allowable_values)
19
+ @allowable_values = allowable_values.map do |value|
20
+ case datatype.to_s
21
+ when /Integer/i
22
+ value.to_i
23
+ when /Float/i
24
+ value.to_f
25
+ else
26
+ value
27
+ end
28
+ end
29
+ end
30
+
31
+ def valid?(value)
32
+ !value || allowable_values.include?(value)
33
+ end
34
+ end
35
+
36
+ # Attribute mapping from ruby-style variable name to JSON key.
37
+ def self.attribute_map
38
+ {
39
+ :'role' => :'role',
40
+ :'parent' => :'parent',
41
+ :'children_count' => :'children_count'
42
+ }
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'role' => :'String',
49
+ :'parent' => :'TranslationKeyLinkedKeyParent',
50
+ :'children_count' => :'Integer'
51
+ }
52
+ end
53
+
54
+ # List of attributes with nullable: true
55
+ def self.openapi_nullable
56
+ Set.new([
57
+ :'parent',
58
+ :'children_count'
59
+ ])
60
+ end
61
+
62
+ # Initializes the object
63
+ # @param [Hash] attributes Model attributes in the form of hash
64
+ def initialize(attributes = {})
65
+ if (!attributes.is_a?(Hash))
66
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::TranslationKeyLinkedKey` initialize method"
67
+ end
68
+
69
+ # check to see if the attribute exists and convert string to symbol for hash key
70
+ attributes = attributes.each_with_object({}) { |(k, v), h|
71
+ if (!self.class.attribute_map.key?(k.to_sym))
72
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::TranslationKeyLinkedKey`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
73
+ end
74
+ h[k.to_sym] = v
75
+ }
76
+
77
+ if attributes.key?(:'role')
78
+ self.role = attributes[:'role']
79
+ end
80
+
81
+ if attributes.key?(:'parent')
82
+ self.parent = attributes[:'parent']
83
+ end
84
+
85
+ if attributes.key?(:'children_count')
86
+ self.children_count = attributes[:'children_count']
87
+ end
88
+ end
89
+
90
+ # Show invalid properties with the reasons. Usually used together with valid?
91
+ # @return Array for valid properties with the reasons
92
+ def list_invalid_properties
93
+ invalid_properties = Array.new
94
+ invalid_properties
95
+ end
96
+
97
+ # Check to see if the all the properties in the model are valid
98
+ # @return true if the model is valid
99
+ def valid?
100
+ role_validator = EnumAttributeValidator.new('String', ["parent", "child"])
101
+ return false unless role_validator.valid?(@role)
102
+ true
103
+ end
104
+
105
+ # Custom attribute writer method checking allowed values (enum).
106
+ # @param [Object] role Object to be assigned
107
+ def role=(role)
108
+ validator = EnumAttributeValidator.new('String', ["parent", "child"])
109
+ unless validator.valid?(role)
110
+ fail ArgumentError, "invalid value for \"role\", must be one of #{validator.allowable_values}."
111
+ end
112
+ @role = role
113
+ end
114
+
115
+ # Checks equality by comparing each attribute.
116
+ # @param [Object] Object to be compared
117
+ def ==(o)
118
+ return true if self.equal?(o)
119
+ self.class == o.class &&
120
+ role == o.role &&
121
+ parent == o.parent &&
122
+ children_count == o.children_count
123
+ end
124
+
125
+ # @see the `==` method
126
+ # @param [Object] Object to be compared
127
+ def eql?(o)
128
+ self == o
129
+ end
130
+
131
+ # Calculates hash code according to all attributes.
132
+ # @return [Integer] Hash code
133
+ def hash
134
+ [role, parent, children_count].hash
135
+ end
136
+
137
+ # Builds the object from hash
138
+ # @param [Hash] attributes Model attributes in the form of hash
139
+ # @return [Object] Returns the model itself
140
+ def self.build_from_hash(attributes)
141
+ new.build_from_hash(attributes)
142
+ end
143
+
144
+ # Builds the object from hash
145
+ # @param [Hash] attributes Model attributes in the form of hash
146
+ # @return [Object] Returns the model itself
147
+ def build_from_hash(attributes)
148
+ return nil unless attributes.is_a?(Hash)
149
+ self.class.openapi_types.each_pair do |key, type|
150
+ if type =~ /\AArray<(.*)>/i
151
+ # check to ensure the input is an array given that the attribute
152
+ # is documented as an array but the input is not
153
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
154
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
155
+ end
156
+ elsif !attributes[self.class.attribute_map[key]].nil?
157
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
158
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
159
+ end
160
+
161
+ self
162
+ end
163
+
164
+ # Deserializes the data based on type
165
+ # @param string type Data type
166
+ # @param string value Value to be deserialized
167
+ # @return [Object] Deserialized data
168
+ def _deserialize(type, value)
169
+ case type.to_sym
170
+ when :DateTime
171
+ DateTime.parse(value)
172
+ when :Date
173
+ Date.parse(value)
174
+ when :Time
175
+ Time.parse(value)
176
+ when :String
177
+ value.to_s
178
+ when :Integer
179
+ value.to_i
180
+ when :Float
181
+ value.to_f
182
+ when :Boolean
183
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
184
+ true
185
+ else
186
+ false
187
+ end
188
+ when :Object
189
+ # generic object (usually a Hash), return directly
190
+ value
191
+ when /\AArray<(?<inner_type>.+)>\z/
192
+ inner_type = Regexp.last_match[:inner_type]
193
+ value.map { |v| _deserialize(inner_type, v) }
194
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
195
+ k_type = Regexp.last_match[:k_type]
196
+ v_type = Regexp.last_match[:v_type]
197
+ {}.tap do |hash|
198
+ value.each do |k, v|
199
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
200
+ end
201
+ end
202
+ else # model
203
+ Phrase.const_get(type).build_from_hash(value)
204
+ end
205
+ end
206
+
207
+ # Returns the string representation of the object
208
+ # @return [String] String presentation of the object
209
+ def to_s
210
+ to_hash.to_s
211
+ end
212
+
213
+ # to_body is an alias to to_hash (backward compatibility)
214
+ # @return [Hash] Returns the object in the form of hash
215
+ def to_body
216
+ to_hash
217
+ end
218
+
219
+ # Returns the object in the form of hash
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_hash
222
+ hash = {}
223
+ self.class.attribute_map.each_pair do |attr, param|
224
+ value = self.send(attr)
225
+ if value.nil?
226
+ is_nullable = self.class.openapi_nullable.include?(attr)
227
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
228
+ end
229
+
230
+ hash[param] = _to_hash(value)
231
+ end
232
+ hash
233
+ end
234
+
235
+ # Outputs non-array value in the form of hash
236
+ # For object, use to_hash. Otherwise, just return the value
237
+ # @param [Object] value Any valid value
238
+ # @return [Hash] Returns the value in the form of hash
239
+ def _to_hash(value)
240
+ if value.is_a?(Array)
241
+ value.compact.map { |v| _to_hash(v) }
242
+ elsif value.is_a?(Hash)
243
+ {}.tap do |hash|
244
+ value.each { |k, v| hash[k] = _to_hash(v) }
245
+ end
246
+ elsif value.respond_to? :to_hash
247
+ value.to_hash
248
+ else
249
+ value
250
+ end
251
+ end
252
+ end
253
+ end