Class: Vapi::CreateByoPhoneNumberDto

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(credential_id:, fallback_destination: OMIT, hooks: OMIT, number_e_164_check_enabled: OMIT, number: OMIT, name: OMIT, assistant_id: OMIT, workflow_id: OMIT, squad_id: OMIT, server: OMIT, additional_properties: nil) ⇒ Vapi::CreateByoPhoneNumberDto



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
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 119

def initialize(credential_id:, fallback_destination: OMIT, hooks: OMIT, number_e_164_check_enabled: OMIT,
               number: OMIT, name: OMIT, assistant_id: OMIT, workflow_id: OMIT, squad_id: OMIT, server: OMIT, additional_properties: nil)
  @fallback_destination = fallback_destination if fallback_destination != OMIT
  @hooks = hooks if hooks != OMIT
  @number_e_164_check_enabled = number_e_164_check_enabled if number_e_164_check_enabled != OMIT
  @number = number if number != OMIT
  @credential_id = credential_id
  @name = name if name != OMIT
  @assistant_id = assistant_id if assistant_id != OMIT
  @workflow_id = workflow_id if workflow_id != OMIT
  @squad_id = squad_id if squad_id != OMIT
  @server = server if server != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "fallbackDestination": fallback_destination,
    "hooks": hooks,
    "numberE164CheckEnabled": number_e_164_check_enabled,
    "number": number,
    "credentialId": credential_id,
    "name": name,
    "assistantId": assistant_id,
    "workflowId": workflow_id,
    "squadId": squad_id,
    "server": server
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



66
67
68
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 66

def additional_properties
  @additional_properties
end

#assistant_idString (readonly)



45
46
47
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 45

def assistant_id
  @assistant_id
end

#credential_idString (readonly)



37
38
39
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 37

def credential_id
  @credential_id
end

#fallback_destinationVapi::CreateByoPhoneNumberDtoFallbackDestination (readonly)



17
18
19
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 17

def fallback_destination
  @fallback_destination
end

#hooksArray<Vapi::PhoneNumberHookCallRinging> (readonly)



19
20
21
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 19

def hooks
  @hooks
end

#nameString (readonly)



39
40
41
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 39

def name
  @name
end

#numberString (readonly)



32
33
34
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 32

def number
  @number
end

#number_e_164_check_enabledBoolean (readonly)



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

def number_e_164_check_enabled
  @number_e_164_check_enabled
end

#serverVapi::Server (readonly)



64
65
66
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 64

def server
  @server
end

#squad_idString (readonly)



57
58
59
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 57

def squad_id
  @squad_id
end

#workflow_idString (readonly)



51
52
53
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 51

def workflow_id
  @workflow_id
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::CreateByoPhoneNumberDto

Deserialize a JSON object to an instance of CreateByoPhoneNumberDto



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 152

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  if parsed_json["fallbackDestination"].nil?
    fallback_destination = nil
  else
    fallback_destination = parsed_json["fallbackDestination"].to_json
    fallback_destination = Vapi::CreateByoPhoneNumberDtoFallbackDestination.from_json(json_object: fallback_destination)
  end
  hooks = parsed_json["hooks"]&.map do |item|
    item = item.to_json
    Vapi::PhoneNumberHookCallRinging.from_json(json_object: item)
  end
  number_e_164_check_enabled = parsed_json["numberE164CheckEnabled"]
  number = parsed_json["number"]
  credential_id = parsed_json["credentialId"]
  name = parsed_json["name"]
  assistant_id = parsed_json["assistantId"]
  workflow_id = parsed_json["workflowId"]
  squad_id = parsed_json["squadId"]
  if parsed_json["server"].nil?
    server = nil
  else
    server = parsed_json["server"].to_json
    server = Vapi::Server.from_json(json_object: server)
  end
  new(
    fallback_destination: fallback_destination,
    hooks: hooks,
    number_e_164_check_enabled: number_e_164_check_enabled,
    number: number,
    credential_id: credential_id,
    name: name,
    assistant_id: assistant_id,
    workflow_id: workflow_id,
    squad_id: squad_id,
    server: server,
    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.


206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 206

def self.validate_raw(obj:)
  obj.fallback_destination.nil? || Vapi::CreateByoPhoneNumberDtoFallbackDestination.validate_raw(obj: obj.fallback_destination)
  obj.hooks&.is_a?(Array) != false || raise("Passed value for field obj.hooks is not the expected type, validation failed.")
  obj.number_e_164_check_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.number_e_164_check_enabled is not the expected type, validation failed.")
  obj.number&.is_a?(String) != false || raise("Passed value for field obj.number is not the expected type, validation failed.")
  obj.credential_id.is_a?(String) != false || raise("Passed value for field obj.credential_id 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.assistant_id&.is_a?(String) != false || raise("Passed value for field obj.assistant_id is not the expected type, validation failed.")
  obj.workflow_id&.is_a?(String) != false || raise("Passed value for field obj.workflow_id is not the expected type, validation failed.")
  obj.squad_id&.is_a?(String) != false || raise("Passed value for field obj.squad_id is not the expected type, validation failed.")
  obj.server.nil? || Vapi::Server.validate_raw(obj: obj.server)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of CreateByoPhoneNumberDto to a JSON object



196
197
198
# File 'lib/vapi_server_sdk/types/create_byo_phone_number_dto.rb', line 196

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