phrase 2.3.1 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -3
  3. data/docs/Distribution.md +2 -0
  4. data/docs/DistributionCreateParameters.md +2 -0
  5. data/docs/DistributionUpdateParameters.md +2 -0
  6. data/docs/ICUApi.md +70 -0
  7. data/docs/Icu.md +17 -0
  8. data/docs/IcuSkeletonParameters.md +23 -0
  9. data/docs/Invitation.md +2 -0
  10. data/docs/InvitationCreateParameters.md +2 -0
  11. data/docs/InvitationUpdateParameters.md +2 -0
  12. data/docs/JobLocaleCompleteReviewParameters.md +17 -0
  13. data/docs/JobLocaleUpdateParameters.md +3 -1
  14. data/docs/JobLocalesApi.md +68 -0
  15. data/docs/JobLocalesCreateParameters.md +4 -2
  16. data/docs/Member.md +6 -0
  17. data/docs/Project.md +2 -0
  18. data/docs/ProjectDetails.md +2 -0
  19. data/docs/ProjectLocales.md +2 -0
  20. data/docs/ProjectMemberSpecific.md +27 -0
  21. data/docs/ReleaseCreateParameters.md +2 -0
  22. data/docs/Team1.md +23 -0
  23. data/docs/UserPreview.md +3 -1
  24. data/lib/phrase/api/icu_api.rb +78 -0
  25. data/lib/phrase/api/job_locales_api.rb +86 -0
  26. data/lib/phrase/models/distribution.rb +12 -1
  27. data/lib/phrase/models/distribution_create_parameters.rb +13 -1
  28. data/lib/phrase/models/distribution_update_parameters.rb +13 -1
  29. data/lib/phrase/models/icu.rb +195 -0
  30. data/lib/phrase/models/icu_skeleton_parameters.rb +227 -0
  31. data/lib/phrase/models/invitation.rb +12 -1
  32. data/lib/phrase/models/invitation_create_parameters.rb +13 -1
  33. data/lib/phrase/models/invitation_update_parameters.rb +13 -1
  34. data/lib/phrase/models/job_locale_complete_review_parameters.rb +195 -0
  35. data/lib/phrase/models/job_locale_update_parameters.rb +16 -4
  36. data/lib/phrase/models/job_locales_create_parameters.rb +17 -5
  37. data/lib/phrase/models/member.rb +30 -1
  38. data/lib/phrase/models/project.rb +10 -1
  39. data/lib/phrase/models/project_details.rb +10 -1
  40. data/lib/phrase/models/project_locales.rb +11 -2
  41. data/lib/phrase/models/project_member_specific.rb +239 -0
  42. data/lib/phrase/models/release_create_parameters.rb +13 -1
  43. data/lib/phrase/models/team1.rb +221 -0
  44. data/lib/phrase/models/user_preview.rb +13 -4
  45. data/lib/phrase/response.rb +1 -1
  46. data/lib/phrase/version.rb +1 -1
  47. data/lib/phrase.rb +6 -0
  48. data/phrase.gemspec +2 -2
  49. data/spec/api/icu_api_spec.rb +36 -0
  50. data/spec/api/job_locales_api_spec.rb +16 -0
  51. data/spec/models/distribution_create_parameters_spec.rb +6 -0
  52. data/spec/models/distribution_spec.rb +6 -0
  53. data/spec/models/distribution_update_parameters_spec.rb +6 -0
  54. data/spec/models/icu_skeleton_parameters_spec.rb +47 -0
  55. data/spec/models/icu_spec.rb +29 -0
  56. data/spec/models/invitation_create_parameters_spec.rb +6 -0
  57. data/spec/models/invitation_spec.rb +6 -0
  58. data/spec/models/invitation_update_parameters_spec.rb +6 -0
  59. data/spec/models/job_locale_complete_review_parameters_spec.rb +29 -0
  60. data/spec/models/job_locale_update_parameters_spec.rb +6 -0
  61. data/spec/models/job_locales_create_parameters_spec.rb +6 -0
  62. data/spec/models/member_spec.rb +18 -0
  63. data/spec/models/project_details_spec.rb +6 -0
  64. data/spec/models/project_locales_spec.rb +6 -0
  65. data/spec/models/project_member_specific_spec.rb +59 -0
  66. data/spec/models/project_spec.rb +6 -0
  67. data/spec/models/release_create_parameters_spec.rb +6 -0
  68. data/spec/models/team1_spec.rb +47 -0
  69. data/spec/models/user_preview_spec.rb +6 -0
  70. metadata +221 -197
@@ -0,0 +1,78 @@
1
+ require 'cgi'
2
+
3
+ module Phrase
4
+ class ICUApi
5
+ attr_accessor :api_client
6
+
7
+ def initialize(api_client = ApiClient.default)
8
+ @api_client = api_client
9
+ end
10
+ # Build icu skeletons
11
+ # Returns icu skeletons for multiple locale codes based on a source content.
12
+ # @param icu_skeleton_parameters [IcuSkeletonParameters]
13
+ # @param [Hash] opts the optional parameters
14
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
15
+ # @return [Icu]
16
+ def icu_skeleton(icu_skeleton_parameters, opts = {})
17
+ data, _status_code, _headers = icu_skeleton_with_http_info(icu_skeleton_parameters, opts)
18
+ data
19
+ end
20
+
21
+ # Build icu skeletons
22
+ # Returns icu skeletons for multiple locale codes based on a source content.
23
+ # @param icu_skeleton_parameters [IcuSkeletonParameters]
24
+ # @param [Hash] opts the optional parameters
25
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
26
+ # @return [Array<(Response<(Icu)>, Integer, Hash)>] Response<(Icu)> data, response status code and response headers
27
+ def icu_skeleton_with_http_info(icu_skeleton_parameters, opts = {})
28
+ if @api_client.config.debugging
29
+ @api_client.config.logger.debug 'Calling API: ICUApi.icu_skeleton ...'
30
+ end
31
+ # verify the required parameter 'icu_skeleton_parameters' is set
32
+ if @api_client.config.client_side_validation && icu_skeleton_parameters.nil?
33
+ fail ArgumentError, "Missing the required parameter 'icu_skeleton_parameters' when calling ICUApi.icu_skeleton"
34
+ end
35
+ # resource path
36
+ local_var_path = '/icu/skeleton'
37
+
38
+ # query parameters
39
+ query_params = opts[:query_params] || {}
40
+
41
+ # header parameters
42
+ header_params = opts[:header_params] || {}
43
+ # HTTP header 'Accept' (if needed)
44
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
45
+ # HTTP header 'Content-Type'
46
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
47
+ header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
48
+
49
+ # form parameters
50
+ form_params = opts[:form_params] || {}
51
+
52
+ # http body (model)
53
+ post_body = opts[:body] || @api_client.object_to_http_body(icu_skeleton_parameters)
54
+
55
+ # return_type
56
+ return_type = opts[:return_type] || 'Icu'
57
+
58
+ # auth_names
59
+ auth_names = opts[:auth_names] || ['Basic', 'Token']
60
+
61
+ new_options = opts.merge(
62
+ :header_params => header_params,
63
+ :query_params => query_params,
64
+ :form_params => form_params,
65
+ :body => post_body,
66
+ :auth_names => auth_names,
67
+ :return_type => return_type
68
+ )
69
+
70
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
71
+ if @api_client.config.debugging
72
+ @api_client.config.logger.debug "API called: ICUApi#icu_skeleton\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
73
+ end
74
+ response = ::Phrase::Response.new(data, headers)
75
+ return response, status_code, headers
76
+ end
77
+ end
78
+ end
@@ -93,6 +93,92 @@ module Phrase
93
93
  return response, status_code, headers
94
94
  end
95
95
 
96
+ # Review a job locale
97
+ # Mark job locale as reviewed.
98
+ # @param project_id [String] Project ID
99
+ # @param job_id [String] Job ID
100
+ # @param id [String] ID
101
+ # @param job_locale_complete_review_parameters [JobLocaleCompleteReviewParameters]
102
+ # @param [Hash] opts the optional parameters
103
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
104
+ # @return [JobLocale]
105
+ def job_locale_complete_review(project_id, job_id, id, job_locale_complete_review_parameters, opts = {})
106
+ data, _status_code, _headers = job_locale_complete_review_with_http_info(project_id, job_id, id, job_locale_complete_review_parameters, opts)
107
+ data
108
+ end
109
+
110
+ # Review a job locale
111
+ # Mark job locale as reviewed.
112
+ # @param project_id [String] Project ID
113
+ # @param job_id [String] Job ID
114
+ # @param id [String] ID
115
+ # @param job_locale_complete_review_parameters [JobLocaleCompleteReviewParameters]
116
+ # @param [Hash] opts the optional parameters
117
+ # @option opts [String] :x_phrase_app_otp Two-Factor-Authentication token (optional)
118
+ # @return [Array<(Response<(JobLocale)>, Integer, Hash)>] Response<(JobLocale)> data, response status code and response headers
119
+ def job_locale_complete_review_with_http_info(project_id, job_id, id, job_locale_complete_review_parameters, opts = {})
120
+ if @api_client.config.debugging
121
+ @api_client.config.logger.debug 'Calling API: JobLocalesApi.job_locale_complete_review ...'
122
+ end
123
+ # verify the required parameter 'project_id' is set
124
+ if @api_client.config.client_side_validation && project_id.nil?
125
+ fail ArgumentError, "Missing the required parameter 'project_id' when calling JobLocalesApi.job_locale_complete_review"
126
+ end
127
+ # verify the required parameter 'job_id' is set
128
+ if @api_client.config.client_side_validation && job_id.nil?
129
+ fail ArgumentError, "Missing the required parameter 'job_id' when calling JobLocalesApi.job_locale_complete_review"
130
+ end
131
+ # verify the required parameter 'id' is set
132
+ if @api_client.config.client_side_validation && id.nil?
133
+ fail ArgumentError, "Missing the required parameter 'id' when calling JobLocalesApi.job_locale_complete_review"
134
+ end
135
+ # verify the required parameter 'job_locale_complete_review_parameters' is set
136
+ if @api_client.config.client_side_validation && job_locale_complete_review_parameters.nil?
137
+ fail ArgumentError, "Missing the required parameter 'job_locale_complete_review_parameters' when calling JobLocalesApi.job_locale_complete_review"
138
+ end
139
+ # resource path
140
+ local_var_path = '/projects/{project_id}/jobs/{job_id}/locales/{id}/complete_review'.sub('{' + 'project_id' + '}', CGI.escape(project_id.to_s)).sub('{' + 'job_id' + '}', CGI.escape(job_id.to_s)).sub('{' + 'id' + '}', CGI.escape(id.to_s))
141
+
142
+ # query parameters
143
+ query_params = opts[:query_params] || {}
144
+
145
+ # header parameters
146
+ header_params = opts[:header_params] || {}
147
+ # HTTP header 'Accept' (if needed)
148
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
149
+ # HTTP header 'Content-Type'
150
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
151
+ header_params[:'X-PhraseApp-OTP'] = opts[:'x_phrase_app_otp'] if !opts[:'x_phrase_app_otp'].nil?
152
+
153
+ # form parameters
154
+ form_params = opts[:form_params] || {}
155
+
156
+ # http body (model)
157
+ post_body = opts[:body] || @api_client.object_to_http_body(job_locale_complete_review_parameters)
158
+
159
+ # return_type
160
+ return_type = opts[:return_type] || 'JobLocale'
161
+
162
+ # auth_names
163
+ auth_names = opts[:auth_names] || ['Basic', 'Token']
164
+
165
+ new_options = opts.merge(
166
+ :header_params => header_params,
167
+ :query_params => query_params,
168
+ :form_params => form_params,
169
+ :body => post_body,
170
+ :auth_names => auth_names,
171
+ :return_type => return_type
172
+ )
173
+
174
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
175
+ if @api_client.config.debugging
176
+ @api_client.config.logger.debug "API called: JobLocalesApi#job_locale_complete_review\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
177
+ end
178
+ response = ::Phrase::Response.new(data, headers)
179
+ return response, status_code, headers
180
+ end
181
+
96
182
  # Delete a job locale
97
183
  # Delete an existing job locale.
98
184
  # @param project_id [String] Project ID
@@ -10,6 +10,8 @@ module Phrase
10
10
 
11
11
  attr_accessor :platforms
12
12
 
13
+ attr_accessor :locales
14
+
13
15
  attr_accessor :releases
14
16
 
15
17
  attr_accessor :created_at
@@ -23,6 +25,7 @@ module Phrase
23
25
  :'name' => :'name',
24
26
  :'project' => :'project',
25
27
  :'platforms' => :'platforms',
28
+ :'locales' => :'locales',
26
29
  :'releases' => :'releases',
27
30
  :'created_at' => :'created_at',
28
31
  :'deleted_at' => :'deleted_at'
@@ -36,6 +39,7 @@ module Phrase
36
39
  :'name' => :'String',
37
40
  :'project' => :'ProjectShort',
38
41
  :'platforms' => :'Array<String>',
42
+ :'locales' => :'Array<LocalePreview>',
39
43
  :'releases' => :'Array<ReleasePreview>',
40
44
  :'created_at' => :'DateTime',
41
45
  :'deleted_at' => :'DateTime'
@@ -81,6 +85,12 @@ module Phrase
81
85
  end
82
86
  end
83
87
 
88
+ if attributes.key?(:'locales')
89
+ if (value = attributes[:'locales']).is_a?(Array)
90
+ self.locales = value
91
+ end
92
+ end
93
+
84
94
  if attributes.key?(:'releases')
85
95
  if (value = attributes[:'releases']).is_a?(Array)
86
96
  self.releases = value
@@ -118,6 +128,7 @@ module Phrase
118
128
  name == o.name &&
119
129
  project == o.project &&
120
130
  platforms == o.platforms &&
131
+ locales == o.locales &&
121
132
  releases == o.releases &&
122
133
  created_at == o.created_at &&
123
134
  deleted_at == o.deleted_at
@@ -132,7 +143,7 @@ module Phrase
132
143
  # Calculates hash code according to all attributes.
133
144
  # @return [Integer] Hash code
134
145
  def hash
135
- [id, name, project, platforms, releases, created_at, deleted_at].hash
146
+ [id, name, project, platforms, locales, releases, created_at, deleted_at].hash
136
147
  end
137
148
 
138
149
  # Builds the object from hash
@@ -11,6 +11,9 @@ module Phrase
11
11
  # List of platforms the distribution should support.
12
12
  attr_accessor :platforms
13
13
 
14
+ # List of locale ids that will be part of distribution releases
15
+ attr_accessor :locale_ids
16
+
14
17
  # Additional formatting and render options. Only <code>enclose_in_cdata</code> is available for platform <code>android</code>.
15
18
  attr_accessor :format_options
16
19
 
@@ -29,6 +32,7 @@ module Phrase
29
32
  :'name' => :'name',
30
33
  :'project_id' => :'project_id',
31
34
  :'platforms' => :'platforms',
35
+ :'locale_ids' => :'locale_ids',
32
36
  :'format_options' => :'format_options',
33
37
  :'fallback_to_non_regional_locale' => :'fallback_to_non_regional_locale',
34
38
  :'fallback_to_default_locale' => :'fallback_to_default_locale',
@@ -42,6 +46,7 @@ module Phrase
42
46
  :'name' => :'String',
43
47
  :'project_id' => :'String',
44
48
  :'platforms' => :'Array<String>',
49
+ :'locale_ids' => :'Array<String>',
45
50
  :'format_options' => :'Hash<String, String>',
46
51
  :'fallback_to_non_regional_locale' => :'Boolean',
47
52
  :'fallback_to_default_locale' => :'Boolean',
@@ -84,6 +89,12 @@ module Phrase
84
89
  end
85
90
  end
86
91
 
92
+ if attributes.key?(:'locale_ids')
93
+ if (value = attributes[:'locale_ids']).is_a?(Array)
94
+ self.locale_ids = value
95
+ end
96
+ end
97
+
87
98
  if attributes.key?(:'format_options')
88
99
  if (value = attributes[:'format_options']).is_a?(Hash)
89
100
  self.format_options = value
@@ -124,6 +135,7 @@ module Phrase
124
135
  name == o.name &&
125
136
  project_id == o.project_id &&
126
137
  platforms == o.platforms &&
138
+ locale_ids == o.locale_ids &&
127
139
  format_options == o.format_options &&
128
140
  fallback_to_non_regional_locale == o.fallback_to_non_regional_locale &&
129
141
  fallback_to_default_locale == o.fallback_to_default_locale &&
@@ -139,7 +151,7 @@ module Phrase
139
151
  # Calculates hash code according to all attributes.
140
152
  # @return [Integer] Hash code
141
153
  def hash
142
- [name, project_id, platforms, format_options, fallback_to_non_regional_locale, fallback_to_default_locale, use_last_reviewed_version].hash
154
+ [name, project_id, platforms, locale_ids, format_options, fallback_to_non_regional_locale, fallback_to_default_locale, use_last_reviewed_version].hash
143
155
  end
144
156
 
145
157
  # Builds the object from hash
@@ -11,6 +11,9 @@ module Phrase
11
11
  # List of platforms the distribution should support.
12
12
  attr_accessor :platforms
13
13
 
14
+ # List of locale ids that will be part of distribution releases
15
+ attr_accessor :locale_ids
16
+
14
17
  # Additional formatting and render options. Only <code>enclose_in_cdata</code> is available for platform <code>android</code>.
15
18
  attr_accessor :format_options
16
19
 
@@ -29,6 +32,7 @@ module Phrase
29
32
  :'name' => :'name',
30
33
  :'project_id' => :'project_id',
31
34
  :'platforms' => :'platforms',
35
+ :'locale_ids' => :'locale_ids',
32
36
  :'format_options' => :'format_options',
33
37
  :'fallback_to_non_regional_locale' => :'fallback_to_non_regional_locale',
34
38
  :'fallback_to_default_locale' => :'fallback_to_default_locale',
@@ -42,6 +46,7 @@ module Phrase
42
46
  :'name' => :'String',
43
47
  :'project_id' => :'String',
44
48
  :'platforms' => :'Array<String>',
49
+ :'locale_ids' => :'Array<String>',
45
50
  :'format_options' => :'Hash<String, String>',
46
51
  :'fallback_to_non_regional_locale' => :'Boolean',
47
52
  :'fallback_to_default_locale' => :'Boolean',
@@ -84,6 +89,12 @@ module Phrase
84
89
  end
85
90
  end
86
91
 
92
+ if attributes.key?(:'locale_ids')
93
+ if (value = attributes[:'locale_ids']).is_a?(Array)
94
+ self.locale_ids = value
95
+ end
96
+ end
97
+
87
98
  if attributes.key?(:'format_options')
88
99
  if (value = attributes[:'format_options']).is_a?(Hash)
89
100
  self.format_options = value
@@ -124,6 +135,7 @@ module Phrase
124
135
  name == o.name &&
125
136
  project_id == o.project_id &&
126
137
  platforms == o.platforms &&
138
+ locale_ids == o.locale_ids &&
127
139
  format_options == o.format_options &&
128
140
  fallback_to_non_regional_locale == o.fallback_to_non_regional_locale &&
129
141
  fallback_to_default_locale == o.fallback_to_default_locale &&
@@ -139,7 +151,7 @@ module Phrase
139
151
  # Calculates hash code according to all attributes.
140
152
  # @return [Integer] Hash code
141
153
  def hash
142
- [name, project_id, platforms, format_options, fallback_to_non_regional_locale, fallback_to_default_locale, use_last_reviewed_version].hash
154
+ [name, project_id, platforms, locale_ids, format_options, fallback_to_non_regional_locale, fallback_to_default_locale, use_last_reviewed_version].hash
143
155
  end
144
156
 
145
157
  # Builds the object from hash
@@ -0,0 +1,195 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class Icu
5
+ # Object keys are dynamic and based on requested locale codes, see example.
6
+ attr_accessor :locale_code
7
+
8
+ # Attribute mapping from ruby-style variable name to JSON key.
9
+ def self.attribute_map
10
+ {
11
+ :'locale_code' => :'locale_code'
12
+ }
13
+ end
14
+
15
+ # Attribute type mapping.
16
+ def self.openapi_types
17
+ {
18
+ :'locale_code' => :'String'
19
+ }
20
+ end
21
+
22
+ # List of attributes with nullable: true
23
+ def self.openapi_nullable
24
+ Set.new([
25
+ ])
26
+ end
27
+
28
+ # Initializes the object
29
+ # @param [Hash] attributes Model attributes in the form of hash
30
+ def initialize(attributes = {})
31
+ if (!attributes.is_a?(Hash))
32
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::Icu` initialize method"
33
+ end
34
+
35
+ # check to see if the attribute exists and convert string to symbol for hash key
36
+ attributes = attributes.each_with_object({}) { |(k, v), h|
37
+ if (!self.class.attribute_map.key?(k.to_sym))
38
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::Icu`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
39
+ end
40
+ h[k.to_sym] = v
41
+ }
42
+
43
+ if attributes.key?(:'locale_code')
44
+ self.locale_code = attributes[:'locale_code']
45
+ end
46
+ end
47
+
48
+ # Show invalid properties with the reasons. Usually used together with valid?
49
+ # @return Array for valid properties with the reasons
50
+ def list_invalid_properties
51
+ invalid_properties = Array.new
52
+ invalid_properties
53
+ end
54
+
55
+ # Check to see if the all the properties in the model are valid
56
+ # @return true if the model is valid
57
+ def valid?
58
+ true
59
+ end
60
+
61
+ # Checks equality by comparing each attribute.
62
+ # @param [Object] Object to be compared
63
+ def ==(o)
64
+ return true if self.equal?(o)
65
+ self.class == o.class &&
66
+ locale_code == o.locale_code
67
+ end
68
+
69
+ # @see the `==` method
70
+ # @param [Object] Object to be compared
71
+ def eql?(o)
72
+ self == o
73
+ end
74
+
75
+ # Calculates hash code according to all attributes.
76
+ # @return [Integer] Hash code
77
+ def hash
78
+ [locale_code].hash
79
+ end
80
+
81
+ # Builds the object from hash
82
+ # @param [Hash] attributes Model attributes in the form of hash
83
+ # @return [Object] Returns the model itself
84
+ def self.build_from_hash(attributes)
85
+ new.build_from_hash(attributes)
86
+ end
87
+
88
+ # Builds the object from hash
89
+ # @param [Hash] attributes Model attributes in the form of hash
90
+ # @return [Object] Returns the model itself
91
+ def build_from_hash(attributes)
92
+ return nil unless attributes.is_a?(Hash)
93
+ self.class.openapi_types.each_pair do |key, type|
94
+ if type =~ /\AArray<(.*)>/i
95
+ # check to ensure the input is an array given that the attribute
96
+ # is documented as an array but the input is not
97
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
98
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
99
+ end
100
+ elsif !attributes[self.class.attribute_map[key]].nil?
101
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
102
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
103
+ end
104
+
105
+ self
106
+ end
107
+
108
+ # Deserializes the data based on type
109
+ # @param string type Data type
110
+ # @param string value Value to be deserialized
111
+ # @return [Object] Deserialized data
112
+ def _deserialize(type, value)
113
+ case type.to_sym
114
+ when :DateTime
115
+ DateTime.parse(value)
116
+ when :Date
117
+ Date.parse(value)
118
+ when :String
119
+ value.to_s
120
+ when :Integer
121
+ value.to_i
122
+ when :Float
123
+ value.to_f
124
+ when :Boolean
125
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
126
+ true
127
+ else
128
+ false
129
+ end
130
+ when :Object
131
+ # generic object (usually a Hash), return directly
132
+ value
133
+ when /\AArray<(?<inner_type>.+)>\z/
134
+ inner_type = Regexp.last_match[:inner_type]
135
+ value.map { |v| _deserialize(inner_type, v) }
136
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
137
+ k_type = Regexp.last_match[:k_type]
138
+ v_type = Regexp.last_match[:v_type]
139
+ {}.tap do |hash|
140
+ value.each do |k, v|
141
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
142
+ end
143
+ end
144
+ else # model
145
+ Phrase.const_get(type).build_from_hash(value)
146
+ end
147
+ end
148
+
149
+ # Returns the string representation of the object
150
+ # @return [String] String presentation of the object
151
+ def to_s
152
+ to_hash.to_s
153
+ end
154
+
155
+ # to_body is an alias to to_hash (backward compatibility)
156
+ # @return [Hash] Returns the object in the form of hash
157
+ def to_body
158
+ to_hash
159
+ end
160
+
161
+ # Returns the object in the form of hash
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_hash
164
+ hash = {}
165
+ self.class.attribute_map.each_pair do |attr, param|
166
+ value = self.send(attr)
167
+ if value.nil?
168
+ is_nullable = self.class.openapi_nullable.include?(attr)
169
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
170
+ end
171
+
172
+ hash[param] = _to_hash(value)
173
+ end
174
+ hash
175
+ end
176
+
177
+ # Outputs non-array value in the form of hash
178
+ # For object, use to_hash. Otherwise, just return the value
179
+ # @param [Object] value Any valid value
180
+ # @return [Hash] Returns the value in the form of hash
181
+ def _to_hash(value)
182
+ if value.is_a?(Array)
183
+ value.compact.map { |v| _to_hash(v) }
184
+ elsif value.is_a?(Hash)
185
+ {}.tap do |hash|
186
+ value.each { |k, v| hash[k] = _to_hash(v) }
187
+ end
188
+ elsif value.respond_to? :to_hash
189
+ value.to_hash
190
+ else
191
+ value
192
+ end
193
+ end
194
+ end
195
+ end