phrase 1.0.2 → 1.0.7

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 (141) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -3
  3. data/docs/Account.md +2 -0
  4. data/docs/AccountDetails.md +3 -3
  5. data/docs/AccountsApi.md +2 -2
  6. data/docs/AuthorizationsApi.md +2 -2
  7. data/docs/BlacklistedKeysApi.md +4 -2
  8. data/docs/BranchesApi.md +2 -2
  9. data/docs/CommentsApi.md +2 -2
  10. data/docs/DistributionsApi.md +2 -2
  11. data/docs/Document.md +23 -0
  12. data/docs/DocumentsApi.md +137 -0
  13. data/docs/GitHubSyncApi.md +130 -0
  14. data/docs/GitLabSyncApi.md +2 -2
  15. data/docs/GithubSyncExportParameters.md +17 -0
  16. data/docs/GithubSyncImportParameters.md +17 -0
  17. data/docs/GlossariesApi.md +2 -2
  18. data/docs/GlossaryTermsApi.md +2 -2
  19. data/docs/InlineResponse422.md +19 -0
  20. data/docs/InlineResponse422Errors.md +21 -0
  21. data/docs/InvitationsApi.md +2 -2
  22. data/docs/Job.md +5 -1
  23. data/docs/JobCreateParameters.md +2 -0
  24. data/docs/JobDetails.md +4 -0
  25. data/docs/JobLocalesApi.md +2 -2
  26. data/docs/JobUpdateParameters.md +3 -1
  27. data/docs/JobsApi.md +74 -2
  28. data/docs/KeysApi.md +4 -4
  29. data/docs/LocalesApi.md +2 -2
  30. data/docs/MembersApi.md +2 -2
  31. data/docs/OrdersApi.md +2 -2
  32. data/docs/Project.md +2 -0
  33. data/docs/ProjectDetails.md +2 -2
  34. data/docs/ProjectsApi.md +2 -2
  35. data/docs/ReleasesApi.md +2 -2
  36. data/docs/ScreenshotMarkersApi.md +2 -2
  37. data/docs/ScreenshotsApi.md +4 -2
  38. data/docs/SpacesApi.md +4 -4
  39. data/docs/StyleGuidesApi.md +2 -2
  40. data/docs/TagsApi.md +2 -2
  41. data/docs/TeamsApi.md +2 -2
  42. data/docs/TranslationsApi.md +8 -8
  43. data/docs/UploadsApi.md +2 -2
  44. data/docs/VersionsHistoryApi.md +2 -2
  45. data/docs/WebhookCreateParameters.md +2 -0
  46. data/docs/WebhookUpdateParameters.md +2 -0
  47. data/docs/WebhooksApi.md +2 -2
  48. data/lib/phrase.rb +7 -0
  49. data/lib/phrase/api/accounts_api.rb +2 -2
  50. data/lib/phrase/api/authorizations_api.rb +2 -2
  51. data/lib/phrase/api/blacklisted_keys_api.rb +5 -2
  52. data/lib/phrase/api/branches_api.rb +2 -2
  53. data/lib/phrase/api/comments_api.rb +2 -2
  54. data/lib/phrase/api/distributions_api.rb +2 -2
  55. data/lib/phrase/api/documents_api.rb +152 -0
  56. data/lib/phrase/api/git_hub_sync_api.rb +146 -0
  57. data/lib/phrase/api/git_lab_sync_api.rb +2 -2
  58. data/lib/phrase/api/glossaries_api.rb +2 -2
  59. data/lib/phrase/api/glossary_terms_api.rb +2 -2
  60. data/lib/phrase/api/invitations_api.rb +2 -2
  61. data/lib/phrase/api/job_locales_api.rb +2 -2
  62. data/lib/phrase/api/jobs_api.rb +83 -2
  63. data/lib/phrase/api/keys_api.rb +4 -4
  64. data/lib/phrase/api/locales_api.rb +2 -2
  65. data/lib/phrase/api/members_api.rb +2 -2
  66. data/lib/phrase/api/orders_api.rb +2 -2
  67. data/lib/phrase/api/projects_api.rb +2 -2
  68. data/lib/phrase/api/releases_api.rb +2 -2
  69. data/lib/phrase/api/screenshot_markers_api.rb +2 -2
  70. data/lib/phrase/api/screenshots_api.rb +5 -2
  71. data/lib/phrase/api/spaces_api.rb +4 -4
  72. data/lib/phrase/api/style_guides_api.rb +2 -2
  73. data/lib/phrase/api/tags_api.rb +2 -2
  74. data/lib/phrase/api/teams_api.rb +2 -2
  75. data/lib/phrase/api/translations_api.rb +8 -8
  76. data/lib/phrase/api/uploads_api.rb +2 -2
  77. data/lib/phrase/api/versions_history_api.rb +2 -2
  78. data/lib/phrase/api/webhooks_api.rb +2 -2
  79. data/lib/phrase/api_client.rb +2 -2
  80. data/lib/phrase/models/account.rb +10 -1
  81. data/lib/phrase/models/account_details.rb +13 -13
  82. data/lib/phrase/models/document.rb +221 -0
  83. data/lib/phrase/models/github_sync_export_parameters.rb +195 -0
  84. data/lib/phrase/models/github_sync_import_parameters.rb +195 -0
  85. data/lib/phrase/models/inline_response422.rb +205 -0
  86. data/lib/phrase/models/inline_response422_errors.rb +212 -0
  87. data/lib/phrase/models/job.rb +22 -4
  88. data/lib/phrase/models/job_create_parameters.rb +11 -1
  89. data/lib/phrase/models/job_details.rb +19 -1
  90. data/lib/phrase/models/job_update_parameters.rb +14 -4
  91. data/lib/phrase/models/project.rb +10 -1
  92. data/lib/phrase/models/project_details.rb +10 -10
  93. data/lib/phrase/models/webhook_create_parameters.rb +11 -1
  94. data/lib/phrase/models/webhook_update_parameters.rb +11 -1
  95. data/lib/phrase/version.rb +1 -1
  96. data/spec/api/accounts_api_spec.rb +1 -1
  97. data/spec/api/authorizations_api_spec.rb +1 -1
  98. data/spec/api/blacklisted_keys_api_spec.rb +2 -1
  99. data/spec/api/branches_api_spec.rb +1 -1
  100. data/spec/api/comments_api_spec.rb +1 -1
  101. data/spec/api/distributions_api_spec.rb +1 -1
  102. data/spec/api/documents_api_spec.rb +52 -0
  103. data/spec/api/git_hub_sync_api_spec.rb +49 -0
  104. data/spec/api/git_lab_sync_api_spec.rb +1 -1
  105. data/spec/api/glossaries_api_spec.rb +1 -1
  106. data/spec/api/glossary_terms_api_spec.rb +1 -1
  107. data/spec/api/invitations_api_spec.rb +1 -1
  108. data/spec/api/job_locales_api_spec.rb +1 -1
  109. data/spec/api/jobs_api_spec.rb +19 -1
  110. data/spec/api/keys_api_spec.rb +2 -2
  111. data/spec/api/locales_api_spec.rb +1 -1
  112. data/spec/api/members_api_spec.rb +1 -1
  113. data/spec/api/orders_api_spec.rb +1 -1
  114. data/spec/api/projects_api_spec.rb +1 -1
  115. data/spec/api/releases_api_spec.rb +1 -1
  116. data/spec/api/screenshot_markers_api_spec.rb +1 -1
  117. data/spec/api/screenshots_api_spec.rb +2 -1
  118. data/spec/api/spaces_api_spec.rb +2 -2
  119. data/spec/api/style_guides_api_spec.rb +1 -1
  120. data/spec/api/tags_api_spec.rb +1 -1
  121. data/spec/api/teams_api_spec.rb +1 -1
  122. data/spec/api/translations_api_spec.rb +4 -4
  123. data/spec/api/uploads_api_spec.rb +1 -1
  124. data/spec/api/versions_history_api_spec.rb +1 -1
  125. data/spec/api/webhooks_api_spec.rb +1 -1
  126. data/spec/models/account_details_spec.rb +4 -4
  127. data/spec/models/account_spec.rb +6 -0
  128. data/spec/models/document_spec.rb +47 -0
  129. data/spec/models/github_sync_export_parameters_spec.rb +29 -0
  130. data/spec/models/github_sync_import_parameters_spec.rb +29 -0
  131. data/spec/models/inline_response422_errors_spec.rb +41 -0
  132. data/spec/models/inline_response422_spec.rb +35 -0
  133. data/spec/models/job_create_parameters_spec.rb +6 -0
  134. data/spec/models/job_details_spec.rb +12 -0
  135. data/spec/models/job_spec.rb +12 -0
  136. data/spec/models/job_update_parameters_spec.rb +6 -0
  137. data/spec/models/project_details_spec.rb +6 -6
  138. data/spec/models/project_spec.rb +6 -0
  139. data/spec/models/webhook_create_parameters_spec.rb +6 -0
  140. data/spec/models/webhook_update_parameters_spec.rb +6 -0
  141. metadata +183 -155
@@ -0,0 +1,195 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class GithubSyncImportParameters
5
+ # Project ID to specify the actual project the GitHub import should be triggered in.
6
+ attr_accessor :project_id
7
+
8
+ # Attribute mapping from ruby-style variable name to JSON key.
9
+ def self.attribute_map
10
+ {
11
+ :'project_id' => :'project_id'
12
+ }
13
+ end
14
+
15
+ # Attribute type mapping.
16
+ def self.openapi_types
17
+ {
18
+ :'project_id' => :'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::GithubSyncImportParameters` 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::GithubSyncImportParameters`. 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?(:'project_id')
44
+ self.project_id = attributes[:'project_id']
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
+ project_id == o.project_id
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
+ [project_id].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
@@ -0,0 +1,205 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class InlineResponse422
5
+ attr_accessor :message
6
+
7
+ attr_accessor :errors
8
+
9
+ # Attribute mapping from ruby-style variable name to JSON key.
10
+ def self.attribute_map
11
+ {
12
+ :'message' => :'message',
13
+ :'errors' => :'errors'
14
+ }
15
+ end
16
+
17
+ # Attribute type mapping.
18
+ def self.openapi_types
19
+ {
20
+ :'message' => :'String',
21
+ :'errors' => :'Array<InlineResponse422Errors>'
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::InlineResponse422` 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::InlineResponse422`. 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?(:'message')
47
+ self.message = attributes[:'message']
48
+ end
49
+
50
+ if attributes.key?(:'errors')
51
+ if (value = attributes[:'errors']).is_a?(Array)
52
+ self.errors = value
53
+ end
54
+ end
55
+ end
56
+
57
+ # Show invalid properties with the reasons. Usually used together with valid?
58
+ # @return Array for valid properties with the reasons
59
+ def list_invalid_properties
60
+ invalid_properties = Array.new
61
+ invalid_properties
62
+ end
63
+
64
+ # Check to see if the all the properties in the model are valid
65
+ # @return true if the model is valid
66
+ def valid?
67
+ true
68
+ end
69
+
70
+ # Checks equality by comparing each attribute.
71
+ # @param [Object] Object to be compared
72
+ def ==(o)
73
+ return true if self.equal?(o)
74
+ self.class == o.class &&
75
+ message == o.message &&
76
+ errors == o.errors
77
+ end
78
+
79
+ # @see the `==` method
80
+ # @param [Object] Object to be compared
81
+ def eql?(o)
82
+ self == o
83
+ end
84
+
85
+ # Calculates hash code according to all attributes.
86
+ # @return [Integer] Hash code
87
+ def hash
88
+ [message, errors].hash
89
+ end
90
+
91
+ # Builds the object from hash
92
+ # @param [Hash] attributes Model attributes in the form of hash
93
+ # @return [Object] Returns the model itself
94
+ def self.build_from_hash(attributes)
95
+ new.build_from_hash(attributes)
96
+ end
97
+
98
+ # Builds the object from hash
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ # @return [Object] Returns the model itself
101
+ def build_from_hash(attributes)
102
+ return nil unless attributes.is_a?(Hash)
103
+ self.class.openapi_types.each_pair do |key, type|
104
+ if type =~ /\AArray<(.*)>/i
105
+ # check to ensure the input is an array given that the attribute
106
+ # is documented as an array but the input is not
107
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
108
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
109
+ end
110
+ elsif !attributes[self.class.attribute_map[key]].nil?
111
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
112
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
113
+ end
114
+
115
+ self
116
+ end
117
+
118
+ # Deserializes the data based on type
119
+ # @param string type Data type
120
+ # @param string value Value to be deserialized
121
+ # @return [Object] Deserialized data
122
+ def _deserialize(type, value)
123
+ case type.to_sym
124
+ when :DateTime
125
+ DateTime.parse(value)
126
+ when :Date
127
+ Date.parse(value)
128
+ when :String
129
+ value.to_s
130
+ when :Integer
131
+ value.to_i
132
+ when :Float
133
+ value.to_f
134
+ when :Boolean
135
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
136
+ true
137
+ else
138
+ false
139
+ end
140
+ when :Object
141
+ # generic object (usually a Hash), return directly
142
+ value
143
+ when /\AArray<(?<inner_type>.+)>\z/
144
+ inner_type = Regexp.last_match[:inner_type]
145
+ value.map { |v| _deserialize(inner_type, v) }
146
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
147
+ k_type = Regexp.last_match[:k_type]
148
+ v_type = Regexp.last_match[:v_type]
149
+ {}.tap do |hash|
150
+ value.each do |k, v|
151
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
152
+ end
153
+ end
154
+ else # model
155
+ Phrase.const_get(type).build_from_hash(value)
156
+ end
157
+ end
158
+
159
+ # Returns the string representation of the object
160
+ # @return [String] String presentation of the object
161
+ def to_s
162
+ to_hash.to_s
163
+ end
164
+
165
+ # to_body is an alias to to_hash (backward compatibility)
166
+ # @return [Hash] Returns the object in the form of hash
167
+ def to_body
168
+ to_hash
169
+ end
170
+
171
+ # Returns the object in the form of hash
172
+ # @return [Hash] Returns the object in the form of hash
173
+ def to_hash
174
+ hash = {}
175
+ self.class.attribute_map.each_pair do |attr, param|
176
+ value = self.send(attr)
177
+ if value.nil?
178
+ is_nullable = self.class.openapi_nullable.include?(attr)
179
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
180
+ end
181
+
182
+ hash[param] = _to_hash(value)
183
+ end
184
+ hash
185
+ end
186
+
187
+ # Outputs non-array value in the form of hash
188
+ # For object, use to_hash. Otherwise, just return the value
189
+ # @param [Object] value Any valid value
190
+ # @return [Hash] Returns the value in the form of hash
191
+ def _to_hash(value)
192
+ if value.is_a?(Array)
193
+ value.compact.map { |v| _to_hash(v) }
194
+ elsif value.is_a?(Hash)
195
+ {}.tap do |hash|
196
+ value.each { |k, v| hash[k] = _to_hash(v) }
197
+ end
198
+ elsif value.respond_to? :to_hash
199
+ value.to_hash
200
+ else
201
+ value
202
+ end
203
+ end
204
+ end
205
+ end
@@ -0,0 +1,212 @@
1
+ require 'date'
2
+
3
+ module Phrase
4
+ class InlineResponse422Errors
5
+ attr_accessor :resource
6
+
7
+ attr_accessor :field
8
+
9
+ attr_accessor :message
10
+
11
+ # Attribute mapping from ruby-style variable name to JSON key.
12
+ def self.attribute_map
13
+ {
14
+ :'resource' => :'resource',
15
+ :'field' => :'field',
16
+ :'message' => :'message'
17
+ }
18
+ end
19
+
20
+ # Attribute type mapping.
21
+ def self.openapi_types
22
+ {
23
+ :'resource' => :'String',
24
+ :'field' => :'String',
25
+ :'message' => :'String'
26
+ }
27
+ end
28
+
29
+ # List of attributes with nullable: true
30
+ def self.openapi_nullable
31
+ Set.new([
32
+ ])
33
+ end
34
+
35
+ # Initializes the object
36
+ # @param [Hash] attributes Model attributes in the form of hash
37
+ def initialize(attributes = {})
38
+ if (!attributes.is_a?(Hash))
39
+ fail ArgumentError, "The input argument (attributes) must be a hash in `Phrase::InlineResponse422Errors` initialize method"
40
+ end
41
+
42
+ # check to see if the attribute exists and convert string to symbol for hash key
43
+ attributes = attributes.each_with_object({}) { |(k, v), h|
44
+ if (!self.class.attribute_map.key?(k.to_sym))
45
+ fail ArgumentError, "`#{k}` is not a valid attribute in `Phrase::InlineResponse422Errors`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
46
+ end
47
+ h[k.to_sym] = v
48
+ }
49
+
50
+ if attributes.key?(:'resource')
51
+ self.resource = attributes[:'resource']
52
+ end
53
+
54
+ if attributes.key?(:'field')
55
+ self.field = attributes[:'field']
56
+ end
57
+
58
+ if attributes.key?(:'message')
59
+ self.message = attributes[:'message']
60
+ end
61
+ end
62
+
63
+ # Show invalid properties with the reasons. Usually used together with valid?
64
+ # @return Array for valid properties with the reasons
65
+ def list_invalid_properties
66
+ invalid_properties = Array.new
67
+ invalid_properties
68
+ end
69
+
70
+ # Check to see if the all the properties in the model are valid
71
+ # @return true if the model is valid
72
+ def valid?
73
+ true
74
+ end
75
+
76
+ # Checks equality by comparing each attribute.
77
+ # @param [Object] Object to be compared
78
+ def ==(o)
79
+ return true if self.equal?(o)
80
+ self.class == o.class &&
81
+ resource == o.resource &&
82
+ field == o.field &&
83
+ message == o.message
84
+ end
85
+
86
+ # @see the `==` method
87
+ # @param [Object] Object to be compared
88
+ def eql?(o)
89
+ self == o
90
+ end
91
+
92
+ # Calculates hash code according to all attributes.
93
+ # @return [Integer] Hash code
94
+ def hash
95
+ [resource, field, message].hash
96
+ end
97
+
98
+ # Builds the object from hash
99
+ # @param [Hash] attributes Model attributes in the form of hash
100
+ # @return [Object] Returns the model itself
101
+ def self.build_from_hash(attributes)
102
+ new.build_from_hash(attributes)
103
+ end
104
+
105
+ # Builds the object from hash
106
+ # @param [Hash] attributes Model attributes in the form of hash
107
+ # @return [Object] Returns the model itself
108
+ def build_from_hash(attributes)
109
+ return nil unless attributes.is_a?(Hash)
110
+ self.class.openapi_types.each_pair do |key, type|
111
+ if type =~ /\AArray<(.*)>/i
112
+ # check to ensure the input is an array given that the attribute
113
+ # is documented as an array but the input is not
114
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
115
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
116
+ end
117
+ elsif !attributes[self.class.attribute_map[key]].nil?
118
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
119
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
120
+ end
121
+
122
+ self
123
+ end
124
+
125
+ # Deserializes the data based on type
126
+ # @param string type Data type
127
+ # @param string value Value to be deserialized
128
+ # @return [Object] Deserialized data
129
+ def _deserialize(type, value)
130
+ case type.to_sym
131
+ when :DateTime
132
+ DateTime.parse(value)
133
+ when :Date
134
+ Date.parse(value)
135
+ when :String
136
+ value.to_s
137
+ when :Integer
138
+ value.to_i
139
+ when :Float
140
+ value.to_f
141
+ when :Boolean
142
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
143
+ true
144
+ else
145
+ false
146
+ end
147
+ when :Object
148
+ # generic object (usually a Hash), return directly
149
+ value
150
+ when /\AArray<(?<inner_type>.+)>\z/
151
+ inner_type = Regexp.last_match[:inner_type]
152
+ value.map { |v| _deserialize(inner_type, v) }
153
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
154
+ k_type = Regexp.last_match[:k_type]
155
+ v_type = Regexp.last_match[:v_type]
156
+ {}.tap do |hash|
157
+ value.each do |k, v|
158
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
159
+ end
160
+ end
161
+ else # model
162
+ Phrase.const_get(type).build_from_hash(value)
163
+ end
164
+ end
165
+
166
+ # Returns the string representation of the object
167
+ # @return [String] String presentation of the object
168
+ def to_s
169
+ to_hash.to_s
170
+ end
171
+
172
+ # to_body is an alias to to_hash (backward compatibility)
173
+ # @return [Hash] Returns the object in the form of hash
174
+ def to_body
175
+ to_hash
176
+ end
177
+
178
+ # Returns the object in the form of hash
179
+ # @return [Hash] Returns the object in the form of hash
180
+ def to_hash
181
+ hash = {}
182
+ self.class.attribute_map.each_pair do |attr, param|
183
+ value = self.send(attr)
184
+ if value.nil?
185
+ is_nullable = self.class.openapi_nullable.include?(attr)
186
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
187
+ end
188
+
189
+ hash[param] = _to_hash(value)
190
+ end
191
+ hash
192
+ end
193
+
194
+ # Outputs non-array value in the form of hash
195
+ # For object, use to_hash. Otherwise, just return the value
196
+ # @param [Object] value Any valid value
197
+ # @return [Hash] Returns the value in the form of hash
198
+ def _to_hash(value)
199
+ if value.is_a?(Array)
200
+ value.compact.map { |v| _to_hash(v) }
201
+ elsif value.is_a?(Hash)
202
+ {}.tap do |hash|
203
+ value.each { |k, v| hash[k] = _to_hash(v) }
204
+ end
205
+ elsif value.respond_to? :to_hash
206
+ value.to_hash
207
+ else
208
+ value
209
+ end
210
+ end
211
+ end
212
+ end