Class: Vapi::PhoneNumbersClient
- Inherits:
-
Object
- Object
- Vapi::PhoneNumbersClient
- Defined in:
- lib/vapi_server_sdk/phone_numbers/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #create(request:, request_options: nil) ⇒ Vapi::PhoneNumbers::PhoneNumbersCreateResponse
- #delete(id:, request_options: nil) ⇒ Vapi::PhoneNumbers::PhoneNumbersDeleteResponse
- #get(id:, request_options: nil) ⇒ Vapi::PhoneNumbers::PhoneNumbersGetResponse
- #initialize(request_client:) ⇒ Vapi::PhoneNumbersClient constructor
- #list(limit: nil, created_at_gt: nil, created_at_lt: nil, created_at_ge: nil, created_at_le: nil, updated_at_gt: nil, updated_at_lt: nil, updated_at_ge: nil, updated_at_le: nil, request_options: nil) ⇒ Array<Vapi::PhoneNumbers::PhoneNumbersListResponseItem>
- #update(id:, fallback_destination: nil, name: nil, assistant_id: nil, squad_id: nil, server_url: nil, server_url_secret: nil, request_options: nil) ⇒ Vapi::PhoneNumbers::PhoneNumbersUpdateResponse
Constructor Details
#initialize(request_client:) ⇒ Vapi::PhoneNumbersClient
22 23 24 |
# File 'lib/vapi_server_sdk/phone_numbers/client.rb', line 22 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Vapi::RequestClient (readonly)
18 19 20 |
# File 'lib/vapi_server_sdk/phone_numbers/client.rb', line 18 def request_client @request_client end |
Instance Method Details
#create(request:, request_options: nil) ⇒ Vapi::PhoneNumbers::PhoneNumbersCreateResponse
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/vapi_server_sdk/phone_numbers/client.rb', line 92 def create(request:, request_options: nil) response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(request_options: )}/phone-number" end Vapi::PhoneNumbers::PhoneNumbersCreateResponse.from_json(json_object: response.body) end |
#delete(id:, request_options: nil) ⇒ Vapi::PhoneNumbers::PhoneNumbersDeleteResponse
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/vapi_server_sdk/phone_numbers/client.rb', line 150 def delete(id:, request_options: nil) response = @request_client.conn.delete do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/phone-number/#{id}" end Vapi::PhoneNumbers::PhoneNumbersDeleteResponse.from_json(json_object: response.body) end |
#get(id:, request_options: nil) ⇒ Vapi::PhoneNumbers::PhoneNumbersGetResponse
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/vapi_server_sdk/phone_numbers/client.rb', line 120 def get(id:, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/phone-number/#{id}" end Vapi::PhoneNumbers::PhoneNumbersGetResponse.from_json(json_object: response.body) end |
#list(limit: nil, created_at_gt: nil, created_at_lt: nil, created_at_ge: nil, created_at_le: nil, updated_at_gt: nil, updated_at_lt: nil, updated_at_ge: nil, updated_at_le: nil, request_options: nil) ⇒ Array<Vapi::PhoneNumbers::PhoneNumbersListResponseItem>
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/vapi_server_sdk/phone_numbers/client.rb', line 48 def list(limit: nil, created_at_gt: nil, created_at_lt: nil, created_at_ge: nil, created_at_le: nil, updated_at_gt: nil, updated_at_lt: nil, updated_at_ge: nil, updated_at_le: nil, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "limit": limit, "createdAtGt": created_at_gt, "createdAtLt": created_at_lt, "createdAtGe": created_at_ge, "createdAtLe": created_at_le, "updatedAtGt": updated_at_gt, "updatedAtLt": updated_at_lt, "updatedAtGe": updated_at_ge, "updatedAtLe": updated_at_le }.compact unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/phone-number" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json Vapi::PhoneNumbers::PhoneNumbersListResponseItem.from_json(json_object: item) end end |
#update(id:, fallback_destination: nil, name: nil, assistant_id: nil, squad_id: nil, server_url: nil, server_url_secret: nil, request_options: nil) ⇒ Vapi::PhoneNumbers::PhoneNumbersUpdateResponse
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/vapi_server_sdk/phone_numbers/client.rb', line 203 def update(id:, fallback_destination: nil, name: nil, assistant_id: nil, squad_id: nil, server_url: nil, server_url_secret: nil, request_options: nil) response = @request_client.conn.patch do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), fallbackDestination: fallback_destination, name: name, assistantId: assistant_id, squadId: squad_id, serverUrl: server_url, serverUrlSecret: server_url_secret }.compact req.url "#{@request_client.get_url(request_options: )}/phone-number/#{id}" end Vapi::PhoneNumbers::PhoneNumbersUpdateResponse.from_json(json_object: response.body) end |