Class: Pinnacle::Event
- Inherits:
-
Object
- Object
- Pinnacle::Event
- Defined in:
- lib/rcs/types/event.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#action_type ⇒ String
readonly
The type of message being sent.
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#end_time ⇒ DateTime
readonly
The end time for the event.
-
#event_description ⇒ String
readonly
The description of the event.
-
#event_title ⇒ String
readonly
The title of the event.
-
#start_time ⇒ DateTime
readonly
The start time for the event.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Pinnacle::Event
Deserialize a JSON object to an instance of Event.
-
.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.
Instance Method Summary collapse
- #initialize(action_type:, start_time:, end_time:, event_title:, event_description: OMIT, additional_properties: nil) ⇒ Pinnacle::Event constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Event to a JSON object.
Constructor Details
#initialize(action_type:, start_time:, end_time:, event_title:, event_description: OMIT, additional_properties: nil) ⇒ Pinnacle::Event
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_type ⇒ String (readonly)
Returns The type of message being sent.
10 11 12 |
# File 'lib/rcs/types/event.rb', line 10 def action_type @action_type end |
#additional_properties ⇒ OpenStruct (readonly)
Returns 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_time ⇒ DateTime (readonly)
Returns The end time for the event.
14 15 16 |
# File 'lib/rcs/types/event.rb', line 14 def end_time @end_time end |
#event_description ⇒ String (readonly)
Returns The description of the event.
18 19 20 |
# File 'lib/rcs/types/event.rb', line 18 def event_description @event_description end |
#event_title ⇒ String (readonly)
Returns The title of the event.
16 17 18 |
# File 'lib/rcs/types/event.rb', line 16 def event_title @event_title end |
#start_time ⇒ DateTime (readonly)
Returns 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
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.
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
78 79 80 |
# File 'lib/rcs/types/event.rb', line 78 def to_json(*_args) @_field_set&.to_json end |