Class: Pinnacle::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/rcs/types/event.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action_type:, start_time:, end_time:, event_title:, event_description: OMIT, additional_properties: nil) ⇒ Pinnacle::Event

Parameters:

  • action_type (String)

    The type of message being sent

  • start_time (DateTime)

    The start time for the event.

  • end_time (DateTime)

    The end time for the event.

  • event_title (String)

    The title of the event.

  • event_description (String) (defaults to: OMIT)

    The description of the event

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/rcs/types/event.rb', line 34

def initialize(action_type:, start_time:, end_time:, event_title:, event_description: OMIT,
               additional_properties: nil)
  @action_type = action_type
  @start_time = start_time
  @end_time = end_time
  @event_title = event_title
  @event_description = event_description if event_description != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "action_type": action_type,
    "start_time": start_time,
    "end_time": end_time,
    "event_title": event_title,
    "event_description": event_description
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#action_typeString (readonly)

Returns The type of message being sent.

Returns:

  • (String)

    The type of message being sent



10
11
12
# File 'lib/rcs/types/event.rb', line 10

def action_type
  @action_type
end

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



20
21
22
# File 'lib/rcs/types/event.rb', line 20

def additional_properties
  @additional_properties
end

#end_timeDateTime (readonly)

Returns The end time for the event.

Returns:

  • (DateTime)

    The end time for the event.



14
15
16
# File 'lib/rcs/types/event.rb', line 14

def end_time
  @end_time
end

#event_descriptionString (readonly)

Returns The description of the event.

Returns:

  • (String)

    The description of the event



18
19
20
# File 'lib/rcs/types/event.rb', line 18

def event_description
  @event_description
end

#event_titleString (readonly)

Returns The title of the event.

Returns:

  • (String)

    The title of the event.



16
17
18
# File 'lib/rcs/types/event.rb', line 16

def event_title
  @event_title
end

#start_timeDateTime (readonly)

Returns The start time for the event.

Returns:

  • (DateTime)

    The start time for the event.



12
13
14
# File 'lib/rcs/types/event.rb', line 12

def start_time
  @start_time
end

Class Method Details

.from_json(json_object:) ⇒ Pinnacle::Event

Deserialize a JSON object to an instance of Event

Parameters:

  • json_object (String)

Returns:



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rcs/types/event.rb', line 57

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  action_type = parsed_json["action_type"]
  start_time = (DateTime.parse(parsed_json["start_time"]) unless parsed_json["start_time"].nil?)
  end_time = (DateTime.parse(parsed_json["end_time"]) unless parsed_json["end_time"].nil?)
  event_title = parsed_json["event_title"]
  event_description = parsed_json["event_description"]
  new(
    action_type: action_type,
    start_time: start_time,
    end_time: end_time,
    event_title: event_title,
    event_description: event_description,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


88
89
90
91
92
93
94
# File 'lib/rcs/types/event.rb', line 88

def self.validate_raw(obj:)
  obj.action_type.is_a?(String) != false || raise("Passed value for field obj.action_type is not the expected type, validation failed.")
  obj.start_time.is_a?(DateTime) != false || raise("Passed value for field obj.start_time is not the expected type, validation failed.")
  obj.end_time.is_a?(DateTime) != false || raise("Passed value for field obj.end_time is not the expected type, validation failed.")
  obj.event_title.is_a?(String) != false || raise("Passed value for field obj.event_title is not the expected type, validation failed.")
  obj.event_description&.is_a?(String) != false || raise("Passed value for field obj.event_description is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Event to a JSON object

Returns:

  • (String)


78
79
80
# File 'lib/rcs/types/event.rb', line 78

def to_json(*_args)
  @_field_set&.to_json
end