moderation_api 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +144 -0
  4. data/Rakefile +10 -0
  5. data/docs/AccountApi.md +74 -0
  6. data/docs/AccountGet200Response.md +26 -0
  7. data/docs/AccountGet200ResponseCurrentProject.md +20 -0
  8. data/docs/ActionsCreateRequest.md +36 -0
  9. data/docs/ActionsCreateRequestWebhooksInner.md +24 -0
  10. data/docs/ActionsDelete200Response.md +20 -0
  11. data/docs/ActionsExecute200Response.md +22 -0
  12. data/docs/ActionsExecuteDeprecatedRequest.md +22 -0
  13. data/docs/ActionsExecuteRequest.md +24 -0
  14. data/docs/ActionsGet200Response.md +40 -0
  15. data/docs/ActionsGet200ResponseWebhooksInner.md +26 -0
  16. data/docs/ActionsList200ResponseInner.md +38 -0
  17. data/docs/ActionsList200ResponseInnerPossibleValuesInner.md +18 -0
  18. data/docs/ActionsList400Response.md +22 -0
  19. data/docs/ActionsList400ResponseIssuesInner.md +18 -0
  20. data/docs/ActionsUpdateRequest.md +36 -0
  21. data/docs/ModerateApi.md +357 -0
  22. data/docs/ModerationAudioRequest.md +28 -0
  23. data/docs/ModerationImage200Response.md +28 -0
  24. data/docs/ModerationImage200ResponseLabelsInner.md +20 -0
  25. data/docs/ModerationImageRequest.md +28 -0
  26. data/docs/ModerationObject200Response.md +36 -0
  27. data/docs/ModerationObject200ResponseAllOfEntitiesInner.md +22 -0
  28. data/docs/ModerationObject200ResponseAllOfFieldsInner.md +22 -0
  29. data/docs/ModerationObject200ResponseAllOfLabelsInner.md +22 -0
  30. data/docs/ModerationObjectRequest.md +28 -0
  31. data/docs/ModerationObjectRequestValue.md +20 -0
  32. data/docs/ModerationObjectRequestValueDataValue.md +22 -0
  33. data/docs/ModerationText200Response.md +64 -0
  34. data/docs/ModerationText200ResponseAllOfAddress.md +28 -0
  35. data/docs/ModerationText200ResponseAllOfEmail.md +28 -0
  36. data/docs/ModerationText200ResponseAllOfName.md +28 -0
  37. data/docs/ModerationText200ResponseAllOfNsfw.md +26 -0
  38. data/docs/ModerationText200ResponseAllOfNsfwLabelScores.md +22 -0
  39. data/docs/ModerationText200ResponseAllOfPhone.md +28 -0
  40. data/docs/ModerationText200ResponseAllOfProfanity.md +28 -0
  41. data/docs/ModerationText200ResponseAllOfPropriety.md +26 -0
  42. data/docs/ModerationText200ResponseAllOfProprietyLabelScores.md +22 -0
  43. data/docs/ModerationText200ResponseAllOfQuality.md +26 -0
  44. data/docs/ModerationText200ResponseAllOfQualityLabelScores.md +24 -0
  45. data/docs/ModerationText200ResponseAllOfRequest.md +20 -0
  46. data/docs/ModerationText200ResponseAllOfSensitive.md +28 -0
  47. data/docs/ModerationText200ResponseAllOfSentiment.md +26 -0
  48. data/docs/ModerationText200ResponseAllOfSentimentLabelScores.md +22 -0
  49. data/docs/ModerationText200ResponseAllOfToxicity.md +26 -0
  50. data/docs/ModerationText200ResponseAllOfToxicityLabelScores.md +30 -0
  51. data/docs/ModerationText200ResponseAllOfUrl.md +28 -0
  52. data/docs/ModerationText200ResponseAllOfUsername.md +28 -0
  53. data/docs/ModerationText200ResponseAllOfWordlist.md +28 -0
  54. data/docs/ModerationText200ResponseAllOfWordlistsInner.md +36 -0
  55. data/docs/ModerationTextRequest.md +28 -0
  56. data/docs/ModerationVideo200Response.md +24 -0
  57. data/docs/ModerationVideoRequest.md +28 -0
  58. data/docs/QueueActionsApi.md +503 -0
  59. data/git_push.sh +57 -0
  60. data/lib/moderation_api/api/account_api.rb +79 -0
  61. data/lib/moderation_api/api/moderate_api.rb +362 -0
  62. data/lib/moderation_api/api/queue_actions_api.rb +492 -0
  63. data/lib/moderation_api/api_client.rb +437 -0
  64. data/lib/moderation_api/api_error.rb +58 -0
  65. data/lib/moderation_api/configuration.rb +392 -0
  66. data/lib/moderation_api/models/account_get200_response.rb +278 -0
  67. data/lib/moderation_api/models/account_get200_response_current_project.rb +237 -0
  68. data/lib/moderation_api/models/actions_create_request.rb +374 -0
  69. data/lib/moderation_api/models/actions_create_request_webhooks_inner.rb +260 -0
  70. data/lib/moderation_api/models/actions_delete200_response.rb +239 -0
  71. data/lib/moderation_api/models/actions_execute200_response.rb +258 -0
  72. data/lib/moderation_api/models/actions_execute_deprecated_request.rb +244 -0
  73. data/lib/moderation_api/models/actions_execute_request.rb +261 -0
  74. data/lib/moderation_api/models/actions_get200_response.rb +408 -0
  75. data/lib/moderation_api/models/actions_get200_response_webhooks_inner.rb +278 -0
  76. data/lib/moderation_api/models/actions_list200_response_inner.rb +396 -0
  77. data/lib/moderation_api/models/actions_list200_response_inner_possible_values_inner.rb +222 -0
  78. data/lib/moderation_api/models/actions_list400_response.rb +248 -0
  79. data/lib/moderation_api/models/actions_list400_response_issues_inner.rb +221 -0
  80. data/lib/moderation_api/models/actions_update_request.rb +367 -0
  81. data/lib/moderation_api/models/moderation_audio_request.rb +302 -0
  82. data/lib/moderation_api/models/moderation_image200_response.rb +296 -0
  83. data/lib/moderation_api/models/moderation_image200_response_labels_inner.rb +301 -0
  84. data/lib/moderation_api/models/moderation_image_request.rb +302 -0
  85. data/lib/moderation_api/models/moderation_object200_response.rb +368 -0
  86. data/lib/moderation_api/models/moderation_object200_response_all_of_entities_inner.rb +251 -0
  87. data/lib/moderation_api/models/moderation_object200_response_all_of_fields_inner.rb +258 -0
  88. data/lib/moderation_api/models/moderation_object200_response_all_of_labels_inner.rb +284 -0
  89. data/lib/moderation_api/models/moderation_object_request.rb +301 -0
  90. data/lib/moderation_api/models/moderation_object_request_value.rb +275 -0
  91. data/lib/moderation_api/models/moderation_object_request_value_data_value.rb +285 -0
  92. data/lib/moderation_api/models/moderation_text200_response.rb +488 -0
  93. data/lib/moderation_api/models/moderation_text200_response_all_of_address.rb +303 -0
  94. data/lib/moderation_api/models/moderation_text200_response_all_of_email.rb +303 -0
  95. data/lib/moderation_api/models/moderation_text200_response_all_of_name.rb +303 -0
  96. data/lib/moderation_api/models/moderation_text200_response_all_of_nsfw.rb +255 -0
  97. data/lib/moderation_api/models/moderation_text200_response_all_of_nsfw_label_scores.rb +235 -0
  98. data/lib/moderation_api/models/moderation_text200_response_all_of_phone.rb +303 -0
  99. data/lib/moderation_api/models/moderation_text200_response_all_of_profanity.rb +303 -0
  100. data/lib/moderation_api/models/moderation_text200_response_all_of_propriety.rb +255 -0
  101. data/lib/moderation_api/models/moderation_text200_response_all_of_propriety_label_scores.rb +235 -0
  102. data/lib/moderation_api/models/moderation_text200_response_all_of_quality.rb +255 -0
  103. data/lib/moderation_api/models/moderation_text200_response_all_of_quality_label_scores.rb +245 -0
  104. data/lib/moderation_api/models/moderation_text200_response_all_of_request.rb +240 -0
  105. data/lib/moderation_api/models/moderation_text200_response_all_of_sensitive.rb +303 -0
  106. data/lib/moderation_api/models/moderation_text200_response_all_of_sentiment.rb +255 -0
  107. data/lib/moderation_api/models/moderation_text200_response_all_of_sentiment_label_scores.rb +235 -0
  108. data/lib/moderation_api/models/moderation_text200_response_all_of_toxicity.rb +262 -0
  109. data/lib/moderation_api/models/moderation_text200_response_all_of_toxicity_label_scores.rb +275 -0
  110. data/lib/moderation_api/models/moderation_text200_response_all_of_url.rb +303 -0
  111. data/lib/moderation_api/models/moderation_text200_response_all_of_username.rb +303 -0
  112. data/lib/moderation_api/models/moderation_text200_response_all_of_wordlist.rb +303 -0
  113. data/lib/moderation_api/models/moderation_text200_response_all_of_wordlists_inner.rb +377 -0
  114. data/lib/moderation_api/models/moderation_text_request.rb +330 -0
  115. data/lib/moderation_api/models/moderation_video200_response.rb +265 -0
  116. data/lib/moderation_api/models/moderation_video_request.rb +302 -0
  117. data/lib/moderation_api/version.rb +15 -0
  118. data/lib/moderation_api.rb +93 -0
  119. data/moderation_api.gemspec +45 -0
  120. data/spec/api/account_api_spec.rb +46 -0
  121. data/spec/api/moderate_api_spec.rb +95 -0
  122. data/spec/api/queue_actions_api_spec.rb +121 -0
  123. data/spec/models/account_get200_response_current_project_spec.rb +42 -0
  124. data/spec/models/account_get200_response_spec.rb +60 -0
  125. data/spec/models/actions_create_request_spec.rb +98 -0
  126. data/spec/models/actions_create_request_webhooks_inner_spec.rb +54 -0
  127. data/spec/models/actions_delete200_response_spec.rb +42 -0
  128. data/spec/models/actions_execute200_response_spec.rb +48 -0
  129. data/spec/models/actions_execute_deprecated_request_spec.rb +48 -0
  130. data/spec/models/actions_execute_request_spec.rb +54 -0
  131. data/spec/models/actions_get200_response_spec.rb +110 -0
  132. data/spec/models/actions_get200_response_webhooks_inner_spec.rb +60 -0
  133. data/spec/models/actions_list200_response_inner_possible_values_inner_spec.rb +36 -0
  134. data/spec/models/actions_list200_response_inner_spec.rb +104 -0
  135. data/spec/models/actions_list400_response_issues_inner_spec.rb +36 -0
  136. data/spec/models/actions_list400_response_spec.rb +48 -0
  137. data/spec/models/actions_update_request_spec.rb +98 -0
  138. data/spec/models/moderation_audio_request_spec.rb +66 -0
  139. data/spec/models/moderation_image200_response_labels_inner_spec.rb +46 -0
  140. data/spec/models/moderation_image200_response_spec.rb +66 -0
  141. data/spec/models/moderation_image_request_spec.rb +66 -0
  142. data/spec/models/moderation_object200_response_all_of_entities_inner_spec.rb +48 -0
  143. data/spec/models/moderation_object200_response_all_of_fields_inner_spec.rb +48 -0
  144. data/spec/models/moderation_object200_response_all_of_labels_inner_spec.rb +48 -0
  145. data/spec/models/moderation_object200_response_spec.rb +90 -0
  146. data/spec/models/moderation_object_request_spec.rb +66 -0
  147. data/spec/models/moderation_object_request_value_data_value_spec.rb +52 -0
  148. data/spec/models/moderation_object_request_value_spec.rb +46 -0
  149. data/spec/models/moderation_text200_response_all_of_address_spec.rb +70 -0
  150. data/spec/models/moderation_text200_response_all_of_email_spec.rb +70 -0
  151. data/spec/models/moderation_text200_response_all_of_name_spec.rb +70 -0
  152. data/spec/models/moderation_text200_response_all_of_nsfw_label_scores_spec.rb +48 -0
  153. data/spec/models/moderation_text200_response_all_of_nsfw_spec.rb +60 -0
  154. data/spec/models/moderation_text200_response_all_of_phone_spec.rb +70 -0
  155. data/spec/models/moderation_text200_response_all_of_profanity_spec.rb +70 -0
  156. data/spec/models/moderation_text200_response_all_of_propriety_label_scores_spec.rb +48 -0
  157. data/spec/models/moderation_text200_response_all_of_propriety_spec.rb +60 -0
  158. data/spec/models/moderation_text200_response_all_of_quality_label_scores_spec.rb +54 -0
  159. data/spec/models/moderation_text200_response_all_of_quality_spec.rb +60 -0
  160. data/spec/models/moderation_text200_response_all_of_request_spec.rb +42 -0
  161. data/spec/models/moderation_text200_response_all_of_sensitive_spec.rb +70 -0
  162. data/spec/models/moderation_text200_response_all_of_sentiment_label_scores_spec.rb +48 -0
  163. data/spec/models/moderation_text200_response_all_of_sentiment_spec.rb +60 -0
  164. data/spec/models/moderation_text200_response_all_of_toxicity_label_scores_spec.rb +72 -0
  165. data/spec/models/moderation_text200_response_all_of_toxicity_spec.rb +60 -0
  166. data/spec/models/moderation_text200_response_all_of_url_spec.rb +70 -0
  167. data/spec/models/moderation_text200_response_all_of_username_spec.rb +70 -0
  168. data/spec/models/moderation_text200_response_all_of_wordlist_spec.rb +70 -0
  169. data/spec/models/moderation_text200_response_all_of_wordlists_inner_spec.rb +94 -0
  170. data/spec/models/moderation_text200_response_spec.rb +174 -0
  171. data/spec/models/moderation_text_request_spec.rb +66 -0
  172. data/spec/models/moderation_video200_response_spec.rb +54 -0
  173. data/spec/models/moderation_video_request_spec.rb +66 -0
  174. data/spec/spec_helper.rb +111 -0
  175. metadata +340 -0
@@ -0,0 +1,261 @@
1
+ =begin
2
+ #Moderation API
3
+
4
+ #API for automated content moderation
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.10.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module ModerationAPI
17
+ class ActionsExecuteRequest
18
+ # The IDs of the content items to perform the action on.
19
+ attr_accessor :content_ids
20
+
21
+ # The ID or key of the action to execute.
22
+ attr_accessor :action_id
23
+
24
+ # The ID of the queue the action was performed from if any.
25
+ attr_accessor :queue_id
26
+
27
+ # The value of the action. Useful to set a reason for the action etc.
28
+ attr_accessor :value
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'content_ids' => :'contentIds',
34
+ :'action_id' => :'actionId',
35
+ :'queue_id' => :'queueId',
36
+ :'value' => :'value'
37
+ }
38
+ end
39
+
40
+ # Returns all the JSON keys this model knows about
41
+ def self.acceptable_attributes
42
+ attribute_map.values
43
+ end
44
+
45
+ # Attribute type mapping.
46
+ def self.openapi_types
47
+ {
48
+ :'content_ids' => :'Array<String>',
49
+ :'action_id' => :'String',
50
+ :'queue_id' => :'String',
51
+ :'value' => :'String'
52
+ }
53
+ end
54
+
55
+ # List of attributes with nullable: true
56
+ def self.openapi_nullable
57
+ Set.new([
58
+ ])
59
+ end
60
+
61
+ # Initializes the object
62
+ # @param [Hash] attributes Model attributes in the form of hash
63
+ def initialize(attributes = {})
64
+ if (!attributes.is_a?(Hash))
65
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ModerationAPI::ActionsExecuteRequest` initialize method"
66
+ end
67
+
68
+ # check to see if the attribute exists and convert string to symbol for hash key
69
+ attributes = attributes.each_with_object({}) { |(k, v), h|
70
+ if (!self.class.attribute_map.key?(k.to_sym))
71
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ModerationAPI::ActionsExecuteRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
72
+ end
73
+ h[k.to_sym] = v
74
+ }
75
+
76
+ if attributes.key?(:'content_ids')
77
+ if (value = attributes[:'content_ids']).is_a?(Array)
78
+ self.content_ids = value
79
+ end
80
+ else
81
+ self.content_ids = nil
82
+ end
83
+
84
+ if attributes.key?(:'action_id')
85
+ self.action_id = attributes[:'action_id']
86
+ else
87
+ self.action_id = nil
88
+ end
89
+
90
+ if attributes.key?(:'queue_id')
91
+ self.queue_id = attributes[:'queue_id']
92
+ end
93
+
94
+ if attributes.key?(:'value')
95
+ self.value = attributes[:'value']
96
+ end
97
+ end
98
+
99
+ # Show invalid properties with the reasons. Usually used together with valid?
100
+ # @return Array for valid properties with the reasons
101
+ def list_invalid_properties
102
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
103
+ invalid_properties = Array.new
104
+ if @content_ids.nil?
105
+ invalid_properties.push('invalid value for "content_ids", content_ids cannot be nil.')
106
+ end
107
+
108
+ if @action_id.nil?
109
+ invalid_properties.push('invalid value for "action_id", action_id cannot be nil.')
110
+ end
111
+
112
+ invalid_properties
113
+ end
114
+
115
+ # Check to see if the all the properties in the model are valid
116
+ # @return true if the model is valid
117
+ def valid?
118
+ warn '[DEPRECATED] the `valid?` method is obsolete'
119
+ return false if @content_ids.nil?
120
+ return false if @action_id.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
+ content_ids == o.content_ids &&
130
+ action_id == o.action_id &&
131
+ queue_id == o.queue_id &&
132
+ value == o.value
133
+ end
134
+
135
+ # @see the `==` method
136
+ # @param [Object] Object to be compared
137
+ def eql?(o)
138
+ self == o
139
+ end
140
+
141
+ # Calculates hash code according to all attributes.
142
+ # @return [Integer] Hash code
143
+ def hash
144
+ [content_ids, action_id, queue_id, value].hash
145
+ end
146
+
147
+ # Builds the object from hash
148
+ # @param [Hash] attributes Model attributes in the form of hash
149
+ # @return [Object] Returns the model itself
150
+ def self.build_from_hash(attributes)
151
+ return nil unless attributes.is_a?(Hash)
152
+ attributes = attributes.transform_keys(&:to_sym)
153
+ transformed_hash = {}
154
+ openapi_types.each_pair do |key, type|
155
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
156
+ transformed_hash["#{key}"] = nil
157
+ elsif type =~ /\AArray<(.*)>/i
158
+ # check to ensure the input is an array given that the attribute
159
+ # is documented as an array but the input is not
160
+ if attributes[attribute_map[key]].is_a?(Array)
161
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
162
+ end
163
+ elsif !attributes[attribute_map[key]].nil?
164
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
165
+ end
166
+ end
167
+ new(transformed_hash)
168
+ end
169
+
170
+ # Deserializes the data based on type
171
+ # @param string type Data type
172
+ # @param string value Value to be deserialized
173
+ # @return [Object] Deserialized data
174
+ def self._deserialize(type, value)
175
+ case type.to_sym
176
+ when :Time
177
+ Time.parse(value)
178
+ when :Date
179
+ Date.parse(value)
180
+ when :String
181
+ value.to_s
182
+ when :Integer
183
+ value.to_i
184
+ when :Float
185
+ value.to_f
186
+ when :Boolean
187
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
188
+ true
189
+ else
190
+ false
191
+ end
192
+ when :Object
193
+ # generic object (usually a Hash), return directly
194
+ value
195
+ when /\AArray<(?<inner_type>.+)>\z/
196
+ inner_type = Regexp.last_match[:inner_type]
197
+ value.map { |v| _deserialize(inner_type, v) }
198
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
199
+ k_type = Regexp.last_match[:k_type]
200
+ v_type = Regexp.last_match[:v_type]
201
+ {}.tap do |hash|
202
+ value.each do |k, v|
203
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
204
+ end
205
+ end
206
+ else # model
207
+ # models (e.g. Pet) or oneOf
208
+ klass = ModerationAPI.const_get(type)
209
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
210
+ end
211
+ end
212
+
213
+ # Returns the string representation of the object
214
+ # @return [String] String presentation of the object
215
+ def to_s
216
+ to_hash.to_s
217
+ end
218
+
219
+ # to_body is an alias to to_hash (backward compatibility)
220
+ # @return [Hash] Returns the object in the form of hash
221
+ def to_body
222
+ to_hash
223
+ end
224
+
225
+ # Returns the object in the form of hash
226
+ # @return [Hash] Returns the object in the form of hash
227
+ def to_hash
228
+ hash = {}
229
+ self.class.attribute_map.each_pair do |attr, param|
230
+ value = self.send(attr)
231
+ if value.nil?
232
+ is_nullable = self.class.openapi_nullable.include?(attr)
233
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
234
+ end
235
+
236
+ hash[param] = _to_hash(value)
237
+ end
238
+ hash
239
+ end
240
+
241
+ # Outputs non-array value in the form of hash
242
+ # For object, use to_hash. Otherwise, just return the value
243
+ # @param [Object] value Any valid value
244
+ # @return [Hash] Returns the value in the form of hash
245
+ def _to_hash(value)
246
+ if value.is_a?(Array)
247
+ value.compact.map { |v| _to_hash(v) }
248
+ elsif value.is_a?(Hash)
249
+ {}.tap do |hash|
250
+ value.each { |k, v| hash[k] = _to_hash(v) }
251
+ end
252
+ elsif value.respond_to? :to_hash
253
+ value.to_hash
254
+ else
255
+ value
256
+ end
257
+ end
258
+
259
+ end
260
+
261
+ end
@@ -0,0 +1,408 @@
1
+ =begin
2
+ #Moderation API
3
+
4
+ #API for automated content moderation
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.10.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module ModerationAPI
17
+ class ActionsGet200Response
18
+ # The ID of the action.
19
+ attr_accessor :id
20
+
21
+ # The date the action was created.
22
+ attr_accessor :created_at
23
+
24
+ # The name of the action.
25
+ attr_accessor :name
26
+
27
+ # User defined key of the action.
28
+ attr_accessor :key
29
+
30
+ # The description of the action.
31
+ attr_accessor :description
32
+
33
+ # Whether the action resolves and removes the item, unresolves and re-add it to the queue, or does not change the resolve status.
34
+ attr_accessor :queue_behaviour
35
+
36
+ # The IDs of the queues the action is available in.
37
+ attr_accessor :filter_in_queue_ids
38
+
39
+ # Show the action in all queues, selected queues or no queues (to use via API only).
40
+ attr_accessor :position
41
+
42
+ # The possible values of the action. The user will be prompted to select one of these values when executing the action.
43
+ attr_accessor :possible_values
44
+
45
+ # Whether the action requires a value to be executed.
46
+ attr_accessor :value_required
47
+
48
+ # Whether the action allows any text to be entered as a value or if it must be one of the possible values.
49
+ attr_accessor :free_text
50
+
51
+ # The action's webhooks.
52
+ attr_accessor :webhooks
53
+
54
+ class EnumAttributeValidator
55
+ attr_reader :datatype
56
+ attr_reader :allowable_values
57
+
58
+ def initialize(datatype, allowable_values)
59
+ @allowable_values = allowable_values.map do |value|
60
+ case datatype.to_s
61
+ when /Integer/i
62
+ value.to_i
63
+ when /Float/i
64
+ value.to_f
65
+ else
66
+ value
67
+ end
68
+ end
69
+ end
70
+
71
+ def valid?(value)
72
+ !value || allowable_values.include?(value)
73
+ end
74
+ end
75
+
76
+ # Attribute mapping from ruby-style variable name to JSON key.
77
+ def self.attribute_map
78
+ {
79
+ :'id' => :'id',
80
+ :'created_at' => :'createdAt',
81
+ :'name' => :'name',
82
+ :'key' => :'key',
83
+ :'description' => :'description',
84
+ :'queue_behaviour' => :'queueBehaviour',
85
+ :'filter_in_queue_ids' => :'filterInQueueIds',
86
+ :'position' => :'position',
87
+ :'possible_values' => :'possibleValues',
88
+ :'value_required' => :'valueRequired',
89
+ :'free_text' => :'freeText',
90
+ :'webhooks' => :'webhooks'
91
+ }
92
+ end
93
+
94
+ # Returns all the JSON keys this model knows about
95
+ def self.acceptable_attributes
96
+ attribute_map.values
97
+ end
98
+
99
+ # Attribute type mapping.
100
+ def self.openapi_types
101
+ {
102
+ :'id' => :'String',
103
+ :'created_at' => :'Time',
104
+ :'name' => :'String',
105
+ :'key' => :'String',
106
+ :'description' => :'String',
107
+ :'queue_behaviour' => :'String',
108
+ :'filter_in_queue_ids' => :'Array<String>',
109
+ :'position' => :'String',
110
+ :'possible_values' => :'Array<ActionsList200ResponseInnerPossibleValuesInner>',
111
+ :'value_required' => :'Boolean',
112
+ :'free_text' => :'Boolean',
113
+ :'webhooks' => :'Array<ActionsGet200ResponseWebhooksInner>'
114
+ }
115
+ end
116
+
117
+ # List of attributes with nullable: true
118
+ def self.openapi_nullable
119
+ Set.new([
120
+ :'key',
121
+ :'description',
122
+ ])
123
+ end
124
+
125
+ # Initializes the object
126
+ # @param [Hash] attributes Model attributes in the form of hash
127
+ def initialize(attributes = {})
128
+ if (!attributes.is_a?(Hash))
129
+ fail ArgumentError, "The input argument (attributes) must be a hash in `ModerationAPI::ActionsGet200Response` initialize method"
130
+ end
131
+
132
+ # check to see if the attribute exists and convert string to symbol for hash key
133
+ attributes = attributes.each_with_object({}) { |(k, v), h|
134
+ if (!self.class.attribute_map.key?(k.to_sym))
135
+ fail ArgumentError, "`#{k}` is not a valid attribute in `ModerationAPI::ActionsGet200Response`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
136
+ end
137
+ h[k.to_sym] = v
138
+ }
139
+
140
+ if attributes.key?(:'id')
141
+ self.id = attributes[:'id']
142
+ else
143
+ self.id = nil
144
+ end
145
+
146
+ if attributes.key?(:'created_at')
147
+ self.created_at = attributes[:'created_at']
148
+ else
149
+ self.created_at = nil
150
+ end
151
+
152
+ if attributes.key?(:'name')
153
+ self.name = attributes[:'name']
154
+ else
155
+ self.name = nil
156
+ end
157
+
158
+ if attributes.key?(:'key')
159
+ self.key = attributes[:'key']
160
+ end
161
+
162
+ if attributes.key?(:'description')
163
+ self.description = attributes[:'description']
164
+ end
165
+
166
+ if attributes.key?(:'queue_behaviour')
167
+ self.queue_behaviour = attributes[:'queue_behaviour']
168
+ else
169
+ self.queue_behaviour = 'NO_CHANGE'
170
+ end
171
+
172
+ if attributes.key?(:'filter_in_queue_ids')
173
+ if (value = attributes[:'filter_in_queue_ids']).is_a?(Array)
174
+ self.filter_in_queue_ids = value
175
+ end
176
+ end
177
+
178
+ if attributes.key?(:'position')
179
+ self.position = attributes[:'position']
180
+ else
181
+ self.position = 'ALL_QUEUES'
182
+ end
183
+
184
+ if attributes.key?(:'possible_values')
185
+ if (value = attributes[:'possible_values']).is_a?(Array)
186
+ self.possible_values = value
187
+ end
188
+ end
189
+
190
+ if attributes.key?(:'value_required')
191
+ self.value_required = attributes[:'value_required']
192
+ else
193
+ self.value_required = false
194
+ end
195
+
196
+ if attributes.key?(:'free_text')
197
+ self.free_text = attributes[:'free_text']
198
+ else
199
+ self.free_text = false
200
+ end
201
+
202
+ if attributes.key?(:'webhooks')
203
+ if (value = attributes[:'webhooks']).is_a?(Array)
204
+ self.webhooks = value
205
+ end
206
+ end
207
+ end
208
+
209
+ # Show invalid properties with the reasons. Usually used together with valid?
210
+ # @return Array for valid properties with the reasons
211
+ def list_invalid_properties
212
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
213
+ invalid_properties = Array.new
214
+ if @id.nil?
215
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
216
+ end
217
+
218
+ if @created_at.nil?
219
+ invalid_properties.push('invalid value for "created_at", created_at cannot be nil.')
220
+ end
221
+
222
+ if @name.nil?
223
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
224
+ end
225
+
226
+ invalid_properties
227
+ end
228
+
229
+ # Check to see if the all the properties in the model are valid
230
+ # @return true if the model is valid
231
+ def valid?
232
+ warn '[DEPRECATED] the `valid?` method is obsolete'
233
+ return false if @id.nil?
234
+ return false if @created_at.nil?
235
+ return false if @name.nil?
236
+ queue_behaviour_validator = EnumAttributeValidator.new('String', ["REMOVE", "ADD", "NO_CHANGE", "unknown_default_open_api"])
237
+ return false unless queue_behaviour_validator.valid?(@queue_behaviour)
238
+ position_validator = EnumAttributeValidator.new('String', ["ALL_QUEUES", "SOME_QUEUES", "HIDDEN", "unknown_default_open_api"])
239
+ return false unless position_validator.valid?(@position)
240
+ true
241
+ end
242
+
243
+ # Custom attribute writer method checking allowed values (enum).
244
+ # @param [Object] queue_behaviour Object to be assigned
245
+ def queue_behaviour=(queue_behaviour)
246
+ validator = EnumAttributeValidator.new('String', ["REMOVE", "ADD", "NO_CHANGE", "unknown_default_open_api"])
247
+ unless validator.valid?(queue_behaviour)
248
+ fail ArgumentError, "invalid value for \"queue_behaviour\", must be one of #{validator.allowable_values}."
249
+ end
250
+ @queue_behaviour = queue_behaviour
251
+ end
252
+
253
+ # Custom attribute writer method checking allowed values (enum).
254
+ # @param [Object] position Object to be assigned
255
+ def position=(position)
256
+ validator = EnumAttributeValidator.new('String', ["ALL_QUEUES", "SOME_QUEUES", "HIDDEN", "unknown_default_open_api"])
257
+ unless validator.valid?(position)
258
+ fail ArgumentError, "invalid value for \"position\", must be one of #{validator.allowable_values}."
259
+ end
260
+ @position = position
261
+ end
262
+
263
+ # Checks equality by comparing each attribute.
264
+ # @param [Object] Object to be compared
265
+ def ==(o)
266
+ return true if self.equal?(o)
267
+ self.class == o.class &&
268
+ id == o.id &&
269
+ created_at == o.created_at &&
270
+ name == o.name &&
271
+ key == o.key &&
272
+ description == o.description &&
273
+ queue_behaviour == o.queue_behaviour &&
274
+ filter_in_queue_ids == o.filter_in_queue_ids &&
275
+ position == o.position &&
276
+ possible_values == o.possible_values &&
277
+ value_required == o.value_required &&
278
+ free_text == o.free_text &&
279
+ webhooks == o.webhooks
280
+ end
281
+
282
+ # @see the `==` method
283
+ # @param [Object] Object to be compared
284
+ def eql?(o)
285
+ self == o
286
+ end
287
+
288
+ # Calculates hash code according to all attributes.
289
+ # @return [Integer] Hash code
290
+ def hash
291
+ [id, created_at, name, key, description, queue_behaviour, filter_in_queue_ids, position, possible_values, value_required, free_text, webhooks].hash
292
+ end
293
+
294
+ # Builds the object from hash
295
+ # @param [Hash] attributes Model attributes in the form of hash
296
+ # @return [Object] Returns the model itself
297
+ def self.build_from_hash(attributes)
298
+ return nil unless attributes.is_a?(Hash)
299
+ attributes = attributes.transform_keys(&:to_sym)
300
+ transformed_hash = {}
301
+ openapi_types.each_pair do |key, type|
302
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
303
+ transformed_hash["#{key}"] = nil
304
+ elsif type =~ /\AArray<(.*)>/i
305
+ # check to ensure the input is an array given that the attribute
306
+ # is documented as an array but the input is not
307
+ if attributes[attribute_map[key]].is_a?(Array)
308
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
309
+ end
310
+ elsif !attributes[attribute_map[key]].nil?
311
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
312
+ end
313
+ end
314
+ new(transformed_hash)
315
+ end
316
+
317
+ # Deserializes the data based on type
318
+ # @param string type Data type
319
+ # @param string value Value to be deserialized
320
+ # @return [Object] Deserialized data
321
+ def self._deserialize(type, value)
322
+ case type.to_sym
323
+ when :Time
324
+ Time.parse(value)
325
+ when :Date
326
+ Date.parse(value)
327
+ when :String
328
+ value.to_s
329
+ when :Integer
330
+ value.to_i
331
+ when :Float
332
+ value.to_f
333
+ when :Boolean
334
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
335
+ true
336
+ else
337
+ false
338
+ end
339
+ when :Object
340
+ # generic object (usually a Hash), return directly
341
+ value
342
+ when /\AArray<(?<inner_type>.+)>\z/
343
+ inner_type = Regexp.last_match[:inner_type]
344
+ value.map { |v| _deserialize(inner_type, v) }
345
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
346
+ k_type = Regexp.last_match[:k_type]
347
+ v_type = Regexp.last_match[:v_type]
348
+ {}.tap do |hash|
349
+ value.each do |k, v|
350
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
351
+ end
352
+ end
353
+ else # model
354
+ # models (e.g. Pet) or oneOf
355
+ klass = ModerationAPI.const_get(type)
356
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
357
+ end
358
+ end
359
+
360
+ # Returns the string representation of the object
361
+ # @return [String] String presentation of the object
362
+ def to_s
363
+ to_hash.to_s
364
+ end
365
+
366
+ # to_body is an alias to to_hash (backward compatibility)
367
+ # @return [Hash] Returns the object in the form of hash
368
+ def to_body
369
+ to_hash
370
+ end
371
+
372
+ # Returns the object in the form of hash
373
+ # @return [Hash] Returns the object in the form of hash
374
+ def to_hash
375
+ hash = {}
376
+ self.class.attribute_map.each_pair do |attr, param|
377
+ value = self.send(attr)
378
+ if value.nil?
379
+ is_nullable = self.class.openapi_nullable.include?(attr)
380
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
381
+ end
382
+
383
+ hash[param] = _to_hash(value)
384
+ end
385
+ hash
386
+ end
387
+
388
+ # Outputs non-array value in the form of hash
389
+ # For object, use to_hash. Otherwise, just return the value
390
+ # @param [Object] value Any valid value
391
+ # @return [Hash] Returns the value in the form of hash
392
+ def _to_hash(value)
393
+ if value.is_a?(Array)
394
+ value.compact.map { |v| _to_hash(v) }
395
+ elsif value.is_a?(Hash)
396
+ {}.tap do |hash|
397
+ value.each { |k, v| hash[k] = _to_hash(v) }
398
+ end
399
+ elsif value.respond_to? :to_hash
400
+ value.to_hash
401
+ else
402
+ value
403
+ end
404
+ end
405
+
406
+ end
407
+
408
+ end