Class: Vapi::Session
- Inherits:
-
Object
- Object
- Vapi::Session
- Defined in:
- lib/vapi_server_sdk/types/session.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#assistant ⇒ Vapi::CreateAssistantDto
readonly
This is the assistant configuration for this session.
-
#assistant_id ⇒ String
readonly
This is the ID of the assistant associated with this session.
-
#created_at ⇒ DateTime
readonly
This is the ISO 8601 timestamp indicating when the session was created.
-
#customer ⇒ Vapi::CreateCustomerDto
readonly
This is the customer information associated with this session.
-
#expiration_seconds ⇒ Float
readonly
Session expiration time in seconds.
-
#id ⇒ String
readonly
This is the unique identifier for the session.
-
#messages ⇒ Array<Vapi::SessionMessagesItem>
readonly
This is an array of chat messages in the session.
-
#name ⇒ String
readonly
This is a user-defined name for the session.
-
#org_id ⇒ String
readonly
This is the unique identifier for the organization that owns this session.
-
#phone_number ⇒ Vapi::ImportTwilioPhoneNumberDto
readonly
This is the phone number configuration for this session.
-
#phone_number_id ⇒ String
readonly
This is the ID of the phone number associated with this session.
-
#status ⇒ Vapi::SessionStatus
readonly
This is the current status of the session.
-
#updated_at ⇒ DateTime
readonly
This is the ISO 8601 timestamp indicating when the session was last updated.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Vapi::Session
Deserialize a JSON object to an instance of Session.
-
.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(id:, org_id:, created_at:, updated_at:, name: OMIT, status: OMIT, expiration_seconds: OMIT, assistant_id: OMIT, assistant: OMIT, messages: OMIT, customer: OMIT, phone_number_id: OMIT, phone_number: OMIT, additional_properties: nil) ⇒ Vapi::Session constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Session to a JSON object.
Constructor Details
#initialize(id:, org_id:, created_at:, updated_at:, name: OMIT, status: OMIT, expiration_seconds: OMIT, assistant_id: OMIT, assistant: OMIT, messages: OMIT, customer: OMIT, phone_number_id: OMIT, phone_number: OMIT, additional_properties: nil) ⇒ Vapi::Session
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/vapi_server_sdk/types/session.rb', line 73 def initialize(id:, org_id:, created_at:, updated_at:, name: OMIT, status: OMIT, expiration_seconds: OMIT, assistant_id: OMIT, assistant: OMIT, messages: OMIT, customer: OMIT, phone_number_id: OMIT, phone_number: OMIT, additional_properties: nil) @id = id @org_id = org_id @created_at = created_at @updated_at = updated_at @name = name if name != OMIT @status = status if status != OMIT @expiration_seconds = expiration_seconds if expiration_seconds != OMIT @assistant_id = assistant_id if assistant_id != OMIT @assistant = assistant if assistant != OMIT @messages = if != OMIT @customer = customer if customer != OMIT @phone_number_id = phone_number_id if phone_number_id != OMIT @phone_number = phone_number if phone_number != OMIT @additional_properties = additional_properties @_field_set = { "id": id, "orgId": org_id, "createdAt": created_at, "updatedAt": updated_at, "name": name, "status": status, "expirationSeconds": expiration_seconds, "assistantId": assistant_id, "assistant": assistant, "messages": , "customer": customer, "phoneNumberId": phone_number_id, "phoneNumber": phone_number }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
46 47 48 |
# File 'lib/vapi_server_sdk/types/session.rb', line 46 def additional_properties @additional_properties end |
#assistant ⇒ Vapi::CreateAssistantDto (readonly)
Returns This is the assistant configuration for this session. Use this when creating a new assistant configuration. If assistantId is provided, this will be ignored.
36 37 38 |
# File 'lib/vapi_server_sdk/types/session.rb', line 36 def assistant @assistant end |
#assistant_id ⇒ String (readonly)
Returns This is the ID of the assistant associated with this session. Use this when referencing an existing assistant.
32 33 34 |
# File 'lib/vapi_server_sdk/types/session.rb', line 32 def assistant_id @assistant_id end |
#created_at ⇒ DateTime (readonly)
Returns This is the ISO 8601 timestamp indicating when the session was created.
19 20 21 |
# File 'lib/vapi_server_sdk/types/session.rb', line 19 def created_at @created_at end |
#customer ⇒ Vapi::CreateCustomerDto (readonly)
Returns This is the customer information associated with this session.
40 41 42 |
# File 'lib/vapi_server_sdk/types/session.rb', line 40 def customer @customer end |
#expiration_seconds ⇒ Float (readonly)
Returns Session expiration time in seconds. Defaults to 24 hours (86400 seconds) if not set.
29 30 31 |
# File 'lib/vapi_server_sdk/types/session.rb', line 29 def expiration_seconds @expiration_seconds end |
#id ⇒ String (readonly)
Returns This is the unique identifier for the session.
15 16 17 |
# File 'lib/vapi_server_sdk/types/session.rb', line 15 def id @id end |
#messages ⇒ Array<Vapi::SessionMessagesItem> (readonly)
Returns This is an array of chat messages in the session.
38 39 40 |
# File 'lib/vapi_server_sdk/types/session.rb', line 38 def @messages end |
#name ⇒ String (readonly)
Returns This is a user-defined name for the session. Maximum length is 40 characters.
23 24 25 |
# File 'lib/vapi_server_sdk/types/session.rb', line 23 def name @name end |
#org_id ⇒ String (readonly)
Returns This is the unique identifier for the organization that owns this session.
17 18 19 |
# File 'lib/vapi_server_sdk/types/session.rb', line 17 def org_id @org_id end |
#phone_number ⇒ Vapi::ImportTwilioPhoneNumberDto (readonly)
Returns This is the phone number configuration for this session.
44 45 46 |
# File 'lib/vapi_server_sdk/types/session.rb', line 44 def phone_number @phone_number end |
#phone_number_id ⇒ String (readonly)
Returns This is the ID of the phone number associated with this session.
42 43 44 |
# File 'lib/vapi_server_sdk/types/session.rb', line 42 def phone_number_id @phone_number_id end |
#status ⇒ Vapi::SessionStatus (readonly)
Returns This is the current status of the session. Can be either ‘active’ or ‘completed’.
26 27 28 |
# File 'lib/vapi_server_sdk/types/session.rb', line 26 def status @status end |
#updated_at ⇒ DateTime (readonly)
Returns This is the ISO 8601 timestamp indicating when the session was last updated.
21 22 23 |
# File 'lib/vapi_server_sdk/types/session.rb', line 21 def updated_at @updated_at end |
Class Method Details
.from_json(json_object:) ⇒ Vapi::Session
Deserialize a JSON object to an instance of Session
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/vapi_server_sdk/types/session.rb', line 112 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = parsed_json["id"] org_id = parsed_json["orgId"] created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?) updated_at = (DateTime.parse(parsed_json["updatedAt"]) unless parsed_json["updatedAt"].nil?) name = parsed_json["name"] status = parsed_json["status"] expiration_seconds = parsed_json["expirationSeconds"] assistant_id = parsed_json["assistantId"] if parsed_json["assistant"].nil? assistant = nil else assistant = parsed_json["assistant"].to_json assistant = Vapi::CreateAssistantDto.from_json(json_object: assistant) end = parsed_json["messages"]&.map do |item| item = item.to_json Vapi::SessionMessagesItem.from_json(json_object: item) end if parsed_json["customer"].nil? customer = nil else customer = parsed_json["customer"].to_json customer = Vapi::CreateCustomerDto.from_json(json_object: customer) end phone_number_id = parsed_json["phoneNumberId"] if parsed_json["phoneNumber"].nil? phone_number = nil else phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ImportTwilioPhoneNumberDto.from_json(json_object: phone_number) end new( id: id, org_id: org_id, created_at: created_at, updated_at: updated_at, name: name, status: status, expiration_seconds: expiration_seconds, assistant_id: assistant_id, assistant: assistant, messages: , customer: customer, phone_number_id: phone_number_id, phone_number: phone_number, 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.
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/vapi_server_sdk/types/session.rb', line 177 def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.org_id.is_a?(String) != false || raise("Passed value for field obj.org_id is not the expected type, validation failed.") obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.status&.is_a?(Vapi::SessionStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") obj.expiration_seconds&.is_a?(Float) != false || raise("Passed value for field obj.expiration_seconds is not the expected type, validation failed.") obj.assistant_id&.is_a?(String) != false || raise("Passed value for field obj.assistant_id is not the expected type, validation failed.") obj.assistant.nil? || Vapi::CreateAssistantDto.validate_raw(obj: obj.assistant) obj.&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") obj.customer.nil? || Vapi::CreateCustomerDto.validate_raw(obj: obj.customer) obj.phone_number_id&.is_a?(String) != false || raise("Passed value for field obj.phone_number_id is not the expected type, validation failed.") obj.phone_number.nil? || Vapi::ImportTwilioPhoneNumberDto.validate_raw(obj: obj.phone_number) end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of Session to a JSON object
167 168 169 |
# File 'lib/vapi_server_sdk/types/session.rb', line 167 def to_json(*_args) @_field_set&.to_json end |