phrase 1.0.10 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +25 -9
  3. data/docs/CurrentUser.md +31 -0
  4. data/docs/Invitation.md +9 -1
  5. data/docs/InvitationCreateParameters.md +4 -0
  6. data/docs/InvitationUpdateParameters.md +4 -0
  7. data/docs/InvitationUpdateSettingsParameters.md +19 -0
  8. data/docs/InvitationsApi.md +66 -0
  9. data/docs/JobLocale.md +5 -1
  10. data/docs/KeysApi.md +5 -5
  11. data/docs/LocalesApi.md +5 -4
  12. data/docs/Member.md +7 -1
  13. data/docs/MemberProjectDetail.md +35 -0
  14. data/docs/MemberProjectDetailProjectRoles.md +19 -0
  15. data/docs/MemberSpaces.md +25 -0
  16. data/docs/MemberUpdateParameters.md +4 -0
  17. data/docs/MemberUpdateSettingsParameters.md +19 -0
  18. data/docs/MembersApi.md +66 -0
  19. data/docs/ProjectUpdateParameters.md +43 -9
  20. data/docs/ScreenshotCreateParameters.md +3 -1
  21. data/docs/ScreenshotMarkerCreateParameters.md +3 -1
  22. data/docs/ScreenshotMarkerUpdateParameters.md +3 -1
  23. data/docs/ScreenshotMarkersApi.md +9 -3
  24. data/docs/ScreenshotUpdateParameters.md +3 -1
  25. data/docs/ScreenshotsApi.md +8 -2
  26. data/docs/TranslationsApi.md +25 -25
  27. data/docs/UsersApi.md +2 -2
  28. data/docs/Variable.md +23 -0
  29. data/docs/VariableCreateParameters.md +19 -0
  30. data/docs/VariableUpdateParameters.md +19 -0
  31. data/docs/VariablesApi.md +331 -0
  32. data/lib/phrase.rb +10 -0
  33. data/lib/phrase/api/invitations_api.rb +80 -0
  34. data/lib/phrase/api/keys_api.rb +6 -6
  35. data/lib/phrase/api/locales_api.rb +5 -3
  36. data/lib/phrase/api/members_api.rb +80 -0
  37. data/lib/phrase/api/screenshot_markers_api.rb +9 -0
  38. data/lib/phrase/api/screenshots_api.rb +9 -0
  39. data/lib/phrase/api/translations_api.rb +35 -35
  40. data/lib/phrase/api/users_api.rb +3 -3
  41. data/lib/phrase/api/variables_api.rb +378 -0
  42. data/lib/phrase/models/current_user.rb +257 -0
  43. data/lib/phrase/models/invitation.rb +48 -4
  44. data/lib/phrase/models/invitation_create_parameters.rb +25 -1
  45. data/lib/phrase/models/invitation_update_parameters.rb +25 -1
  46. data/lib/phrase/models/invitation_update_settings_parameters.rb +207 -0
  47. data/lib/phrase/models/job_locale.rb +22 -4
  48. data/lib/phrase/models/member.rb +35 -4
  49. data/lib/phrase/models/member_project_detail.rb +285 -0
  50. data/lib/phrase/models/member_project_detail_project_roles.rb +203 -0
  51. data/lib/phrase/models/member_spaces.rb +230 -0
  52. data/lib/phrase/models/member_update_parameters.rb +25 -1
  53. data/lib/phrase/models/member_update_settings_parameters.rb +207 -0
  54. data/lib/phrase/models/project_update_parameters.rb +183 -13
  55. data/lib/phrase/models/screenshot_create_parameters.rb +11 -1
  56. data/lib/phrase/models/screenshot_marker_create_parameters.rb +11 -1
  57. data/lib/phrase/models/screenshot_marker_update_parameters.rb +11 -1
  58. data/lib/phrase/models/screenshot_update_parameters.rb +11 -1
  59. data/lib/phrase/models/variable.rb +221 -0
  60. data/lib/phrase/models/variable_create_parameters.rb +205 -0
  61. data/lib/phrase/models/variable_update_parameters.rb +205 -0
  62. data/lib/phrase/version.rb +1 -1
  63. data/spec/api/invitations_api_spec.rb +15 -0
  64. data/spec/api/keys_api_spec.rb +2 -2
  65. data/spec/api/locales_api_spec.rb +1 -1
  66. data/spec/api/members_api_spec.rb +15 -0
  67. data/spec/api/screenshot_markers_api_spec.rb +3 -0
  68. data/spec/api/screenshots_api_spec.rb +3 -0
  69. data/spec/api/translations_api_spec.rb +10 -10
  70. data/spec/api/users_api_spec.rb +1 -1
  71. data/spec/api/variables_api_spec.rb +95 -0
  72. data/spec/models/current_user_spec.rb +71 -0
  73. data/spec/models/invitation_create_parameters_spec.rb +12 -0
  74. data/spec/models/invitation_spec.rb +24 -0
  75. data/spec/models/invitation_update_parameters_spec.rb +12 -0
  76. data/spec/models/invitation_update_settings_parameters_spec.rb +35 -0
  77. data/spec/models/job_locale_spec.rb +12 -0
  78. data/spec/models/member_project_detail_project_roles_spec.rb +35 -0
  79. data/spec/models/member_project_detail_spec.rb +83 -0
  80. data/spec/models/member_spaces_spec.rb +53 -0
  81. data/spec/models/member_spec.rb +18 -0
  82. data/spec/models/member_update_parameters_spec.rb +12 -0
  83. data/spec/models/member_update_settings_parameters_spec.rb +35 -0
  84. data/spec/models/project_update_parameters_spec.rb +103 -1
  85. data/spec/models/screenshot_create_parameters_spec.rb +6 -0
  86. data/spec/models/screenshot_marker_create_parameters_spec.rb +6 -0
  87. data/spec/models/screenshot_marker_update_parameters_spec.rb +6 -0
  88. data/spec/models/screenshot_update_parameters_spec.rb +6 -0
  89. data/spec/models/variable_create_parameters_spec.rb +35 -0
  90. data/spec/models/variable_spec.rb +47 -0
  91. data/spec/models/variable_update_parameters_spec.rb +35 -0
  92. metadata +203 -163
@@ -12,6 +12,10 @@ module Phrase
12
12
 
13
13
  attr_accessor :completed
14
14
 
15
+ attr_accessor :translation_completed_at
16
+
17
+ attr_accessor :review_completed_at
18
+
15
19
  # Attribute mapping from ruby-style variable name to JSON key.
16
20
  def self.attribute_map
17
21
  {
@@ -19,7 +23,9 @@ module Phrase
19
23
  :'job' => :'job',
20
24
  :'locale' => :'locale',
21
25
  :'users' => :'users',
22
- :'completed' => :'completed'
26
+ :'completed' => :'completed',
27
+ :'translation_completed_at' => :'translation_completed_at',
28
+ :'review_completed_at' => :'review_completed_at'
23
29
  }
24
30
  end
25
31
 
@@ -30,7 +36,9 @@ module Phrase
30
36
  :'job' => :'JobPreview',
31
37
  :'locale' => :'LocalePreview',
32
38
  :'users' => :'Array<UserPreview>',
33
- :'completed' => :'Boolean'
39
+ :'completed' => :'Boolean',
40
+ :'translation_completed_at' => :'DateTime',
41
+ :'review_completed_at' => :'DateTime'
34
42
  }
35
43
  end
36
44
 
@@ -76,6 +84,14 @@ module Phrase
76
84
  if attributes.key?(:'completed')
77
85
  self.completed = attributes[:'completed']
78
86
  end
87
+
88
+ if attributes.key?(:'translation_completed_at')
89
+ self.translation_completed_at = attributes[:'translation_completed_at']
90
+ end
91
+
92
+ if attributes.key?(:'review_completed_at')
93
+ self.review_completed_at = attributes[:'review_completed_at']
94
+ end
79
95
  end
80
96
 
81
97
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -100,7 +116,9 @@ module Phrase
100
116
  job == o.job &&
101
117
  locale == o.locale &&
102
118
  users == o.users &&
103
- completed == o.completed
119
+ completed == o.completed &&
120
+ translation_completed_at == o.translation_completed_at &&
121
+ review_completed_at == o.review_completed_at
104
122
  end
105
123
 
106
124
  # @see the `==` method
@@ -112,7 +130,7 @@ module Phrase
112
130
  # Calculates hash code according to all attributes.
113
131
  # @return [Integer] Hash code
114
132
  def hash
115
- [id, job, locale, users, completed].hash
133
+ [id, job, locale, users, completed, translation_completed_at, review_completed_at].hash
116
134
  end
117
135
 
118
136
  # Builds the object from hash
@@ -12,6 +12,12 @@ module Phrase
12
12
 
13
13
  attr_accessor :projects
14
14
 
15
+ attr_accessor :permissions
16
+
17
+ attr_accessor :default_locale_codes
18
+
19
+ attr_accessor :spaces
20
+
15
21
  # Attribute mapping from ruby-style variable name to JSON key.
16
22
  def self.attribute_map
17
23
  {
@@ -19,7 +25,10 @@ module Phrase
19
25
  :'email' => :'email',
20
26
  :'username' => :'username',
21
27
  :'role' => :'role',
22
- :'projects' => :'projects'
28
+ :'projects' => :'projects',
29
+ :'permissions' => :'permissions',
30
+ :'default_locale_codes' => :'default_locale_codes',
31
+ :'spaces' => :'spaces'
23
32
  }
24
33
  end
25
34
 
@@ -30,7 +39,10 @@ module Phrase
30
39
  :'email' => :'String',
31
40
  :'username' => :'String',
32
41
  :'role' => :'String',
33
- :'projects' => :'Array<ProjectLocales>'
42
+ :'projects' => :'Array<ProjectLocales>',
43
+ :'permissions' => :'Object',
44
+ :'default_locale_codes' => :'Array<String>',
45
+ :'spaces' => :'Array<MemberSpaces>'
34
46
  }
35
47
  end
36
48
 
@@ -76,6 +88,22 @@ module Phrase
76
88
  self.projects = value
77
89
  end
78
90
  end
91
+
92
+ if attributes.key?(:'permissions')
93
+ self.permissions = attributes[:'permissions']
94
+ end
95
+
96
+ if attributes.key?(:'default_locale_codes')
97
+ if (value = attributes[:'default_locale_codes']).is_a?(Array)
98
+ self.default_locale_codes = value
99
+ end
100
+ end
101
+
102
+ if attributes.key?(:'spaces')
103
+ if (value = attributes[:'spaces']).is_a?(Array)
104
+ self.spaces = value
105
+ end
106
+ end
79
107
  end
80
108
 
81
109
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -100,7 +128,10 @@ module Phrase
100
128
  email == o.email &&
101
129
  username == o.username &&
102
130
  role == o.role &&
103
- projects == o.projects
131
+ projects == o.projects &&
132
+ permissions == o.permissions &&
133
+ default_locale_codes == o.default_locale_codes &&
134
+ spaces == o.spaces
104
135
  end
105
136
 
106
137
  # @see the `==` method
@@ -112,7 +143,7 @@ module Phrase
112
143
  # Calculates hash code according to all attributes.
113
144
  # @return [Integer] Hash code
114
145
  def hash
115
- [id, email, username, role, projects].hash
146
+ [id, email, username, role, projects, permissions, default_locale_codes, spaces].hash
116
147
  end
117
148
 
118
149
  # Builds the object from hash
@@ -0,0 +1,285 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class MemberProjectDetail
5
+ attr_accessor :id
6
+
7
+ attr_accessor :email
8
+
9
+ attr_accessor :username
10
+
11
+ attr_accessor :role
12
+
13
+ attr_accessor :projects
14
+
15
+ attr_accessor :permissions
16
+
17
+ attr_accessor :locale_ids
18
+
19
+ attr_accessor :default_locale_codes
20
+
21
+ attr_accessor :spaces
22
+
23
+ attr_accessor :project_roles
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'id' => :'id',
29
+ :'email' => :'email',
30
+ :'username' => :'username',
31
+ :'role' => :'role',
32
+ :'projects' => :'projects',
33
+ :'permissions' => :'permissions',
34
+ :'locale_ids' => :'locale_ids',
35
+ :'default_locale_codes' => :'default_locale_codes',
36
+ :'spaces' => :'spaces',
37
+ :'project_roles' => :'project_roles'
38
+ }
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'id' => :'String',
45
+ :'email' => :'String',
46
+ :'username' => :'String',
47
+ :'role' => :'String',
48
+ :'projects' => :'Array<ProjectLocales>',
49
+ :'permissions' => :'Object',
50
+ :'locale_ids' => :'Array<String>',
51
+ :'default_locale_codes' => :'Array<String>',
52
+ :'spaces' => :'Array<MemberSpaces>',
53
+ :'project_roles' => :'Array<MemberProjectDetailProjectRoles>'
54
+ }
55
+ end
56
+
57
+ # List of attributes with nullable: true
58
+ def self.openapi_nullable
59
+ Set.new([
60
+ ])
61
+ end
62
+
63
+ # Initializes the object
64
+ # @param [Hash] attributes Model attributes in the form of hash
65
+ def initialize(attributes = {})
66
+ if (!attributes.is_a?(Hash))
67
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::MemberProjectDetail` initialize method"
68
+ end
69
+
70
+ # check to see if the attribute exists and convert string to symbol for hash key
71
+ attributes = attributes.each_with_object({}) { |(k, v), h|
72
+ if (!self.class.attribute_map.key?(k.to_sym))
73
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::MemberProjectDetail`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
74
+ end
75
+ h[k.to_sym] = v
76
+ }
77
+
78
+ if attributes.key?(:'id')
79
+ self.id = attributes[:'id']
80
+ end
81
+
82
+ if attributes.key?(:'email')
83
+ self.email = attributes[:'email']
84
+ end
85
+
86
+ if attributes.key?(:'username')
87
+ self.username = attributes[:'username']
88
+ end
89
+
90
+ if attributes.key?(:'role')
91
+ self.role = attributes[:'role']
92
+ end
93
+
94
+ if attributes.key?(:'projects')
95
+ if (value = attributes[:'projects']).is_a?(Array)
96
+ self.projects = value
97
+ end
98
+ end
99
+
100
+ if attributes.key?(:'permissions')
101
+ self.permissions = attributes[:'permissions']
102
+ end
103
+
104
+ if attributes.key?(:'locale_ids')
105
+ if (value = attributes[:'locale_ids']).is_a?(Array)
106
+ self.locale_ids = value
107
+ end
108
+ end
109
+
110
+ if attributes.key?(:'default_locale_codes')
111
+ if (value = attributes[:'default_locale_codes']).is_a?(Array)
112
+ self.default_locale_codes = value
113
+ end
114
+ end
115
+
116
+ if attributes.key?(:'spaces')
117
+ if (value = attributes[:'spaces']).is_a?(Array)
118
+ self.spaces = value
119
+ end
120
+ end
121
+
122
+ if attributes.key?(:'project_roles')
123
+ if (value = attributes[:'project_roles']).is_a?(Array)
124
+ self.project_roles = value
125
+ end
126
+ end
127
+ end
128
+
129
+ # Show invalid properties with the reasons. Usually used together with valid?
130
+ # @return Array for valid properties with the reasons
131
+ def list_invalid_properties
132
+ invalid_properties = Array.new
133
+ invalid_properties
134
+ end
135
+
136
+ # Check to see if the all the properties in the model are valid
137
+ # @return true if the model is valid
138
+ def valid?
139
+ true
140
+ end
141
+
142
+ # Checks equality by comparing each attribute.
143
+ # @param [Object] Object to be compared
144
+ def ==(o)
145
+ return true if self.equal?(o)
146
+ self.class == o.class &&
147
+ id == o.id &&
148
+ email == o.email &&
149
+ username == o.username &&
150
+ role == o.role &&
151
+ projects == o.projects &&
152
+ permissions == o.permissions &&
153
+ locale_ids == o.locale_ids &&
154
+ default_locale_codes == o.default_locale_codes &&
155
+ spaces == o.spaces &&
156
+ project_roles == o.project_roles
157
+ end
158
+
159
+ # @see the `==` method
160
+ # @param [Object] Object to be compared
161
+ def eql?(o)
162
+ self == o
163
+ end
164
+
165
+ # Calculates hash code according to all attributes.
166
+ # @return [Integer] Hash code
167
+ def hash
168
+ [id, email, username, role, projects, permissions, locale_ids, default_locale_codes, spaces, project_roles].hash
169
+ end
170
+
171
+ # Builds the object from hash
172
+ # @param [Hash] attributes Model attributes in the form of hash
173
+ # @return [Object] Returns the model itself
174
+ def self.build_from_hash(attributes)
175
+ new.build_from_hash(attributes)
176
+ end
177
+
178
+ # Builds the object from hash
179
+ # @param [Hash] attributes Model attributes in the form of hash
180
+ # @return [Object] Returns the model itself
181
+ def build_from_hash(attributes)
182
+ return nil unless attributes.is_a?(Hash)
183
+ self.class.openapi_types.each_pair do |key, type|
184
+ if type =~ /\AArray<(.*)>/i
185
+ # check to ensure the input is an array given that the attribute
186
+ # is documented as an array but the input is not
187
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
188
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
189
+ end
190
+ elsif !attributes[self.class.attribute_map[key]].nil?
191
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
192
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
193
+ end
194
+
195
+ self
196
+ end
197
+
198
+ # Deserializes the data based on type
199
+ # @param string type Data type
200
+ # @param string value Value to be deserialized
201
+ # @return [Object] Deserialized data
202
+ def _deserialize(type, value)
203
+ case type.to_sym
204
+ when :DateTime
205
+ DateTime.parse(value)
206
+ when :Date
207
+ Date.parse(value)
208
+ when :String
209
+ value.to_s
210
+ when :Integer
211
+ value.to_i
212
+ when :Float
213
+ value.to_f
214
+ when :Boolean
215
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
216
+ true
217
+ else
218
+ false
219
+ end
220
+ when :Object
221
+ # generic object (usually a Hash), return directly
222
+ value
223
+ when /\AArray<(?<inner_type>.+)>\z/
224
+ inner_type = Regexp.last_match[:inner_type]
225
+ value.map { |v| _deserialize(inner_type, v) }
226
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
227
+ k_type = Regexp.last_match[:k_type]
228
+ v_type = Regexp.last_match[:v_type]
229
+ {}.tap do |hash|
230
+ value.each do |k, v|
231
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
232
+ end
233
+ end
234
+ else # model
235
+ Phrase.const_get(type).build_from_hash(value)
236
+ end
237
+ end
238
+
239
+ # Returns the string representation of the object
240
+ # @return [String] String presentation of the object
241
+ def to_s
242
+ to_hash.to_s
243
+ end
244
+
245
+ # to_body is an alias to to_hash (backward compatibility)
246
+ # @return [Hash] Returns the object in the form of hash
247
+ def to_body
248
+ to_hash
249
+ end
250
+
251
+ # Returns the object in the form of hash
252
+ # @return [Hash] Returns the object in the form of hash
253
+ def to_hash
254
+ hash = {}
255
+ self.class.attribute_map.each_pair do |attr, param|
256
+ value = self.send(attr)
257
+ if value.nil?
258
+ is_nullable = self.class.openapi_nullable.include?(attr)
259
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
260
+ end
261
+
262
+ hash[param] = _to_hash(value)
263
+ end
264
+ hash
265
+ end
266
+
267
+ # Outputs non-array value in the form of hash
268
+ # For object, use to_hash. Otherwise, just return the value
269
+ # @param [Object] value Any valid value
270
+ # @return [Hash] Returns the value in the form of hash
271
+ def _to_hash(value)
272
+ if value.is_a?(Array)
273
+ value.compact.map { |v| _to_hash(v) }
274
+ elsif value.is_a?(Hash)
275
+ {}.tap do |hash|
276
+ value.each { |k, v| hash[k] = _to_hash(v) }
277
+ end
278
+ elsif value.respond_to? :to_hash
279
+ value.to_hash
280
+ else
281
+ value
282
+ end
283
+ end
284
+ end
285
+ end
@@ -0,0 +1,203 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class MemberProjectDetailProjectRoles
5
+ attr_accessor :project_id
6
+
7
+ attr_accessor :role
8
+
9
+ # Attribute mapping from ruby-style variable name to JSON key.
10
+ def self.attribute_map
11
+ {
12
+ :'project_id' => :'project_id',
13
+ :'role' => :'role'
14
+ }
15
+ end
16
+
17
+ # Attribute type mapping.
18
+ def self.openapi_types
19
+ {
20
+ :'project_id' => :'String',
21
+ :'role' => :'String'
22
+ }
23
+ end
24
+
25
+ # List of attributes with nullable: true
26
+ def self.openapi_nullable
27
+ Set.new([
28
+ ])
29
+ end
30
+
31
+ # Initializes the object
32
+ # @param [Hash] attributes Model attributes in the form of hash
33
+ def initialize(attributes = {})
34
+ if (!attributes.is_a?(Hash))
35
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::MemberProjectDetailProjectRoles` initialize method"
36
+ end
37
+
38
+ # check to see if the attribute exists and convert string to symbol for hash key
39
+ attributes = attributes.each_with_object({}) { |(k, v), h|
40
+ if (!self.class.attribute_map.key?(k.to_sym))
41
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::MemberProjectDetailProjectRoles`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
42
+ end
43
+ h[k.to_sym] = v
44
+ }
45
+
46
+ if attributes.key?(:'project_id')
47
+ self.project_id = attributes[:'project_id']
48
+ end
49
+
50
+ if attributes.key?(:'role')
51
+ self.role = attributes[:'role']
52
+ end
53
+ end
54
+
55
+ # Show invalid properties with the reasons. Usually used together with valid?
56
+ # @return Array for valid properties with the reasons
57
+ def list_invalid_properties
58
+ invalid_properties = Array.new
59
+ invalid_properties
60
+ end
61
+
62
+ # Check to see if the all the properties in the model are valid
63
+ # @return true if the model is valid
64
+ def valid?
65
+ true
66
+ end
67
+
68
+ # Checks equality by comparing each attribute.
69
+ # @param [Object] Object to be compared
70
+ def ==(o)
71
+ return true if self.equal?(o)
72
+ self.class == o.class &&
73
+ project_id == o.project_id &&
74
+ role == o.role
75
+ end
76
+
77
+ # @see the `==` method
78
+ # @param [Object] Object to be compared
79
+ def eql?(o)
80
+ self == o
81
+ end
82
+
83
+ # Calculates hash code according to all attributes.
84
+ # @return [Integer] Hash code
85
+ def hash
86
+ [project_id, role].hash
87
+ end
88
+
89
+ # Builds the object from hash
90
+ # @param [Hash] attributes Model attributes in the form of hash
91
+ # @return [Object] Returns the model itself
92
+ def self.build_from_hash(attributes)
93
+ new.build_from_hash(attributes)
94
+ end
95
+
96
+ # Builds the object from hash
97
+ # @param [Hash] attributes Model attributes in the form of hash
98
+ # @return [Object] Returns the model itself
99
+ def build_from_hash(attributes)
100
+ return nil unless attributes.is_a?(Hash)
101
+ self.class.openapi_types.each_pair do |key, type|
102
+ if type =~ /\AArray<(.*)>/i
103
+ # check to ensure the input is an array given that the attribute
104
+ # is documented as an array but the input is not
105
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
106
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
107
+ end
108
+ elsif !attributes[self.class.attribute_map[key]].nil?
109
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
110
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
111
+ end
112
+
113
+ self
114
+ end
115
+
116
+ # Deserializes the data based on type
117
+ # @param string type Data type
118
+ # @param string value Value to be deserialized
119
+ # @return [Object] Deserialized data
120
+ def _deserialize(type, value)
121
+ case type.to_sym
122
+ when :DateTime
123
+ DateTime.parse(value)
124
+ when :Date
125
+ Date.parse(value)
126
+ when :String
127
+ value.to_s
128
+ when :Integer
129
+ value.to_i
130
+ when :Float
131
+ value.to_f
132
+ when :Boolean
133
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
134
+ true
135
+ else
136
+ false
137
+ end
138
+ when :Object
139
+ # generic object (usually a Hash), return directly
140
+ value
141
+ when /\AArray<(?<inner_type>.+)>\z/
142
+ inner_type = Regexp.last_match[:inner_type]
143
+ value.map { |v| _deserialize(inner_type, v) }
144
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
145
+ k_type = Regexp.last_match[:k_type]
146
+ v_type = Regexp.last_match[:v_type]
147
+ {}.tap do |hash|
148
+ value.each do |k, v|
149
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
150
+ end
151
+ end
152
+ else # model
153
+ Phrase.const_get(type).build_from_hash(value)
154
+ end
155
+ end
156
+
157
+ # Returns the string representation of the object
158
+ # @return [String] String presentation of the object
159
+ def to_s
160
+ to_hash.to_s
161
+ end
162
+
163
+ # to_body is an alias to to_hash (backward compatibility)
164
+ # @return [Hash] Returns the object in the form of hash
165
+ def to_body
166
+ to_hash
167
+ end
168
+
169
+ # Returns the object in the form of hash
170
+ # @return [Hash] Returns the object in the form of hash
171
+ def to_hash
172
+ hash = {}
173
+ self.class.attribute_map.each_pair do |attr, param|
174
+ value = self.send(attr)
175
+ if value.nil?
176
+ is_nullable = self.class.openapi_nullable.include?(attr)
177
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
178
+ end
179
+
180
+ hash[param] = _to_hash(value)
181
+ end
182
+ hash
183
+ end
184
+
185
+ # Outputs non-array value in the form of hash
186
+ # For object, use to_hash. Otherwise, just return the value
187
+ # @param [Object] value Any valid value
188
+ # @return [Hash] Returns the value in the form of hash
189
+ def _to_hash(value)
190
+ if value.is_a?(Array)
191
+ value.compact.map { |v| _to_hash(v) }
192
+ elsif value.is_a?(Hash)
193
+ {}.tap do |hash|
194
+ value.each { |k, v| hash[k] = _to_hash(v) }
195
+ end
196
+ elsif value.respond_to? :to_hash
197
+ value.to_hash
198
+ else
199
+ value
200
+ end
201
+ end
202
+ end
203
+ end