Class: Pinnacle::Action
- Inherits:
-
Object
- Object
- Pinnacle::Action
- Defined in:
- lib/rcs/types/action.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#event_description ⇒ String
readonly
Optional event description.
-
#event_end_time ⇒ String
readonly
End time for events in ISO 8601 format.
-
#event_start_time ⇒ String
readonly
Start time for events in ISO 8601 format.
-
#event_title ⇒ String
readonly
Event title.
-
#lat_long ⇒ Pinnacle::ActionLatLong
readonly
Latitude and longitude coordinates.
-
#metadata ⇒ String
readonly
Optional metadata.
-
#payload ⇒ String
readonly
Optional payload associated with the action.
-
#title ⇒ String
readonly
Title of the action (must be less than 25 characters).
-
#type ⇒ Pinnacle::ActionType
readonly
Type of action for the button.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Pinnacle::Action
Deserialize a JSON object to an instance of Action.
-
.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(title: OMIT, type: OMIT, payload: OMIT, metadata: OMIT, event_start_time: OMIT, event_end_time: OMIT, event_title: OMIT, event_description: OMIT, lat_long: OMIT, additional_properties: nil) ⇒ Pinnacle::Action constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Action to a JSON object.
Constructor Details
#initialize(title: OMIT, type: OMIT, payload: OMIT, metadata: OMIT, event_start_time: OMIT, event_end_time: OMIT, event_title: OMIT, event_description: OMIT, lat_long: OMIT, additional_properties: nil) ⇒ Pinnacle::Action
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/rcs/types/action.rb', line 67 def initialize(title: OMIT, type: OMIT, payload: OMIT, metadata: OMIT, event_start_time: OMIT, event_end_time: OMIT, event_title: OMIT, event_description: OMIT, lat_long: OMIT, additional_properties: nil) @title = title if title != OMIT @type = type if type != OMIT @payload = payload if payload != OMIT @metadata = if != OMIT @event_start_time = event_start_time if event_start_time != OMIT @event_end_time = event_end_time if event_end_time != OMIT @event_title = event_title if event_title != OMIT @event_description = event_description if event_description != OMIT @lat_long = lat_long if lat_long != OMIT @additional_properties = additional_properties @_field_set = { "title": title, "type": type, "payload": payload, "metadata": , "eventStartTime": event_start_time, "eventEndTime": event_end_time, "eventTitle": event_title, "eventDescription": event_description, "latLong": lat_long }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
39 40 41 |
# File 'lib/rcs/types/action.rb', line 39 def additional_properties @additional_properties end |
#event_description ⇒ String (readonly)
Returns Optional event description.
35 36 37 |
# File 'lib/rcs/types/action.rb', line 35 def event_description @event_description end |
#event_end_time ⇒ String (readonly)
Returns End time for events in ISO 8601 format. For example, ‘2022-01-01T12:00:00Z’. Required for ‘scheduleEvent’.
31 32 33 |
# File 'lib/rcs/types/action.rb', line 31 def event_end_time @event_end_time end |
#event_start_time ⇒ String (readonly)
Returns Start time for events in ISO 8601 format. For example, ‘2022-01-01T12:00:00Z’. Required for ‘scheduleEvent’.
28 29 30 |
# File 'lib/rcs/types/action.rb', line 28 def event_start_time @event_start_time end |
#event_title ⇒ String (readonly)
Returns Event title. Required for ‘scheduleEvent’.
33 34 35 |
# File 'lib/rcs/types/action.rb', line 33 def event_title @event_title end |
#lat_long ⇒ Pinnacle::ActionLatLong (readonly)
Returns Latitude and longitude coordinates. Required for ‘sendLocation’.
37 38 39 |
# File 'lib/rcs/types/action.rb', line 37 def lat_long @lat_long end |
#metadata ⇒ String (readonly)
Returns Optional metadata. Only used for type ‘trigger’ ignored for other action types. When the user presses the action, the metadata is sent to the webhook alongside the payload.
25 26 27 |
# File 'lib/rcs/types/action.rb', line 25 def @metadata end |
#payload ⇒ String (readonly)
Returns Optional payload associated with the action. This payload encodes the respective fields for the action type and is required. For ‘openUrl’, the payload is the URL to open. For ‘call’, the payload is the phone number to dial. For ‘trigger’, the payload is the predefined payload to send to the webhook.
21 22 23 |
# File 'lib/rcs/types/action.rb', line 21 def payload @payload end |
#title ⇒ String (readonly)
Returns Title of the action (must be less than 25 characters).
11 12 13 |
# File 'lib/rcs/types/action.rb', line 11 def title @title end |
#type ⇒ Pinnacle::ActionType (readonly)
Returns Type of action for the button. ‘openUrl’ opens a URL, ‘call’ dials a phone number, ‘trigger’ sends the predefined payload to the webhook when pressed, ‘requestUserLocation’ requests the user’s location, ‘scheduleEvent’ creates a calendar event, ‘sendLocation’ sends a location.
16 17 18 |
# File 'lib/rcs/types/action.rb', line 16 def type @type end |
Class Method Details
.from_json(json_object:) ⇒ Pinnacle::Action
Deserialize a JSON object to an instance of Action
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 126 127 |
# File 'lib/rcs/types/action.rb', line 98 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) title = parsed_json["title"] type = parsed_json["type"] payload = parsed_json["payload"] = parsed_json["metadata"] event_start_time = parsed_json["eventStartTime"] event_end_time = parsed_json["eventEndTime"] event_title = parsed_json["eventTitle"] event_description = parsed_json["eventDescription"] if parsed_json["latLong"].nil? lat_long = nil else lat_long = parsed_json["latLong"].to_json lat_long = Pinnacle::ActionLatLong.from_json(json_object: lat_long) end new( title: title, type: type, payload: payload, metadata: , event_start_time: event_start_time, event_end_time: event_end_time, event_title: event_title, event_description: event_description, lat_long: lat_long, 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.
142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/rcs/types/action.rb', line 142 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.type&.is_a?(Pinnacle::ActionType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.payload&.is_a?(String) != false || raise("Passed value for field obj.payload is not the expected type, validation failed.") obj.&.is_a?(String) != false || raise("Passed value for field obj.metadata is not the expected type, validation failed.") obj.event_start_time&.is_a?(String) != false || raise("Passed value for field obj.event_start_time is not the expected type, validation failed.") obj.event_end_time&.is_a?(String) != false || raise("Passed value for field obj.event_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.") obj.lat_long.nil? || Pinnacle::ActionLatLong.validate_raw(obj: obj.lat_long) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of Action to a JSON object
132 133 134 |
# File 'lib/rcs/types/action.rb', line 132 def to_json(*_args) @_field_set&.to_json end |