Class: Vapi::TransferDestinationSip

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/transfer_destination_sip.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sip_uri:, message: OMIT, transfer_plan: OMIT, sip_headers: OMIT, description: OMIT, additional_properties: nil) ⇒ Vapi::TransferDestinationSip

Parameters:

  • message (Vapi::TransferDestinationSipMessage) (defaults to: OMIT)

    This is spoken to the customer before connecting them to the destination. Usage:

    • If this is not provided and transfer tool messages is not provided, default is

    “Transferring the call now”.

    • If set to “”, nothing is spoken. This is useful when you want to silently

    transfer. This is especially useful when transferring between assistants in a squad. In this scenario, you likely also want to set ‘assistant.firstMessageMode=assistant-speaks-first-with-model-generated-message` for the destination assistant. This accepts a string or a ToolMessageStart class. Latter is useful if you want to specify multiple messages for different languages through the `contents` field.

  • sip_uri (String)

    This is the SIP URI to transfer the call to.

  • transfer_plan (Vapi::TransferPlan) (defaults to: OMIT)

    This configures how transfer is executed and the experience of the destination party receiving the call. Defaults to ‘blind-transfer`. @default `transferPlan.mode=’blind-transfer’‘

  • sip_headers (Hash{String => Object}) (defaults to: OMIT)

    These are custom headers to be added to SIP refer during transfer call.

  • description (String) (defaults to: OMIT)

    This is the description of the destination, used by the AI to choose when and how to transfer the call.

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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

def initialize(sip_uri:, message: OMIT, transfer_plan: OMIT, sip_headers: OMIT, description: OMIT,
               additional_properties: nil)
  @message = message if message != OMIT
  @sip_uri = sip_uri
  @transfer_plan = transfer_plan if transfer_plan != OMIT
  @sip_headers = sip_headers if sip_headers != OMIT
  @description = description if description != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "message": message,
    "sipUri": sip_uri,
    "transferPlan": transfer_plan,
    "sipHeaders": sip_headers,
    "description": description
  }.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/vapi_server_sdk/types/transfer_destination_sip.rb', line 35

def additional_properties
  @additional_properties
end

#descriptionString (readonly)

Returns This is the description of the destination, used by the AI to choose when and how to transfer the call.

Returns:

  • (String)

    This is the description of the destination, used by the AI to choose when and how to transfer the call.



33
34
35
# File 'lib/vapi_server_sdk/types/transfer_destination_sip.rb', line 33

def description
  @description
end

#messageVapi::TransferDestinationSipMessage (readonly)

Returns This is spoken to the customer before connecting them to the destination. Usage:

  • If this is not provided and transfer tool messages is not provided, default is

“Transferring the call now”.

  • If set to “”, nothing is spoken. This is useful when you want to silently

transfer. This is especially useful when transferring between assistants in a squad. In this scenario, you likely also want to set ‘assistant.firstMessageMode=assistant-speaks-first-with-model-generated-message` for the destination assistant. This accepts a string or a ToolMessageStart class. Latter is useful if you want to specify multiple messages for different languages through the `contents` field.

Returns:

  • (Vapi::TransferDestinationSipMessage)

    This is spoken to the customer before connecting them to the destination. Usage:

    • If this is not provided and transfer tool messages is not provided, default is

    “Transferring the call now”.

    • If set to “”, nothing is spoken. This is useful when you want to silently

    transfer. This is especially useful when transferring between assistants in a squad. In this scenario, you likely also want to set ‘assistant.firstMessageMode=assistant-speaks-first-with-model-generated-message` for the destination assistant. This accepts a string or a ToolMessageStart class. Latter is useful if you want to specify multiple messages for different languages through the `contents` field.



22
23
24
# File 'lib/vapi_server_sdk/types/transfer_destination_sip.rb', line 22

def message
  @message
end

#sip_headersHash{String => Object} (readonly)

Returns These are custom headers to be added to SIP refer during transfer call.

Returns:

  • (Hash{String => Object})

    These are custom headers to be added to SIP refer during transfer call.



30
31
32
# File 'lib/vapi_server_sdk/types/transfer_destination_sip.rb', line 30

def sip_headers
  @sip_headers
end

#sip_uriString (readonly)

Returns This is the SIP URI to transfer the call to.

Returns:

  • (String)

    This is the SIP URI to transfer the call to.



24
25
26
# File 'lib/vapi_server_sdk/types/transfer_destination_sip.rb', line 24

def sip_uri
  @sip_uri
end

#transfer_planVapi::TransferPlan (readonly)

Returns This configures how transfer is executed and the experience of the destination party receiving the call. Defaults to ‘blind-transfer`. @default `transferPlan.mode=’blind-transfer’‘.

Returns:

  • (Vapi::TransferPlan)

    This configures how transfer is executed and the experience of the destination party receiving the call. Defaults to ‘blind-transfer`. @default `transferPlan.mode=’blind-transfer’‘



28
29
30
# File 'lib/vapi_server_sdk/types/transfer_destination_sip.rb', line 28

def transfer_plan
  @transfer_plan
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::TransferDestinationSip

Deserialize a JSON object to an instance of TransferDestinationSip

Parameters:

  • json_object (String)

Returns:



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/vapi_server_sdk/types/transfer_destination_sip.rb', line 86

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["message"].nil?
    message = nil
  else
    message = parsed_json["message"].to_json
    message = Vapi::TransferDestinationSipMessage.from_json(json_object: message)
  end
  sip_uri = parsed_json["sipUri"]
  if parsed_json["transferPlan"].nil?
    transfer_plan = nil
  else
    transfer_plan = parsed_json["transferPlan"].to_json
    transfer_plan = Vapi::TransferPlan.from_json(json_object: transfer_plan)
  end
  sip_headers = parsed_json["sipHeaders"]
  description = parsed_json["description"]
  new(
    message: message,
    sip_uri: sip_uri,
    transfer_plan: transfer_plan,
    sip_headers: sip_headers,
    description: 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)


127
128
129
130
131
132
133
# File 'lib/vapi_server_sdk/types/transfer_destination_sip.rb', line 127

def self.validate_raw(obj:)
  obj.message.nil? || Vapi::TransferDestinationSipMessage.validate_raw(obj: obj.message)
  obj.sip_uri.is_a?(String) != false || raise("Passed value for field obj.sip_uri is not the expected type, validation failed.")
  obj.transfer_plan.nil? || Vapi::TransferPlan.validate_raw(obj: obj.transfer_plan)
  obj.sip_headers&.is_a?(Hash) != false || raise("Passed value for field obj.sip_headers is not the expected type, validation failed.")
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of TransferDestinationSip to a JSON object

Returns:

  • (String)


117
118
119
# File 'lib/vapi_server_sdk/types/transfer_destination_sip.rb', line 117

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