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.
-
#event_start_time ⇒ String
readonly
Start time for events.
-
#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
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/rcs/types/action.rb', line 59 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.
35 36 37 |
# File 'lib/rcs/types/action.rb', line 35 def additional_properties @additional_properties end |
#event_description ⇒ String (readonly)
Returns Optional event description.
31 32 33 |
# File 'lib/rcs/types/action.rb', line 31 def event_description @event_description end |
#event_end_time ⇒ String (readonly)
Returns End time for events. Required for ‘scheduleEvent’.
27 28 29 |
# File 'lib/rcs/types/action.rb', line 27 def event_end_time @event_end_time end |
#event_start_time ⇒ String (readonly)
Returns Start time for events. Required for ‘scheduleEvent’.
25 26 27 |
# File 'lib/rcs/types/action.rb', line 25 def event_start_time @event_start_time end |
#event_title ⇒ String (readonly)
Returns Event title. Required for ‘scheduleEvent’.
29 30 31 |
# File 'lib/rcs/types/action.rb', line 29 def event_title @event_title end |
#lat_long ⇒ Pinnacle::ActionLatLong (readonly)
Returns Latitude and longitude coordinates. Required for ‘sendLocation’.
33 34 35 |
# File 'lib/rcs/types/action.rb', line 33 def lat_long @lat_long end |
#metadata ⇒ String (readonly)
Returns Optional metadata. This is sent alongside the payload to the webhook.
23 24 25 |
# File 'lib/rcs/types/action.rb', line 23 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, ‘requestLocation’ 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
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/rcs/types/action.rb', line 90 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.
134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/rcs/types/action.rb', line 134 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
124 125 126 |
# File 'lib/rcs/types/action.rb', line 124 def to_json(*_args) @_field_set&.to_json end |