Class: Pinnacle::Action

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

Parameters:

  • title (String) (defaults to: OMIT)

    Title of the action (must be less than 25 characters).

  • type (Pinnacle::ActionType) (defaults to: OMIT)

    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.

  • payload (String) (defaults to: OMIT)

    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.

  • metadata (String) (defaults to: OMIT)

    Optional metadata. This is sent alongside the payload to the webhook.

  • event_start_time (String) (defaults to: OMIT)

    Start time for events. Required for ‘scheduleEvent’.

  • event_end_time (String) (defaults to: OMIT)

    End time for events. Required for ‘scheduleEvent’.

  • event_title (String) (defaults to: OMIT)

    Event title. Required for ‘scheduleEvent’.

  • event_description (String) (defaults to: OMIT)

    Optional event description.

  • lat_long (Pinnacle::ActionLatLong) (defaults to: OMIT)

    Latitude and longitude coordinates. Required for ‘sendLocation’.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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_descriptionString (readonly)

Returns Optional event description.

Returns:

  • (String)

    Optional event description.



31
32
33
# File 'lib/rcs/types/action.rb', line 31

def event_description
  @event_description
end

#event_end_timeString (readonly)

Returns End time for events. Required for ‘scheduleEvent’.

Returns:

  • (String)

    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_timeString (readonly)

Returns Start time for events. Required for ‘scheduleEvent’.

Returns:

  • (String)

    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_titleString (readonly)

Returns Event title. Required for ‘scheduleEvent’.

Returns:

  • (String)

    Event title. Required for ‘scheduleEvent’.



29
30
31
# File 'lib/rcs/types/action.rb', line 29

def event_title
  @event_title
end

#lat_longPinnacle::ActionLatLong (readonly)

Returns Latitude and longitude coordinates. Required for ‘sendLocation’.

Returns:



33
34
35
# File 'lib/rcs/types/action.rb', line 33

def lat_long
  @lat_long
end

#metadataString (readonly)

Returns Optional metadata. This is sent alongside the payload to the webhook.

Returns:

  • (String)

    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

#payloadString (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.

Returns:

  • (String)

    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

#titleString (readonly)

Returns Title of the action (must be less than 25 characters).

Returns:

  • (String)

    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

#typePinnacle::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.

Returns:

  • (Pinnacle::ActionType)

    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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


124
125
126
# File 'lib/rcs/types/action.rb', line 124

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