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(title:, action_type:, start_time:, end_time:, event_title:, event_description: OMIT, additional_properties: nil) ⇒ Pinnacle::Event

Parameters:

  • title (String)

    The title for the event action. Maximum length is 25 characters.

  • 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



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/rcs/types/event.rb', line 37

def initialize(title:, action_type:, start_time:, end_time:, event_title:, event_description: OMIT,
               additional_properties: nil)
  @title = title
  @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 = {
    "title": title,
    "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



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

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



22
23
24
# File 'lib/rcs/types/event.rb', line 22

def additional_properties
  @additional_properties
end

#end_timeDateTime (readonly)

Returns The end time for the event.

Returns:

  • (DateTime)

    The end time for the event.



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

def end_time
  @end_time
end

#event_descriptionString (readonly)

Returns The description of the event.

Returns:

  • (String)

    The description of the event



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

def event_description
  @event_description
end

#event_titleString (readonly)

Returns The title of the event.

Returns:

  • (String)

    The title of the event.



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

def event_title
  @event_title
end

#start_timeDateTime (readonly)

Returns The start time for the event.

Returns:

  • (DateTime)

    The start time for the event.



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

def start_time
  @start_time
end

#titleString (readonly)

Returns The title for the event action. Maximum length is 25 characters.

Returns:

  • (String)

    The title for the event action. Maximum length is 25 characters.



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

def title
  @title
end

Class Method Details

.from_json(json_object:) ⇒ Pinnacle::Event

Deserialize a JSON object to an instance of Event

Parameters:

  • json_object (String)

Returns:



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/rcs/types/event.rb', line 62

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  title = parsed_json["title"]
  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(
    title: title,
    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)


95
96
97
98
99
100
101
102
# File 'lib/rcs/types/event.rb', line 95

def self.validate_raw(obj:)
  obj.title.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.")
  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)


85
86
87
# File 'lib/rcs/types/event.rb', line 85

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