phrase 2.8.3 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +31 -12
  4. data/docs/BitbucketSyncApi.md +2 -2
  5. data/docs/BranchesApi.md +3 -3
  6. data/docs/GitHubSyncApi.md +2 -2
  7. data/docs/GitLabSyncApi.md +2 -2
  8. data/docs/JobCommentsApi.md +6 -6
  9. data/docs/JobLocale.md +3 -1
  10. data/docs/JobLocaleUpdateParameters.md +5 -1
  11. data/docs/JobLocalesCreateParameters.md +6 -2
  12. data/docs/JobTemplateDetails.md +35 -0
  13. data/docs/JobTemplateDetails1.md +21 -0
  14. data/docs/JobTemplateLocaleUpdateParameters.md +6 -2
  15. data/docs/{JobTemplateLocale.md → JobTemplateLocales.md} +6 -4
  16. data/docs/JobTemplateLocalesApi.md +8 -8
  17. data/docs/JobTemplateLocalesCreateParameters.md +5 -1
  18. data/docs/JobTemplatesApi.md +41 -41
  19. data/docs/KeysSearchParameters.md +1 -1
  20. data/docs/LocaleTeamPreview.md +21 -0
  21. data/docs/{JobTemplateUserPreview.md → LocaleUserPreview.md} +2 -2
  22. data/docs/LocalesApi.md +8 -4
  23. data/docs/NotificationGroupDetail.md +1 -1
  24. data/docs/NotificationGroupsApi.md +4 -4
  25. data/docs/NotificationsApi.md +4 -4
  26. data/docs/OrganizationJobTemplate.md +25 -0
  27. data/docs/OrganizationJobTemplateCreateParameters.md +19 -0
  28. data/docs/OrganizationJobTemplateDetails.md +31 -0
  29. data/docs/OrganizationJobTemplateLocaleUpdateParameters.md +27 -0
  30. data/docs/OrganizationJobTemplateLocalesApi.md +341 -0
  31. data/docs/OrganizationJobTemplateLocalesCreateParameters.md +27 -0
  32. data/docs/OrganizationJobTemplateUpdateParameters.md +19 -0
  33. data/docs/OrganizationJobTemplatesApi.md +331 -0
  34. data/docs/Project.md +2 -0
  35. data/docs/ProjectCreateParameters.md +5 -1
  36. data/docs/ProjectDetails.md +2 -0
  37. data/docs/ProjectUpdateParameters.md +5 -1
  38. data/docs/SearchApi.md +1 -1
  39. data/docs/TranslationsApi.md +23 -19
  40. data/docs/TranslationsExcludeParameters.md +1 -1
  41. data/docs/TranslationsIncludeParameters.md +1 -1
  42. data/docs/TranslationsReviewParameters.md +1 -1
  43. data/docs/TranslationsSearchParameters.md +1 -1
  44. data/docs/TranslationsUnverifyParameters.md +1 -1
  45. data/docs/TranslationsVerifyParameters.md +1 -1
  46. data/docs/UploadsApi.md +3 -3
  47. data/lib/phrase/api/bitbucket_sync_api.rb +4 -4
  48. data/lib/phrase/api/branches_api.rb +6 -6
  49. data/lib/phrase/api/git_hub_sync_api.rb +4 -4
  50. data/lib/phrase/api/git_lab_sync_api.rb +4 -4
  51. data/lib/phrase/api/job_comments_api.rb +9 -9
  52. data/lib/phrase/api/job_template_locales_api.rb +12 -12
  53. data/lib/phrase/api/job_templates_api.rb +72 -72
  54. data/lib/phrase/api/locales_api.rb +10 -4
  55. data/lib/phrase/api/notification_groups_api.rb +6 -6
  56. data/lib/phrase/api/notifications_api.rb +6 -6
  57. data/lib/phrase/api/organization_job_template_locales_api.rb +408 -0
  58. data/lib/phrase/api/organization_job_templates_api.rb +378 -0
  59. data/lib/phrase/api/search_api.rb +2 -2
  60. data/lib/phrase/api/translations_api.rb +20 -14
  61. data/lib/phrase/api/uploads_api.rb +2 -2
  62. data/lib/phrase/models/job_locale.rb +13 -2
  63. data/lib/phrase/models/job_locale_update_parameters.rb +28 -4
  64. data/lib/phrase/models/job_locales_create_parameters.rb +33 -4
  65. data/lib/phrase/models/job_template_details.rb +285 -0
  66. data/lib/phrase/models/job_template_details1.rb +214 -0
  67. data/lib/phrase/models/job_template_locale_update_parameters.rb +28 -9
  68. data/lib/phrase/models/{job_template_locale.rb → job_template_locales.rb} +18 -7
  69. data/lib/phrase/models/job_template_locales_create_parameters.rb +28 -4
  70. data/lib/phrase/models/keys_search_parameters.rb +1 -1
  71. data/lib/phrase/models/locale_team_preview.rb +212 -0
  72. data/lib/phrase/models/{job_template_user_preview.rb → locale_user_preview.rb} +3 -3
  73. data/lib/phrase/models/notification_group_detail.rb +1 -1
  74. data/lib/phrase/models/organization_job_template.rb +230 -0
  75. data/lib/phrase/models/organization_job_template_create_parameters.rb +210 -0
  76. data/lib/phrase/models/organization_job_template_details.rb +267 -0
  77. data/lib/phrase/models/organization_job_template_locale_update_parameters.rb +253 -0
  78. data/lib/phrase/models/organization_job_template_locales_create_parameters.rb +263 -0
  79. data/lib/phrase/models/organization_job_template_update_parameters.rb +210 -0
  80. data/lib/phrase/models/project.rb +10 -1
  81. data/lib/phrase/models/project_create_parameters.rb +22 -2
  82. data/lib/phrase/models/project_details.rb +10 -1
  83. data/lib/phrase/models/project_update_parameters.rb +22 -2
  84. data/lib/phrase/models/translations_exclude_parameters.rb +1 -1
  85. data/lib/phrase/models/translations_include_parameters.rb +1 -1
  86. data/lib/phrase/models/translations_review_parameters.rb +1 -1
  87. data/lib/phrase/models/translations_search_parameters.rb +1 -1
  88. data/lib/phrase/models/translations_unverify_parameters.rb +1 -1
  89. data/lib/phrase/models/translations_verify_parameters.rb +1 -1
  90. data/lib/phrase/version.rb +1 -1
  91. data/lib/phrase.rb +13 -2
  92. data/spec/api/bitbucket_sync_api_spec.rb +2 -2
  93. data/spec/api/branches_api_spec.rb +3 -3
  94. data/spec/api/git_hub_sync_api_spec.rb +2 -2
  95. data/spec/api/git_lab_sync_api_spec.rb +2 -2
  96. data/spec/api/job_comments_api_spec.rb +3 -3
  97. data/spec/api/job_template_locales_api_spec.rb +4 -4
  98. data/spec/api/job_templates_api_spec.rb +17 -17
  99. data/spec/api/locales_api_spec.rb +4 -2
  100. data/spec/api/notification_groups_api_spec.rb +2 -2
  101. data/spec/api/notifications_api_spec.rb +2 -2
  102. data/spec/api/organization_job_template_locales_api_spec.rb +100 -0
  103. data/spec/api/organization_job_templates_api_spec.rb +95 -0
  104. data/spec/api/search_api_spec.rb +1 -1
  105. data/spec/api/translations_api_spec.rb +9 -7
  106. data/spec/api/uploads_api_spec.rb +1 -1
  107. data/spec/models/job_locale_spec.rb +6 -0
  108. data/spec/models/job_locale_update_parameters_spec.rb +12 -0
  109. data/spec/models/job_locales_create_parameters_spec.rb +12 -0
  110. data/spec/models/job_template_details1_spec.rb +41 -0
  111. data/spec/models/job_template_details_spec.rb +83 -0
  112. data/spec/models/job_template_locale_update_parameters_spec.rb +12 -0
  113. data/spec/models/job_template_locales_create_parameters_spec.rb +12 -0
  114. data/spec/models/{job_template_locale_spec.rb → job_template_locales_spec.rb} +12 -6
  115. data/spec/models/locale_team_preview_spec.rb +41 -0
  116. data/spec/models/{job_template_user_preview_spec.rb → locale_user_preview_spec.rb} +6 -6
  117. data/spec/models/organization_job_template_create_parameters_spec.rb +35 -0
  118. data/spec/models/organization_job_template_details_spec.rb +71 -0
  119. data/spec/models/organization_job_template_locale_update_parameters_spec.rb +59 -0
  120. data/spec/models/organization_job_template_locales_create_parameters_spec.rb +59 -0
  121. data/spec/models/organization_job_template_spec.rb +53 -0
  122. data/spec/models/organization_job_template_update_parameters_spec.rb +35 -0
  123. data/spec/models/project_create_parameters_spec.rb +12 -0
  124. data/spec/models/project_details_spec.rb +6 -0
  125. data/spec/models/project_spec.rb +6 -0
  126. data/spec/models/project_update_parameters_spec.rb +12 -0
  127. metadata +269 -225
@@ -0,0 +1,253 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class OrganizationJobTemplateLocaleUpdateParameters
5
+ # locale name
6
+ attr_accessor :locale_name
7
+
8
+ # locale code
9
+ attr_accessor :locale_code
10
+
11
+ # Array of user ids to be assigned to the job template locale
12
+ attr_accessor :user_ids
13
+
14
+ # Array of reviewer ids to be assigned to the job template locale
15
+ attr_accessor :reviewer_ids
16
+
17
+ # Array of team ids to be assigned to the job locale as translators
18
+ attr_accessor :translator_team_ids
19
+
20
+ # Array of team ids to be assigned to the job locale as reviewers
21
+ attr_accessor :reviewer_team_ids
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'locale_name' => :'locale_name',
27
+ :'locale_code' => :'locale_code',
28
+ :'user_ids' => :'user_ids',
29
+ :'reviewer_ids' => :'reviewer_ids',
30
+ :'translator_team_ids' => :'translator_team_ids',
31
+ :'reviewer_team_ids' => :'reviewer_team_ids'
32
+ }
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'locale_name' => :'String',
39
+ :'locale_code' => :'String',
40
+ :'user_ids' => :'Array<String>',
41
+ :'reviewer_ids' => :'Array<String>',
42
+ :'translator_team_ids' => :'Array<String>',
43
+ :'reviewer_team_ids' => :'Array<String>'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ ])
51
+ end
52
+
53
+ # Initializes the object
54
+ # @param [Hash] attributes Model attributes in the form of hash
55
+ def initialize(attributes = {})
56
+ if (!attributes.is_a?(Hash))
57
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::OrganizationJobTemplateLocaleUpdateParameters` initialize method"
58
+ end
59
+
60
+ # check to see if the attribute exists and convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h|
62
+ if (!self.class.attribute_map.key?(k.to_sym))
63
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::OrganizationJobTemplateLocaleUpdateParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
64
+ end
65
+ h[k.to_sym] = v
66
+ }
67
+
68
+ if attributes.key?(:'locale_name')
69
+ self.locale_name = attributes[:'locale_name']
70
+ end
71
+
72
+ if attributes.key?(:'locale_code')
73
+ self.locale_code = attributes[:'locale_code']
74
+ end
75
+
76
+ if attributes.key?(:'user_ids')
77
+ if (value = attributes[:'user_ids']).is_a?(Array)
78
+ self.user_ids = value
79
+ end
80
+ end
81
+
82
+ if attributes.key?(:'reviewer_ids')
83
+ if (value = attributes[:'reviewer_ids']).is_a?(Array)
84
+ self.reviewer_ids = value
85
+ end
86
+ end
87
+
88
+ if attributes.key?(:'translator_team_ids')
89
+ if (value = attributes[:'translator_team_ids']).is_a?(Array)
90
+ self.translator_team_ids = value
91
+ end
92
+ end
93
+
94
+ if attributes.key?(:'reviewer_team_ids')
95
+ if (value = attributes[:'reviewer_team_ids']).is_a?(Array)
96
+ self.reviewer_team_ids = value
97
+ end
98
+ end
99
+ end
100
+
101
+ # Show invalid properties with the reasons. Usually used together with valid?
102
+ # @return Array for valid properties with the reasons
103
+ def list_invalid_properties
104
+ invalid_properties = Array.new
105
+ invalid_properties
106
+ end
107
+
108
+ # Check to see if the all the properties in the model are valid
109
+ # @return true if the model is valid
110
+ def valid?
111
+ true
112
+ end
113
+
114
+ # Checks equality by comparing each attribute.
115
+ # @param [Object] Object to be compared
116
+ def ==(o)
117
+ return true if self.equal?(o)
118
+ self.class == o.class &&
119
+ locale_name == o.locale_name &&
120
+ locale_code == o.locale_code &&
121
+ user_ids == o.user_ids &&
122
+ reviewer_ids == o.reviewer_ids &&
123
+ translator_team_ids == o.translator_team_ids &&
124
+ reviewer_team_ids == o.reviewer_team_ids
125
+ end
126
+
127
+ # @see the `==` method
128
+ # @param [Object] Object to be compared
129
+ def eql?(o)
130
+ self == o
131
+ end
132
+
133
+ # Calculates hash code according to all attributes.
134
+ # @return [Integer] Hash code
135
+ def hash
136
+ [locale_name, locale_code, user_ids, reviewer_ids, translator_team_ids, reviewer_team_ids].hash
137
+ end
138
+
139
+ # Builds the object from hash
140
+ # @param [Hash] attributes Model attributes in the form of hash
141
+ # @return [Object] Returns the model itself
142
+ def self.build_from_hash(attributes)
143
+ new.build_from_hash(attributes)
144
+ end
145
+
146
+ # Builds the object from hash
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ # @return [Object] Returns the model itself
149
+ def build_from_hash(attributes)
150
+ return nil unless attributes.is_a?(Hash)
151
+ self.class.openapi_types.each_pair do |key, type|
152
+ if type =~ /\AArray<(.*)>/i
153
+ # check to ensure the input is an array given that the attribute
154
+ # is documented as an array but the input is not
155
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
156
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
157
+ end
158
+ elsif !attributes[self.class.attribute_map[key]].nil?
159
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
160
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
161
+ end
162
+
163
+ self
164
+ end
165
+
166
+ # Deserializes the data based on type
167
+ # @param string type Data type
168
+ # @param string value Value to be deserialized
169
+ # @return [Object] Deserialized data
170
+ def _deserialize(type, value)
171
+ case type.to_sym
172
+ when :DateTime
173
+ DateTime.parse(value)
174
+ when :Date
175
+ Date.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
@@ -0,0 +1,263 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class OrganizationJobTemplateLocalesCreateParameters
5
+ # locale name
6
+ attr_accessor :locale_name
7
+
8
+ # locale code
9
+ attr_accessor :locale_code
10
+
11
+ # Array of user ids to be assigned to the job template locale
12
+ attr_accessor :user_ids
13
+
14
+ # Array of reviewer ids to be assigned to the job template locale
15
+ attr_accessor :reviewer_ids
16
+
17
+ # Array of team ids to be assigned to the job locale as translators
18
+ attr_accessor :translator_team_ids
19
+
20
+ # Array of team ids to be assigned to the job locale as reviewers
21
+ attr_accessor :reviewer_team_ids
22
+
23
+ # Attribute mapping from ruby-style variable name to JSON key.
24
+ def self.attribute_map
25
+ {
26
+ :'locale_name' => :'locale_name',
27
+ :'locale_code' => :'locale_code',
28
+ :'user_ids' => :'user_ids',
29
+ :'reviewer_ids' => :'reviewer_ids',
30
+ :'translator_team_ids' => :'translator_team_ids',
31
+ :'reviewer_team_ids' => :'reviewer_team_ids'
32
+ }
33
+ end
34
+
35
+ # Attribute type mapping.
36
+ def self.openapi_types
37
+ {
38
+ :'locale_name' => :'String',
39
+ :'locale_code' => :'String',
40
+ :'user_ids' => :'Array<String>',
41
+ :'reviewer_ids' => :'Array<String>',
42
+ :'translator_team_ids' => :'Array<String>',
43
+ :'reviewer_team_ids' => :'Array<String>'
44
+ }
45
+ end
46
+
47
+ # List of attributes with nullable: true
48
+ def self.openapi_nullable
49
+ Set.new([
50
+ ])
51
+ end
52
+
53
+ # Initializes the object
54
+ # @param [Hash] attributes Model attributes in the form of hash
55
+ def initialize(attributes = {})
56
+ if (!attributes.is_a?(Hash))
57
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::OrganizationJobTemplateLocalesCreateParameters` initialize method"
58
+ end
59
+
60
+ # check to see if the attribute exists and convert string to symbol for hash key
61
+ attributes = attributes.each_with_object({}) { |(k, v), h|
62
+ if (!self.class.attribute_map.key?(k.to_sym))
63
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::OrganizationJobTemplateLocalesCreateParameters`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
64
+ end
65
+ h[k.to_sym] = v
66
+ }
67
+
68
+ if attributes.key?(:'locale_name')
69
+ self.locale_name = attributes[:'locale_name']
70
+ end
71
+
72
+ if attributes.key?(:'locale_code')
73
+ self.locale_code = attributes[:'locale_code']
74
+ end
75
+
76
+ if attributes.key?(:'user_ids')
77
+ if (value = attributes[:'user_ids']).is_a?(Array)
78
+ self.user_ids = value
79
+ end
80
+ end
81
+
82
+ if attributes.key?(:'reviewer_ids')
83
+ if (value = attributes[:'reviewer_ids']).is_a?(Array)
84
+ self.reviewer_ids = value
85
+ end
86
+ end
87
+
88
+ if attributes.key?(:'translator_team_ids')
89
+ if (value = attributes[:'translator_team_ids']).is_a?(Array)
90
+ self.translator_team_ids = value
91
+ end
92
+ end
93
+
94
+ if attributes.key?(:'reviewer_team_ids')
95
+ if (value = attributes[:'reviewer_team_ids']).is_a?(Array)
96
+ self.reviewer_team_ids = value
97
+ end
98
+ end
99
+ end
100
+
101
+ # Show invalid properties with the reasons. Usually used together with valid?
102
+ # @return Array for valid properties with the reasons
103
+ def list_invalid_properties
104
+ invalid_properties = Array.new
105
+ if @locale_name.nil?
106
+ invalid_properties.push('invalid value for "locale_name", locale_name cannot be nil.')
107
+ end
108
+
109
+ if @locale_code.nil?
110
+ invalid_properties.push('invalid value for "locale_code", locale_code cannot be nil.')
111
+ end
112
+
113
+ invalid_properties
114
+ end
115
+
116
+ # Check to see if the all the properties in the model are valid
117
+ # @return true if the model is valid
118
+ def valid?
119
+ return false if @locale_name.nil?
120
+ return false if @locale_code.nil?
121
+ true
122
+ end
123
+
124
+ # Checks equality by comparing each attribute.
125
+ # @param [Object] Object to be compared
126
+ def ==(o)
127
+ return true if self.equal?(o)
128
+ self.class == o.class &&
129
+ locale_name == o.locale_name &&
130
+ locale_code == o.locale_code &&
131
+ user_ids == o.user_ids &&
132
+ reviewer_ids == o.reviewer_ids &&
133
+ translator_team_ids == o.translator_team_ids &&
134
+ reviewer_team_ids == o.reviewer_team_ids
135
+ end
136
+
137
+ # @see the `==` method
138
+ # @param [Object] Object to be compared
139
+ def eql?(o)
140
+ self == o
141
+ end
142
+
143
+ # Calculates hash code according to all attributes.
144
+ # @return [Integer] Hash code
145
+ def hash
146
+ [locale_name, locale_code, user_ids, reviewer_ids, translator_team_ids, reviewer_team_ids].hash
147
+ end
148
+
149
+ # Builds the object from hash
150
+ # @param [Hash] attributes Model attributes in the form of hash
151
+ # @return [Object] Returns the model itself
152
+ def self.build_from_hash(attributes)
153
+ new.build_from_hash(attributes)
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 build_from_hash(attributes)
160
+ return nil unless attributes.is_a?(Hash)
161
+ self.class.openapi_types.each_pair do |key, type|
162
+ if type =~ /\AArray<(.*)>/i
163
+ # check to ensure the input is an array given that the attribute
164
+ # is documented as an array but the input is not
165
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
166
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
167
+ end
168
+ elsif !attributes[self.class.attribute_map[key]].nil?
169
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
170
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
171
+ end
172
+
173
+ self
174
+ end
175
+
176
+ # Deserializes the data based on type
177
+ # @param string type Data type
178
+ # @param string value Value to be deserialized
179
+ # @return [Object] Deserialized data
180
+ def _deserialize(type, value)
181
+ case type.to_sym
182
+ when :DateTime
183
+ DateTime.parse(value)
184
+ when :Date
185
+ Date.parse(value)
186
+ when :String
187
+ value.to_s
188
+ when :Integer
189
+ value.to_i
190
+ when :Float
191
+ value.to_f
192
+ when :Boolean
193
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
194
+ true
195
+ else
196
+ false
197
+ end
198
+ when :Object
199
+ # generic object (usually a Hash), return directly
200
+ value
201
+ when /\AArray<(?<inner_type>.+)>\z/
202
+ inner_type = Regexp.last_match[:inner_type]
203
+ value.map { |v| _deserialize(inner_type, v) }
204
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
205
+ k_type = Regexp.last_match[:k_type]
206
+ v_type = Regexp.last_match[:v_type]
207
+ {}.tap do |hash|
208
+ value.each do |k, v|
209
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
210
+ end
211
+ end
212
+ else # model
213
+ Phrase.const_get(type).build_from_hash(value)
214
+ end
215
+ end
216
+
217
+ # Returns the string representation of the object
218
+ # @return [String] String presentation of the object
219
+ def to_s
220
+ to_hash.to_s
221
+ end
222
+
223
+ # to_body is an alias to to_hash (backward compatibility)
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_body
226
+ to_hash
227
+ end
228
+
229
+ # Returns the object in the form of hash
230
+ # @return [Hash] Returns the object in the form of hash
231
+ def to_hash
232
+ hash = {}
233
+ self.class.attribute_map.each_pair do |attr, param|
234
+ value = self.send(attr)
235
+ if value.nil?
236
+ is_nullable = self.class.openapi_nullable.include?(attr)
237
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
238
+ end
239
+
240
+ hash[param] = _to_hash(value)
241
+ end
242
+ hash
243
+ end
244
+
245
+ # Outputs non-array value in the form of hash
246
+ # For object, use to_hash. Otherwise, just return the value
247
+ # @param [Object] value Any valid value
248
+ # @return [Hash] Returns the value in the form of hash
249
+ def _to_hash(value)
250
+ if value.is_a?(Array)
251
+ value.compact.map { |v| _to_hash(v) }
252
+ elsif value.is_a?(Hash)
253
+ {}.tap do |hash|
254
+ value.each { |k, v| hash[k] = _to_hash(v) }
255
+ end
256
+ elsif value.respond_to? :to_hash
257
+ value.to_hash
258
+ else
259
+ value
260
+ end
261
+ end
262
+ end
263
+ end