Class: TalonOne::RiskDetail

Inherits:
ApiModelBase show all
Defined in:
lib/talon_one_sdk/models/risk_detail.rb

Overview

Details of a risk, including its most severely affected entities.

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ RiskDetail

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 178

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `TalonOne::RiskDetail` initialize method"
  end

  # check to see if the attribute exists and convert string to symbol for hash key
  acceptable_attribute_map = self.class.acceptable_attribute_map
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!acceptable_attribute_map.key?(k.to_sym))
      fail ArgumentError, "`#{k}` is not a valid attribute in `TalonOne::RiskDetail`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
    end
    h[k.to_sym] = v
  }

  if attributes.key?(:'id')
    self.id = attributes[:'id']
  else
    self.id = nil
  end

  if attributes.key?(:'created')
    self.created = attributes[:'created']
  else
    self.created = nil
  end

  if attributes.key?(:'notification_id')
    self.notification_id = attributes[:'notification_id']
  else
    self.notification_id = nil
  end

  if attributes.key?(:'feature_date')
    self.feature_date = attributes[:'feature_date']
  else
    self.feature_date = nil
  end

  if attributes.key?(:'group_key')
    self.group_key = attributes[:'group_key']
  else
    self.group_key = nil
  end

  if attributes.key?(:'application_id')
    self.application_id = attributes[:'application_id']
  end

  if attributes.key?(:'status')
    self.status = attributes[:'status']
  else
    self.status = nil
  end

  if attributes.key?(:'criticality')
    self.criticality = attributes[:'criticality']
  else
    self.criticality = nil
  end

  if attributes.key?(:'entity')
    self.entity = attributes[:'entity']
  else
    self.entity = nil
  end

  if attributes.key?(:'activity')
    self.activity = attributes[:'activity']
  else
    self.activity = nil
  end

  if attributes.key?(:'time_frame')
    self.time_frame = attributes[:'time_frame']
  else
    self.time_frame = nil
  end

  if attributes.key?(:'reported_date')
    self.reported_date = attributes[:'reported_date']
  else
    self.reported_date = nil
  end

  if attributes.key?(:'affected_entity_count')
    self.affected_entity_count = attributes[:'affected_entity_count']
  else
    self.affected_entity_count = nil
  end

  if attributes.key?(:'description')
    self.description = attributes[:'description']
  end

  if attributes.key?(:'discard_reason')
    self.discard_reason = attributes[:'discard_reason']
  end

  if attributes.key?(:'status_comment')
    self.status_comment = attributes[:'status_comment']
  end

  if attributes.key?(:'status_changed_by')
    self.status_changed_by = attributes[:'status_changed_by']
  end

  if attributes.key?(:'status_changed_at')
    self.status_changed_at = attributes[:'status_changed_at']
  end

  if attributes.key?(:'modified')
    self.modified = attributes[:'modified']
  else
    self.modified = nil
  end

  if attributes.key?(:'affected_entities')
    if (value = attributes[:'affected_entities']).is_a?(Array)
      self.affected_entities = value
    end
  else
    self.affected_entities = nil
  end
end

Instance Attribute Details

#activityObject

The activity metric the risk was detected in.



47
48
49
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 47

def activity
  @activity
end

#affected_entitiesObject

The affected entities with the highest severity ratios, in descending order.



77
78
79
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 77

def affected_entities
  @affected_entities
end

#affected_entity_countObject

The total number of entities affected by this risk.



56
57
58
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 56

def affected_entity_count
  @affected_entity_count
end

#application_idObject

The ID of the Application this risk belongs to. Absent for global metrics.



35
36
37
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 35

def application_id
  @application_id
end

#createdObject

The time this entity was created.



23
24
25
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 23

def created
  @created
end

#criticalityObject

The critical classification bucket of this risk.



41
42
43
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 41

def criticality
  @criticality
end

#descriptionObject

Human-readable description of the detected anomaly.



59
60
61
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 59

def description
  @description
end

#discard_reasonObject

The reason this risk was discarded. Only present on discarded risks.



62
63
64
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 62

def discard_reason
  @discard_reason
end

#entityObject

The entity type the risk was detected in.



44
45
46
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 44

def entity
  @entity
end

#feature_dateObject

The date of the activity data in which this risk was detected. The anomaly detection pipeline scores complete 24-hour cycles, so this is always the day before the risk was reported, not the reporting date itself.



29
30
31
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 29

def feature_date
  @feature_date
end

#group_keyObject

The Application group this risk was detected in. Contains the Application ID, or __GLOBAL__ for metrics that are not grouped by Application.



32
33
34
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 32

def group_key
  @group_key
end

#idObject

The internal ID of this entity.



20
21
22
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 20

def id
  @id
end

#modifiedObject

Timestamp of the most recent update.



74
75
76
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 74

def modified
  @modified
end

#notification_idObject

The ID of the risk notification rule that flagged this risk.



26
27
28
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 26

def notification_id
  @notification_id
end

#reported_dateObject

The time the ML service reported this risk.



53
54
55
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 53

def reported_date
  @reported_date
end

#statusObject

The triage lifecycle status of this risk.



38
39
40
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 38

def status
  @status
end

#status_changed_atObject

The time of the latest reclassification action.



71
72
73
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 71

def status_changed_at
  @status_changed_at
end

#status_changed_byObject

The ID of the user who performed the latest reclassification action.



68
69
70
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 68

def status_changed_by
  @status_changed_by
end

#status_commentObject

The free-text details of the latest reclassification action: the description for resolving confirmed risks, or the details for discarding risks.



65
66
67
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 65

def status_comment
  @status_comment
end

#time_frameObject

The rolling time window of the risk evaluation.



50
51
52
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 50

def time_frame
  @time_frame
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



128
129
130
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 128

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



133
134
135
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 133

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 102

def self.attribute_map
  {
    :'id' => :'id',
    :'created' => :'created',
    :'notification_id' => :'notificationId',
    :'feature_date' => :'featureDate',
    :'group_key' => :'groupKey',
    :'application_id' => :'applicationId',
    :'status' => :'status',
    :'criticality' => :'criticality',
    :'entity' => :'entity',
    :'activity' => :'activity',
    :'time_frame' => :'timeFrame',
    :'reported_date' => :'reportedDate',
    :'affected_entity_count' => :'affectedEntityCount',
    :'description' => :'description',
    :'discard_reason' => :'discardReason',
    :'status_comment' => :'statusComment',
    :'status_changed_by' => :'statusChangedBy',
    :'status_changed_at' => :'statusChangedAt',
    :'modified' => :'modified',
    :'affected_entities' => :'affectedEntities'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 592

def self.build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  attributes = attributes.transform_keys(&:to_sym)
  transformed_hash = {}
  openapi_types.each_pair do |key, type|
    if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = nil
    elsif type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the attribute
      # is documented as an array but the input is not
      if attributes[attribute_map[key]].is_a?(Array)
        transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
      end
    elsif !attributes[attribute_map[key]].nil?
      transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
    end
  end
  new(transformed_hash)
end

.openapi_all_ofObject

List of class defined in allOf (OpenAPI v3)



170
171
172
173
174
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 170

def self.openapi_all_of
  [
  :'Risk'
  ]
end

.openapi_nullableObject

List of attributes with nullable: true



164
165
166
167
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 164

def self.openapi_nullable
  Set.new([
  ])
end

.openapi_typesObject

Attribute type mapping.



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 138

def self.openapi_types
  {
    :'id' => :'Integer',
    :'created' => :'Time',
    :'notification_id' => :'Integer',
    :'feature_date' => :'Date',
    :'group_key' => :'String',
    :'application_id' => :'Integer',
    :'status' => :'String',
    :'criticality' => :'String',
    :'entity' => :'String',
    :'activity' => :'String',
    :'time_frame' => :'String',
    :'reported_date' => :'Time',
    :'affected_entity_count' => :'Integer',
    :'description' => :'String',
    :'discard_reason' => :'String',
    :'status_comment' => :'String',
    :'status_changed_by' => :'Integer',
    :'status_changed_at' => :'Time',
    :'modified' => :'Time',
    :'affected_entities' => :'Array<RiskAffectedEntityItem>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 552

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      created == o.created &&
      notification_id == o.notification_id &&
      feature_date == o.feature_date &&
      group_key == o.group_key &&
      application_id == o.application_id &&
      status == o.status &&
      criticality == o.criticality &&
      entity == o.entity &&
      activity == o.activity &&
      time_frame == o.time_frame &&
      reported_date == o.reported_date &&
      affected_entity_count == o.affected_entity_count &&
      description == o.description &&
      discard_reason == o.discard_reason &&
      status_comment == o.status_comment &&
      status_changed_by == o.status_changed_by &&
      status_changed_at == o.status_changed_at &&
      modified == o.modified &&
      affected_entities == o.affected_entities
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


579
580
581
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 579

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



585
586
587
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 585

def hash
  [id, created, notification_id, feature_date, group_key, application_id, status, criticality, entity, activity, time_frame, reported_date, affected_entity_count, description, discard_reason, status_comment, status_changed_by, status_changed_at, modified, affected_entities].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 305

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  if @id.nil?
    invalid_properties.push('invalid value for "id", id cannot be nil.')
  end

  if @created.nil?
    invalid_properties.push('invalid value for "created", created cannot be nil.')
  end

  if @notification_id.nil?
    invalid_properties.push('invalid value for "notification_id", notification_id cannot be nil.')
  end

  if @feature_date.nil?
    invalid_properties.push('invalid value for "feature_date", feature_date cannot be nil.')
  end

  if @group_key.nil?
    invalid_properties.push('invalid value for "group_key", group_key cannot be nil.')
  end

  if @status.nil?
    invalid_properties.push('invalid value for "status", status cannot be nil.')
  end

  if @criticality.nil?
    invalid_properties.push('invalid value for "criticality", criticality cannot be nil.')
  end

  if @entity.nil?
    invalid_properties.push('invalid value for "entity", entity cannot be nil.')
  end

  if @activity.nil?
    invalid_properties.push('invalid value for "activity", activity cannot be nil.')
  end

  if @time_frame.nil?
    invalid_properties.push('invalid value for "time_frame", time_frame cannot be nil.')
  end

  if @reported_date.nil?
    invalid_properties.push('invalid value for "reported_date", reported_date cannot be nil.')
  end

  if @affected_entity_count.nil?
    invalid_properties.push('invalid value for "affected_entity_count", affected_entity_count cannot be nil.')
  end

  if @modified.nil?
    invalid_properties.push('invalid value for "modified", modified cannot be nil.')
  end

  if @affected_entities.nil?
    invalid_properties.push('invalid value for "affected_entities", affected_entities cannot be nil.')
  end

  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



614
615
616
617
618
619
620
621
622
623
624
625
626
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 614

def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    if value.nil?
      is_nullable = self.class.openapi_nullable.include?(attr)
      next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
    end

    hash[param] = _to_hash(value)
  end
  hash
end

#valid?Boolean

Check to see if the all the properties in the model are valid

Returns:

  • (Boolean)

    true if the model is valid



369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
# File 'lib/talon_one_sdk/models/risk_detail.rb', line 369

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  return false if @id.nil?
  return false if @created.nil?
  return false if @notification_id.nil?
  return false if @feature_date.nil?
  return false if @group_key.nil?
  return false if @status.nil?
  status_validator = EnumAttributeValidator.new('String', ["active", "in_review", "confirmed", "discarded"])
  return false unless status_validator.valid?(@status)
  return false if @criticality.nil?
  criticality_validator = EnumAttributeValidator.new('String', ["critical", "not_critical"])
  return false unless criticality_validator.valid?(@criticality)
  return false if @entity.nil?
  entity_validator = EnumAttributeValidator.new('String', ["customer_profile", "customer_session"])
  return false unless entity_validator.valid?(@entity)
  return false if @activity.nil?
  activity_validator = EnumAttributeValidator.new('String', ["loyalty_points_earned", "discounted_amount", "completed_orders", "coupon_attempts"])
  return false unless activity_validator.valid?(@activity)
  return false if @time_frame.nil?
  time_frame_validator = EnumAttributeValidator.new('String', ["1D", "7D", "30D"])
  return false unless time_frame_validator.valid?(@time_frame)
  return false if @reported_date.nil?
  return false if @affected_entity_count.nil?
  discard_reason_validator = EnumAttributeValidator.new('String', ["expected_behavior", "other"])
  return false unless discard_reason_validator.valid?(@discard_reason)
  return false if @modified.nil?
  return false if @affected_entities.nil?
  true
end