cloudmersive-phishing-detection-api-client 2.2.2 → 2.2.4

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 (26) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -9
  3. data/docs/PhishingDetectionAdvancedRequest.md +8 -1
  4. data/docs/PhishingDetectionAdvancedResponse.md +7 -1
  5. data/docs/PhishingDetectionApi.md +66 -12
  6. data/docs/PhishingDetectionTextStringRequest.md +10 -0
  7. data/docs/PhishingDetectionTextStringResponse.md +10 -0
  8. data/docs/PriorHistoryItem.md +15 -0
  9. data/docs/UnsafeUrlResult.md +12 -0
  10. data/lib/cloudmersive-phishing-detection-api-client/api/phishing_detection_api.rb +56 -8
  11. data/lib/cloudmersive-phishing-detection-api-client/models/phishing_detection_advanced_request.rb +86 -14
  12. data/lib/cloudmersive-phishing-detection-api-client/models/phishing_detection_advanced_response.rb +73 -11
  13. data/lib/cloudmersive-phishing-detection-api-client/models/phishing_detection_text_string_request.rb +206 -0
  14. data/lib/cloudmersive-phishing-detection-api-client/models/phishing_detection_text_string_response.rb +206 -0
  15. data/lib/cloudmersive-phishing-detection-api-client/models/prior_history_item.rb +256 -0
  16. data/lib/cloudmersive-phishing-detection-api-client/models/unsafe_url_result.rb +226 -0
  17. data/lib/cloudmersive-phishing-detection-api-client/version.rb +1 -1
  18. data/lib/cloudmersive-phishing-detection-api-client.rb +4 -0
  19. data/spec/api/phishing_detection_api_spec.rb +15 -4
  20. data/spec/models/phishing_detection_advanced_request_spec.rb +45 -3
  21. data/spec/models/phishing_detection_advanced_response_spec.rb +37 -1
  22. data/spec/models/phishing_detection_text_string_request_spec.rb +53 -0
  23. data/spec/models/phishing_detection_text_string_response_spec.rb +53 -0
  24. data/spec/models/prior_history_item_spec.rb +83 -0
  25. data/spec/models/unsafe_url_result_spec.rb +65 -0
  26. metadata +14 -2
@@ -18,18 +18,36 @@ module CloudmersivePhishingDetectionApiClient
18
18
  # Input text string to detect phishing against
19
19
  attr_accessor :input_string
20
20
 
21
+ # Optional: Type of text being analyzed. Must be one of: \"TextMessage\", \"UserMessage\", \"SalesLead\", \"EmailMessage\", \"SupportCase\", \"AppMessage\", \"Other\".
22
+ attr_accessor :text_type
23
+
21
24
  # Optional: Specify which AI model to use. Possible choices are Normal and Advanced. Default is Advanced.
22
25
  attr_accessor :model
23
26
 
27
+ # Optional: True if unsolicited sales should be allowed, false otherwise. Defaults to true.
28
+ attr_accessor :allow_unsolicited_sales
29
+
30
+ # Optional: True if promotional content should be allowed, false otherwise. Defaults to true.
31
+ attr_accessor :allow_promotional_content
32
+
33
+ # Optional: True if web URLs should be allowed in the input text, false otherwise. Defaults to true. When false, input containing URLs (including homoglyph URLs and spaced-out URLs) will be flagged as not clean.
34
+ attr_accessor :allow_web_urls
35
+
36
+ # Optional: True if phone numbers should be allowed in the input text, false otherwise. Defaults to true. When false, input containing phone numbers (including homoglyph digits and spaced-out or spelled-out workarounds) will be flagged as not clean.
37
+ attr_accessor :allow_phone_numbers
38
+
39
+ # Optional: True if email addresses should be allowed in the input text, false otherwise. Defaults to true. When false, input containing email addresses (including homoglyph characters and obfuscated workarounds like \"danny at somedomaine [DOT] com\") will be flagged as not clean.
40
+ attr_accessor :allow_email_addresses
41
+
42
+ # Optional: True to perform deep URL analysis on any URLs detected in the text. When enabled, if the initial AI scan detects URLs, a second AI call enumerates them and each URL is individually analyzed for phishing. Defaults to true.
43
+ attr_accessor :provide_url_analysis
44
+
24
45
  # Apply a Custom Policy for Phishing Enforcement by providing the ID; to create a Custom Policy, navigate to the Cloudmersive Management Portal and select Custom Policies. Requires Managed Instance or Private Cloud
25
46
  attr_accessor :custom_policy_id
26
47
 
27
48
  # Optional: Set to true to include an analysis rationale in the response explaining why the content was or was not flagged. Default is true.
28
49
  attr_accessor :provide_analysis_rationale
29
50
 
30
- # Optional: Type of text being analyzed. Must be one of: \"Text Message\", \"User Message\", \"Sales Lead\", \"Email Message\", \"Support Case\", \"Other\".
31
- attr_accessor :text_type
32
-
33
51
  # Optional: Name of the sender
34
52
  attr_accessor :from_name
35
53
 
@@ -48,20 +66,30 @@ module CloudmersivePhishingDetectionApiClient
48
66
  # Optional: Email address of the recipient
49
67
  attr_accessor :to_email_address
50
68
 
69
+ # Optional: Prior context history (e.g. message history) leading up to the current input string. If provided, the AI will take this history into account as context when evaluating the current input.
70
+ attr_accessor :prior_history
71
+
51
72
  # Attribute mapping from ruby-style variable name to JSON key.
52
73
  def self.attribute_map
53
74
  {
54
75
  :'input_string' => :'InputString',
76
+ :'text_type' => :'TextType',
55
77
  :'model' => :'Model',
78
+ :'allow_unsolicited_sales' => :'AllowUnsolicitedSales',
79
+ :'allow_promotional_content' => :'AllowPromotionalContent',
80
+ :'allow_web_urls' => :'AllowWebUrls',
81
+ :'allow_phone_numbers' => :'AllowPhoneNumbers',
82
+ :'allow_email_addresses' => :'AllowEmailAddresses',
83
+ :'provide_url_analysis' => :'ProvideUrlAnalysis',
56
84
  :'custom_policy_id' => :'CustomPolicyID',
57
85
  :'provide_analysis_rationale' => :'ProvideAnalysisRationale',
58
- :'text_type' => :'TextType',
59
86
  :'from_name' => :'FromName',
60
87
  :'to_name' => :'ToName',
61
88
  :'from_phone_number' => :'FromPhoneNumber',
62
89
  :'to_phone_number' => :'ToPhoneNumber',
63
90
  :'from_email_address' => :'FromEmailAddress',
64
- :'to_email_address' => :'ToEmailAddress'
91
+ :'to_email_address' => :'ToEmailAddress',
92
+ :'prior_history' => :'PriorHistory'
65
93
  }
66
94
  end
67
95
 
@@ -69,16 +97,23 @@ module CloudmersivePhishingDetectionApiClient
69
97
  def self.swagger_types
70
98
  {
71
99
  :'input_string' => :'String',
100
+ :'text_type' => :'String',
72
101
  :'model' => :'String',
102
+ :'allow_unsolicited_sales' => :'BOOLEAN',
103
+ :'allow_promotional_content' => :'BOOLEAN',
104
+ :'allow_web_urls' => :'BOOLEAN',
105
+ :'allow_phone_numbers' => :'BOOLEAN',
106
+ :'allow_email_addresses' => :'BOOLEAN',
107
+ :'provide_url_analysis' => :'BOOLEAN',
73
108
  :'custom_policy_id' => :'String',
74
109
  :'provide_analysis_rationale' => :'BOOLEAN',
75
- :'text_type' => :'String',
76
110
  :'from_name' => :'String',
77
111
  :'to_name' => :'String',
78
112
  :'from_phone_number' => :'String',
79
113
  :'to_phone_number' => :'String',
80
114
  :'from_email_address' => :'String',
81
- :'to_email_address' => :'String'
115
+ :'to_email_address' => :'String',
116
+ :'prior_history' => :'Array<PriorHistoryItem>'
82
117
  }
83
118
  end
84
119
 
@@ -94,10 +129,38 @@ module CloudmersivePhishingDetectionApiClient
94
129
  self.input_string = attributes[:'InputString']
95
130
  end
96
131
 
132
+ if attributes.has_key?(:'TextType')
133
+ self.text_type = attributes[:'TextType']
134
+ end
135
+
97
136
  if attributes.has_key?(:'Model')
98
137
  self.model = attributes[:'Model']
99
138
  end
100
139
 
140
+ if attributes.has_key?(:'AllowUnsolicitedSales')
141
+ self.allow_unsolicited_sales = attributes[:'AllowUnsolicitedSales']
142
+ end
143
+
144
+ if attributes.has_key?(:'AllowPromotionalContent')
145
+ self.allow_promotional_content = attributes[:'AllowPromotionalContent']
146
+ end
147
+
148
+ if attributes.has_key?(:'AllowWebUrls')
149
+ self.allow_web_urls = attributes[:'AllowWebUrls']
150
+ end
151
+
152
+ if attributes.has_key?(:'AllowPhoneNumbers')
153
+ self.allow_phone_numbers = attributes[:'AllowPhoneNumbers']
154
+ end
155
+
156
+ if attributes.has_key?(:'AllowEmailAddresses')
157
+ self.allow_email_addresses = attributes[:'AllowEmailAddresses']
158
+ end
159
+
160
+ if attributes.has_key?(:'ProvideUrlAnalysis')
161
+ self.provide_url_analysis = attributes[:'ProvideUrlAnalysis']
162
+ end
163
+
101
164
  if attributes.has_key?(:'CustomPolicyID')
102
165
  self.custom_policy_id = attributes[:'CustomPolicyID']
103
166
  end
@@ -106,10 +169,6 @@ module CloudmersivePhishingDetectionApiClient
106
169
  self.provide_analysis_rationale = attributes[:'ProvideAnalysisRationale']
107
170
  end
108
171
 
109
- if attributes.has_key?(:'TextType')
110
- self.text_type = attributes[:'TextType']
111
- end
112
-
113
172
  if attributes.has_key?(:'FromName')
114
173
  self.from_name = attributes[:'FromName']
115
174
  end
@@ -133,6 +192,12 @@ module CloudmersivePhishingDetectionApiClient
133
192
  if attributes.has_key?(:'ToEmailAddress')
134
193
  self.to_email_address = attributes[:'ToEmailAddress']
135
194
  end
195
+
196
+ if attributes.has_key?(:'PriorHistory')
197
+ if (value = attributes[:'PriorHistory']).is_a?(Array)
198
+ self.prior_history = value
199
+ end
200
+ end
136
201
  end
137
202
 
138
203
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -154,16 +219,23 @@ module CloudmersivePhishingDetectionApiClient
154
219
  return true if self.equal?(o)
155
220
  self.class == o.class &&
156
221
  input_string == o.input_string &&
222
+ text_type == o.text_type &&
157
223
  model == o.model &&
224
+ allow_unsolicited_sales == o.allow_unsolicited_sales &&
225
+ allow_promotional_content == o.allow_promotional_content &&
226
+ allow_web_urls == o.allow_web_urls &&
227
+ allow_phone_numbers == o.allow_phone_numbers &&
228
+ allow_email_addresses == o.allow_email_addresses &&
229
+ provide_url_analysis == o.provide_url_analysis &&
158
230
  custom_policy_id == o.custom_policy_id &&
159
231
  provide_analysis_rationale == o.provide_analysis_rationale &&
160
- text_type == o.text_type &&
161
232
  from_name == o.from_name &&
162
233
  to_name == o.to_name &&
163
234
  from_phone_number == o.from_phone_number &&
164
235
  to_phone_number == o.to_phone_number &&
165
236
  from_email_address == o.from_email_address &&
166
- to_email_address == o.to_email_address
237
+ to_email_address == o.to_email_address &&
238
+ prior_history == o.prior_history
167
239
  end
168
240
 
169
241
  # @see the `==` method
@@ -175,7 +247,7 @@ module CloudmersivePhishingDetectionApiClient
175
247
  # Calculates hash code according to all attributes.
176
248
  # @return [Fixnum] Hash code
177
249
  def hash
178
- [input_string, model, custom_policy_id, provide_analysis_rationale, text_type, from_name, to_name, from_phone_number, to_phone_number, from_email_address, to_email_address].hash
250
+ [input_string, text_type, model, allow_unsolicited_sales, allow_promotional_content, allow_web_urls, allow_phone_numbers, allow_email_addresses, provide_url_analysis, custom_policy_id, provide_analysis_rationale, from_name, to_name, from_phone_number, to_phone_number, from_email_address, to_email_address, prior_history].hash
179
251
  end
180
252
 
181
253
  # Builds the object from hash
@@ -18,8 +18,23 @@ module CloudmersivePhishingDetectionApiClient
18
18
  # True if the result is not phishing (clean), and false otherwise
19
19
  attr_accessor :clean_result
20
20
 
21
- # Overall phishing risk level between 0.0 and 1.0
22
- attr_accessor :phishing_risk_level
21
+ # True if the input text contains a phishing attempt, false otherwise
22
+ attr_accessor :contains_phishing
23
+
24
+ # True if the input text contains unsolicited sales, false otherwise
25
+ attr_accessor :contains_unsolicited_sales
26
+
27
+ # True if the input text contains promotional content, false otherwise
28
+ attr_accessor :contains_promotional_content
29
+
30
+ # True if the input text contains web URLs, including homoglyph URLs and spaced-out URL workarounds
31
+ attr_accessor :contains_web_urls
32
+
33
+ # True if the input text contains phone numbers, including homoglyph digits and spaced-out or spelled-out workarounds
34
+ attr_accessor :contains_phone_numbers
35
+
36
+ # True if the input text contains email addresses, including homoglyph characters and obfuscated workarounds
37
+ attr_accessor :contains_email_addresses
23
38
 
24
39
  # Confidence level between 0.0 and 1.0 where values over 0.9 indicate high confidence
25
40
  attr_accessor :confidence_level
@@ -27,13 +42,22 @@ module CloudmersivePhishingDetectionApiClient
27
42
  # Rationale for why the conclusion was formed
28
43
  attr_accessor :analysis_rationale
29
44
 
45
+ # URLs detected in the input text that were analyzed and found to be unsafe. Only populated when ProvideUrlAnalysis is true and URLs are detected.
46
+ attr_accessor :unsafe_urls
47
+
30
48
  # Attribute mapping from ruby-style variable name to JSON key.
31
49
  def self.attribute_map
32
50
  {
33
51
  :'clean_result' => :'CleanResult',
34
- :'phishing_risk_level' => :'PhishingRiskLevel',
52
+ :'contains_phishing' => :'ContainsPhishing',
53
+ :'contains_unsolicited_sales' => :'ContainsUnsolicitedSales',
54
+ :'contains_promotional_content' => :'ContainsPromotionalContent',
55
+ :'contains_web_urls' => :'ContainsWebUrls',
56
+ :'contains_phone_numbers' => :'ContainsPhoneNumbers',
57
+ :'contains_email_addresses' => :'ContainsEmailAddresses',
35
58
  :'confidence_level' => :'ConfidenceLevel',
36
- :'analysis_rationale' => :'AnalysisRationale'
59
+ :'analysis_rationale' => :'AnalysisRationale',
60
+ :'unsafe_urls' => :'UnsafeUrls'
37
61
  }
38
62
  end
39
63
 
@@ -41,9 +65,15 @@ module CloudmersivePhishingDetectionApiClient
41
65
  def self.swagger_types
42
66
  {
43
67
  :'clean_result' => :'BOOLEAN',
44
- :'phishing_risk_level' => :'Float',
68
+ :'contains_phishing' => :'BOOLEAN',
69
+ :'contains_unsolicited_sales' => :'BOOLEAN',
70
+ :'contains_promotional_content' => :'BOOLEAN',
71
+ :'contains_web_urls' => :'BOOLEAN',
72
+ :'contains_phone_numbers' => :'BOOLEAN',
73
+ :'contains_email_addresses' => :'BOOLEAN',
45
74
  :'confidence_level' => :'Float',
46
- :'analysis_rationale' => :'String'
75
+ :'analysis_rationale' => :'String',
76
+ :'unsafe_urls' => :'Array<UnsafeUrlResult>'
47
77
  }
48
78
  end
49
79
 
@@ -59,8 +89,28 @@ module CloudmersivePhishingDetectionApiClient
59
89
  self.clean_result = attributes[:'CleanResult']
60
90
  end
61
91
 
62
- if attributes.has_key?(:'PhishingRiskLevel')
63
- self.phishing_risk_level = attributes[:'PhishingRiskLevel']
92
+ if attributes.has_key?(:'ContainsPhishing')
93
+ self.contains_phishing = attributes[:'ContainsPhishing']
94
+ end
95
+
96
+ if attributes.has_key?(:'ContainsUnsolicitedSales')
97
+ self.contains_unsolicited_sales = attributes[:'ContainsUnsolicitedSales']
98
+ end
99
+
100
+ if attributes.has_key?(:'ContainsPromotionalContent')
101
+ self.contains_promotional_content = attributes[:'ContainsPromotionalContent']
102
+ end
103
+
104
+ if attributes.has_key?(:'ContainsWebUrls')
105
+ self.contains_web_urls = attributes[:'ContainsWebUrls']
106
+ end
107
+
108
+ if attributes.has_key?(:'ContainsPhoneNumbers')
109
+ self.contains_phone_numbers = attributes[:'ContainsPhoneNumbers']
110
+ end
111
+
112
+ if attributes.has_key?(:'ContainsEmailAddresses')
113
+ self.contains_email_addresses = attributes[:'ContainsEmailAddresses']
64
114
  end
65
115
 
66
116
  if attributes.has_key?(:'ConfidenceLevel')
@@ -70,6 +120,12 @@ module CloudmersivePhishingDetectionApiClient
70
120
  if attributes.has_key?(:'AnalysisRationale')
71
121
  self.analysis_rationale = attributes[:'AnalysisRationale']
72
122
  end
123
+
124
+ if attributes.has_key?(:'UnsafeUrls')
125
+ if (value = attributes[:'UnsafeUrls']).is_a?(Array)
126
+ self.unsafe_urls = value
127
+ end
128
+ end
73
129
  end
74
130
 
75
131
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -91,9 +147,15 @@ module CloudmersivePhishingDetectionApiClient
91
147
  return true if self.equal?(o)
92
148
  self.class == o.class &&
93
149
  clean_result == o.clean_result &&
94
- phishing_risk_level == o.phishing_risk_level &&
150
+ contains_phishing == o.contains_phishing &&
151
+ contains_unsolicited_sales == o.contains_unsolicited_sales &&
152
+ contains_promotional_content == o.contains_promotional_content &&
153
+ contains_web_urls == o.contains_web_urls &&
154
+ contains_phone_numbers == o.contains_phone_numbers &&
155
+ contains_email_addresses == o.contains_email_addresses &&
95
156
  confidence_level == o.confidence_level &&
96
- analysis_rationale == o.analysis_rationale
157
+ analysis_rationale == o.analysis_rationale &&
158
+ unsafe_urls == o.unsafe_urls
97
159
  end
98
160
 
99
161
  # @see the `==` method
@@ -105,7 +167,7 @@ module CloudmersivePhishingDetectionApiClient
105
167
  # Calculates hash code according to all attributes.
106
168
  # @return [Fixnum] Hash code
107
169
  def hash
108
- [clean_result, phishing_risk_level, confidence_level, analysis_rationale].hash
170
+ [clean_result, contains_phishing, contains_unsolicited_sales, contains_promotional_content, contains_web_urls, contains_phone_numbers, contains_email_addresses, confidence_level, analysis_rationale, unsafe_urls].hash
109
171
  end
110
172
 
111
173
  # Builds the object from hash
@@ -0,0 +1,206 @@
1
+ =begin
2
+ #phishingapi
3
+
4
+ #Easily and directly scan and block phishing security threats in input.
5
+
6
+ OpenAPI spec version: v1
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.14
10
+
11
+ =end
12
+
13
+ require 'date'
14
+
15
+ module CloudmersivePhishingDetectionApiClient
16
+ # AI phishing detection request for basic text string analysis
17
+ class PhishingDetectionTextStringRequest
18
+ # Input text string to detect phishing against
19
+ attr_accessor :input_string
20
+
21
+ # Optional: Specify which AI model to use. Possible choices are Normal and Advanced. Default is Advanced.
22
+ attr_accessor :model
23
+
24
+ # Optional: Set to true to include an analysis rationale in the response explaining why the content was or was not flagged. Default is true.
25
+ attr_accessor :provide_analysis_rationale
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'input_string' => :'InputString',
31
+ :'model' => :'Model',
32
+ :'provide_analysis_rationale' => :'ProvideAnalysisRationale'
33
+ }
34
+ end
35
+
36
+ # Attribute type mapping.
37
+ def self.swagger_types
38
+ {
39
+ :'input_string' => :'String',
40
+ :'model' => :'String',
41
+ :'provide_analysis_rationale' => :'BOOLEAN'
42
+ }
43
+ end
44
+
45
+ # Initializes the object
46
+ # @param [Hash] attributes Model attributes in the form of hash
47
+ def initialize(attributes = {})
48
+ return unless attributes.is_a?(Hash)
49
+
50
+ # convert string to symbol for hash key
51
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
52
+
53
+ if attributes.has_key?(:'InputString')
54
+ self.input_string = attributes[:'InputString']
55
+ end
56
+
57
+ if attributes.has_key?(:'Model')
58
+ self.model = attributes[:'Model']
59
+ end
60
+
61
+ if attributes.has_key?(:'ProvideAnalysisRationale')
62
+ self.provide_analysis_rationale = attributes[:'ProvideAnalysisRationale']
63
+ end
64
+ end
65
+
66
+ # Show invalid properties with the reasons. Usually used together with valid?
67
+ # @return Array for valid properties with the reasons
68
+ def list_invalid_properties
69
+ invalid_properties = Array.new
70
+ invalid_properties
71
+ end
72
+
73
+ # Check to see if the all the properties in the model are valid
74
+ # @return true if the model is valid
75
+ def valid?
76
+ true
77
+ end
78
+
79
+ # Checks equality by comparing each attribute.
80
+ # @param [Object] Object to be compared
81
+ def ==(o)
82
+ return true if self.equal?(o)
83
+ self.class == o.class &&
84
+ input_string == o.input_string &&
85
+ model == o.model &&
86
+ provide_analysis_rationale == o.provide_analysis_rationale
87
+ end
88
+
89
+ # @see the `==` method
90
+ # @param [Object] Object to be compared
91
+ def eql?(o)
92
+ self == o
93
+ end
94
+
95
+ # Calculates hash code according to all attributes.
96
+ # @return [Fixnum] Hash code
97
+ def hash
98
+ [input_string, model, provide_analysis_rationale].hash
99
+ end
100
+
101
+ # Builds the object from hash
102
+ # @param [Hash] attributes Model attributes in the form of hash
103
+ # @return [Object] Returns the model itself
104
+ def build_from_hash(attributes)
105
+ return nil unless attributes.is_a?(Hash)
106
+ self.class.swagger_types.each_pair do |key, type|
107
+ if type =~ /\AArray<(.*)>/i
108
+ # check to ensure the input is an array given that the attribute
109
+ # is documented as an array but the input is not
110
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
111
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
112
+ end
113
+ elsif !attributes[self.class.attribute_map[key]].nil?
114
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
115
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
116
+ end
117
+
118
+ self
119
+ end
120
+
121
+ # Deserializes the data based on type
122
+ # @param string type Data type
123
+ # @param string value Value to be deserialized
124
+ # @return [Object] Deserialized data
125
+ def _deserialize(type, value)
126
+ case type.to_sym
127
+ when :DateTime
128
+ DateTime.parse(value)
129
+ when :Date
130
+ Date.parse(value)
131
+ when :String
132
+ value.to_s
133
+ when :Integer
134
+ value.to_i
135
+ when :Float
136
+ value.to_f
137
+ when :BOOLEAN
138
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
139
+ true
140
+ else
141
+ false
142
+ end
143
+ when :Object
144
+ # generic object (usually a Hash), return directly
145
+ value
146
+ when /\AArray<(?<inner_type>.+)>\z/
147
+ inner_type = Regexp.last_match[:inner_type]
148
+ value.map { |v| _deserialize(inner_type, v) }
149
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
150
+ k_type = Regexp.last_match[:k_type]
151
+ v_type = Regexp.last_match[:v_type]
152
+ {}.tap do |hash|
153
+ value.each do |k, v|
154
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
155
+ end
156
+ end
157
+ else # model
158
+ temp_model = CloudmersivePhishingDetectionApiClient.const_get(type).new
159
+ temp_model.build_from_hash(value)
160
+ end
161
+ end
162
+
163
+ # Returns the string representation of the object
164
+ # @return [String] String presentation of the object
165
+ def to_s
166
+ to_hash.to_s
167
+ end
168
+
169
+ # to_body is an alias to to_hash (backward compatibility)
170
+ # @return [Hash] Returns the object in the form of hash
171
+ def to_body
172
+ to_hash
173
+ end
174
+
175
+ # Returns the object in the form of hash
176
+ # @return [Hash] Returns the object in the form of hash
177
+ def to_hash
178
+ hash = {}
179
+ self.class.attribute_map.each_pair do |attr, param|
180
+ value = self.send(attr)
181
+ next if value.nil?
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
+
205
+ end
206
+ end