Class: NewStoreApi::RoutingInsightsActivity

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/new_store_api/models/routing_insights_activity.rb

Overview

RoutingInsightsActivity Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(correlation = nil, summary = nil, timestamp = nil, type = nil, value = nil) ⇒ RoutingInsightsActivity

Returns a new instance of RoutingInsightsActivity.



54
55
56
57
58
59
60
61
# File 'lib/new_store_api/models/routing_insights_activity.rb', line 54

def initialize(correlation = nil, summary = nil, timestamp = nil,
               type = nil, value = nil)
  @correlation = correlation
  @summary = summary
  @timestamp = timestamp
  @type = type
  @value = value
end

Instance Attribute Details

#correlationRoutingInsightsCorrelation

Information regarding which entities were affected by this event



15
16
17
# File 'lib/new_store_api/models/routing_insights_activity.rb', line 15

def correlation
  @correlation
end

#summaryString

Information regarding the event type

Returns:

  • (String)


19
20
21
# File 'lib/new_store_api/models/routing_insights_activity.rb', line 19

def summary
  @summary
end

#timestampDateTime

Information regarding the event type

Returns:

  • (DateTime)


23
24
25
# File 'lib/new_store_api/models/routing_insights_activity.rb', line 23

def timestamp
  @timestamp
end

#typeString

Event type

Returns:

  • (String)


27
28
29
# File 'lib/new_store_api/models/routing_insights_activity.rb', line 27

def type
  @type
end

#valueObject

Event type

Returns:

  • (Object)


31
32
33
# File 'lib/new_store_api/models/routing_insights_activity.rb', line 31

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/new_store_api/models/routing_insights_activity.rb', line 64

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  correlation = RoutingInsightsCorrelation.from_hash(hash['correlation']) if
    hash['correlation']
  summary = hash.key?('summary') ? hash['summary'] : nil
  timestamp = if hash.key?('timestamp')
                (DateTimeHelper.from_rfc3339(hash['timestamp']) if hash['timestamp'])
              end
  type = hash.key?('type') ? hash['type'] : nil
  value = hash.key?('value') ? APIHelper.deserialize_union_type(
    UnionTypeLookUp.get(:RoutingInsightsActivityValue), hash['value']
  ) : nil

  # Create object from extracted values.
  RoutingInsightsActivity.new(correlation,
                              summary,
                              timestamp,
                              type,
                              value)
end

.namesObject

A mapping from model property names to API property names.



34
35
36
37
38
39
40
41
42
# File 'lib/new_store_api/models/routing_insights_activity.rb', line 34

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['correlation'] = 'correlation'
  @_hash['summary'] = 'summary'
  @_hash['timestamp'] = 'timestamp'
  @_hash['type'] = 'type'
  @_hash['value'] = 'value'
  @_hash
end

.nullablesObject

An array for nullable fields



50
51
52
# File 'lib/new_store_api/models/routing_insights_activity.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
# File 'lib/new_store_api/models/routing_insights_activity.rb', line 45

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



93
94
95
96
97
98
99
100
101
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/new_store_api/models/routing_insights_activity.rb', line 93

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.correlation,
                            ->(val) { RoutingInsightsCorrelation.validate(val) },
                            is_model_hash: true) and
        APIHelper.valid_type?(value.summary,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.timestamp,
                              ->(val) { val.instance_of? DateTime }) and
        APIHelper.valid_type?(value.type,
                              ->(val) { val.instance_of? String }) and
        UnionTypeLookUp.get(:RoutingInsightsActivityValue)
                       .validate(value.value)
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['correlation'],
                          ->(val) { RoutingInsightsCorrelation.validate(val) },
                          is_model_hash: true) and
      APIHelper.valid_type?(value['summary'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['timestamp'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['type'],
                            ->(val) { val.instance_of? String }) and
      UnionTypeLookUp.get(:RoutingInsightsActivityValue)
                     .validate(value['value'])
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



135
136
137
138
139
# File 'lib/new_store_api/models/routing_insights_activity.rb', line 135

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} correlation: #{@correlation.inspect}, summary: #{@summary.inspect},"\
  " timestamp: #{@timestamp.inspect}, type: #{@type.inspect}, value: #{@value.inspect}>"
end

#to_custom_timestampObject



87
88
89
# File 'lib/new_store_api/models/routing_insights_activity.rb', line 87

def to_custom_timestamp
  DateTimeHelper.to_rfc3339(timestamp)
end

#to_sObject

Provides a human-readable string representation of the object.



128
129
130
131
132
# File 'lib/new_store_api/models/routing_insights_activity.rb', line 128

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} correlation: #{@correlation}, summary: #{@summary}, timestamp:"\
  " #{@timestamp}, type: #{@type}, value: #{@value}>"
end