Class: VoiceML::Client
- Inherits:
-
Object
- Object
- VoiceML::Client
- Defined in:
- lib/voiceml/client.rb
Overview
Synchronous client for the VoiceML REST API.
VoiceML uses HTTP Basic auth: the account_sid (Twilio-format AC + 32 hex) is the
username and api_key is the password. Drop-in compatible with the Twilio Ruby SDK
constructor signature.
Instance Attribute Summary collapse
-
#applications ⇒ Object
readonly
Returns the value of attribute applications.
-
#assistants_v1 ⇒ Object
readonly
Returns the value of attribute assistants_v1.
-
#calls ⇒ Object
readonly
Returns the value of attribute calls.
-
#conferences ⇒ Object
readonly
Returns the value of attribute conferences.
-
#conversations_v1 ⇒ Object
readonly
Returns the value of attribute conversations_v1.
-
#diagnostics ⇒ Object
readonly
Returns the value of attribute diagnostics.
-
#incoming_phone_numbers ⇒ Object
readonly
Returns the value of attribute incoming_phone_numbers.
-
#messages ⇒ Object
readonly
Returns the value of attribute messages.
-
#messaging_v1 ⇒ Object
readonly
Returns the value of attribute messaging_v1.
-
#notifications ⇒ Object
readonly
Returns the value of attribute notifications.
-
#pricing ⇒ Object
readonly
Returns the value of attribute pricing.
-
#queues ⇒ Object
readonly
Returns the value of attribute queues.
-
#recordings ⇒ Object
readonly
Returns the value of attribute recordings.
-
#routes_v2 ⇒ Object
readonly
Returns the value of attribute routes_v2.
-
#sip ⇒ Object
readonly
Returns the value of attribute sip.
-
#voice_v1 ⇒ Object
readonly
Returns the value of attribute voice_v1.
Instance Method Summary collapse
- #account_sid ⇒ Object
- #base_url ⇒ Object
-
#initialize(account_sid:, api_key: nil, auth_token: nil, base_url: Transport::DEFAULT_BASE_URL, timeout: Transport::DEFAULT_TIMEOUT, max_retries: Transport::DEFAULT_MAX_RETRIES, user_agent: nil, http_client: nil, messaging_base_url: nil, conversations_base_url: nil) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(account_sid:, api_key: nil, auth_token: nil, base_url: Transport::DEFAULT_BASE_URL, timeout: Transport::DEFAULT_TIMEOUT, max_retries: Transport::DEFAULT_MAX_RETRIES, user_agent: nil, http_client: nil, messaging_base_url: nil, conversations_base_url: nil) ⇒ Client
Returns a new instance of Client.
57 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 |
# File 'lib/voiceml/client.rb', line 57 def initialize(account_sid:, api_key: nil, auth_token: nil, base_url: Transport::DEFAULT_BASE_URL, timeout: Transport::DEFAULT_TIMEOUT, max_retries: Transport::DEFAULT_MAX_RETRIES, user_agent: nil, http_client: nil, messaging_base_url: nil, conversations_base_url: nil) if !api_key.nil? && !auth_token.nil? raise ArgumentError, 'pass either api_key: or auth_token:, not both' end resolved_key = api_key || auth_token @transport = Transport.new( account_sid: account_sid, api_key: resolved_key, base_url: base_url, timeout: timeout, max_retries: max_retries, user_agent: user_agent, http_client: http_client ) # VoiceML mirrors Twilio's product-per-subdomain model: the whole Conversations group # rides `conversations.voicetel.com` and Messaging Service rides `messaging.voicetel.com`, # while everything else stays on the default host. See VoiceML::Hosts. _default, messaging_host, conversations_host = Hosts.resolve_product_base_urls(base_url, messaging_base_url: messaging_base_url, conversations_base_url: conversations_base_url) messaging_transport = ScopedTransport.new(@transport, messaging_host) conversations_transport = ScopedTransport.new(@transport, conversations_host) @calls = CallsResource.new(@transport) @conferences = ConferencesResource.new(@transport) @queues = QueuesResource.new(@transport) @applications = ApplicationsResource.new(@transport) @recordings = RecordingsResource.new(@transport) @incoming_phone_numbers = IncomingPhoneNumbersResource.new(@transport) @notifications = NotificationsResource.new(@transport) @diagnostics = DiagnosticsResource.new(@transport) @messages = MessagesResource.new(@transport) @sip = SipResource.new(@transport) @routes_v2 = RoutesV2Resource.new(@transport) @voice_v1 = VoiceV1Resource.new(@transport) @conversations_v1 = ConversationsV1Resource.new(conversations_transport) @assistants_v1 = AssistantsV1Resource.new(@transport) @messaging_v1 = MessagingV1Resource.new(messaging_transport) @pricing = PricingResource.new(@transport) end |
Instance Attribute Details
#applications ⇒ Object (readonly)
Returns the value of attribute applications.
38 39 40 |
# File 'lib/voiceml/client.rb', line 38 def applications @applications end |
#assistants_v1 ⇒ Object (readonly)
Returns the value of attribute assistants_v1.
38 39 40 |
# File 'lib/voiceml/client.rb', line 38 def assistants_v1 @assistants_v1 end |
#calls ⇒ Object (readonly)
Returns the value of attribute calls.
38 39 40 |
# File 'lib/voiceml/client.rb', line 38 def calls @calls end |
#conferences ⇒ Object (readonly)
Returns the value of attribute conferences.
38 39 40 |
# File 'lib/voiceml/client.rb', line 38 def conferences @conferences end |
#conversations_v1 ⇒ Object (readonly)
Returns the value of attribute conversations_v1.
38 39 40 |
# File 'lib/voiceml/client.rb', line 38 def conversations_v1 @conversations_v1 end |
#diagnostics ⇒ Object (readonly)
Returns the value of attribute diagnostics.
38 39 40 |
# File 'lib/voiceml/client.rb', line 38 def diagnostics @diagnostics end |
#incoming_phone_numbers ⇒ Object (readonly)
Returns the value of attribute incoming_phone_numbers.
38 39 40 |
# File 'lib/voiceml/client.rb', line 38 def incoming_phone_numbers @incoming_phone_numbers end |
#messages ⇒ Object (readonly)
Returns the value of attribute messages.
38 39 40 |
# File 'lib/voiceml/client.rb', line 38 def @messages end |
#messaging_v1 ⇒ Object (readonly)
Returns the value of attribute messaging_v1.
38 39 40 |
# File 'lib/voiceml/client.rb', line 38 def messaging_v1 @messaging_v1 end |
#notifications ⇒ Object (readonly)
Returns the value of attribute notifications.
38 39 40 |
# File 'lib/voiceml/client.rb', line 38 def notifications @notifications end |
#pricing ⇒ Object (readonly)
Returns the value of attribute pricing.
38 39 40 |
# File 'lib/voiceml/client.rb', line 38 def pricing @pricing end |
#queues ⇒ Object (readonly)
Returns the value of attribute queues.
38 39 40 |
# File 'lib/voiceml/client.rb', line 38 def queues @queues end |
#recordings ⇒ Object (readonly)
Returns the value of attribute recordings.
38 39 40 |
# File 'lib/voiceml/client.rb', line 38 def recordings @recordings end |
#routes_v2 ⇒ Object (readonly)
Returns the value of attribute routes_v2.
38 39 40 |
# File 'lib/voiceml/client.rb', line 38 def routes_v2 @routes_v2 end |
#sip ⇒ Object (readonly)
Returns the value of attribute sip.
38 39 40 |
# File 'lib/voiceml/client.rb', line 38 def sip @sip end |
#voice_v1 ⇒ Object (readonly)
Returns the value of attribute voice_v1.
38 39 40 |
# File 'lib/voiceml/client.rb', line 38 def voice_v1 @voice_v1 end |
Instance Method Details
#account_sid ⇒ Object
107 108 109 |
# File 'lib/voiceml/client.rb', line 107 def account_sid @transport.account_sid end |
#base_url ⇒ Object
111 112 113 |
# File 'lib/voiceml/client.rb', line 111 def base_url @transport.base_url end |