Class: SignalWire::REST::RestClient
- Inherits:
-
Object
- Object
- SignalWire::REST::RestClient
- Defined in:
- lib/signalwire/rest/rest_client.rb
Overview
REST client for the SignalWire platform APIs.
Usage:
client = SignalWire::REST::RestClient.new(
project: 'your-project-id',
token: 'your-api-token',
host: 'your-space.signalwire.com'
)
# Or use environment variables:
# SIGNALWIRE_PROJECT_ID, SIGNALWIRE_API_TOKEN, SIGNALWIRE_SPACE
client = SignalWire::REST::RestClient.new
# Use namespaced resources
client.fabric.ai_agents.list
client.calling.play(call_id, play: [...])
client.phone_numbers.search(area_code: '512')
client.video.rooms.create(name: 'standup')
client.compat.calls.list
Instance Attribute Summary collapse
-
#addresses ⇒ Object
readonly
Returns the value of attribute addresses.
-
#calling ⇒ Object
readonly
Returns the value of attribute calling.
-
#chat ⇒ Object
readonly
Returns the value of attribute chat.
-
#compat ⇒ Object
readonly
Returns the value of attribute compat.
-
#datasphere ⇒ Object
readonly
Returns the value of attribute datasphere.
-
#fabric ⇒ Object
readonly
Returns the value of attribute fabric.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#imported_numbers ⇒ Object
readonly
Returns the value of attribute imported_numbers.
-
#logs ⇒ Object
readonly
Returns the value of attribute logs.
-
#lookup ⇒ Object
readonly
Returns the value of attribute lookup.
-
#mfa ⇒ Object
readonly
Returns the value of attribute mfa.
-
#number_groups ⇒ Object
readonly
Returns the value of attribute number_groups.
-
#phone_numbers ⇒ Object
readonly
Returns the value of attribute phone_numbers.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
-
#project_id ⇒ Object
readonly
Returns the value of attribute project_id.
-
#pubsub ⇒ Object
readonly
Returns the value of attribute pubsub.
-
#queues ⇒ Object
readonly
Returns the value of attribute queues.
-
#recordings ⇒ Object
readonly
Returns the value of attribute recordings.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
-
#short_codes ⇒ Object
readonly
Returns the value of attribute short_codes.
-
#sip_profile ⇒ Object
readonly
Returns the value of attribute sip_profile.
-
#verified_callers ⇒ Object
readonly
Returns the value of attribute verified_callers.
-
#video ⇒ Object
readonly
Returns the value of attribute video.
Instance Method Summary collapse
-
#initialize(project: nil, token: nil, host: nil, base_url: nil) ⇒ RestClient
constructor
base_urloverrides the derived https://{space} default.
Constructor Details
#initialize(project: nil, token: nil, host: nil, base_url: nil) ⇒ RestClient
base_url overrides the derived https://{space} default. The audit harness uses this to point at the local fixture server.
58 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 85 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 |
# File 'lib/signalwire/rest/rest_client.rb', line 58 def initialize(project: nil, token: nil, host: nil, base_url: nil) project_id = project || ENV['SIGNALWIRE_PROJECT_ID'] || '' api_token = token || ENV['SIGNALWIRE_API_TOKEN'] || '' space = host || ENV['SIGNALWIRE_SPACE'] || '' if project_id.empty? || api_token.empty? || (space.empty? && (base_url.nil? || base_url.empty?)) raise ArgumentError, 'project, token, and host are required. ' \ 'Provide them as arguments or set SIGNALWIRE_PROJECT_ID, ' \ 'SIGNALWIRE_API_TOKEN, and SIGNALWIRE_SPACE environment variables.' end @project_id = project_id @http = HttpClient.new(project_id, api_token, space, base_url: base_url) # Fabric API @fabric = Namespaces::FabricNamespace.new(@http) # Calling API @calling = Namespaces::CallingNamespace.new(@http) # Relay REST resources @phone_numbers = Namespaces::PhoneNumbersResource.new(@http) @addresses = Namespaces::AddressesResource.new(@http) @queues = Namespaces::QueuesResource.new(@http) @recordings = Namespaces::RecordingsResource.new(@http) @number_groups = Namespaces::NumberGroupsResource.new(@http) @verified_callers = Namespaces::VerifiedCallersResource.new(@http) @sip_profile = Namespaces::SipProfileResource.new(@http) @lookup = Namespaces::LookupResource.new(@http) @short_codes = Namespaces::ShortCodesResource.new(@http) @imported_numbers = Namespaces::ImportedNumbersResource.new(@http) @mfa = Namespaces::MfaResource.new(@http) @registry = Namespaces::RegistryNamespace.new(@http) # Datasphere API @datasphere = Namespaces::DatasphereNamespace.new(@http) # Video API @video = Namespaces::VideoNamespace.new(@http) # Logs @logs = Namespaces::LogsNamespace.new(@http) # Project management @project = Namespaces::ProjectNamespace.new(@http) # PubSub & Chat @pubsub = Namespaces::PubSubResource.new(@http) @chat = Namespaces::ChatResource.new(@http) # Compatibility (Twilio-compatible) API @compat = Namespaces::CompatNamespace.new(@http, project_id) end |
Instance Attribute Details
#addresses ⇒ Object (readonly)
Returns the value of attribute addresses.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def addresses @addresses end |
#calling ⇒ Object (readonly)
Returns the value of attribute calling.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def calling @calling end |
#chat ⇒ Object (readonly)
Returns the value of attribute chat.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def chat @chat end |
#compat ⇒ Object (readonly)
Returns the value of attribute compat.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def compat @compat end |
#datasphere ⇒ Object (readonly)
Returns the value of attribute datasphere.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def datasphere @datasphere end |
#fabric ⇒ Object (readonly)
Returns the value of attribute fabric.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def fabric @fabric end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def http @http end |
#imported_numbers ⇒ Object (readonly)
Returns the value of attribute imported_numbers.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def imported_numbers @imported_numbers end |
#logs ⇒ Object (readonly)
Returns the value of attribute logs.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def logs @logs end |
#lookup ⇒ Object (readonly)
Returns the value of attribute lookup.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def lookup @lookup end |
#mfa ⇒ Object (readonly)
Returns the value of attribute mfa.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def mfa @mfa end |
#number_groups ⇒ Object (readonly)
Returns the value of attribute number_groups.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def number_groups @number_groups end |
#phone_numbers ⇒ Object (readonly)
Returns the value of attribute phone_numbers.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def phone_numbers @phone_numbers end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def project @project end |
#project_id ⇒ Object (readonly)
Returns the value of attribute project_id.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def project_id @project_id end |
#pubsub ⇒ Object (readonly)
Returns the value of attribute pubsub.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def pubsub @pubsub end |
#queues ⇒ Object (readonly)
Returns the value of attribute queues.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def queues @queues end |
#recordings ⇒ Object (readonly)
Returns the value of attribute recordings.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def recordings @recordings end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def registry @registry end |
#short_codes ⇒ Object (readonly)
Returns the value of attribute short_codes.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def short_codes @short_codes end |
#sip_profile ⇒ Object (readonly)
Returns the value of attribute sip_profile.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def sip_profile @sip_profile end |
#verified_callers ⇒ Object (readonly)
Returns the value of attribute verified_callers.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def verified_callers @verified_callers end |
#video ⇒ Object (readonly)
Returns the value of attribute video.
50 51 52 |
# File 'lib/signalwire/rest/rest_client.rb', line 50 def video @video end |