Class: MistApi::WebhookMinisReachability

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mist_api/models/webhook_minis_reachability.rb

Overview

Sample of the ‘minis-reachability` webhook payload.

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(events = nil) ⇒ WebhookMinisReachability

Returns a new instance of WebhookMinisReachability.



38
39
40
41
# File 'lib/mist_api/models/webhook_minis_reachability.rb', line 38

def initialize(events = nil)
  @events = events
  @topic = 'minis-reachability'
end

Instance Attribute Details

#eventsArray[WebhookMinisReachabilityEvent]

TODO: Write general description for this method

Returns:



14
15
16
# File 'lib/mist_api/models/webhook_minis_reachability.rb', line 14

def events
  @events
end

#topicString (readonly)

enum: ‘minis-reachability`

Returns:

  • (String)


18
19
20
# File 'lib/mist_api/models/webhook_minis_reachability.rb', line 18

def topic
  @topic
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/mist_api/models/webhook_minis_reachability.rb', line 44

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  # Parameter is an array, so we need to iterate through it
  events = nil
  unless hash['events'].nil?
    events = []
    hash['events'].each do |structure|
      events << (WebhookMinisReachabilityEvent.from_hash(structure) if structure)
    end
  end

  events = nil unless hash.key?('events')

  # Create object from extracted values.
  WebhookMinisReachability.new(events)
end

.namesObject

A mapping from model property names to API property names.



21
22
23
24
25
26
# File 'lib/mist_api/models/webhook_minis_reachability.rb', line 21

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['events'] = 'events'
  @_hash['topic'] = 'topic'
  @_hash
end

.nullablesObject

An array for nullable fields



34
35
36
# File 'lib/mist_api/models/webhook_minis_reachability.rb', line 34

def self.nullables
  []
end

.optionalsObject

An array for optional fields



29
30
31
# File 'lib/mist_api/models/webhook_minis_reachability.rb', line 29

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



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

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.events,
                            ->(val) { WebhookMinisReachabilityEvent.validate(val) },
                            is_model_hash: true,
                            is_inner_model_hash: true) and
        APIHelper.valid_type?(value.topic,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['events'],
                          ->(val) { WebhookMinisReachabilityEvent.validate(val) },
                          is_model_hash: true,
                          is_inner_model_hash: true) and
      APIHelper.valid_type?(value['topic'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



96
97
98
99
# File 'lib/mist_api/models/webhook_minis_reachability.rb', line 96

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} events: #{@events.inspect}, topic: #{@topic.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



90
91
92
93
# File 'lib/mist_api/models/webhook_minis_reachability.rb', line 90

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} events: #{@events}, topic: #{@topic}>"
end