signalwire 1.4.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +55 -0
  3. data/.rubocop.yml +14 -2
  4. data/AUTHORS.md +1 -0
  5. data/CHANGELOG.md +30 -5
  6. data/Gemfile +4 -18
  7. data/LICENSE +21 -0
  8. data/README.md +22 -82
  9. data/Rakefile +0 -17
  10. data/examples/relay/inbound_consumer.rb +26 -0
  11. data/examples/relay/inbound_dial.rb +28 -0
  12. data/examples/relay/outbound_collect.rb +27 -0
  13. data/examples/relay/outbound_consumer.rb +22 -0
  14. data/examples/relay/outbound_record.rb +25 -0
  15. data/lib/signalwire.rb +13 -0
  16. data/lib/signalwire/blade.rb +12 -0
  17. data/lib/signalwire/blade/connection.rb +200 -0
  18. data/lib/signalwire/blade/event_handler.rb +15 -0
  19. data/lib/signalwire/blade/message.rb +38 -0
  20. data/lib/signalwire/blade/message/connect.rb +18 -0
  21. data/lib/signalwire/blade/message/execute.rb +16 -0
  22. data/lib/signalwire/blade/message/subscribe.rb +15 -0
  23. data/lib/signalwire/common.rb +6 -0
  24. data/lib/signalwire/logger.rb +27 -0
  25. data/lib/signalwire/relay.rb +40 -0
  26. data/lib/signalwire/relay/calling.rb +82 -0
  27. data/lib/signalwire/relay/calling/action.rb +16 -0
  28. data/lib/signalwire/relay/calling/action/connect_action.rb +11 -0
  29. data/lib/signalwire/relay/calling/action/play_action.rb +15 -0
  30. data/lib/signalwire/relay/calling/action/prompt_action.rb +15 -0
  31. data/lib/signalwire/relay/calling/action/record_action.rb +15 -0
  32. data/lib/signalwire/relay/calling/call.rb +210 -0
  33. data/lib/signalwire/relay/calling/call_convenience_methods.rb +79 -0
  34. data/lib/signalwire/relay/calling/component.rb +115 -0
  35. data/lib/signalwire/relay/calling/component/answer.rb +27 -0
  36. data/lib/signalwire/relay/calling/component/await.rb +20 -0
  37. data/lib/signalwire/relay/calling/component/connect.rb +45 -0
  38. data/lib/signalwire/relay/calling/component/dial.rb +34 -0
  39. data/lib/signalwire/relay/calling/component/hangup.rb +41 -0
  40. data/lib/signalwire/relay/calling/component/play.rb +46 -0
  41. data/lib/signalwire/relay/calling/component/prompt.rb +62 -0
  42. data/lib/signalwire/relay/calling/component/record.rb +53 -0
  43. data/lib/signalwire/relay/calling/control_component.rb +35 -0
  44. data/lib/signalwire/relay/calling/result.rb +16 -0
  45. data/lib/signalwire/relay/calling/result/answer_result.rb +6 -0
  46. data/lib/signalwire/relay/calling/result/connect_result.rb +9 -0
  47. data/lib/signalwire/relay/calling/result/dial_result.rb +7 -0
  48. data/lib/signalwire/relay/calling/result/hangup_result.rb +7 -0
  49. data/lib/signalwire/relay/calling/result/play_result.rb +6 -0
  50. data/lib/signalwire/relay/calling/result/prompt_result.rb +11 -0
  51. data/lib/signalwire/relay/calling/result/record_result.rb +7 -0
  52. data/lib/signalwire/relay/client.rb +147 -0
  53. data/lib/signalwire/relay/constants.rb +109 -0
  54. data/lib/signalwire/relay/consumer.rb +88 -0
  55. data/lib/signalwire/relay/event.rb +41 -0
  56. data/lib/signalwire/relay/request.rb +6 -0
  57. data/lib/signalwire/rest/client.rb +5 -5
  58. data/lib/signalwire/sdk/fax_response.rb +3 -3
  59. data/lib/signalwire/sdk/messaging_response.rb +0 -2
  60. data/lib/signalwire/sdk/twilio_set_fax.rb +9 -8
  61. data/lib/signalwire/sdk/twilio_set_host.rb +8 -3
  62. data/lib/signalwire/version.rb +5 -0
  63. data/signalwire.gemspec +36 -106
  64. metadata +173 -76
  65. data/LICENSE.txt +0 -20
  66. data/VERSION +0 -1
  67. data/spec/signalwire/rest/client_spec.rb +0 -30
  68. data/spec/signalwire/rest/integration_spec.rb +0 -102
  69. data/spec/signalwire/sdk/configuration_spec.rb +0 -28
  70. data/spec/signalwire/sdk/fax_response_spec.rb +0 -26
  71. data/spec/signalwire/sdk/messaging_response_spec.rb +0 -18
  72. data/spec/signalwire/sdk/voice_response_spec.rb +0 -20
  73. data/spec/signalwire/sdk_spec.rb +0 -27
  74. data/spec/spec_helper.rb +0 -119
  75. data/spec/vcr_cassettes/accounts.yml +0 -27
  76. data/spec/vcr_cassettes/applications.yml +0 -29
  77. data/spec/vcr_cassettes/get_fax.yml +0 -25
  78. data/spec/vcr_cassettes/get_fax_media_instance.yml +0 -27
  79. data/spec/vcr_cassettes/get_fax_media_list.yml +0 -47
  80. data/spec/vcr_cassettes/list_faxes.yml +0 -25
  81. data/spec/vcr_cassettes/local_numbers.yml +0 -26
  82. data/spec/vcr_cassettes/recordings.yml +0 -27
  83. data/spec/vcr_cassettes/send_fax.yml +0 -27
  84. data/spec/vcr_cassettes/toll_free_numbers.yml +0 -34
  85. data/spec/vcr_cassettes/transcriptions.yml +0 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ecfc761a788ea1f51afb5a6fb76b03548f688297f7b92de138e1b64c2bd01159
4
- data.tar.gz: c5a163403dd5040df090cd5942f17c0d522b7b3e29672a9e1ec99a505254e403
3
+ metadata.gz: 4d68736f7bf37f324c9f85a604165cd994d45974d73741c90cd9290e4ef63b4c
4
+ data.tar.gz: f47bcfe838a3ce0576d7f2ba199f415ab5a36f23d07feef554ad3c340c20d015
5
5
  SHA512:
6
- metadata.gz: 38904d4aa3d5e1b09d69677f6797f8df55db93a46d72d11ec74f3b93aeee649e6f48b4d209139638a8c8db710a2554ab42150226077eab42b1fb5fdf1b061fa5
7
- data.tar.gz: f02caa8270688fa1cd482da9042949113110cde811028bd7f089426bc98497bfaa3114f25a6ff3e75f9e3fd1b617a4159557769343854e8d919855fd09e51c25
6
+ metadata.gz: 782c53f901d1bf44cb4bf9dd523a6268bf4bd6c165aa39223e054501f75092524e47a92ce97acb6b247cf2ad89f311fb44722bb27c5db82fbf6da7c9e88cd65e
7
+ data.tar.gz: 0ace788a9baf5c7c9aee04bcae89478777bdbbd7f107040da98687e5bb211d0ecccc8222fb11e6ce97037c8d773c61914538df43ab40eeb0360a1aab7358ccca
@@ -0,0 +1,55 @@
1
+ # rcov generated
2
+ coverage
3
+ coverage.data
4
+
5
+ # rdoc generated
6
+ rdoc
7
+
8
+ # yard generated
9
+ doc
10
+ .yardoc
11
+
12
+ # bundler
13
+ .bundle
14
+
15
+ # juwelier generated
16
+ pkg
17
+ tmp
18
+
19
+ # Gems should not check in Gemfile.lock
20
+ Gemfile.lock
21
+
22
+ # Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
23
+ #
24
+ # * Create a file at ~/.gitignore
25
+ # * Include files you want ignored
26
+ # * Run: git config --global core.excludesfile ~/.gitignore
27
+ #
28
+ # After doing this, these files will be ignored in all your git projects,
29
+ # saving you from having to 'pollute' every project you touch with them
30
+ #
31
+ # Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
32
+ #
33
+ # For MacOS:
34
+ #
35
+ .DS_Store
36
+
37
+ # For TextMate
38
+ #*.tmproj
39
+ #tmtags
40
+
41
+ # For emacs:
42
+ #*~
43
+ #\#*
44
+ #.\#*
45
+
46
+ # For vim:
47
+ #*.swp
48
+
49
+ # For redcar:
50
+ #.redcar
51
+
52
+ # For rubinius:
53
+ #*.rbc
54
+ .env
55
+ *.gem
@@ -1,10 +1,13 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.3
3
2
  Exclude:
4
3
  - 'bin/**/*'
5
- - 'signalwire-client.gemspec'
4
+ - 'signalwire.gemspec'
6
5
  - 'Gemfile'
7
6
  - 'vendor/**/*'
7
+ - 'spec/**/*'
8
+ - 'examples/**/*'
9
+ - 'tmp/**/*'
10
+ - 'lib/signalwire/rest/client.rb' # it is just a shim, and has a weird signature
8
11
 
9
12
  Metrics/ClassLength:
10
13
  Max: 512
@@ -12,6 +15,9 @@ Metrics/ClassLength:
12
15
  Metrics/LineLength:
13
16
  Max: 120
14
17
 
18
+ Metrics/MethodLength:
19
+ Max: 20
20
+
15
21
  Metrics/ModuleLength:
16
22
  Max: 132
17
23
 
@@ -24,9 +30,15 @@ Layout/AccessModifierIndentation:
24
30
  Style/Documentation:
25
31
  Enabled: false
26
32
 
33
+ # Layout/AlignArguments:
34
+ # Enabled: false
35
+
27
36
  Layout/AlignParameters:
28
37
  EnforcedStyle: with_fixed_indentation
29
38
 
39
+ Layout/AlignHash:
40
+ Enabled: false
41
+
30
42
  Style/ConditionalAssignment:
31
43
  Enabled: false
32
44
 
data/AUTHORS.md CHANGED
@@ -5,3 +5,4 @@ A huge thanks to all of our contributors:
5
5
 
6
6
 
7
7
  - Luca Pradovera
8
+ - Edoardo Gallo
@@ -1,14 +1,39 @@
1
1
  # Changelog
2
+ All notable changes to this project will be documented in this file.
2
3
 
3
- ## 1.4.0
4
+ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
4
5
 
6
+ ## [2.0.0] - 2019-07-16
7
+ ### Added
8
+ - Connection Retry upon disconnect.
9
+ ### Changed
10
+ - Switch to using hostname only to specify URLs
11
+
12
+ ## [2.0.0-rc.1] - 2019-07-15
13
+ ### Added
14
+ - Released new Relay Client interface.
15
+
16
+ ## [1.4.0] - 2019-04-12
17
+ ### Added
5
18
  - Add ability to specify domain via parameter
6
19
  - Accept both `SIGNALWIRE_SPACE_URL` and `SIGNALWIRE_API_HOSTNAME` variables for configuration
7
20
 
8
- ## 1.3.0
9
-
21
+ ## [1.3.0] - 2019-01-15
22
+ ### Added
10
23
  - Fax REST API support, better tests
11
24
 
12
- ## 1.2.0
25
+ ## [1.2.0] - 2018-12-29
26
+ ### Added
27
+ - LaML Fax support
28
+
29
+ ## [1.0.0] - 2018-10-20
30
+ ### Added
31
+ - First release!
13
32
 
14
- - Added Fax support
33
+ <!---
34
+ ### Added
35
+ ### Changed
36
+ ### Removed
37
+ ### Fixed
38
+ ### Security
39
+ -->
data/Gemfile CHANGED
@@ -1,21 +1,7 @@
1
1
  source "https://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
2
 
6
- gem "twilio-ruby", "~> 5.0"
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in signalwire-client.gemspec
6
+ gemspec
7
7
 
8
- # Add dependencies to develop your gem here.
9
- # Include everything needed to run rake, tests, features, etc.
10
- group :development do
11
- gem "rspec", "~> 3.5.0"
12
- gem "rdoc", "~> 3.12"
13
- gem "bundler", "~> 1.0"
14
- gem "juwelier", "~> 2.1.0"
15
- gem "simplecov", ">= 0"
16
- gem 'rubocop', require: false
17
- gem 'bundler-audit', require: false
18
- gem 'guard-rspec'
19
- gem 'webmock'
20
- gem 'vcr'
21
- end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 SignalWire
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,98 +1,38 @@
1
- # signalwire-client-ruby
1
+ # SignalWire Ruby
2
2
 
3
- This gem provides a client for the Signalwire LAML and REST services.
4
3
 
5
- It supports all of the features in the SignalWire REST API, and generation of LAML responses.
4
+ [![Build Status](https://ci.signalwire.com/api/badges/signalwire/signalwire-ruby/status.svg)](https://ci.signalwire.com/signalwire/signalwire-ruby) [![Gem Version](https://badge.fury.io/rb/signalwire.svg)](https://badge.fury.io/rb/signalwire)
6
5
 
7
- [![Gem Version](https://badge.fury.io/rb/signalwire.svg)](https://badge.fury.io/rb/signalwire)
6
+ The Relay SDK for Ruby enables Ruby developers to connect and use SignalWire's Relay APIs within their own Ruby code. Our Relay SDK allows developers to build or add robust and innovative communication services to their applications.
8
7
 
9
- ![Drone CI](https://ci.signalwire.com/api/badges/signalwire/signalwire-ruby/status.svg)
8
+ ## Getting Started
10
9
 
11
- ## Installation
10
+ Read the implementation documentation, guides and API Reference at the official [Relay SDK for Ruby Documentation](https://docs.signalwire.com/topics/relay-sdk-ruby) site.
12
11
 
13
- Add `gem 'signalwire'` to your `Gemfile`, or simply `gem install signalwire`.
12
+ ---
14
13
 
15
- ## SDK Usage
14
+ ## Contributing
16
15
 
17
- Configure your signalwire subdomain, either by setting the environment variables `SIGNALWIRE_SPACE_URL` or `SIGNALWIRE_API_HOSTNAME` to `your_subdomain.signalwire.com` within an
18
- initializer, or simply passing in the parameter to the constructor as seen below in the "Making a call" example:
16
+ Relay SDK for Ruby is open source and maintained by the SignalWire team, but we are very grateful for [everyone](https://github.com/signalwire/signalwire-ruby/contributors) who has contributed and assisted so far.
19
17
 
20
- ```ruby
21
- require 'signalwire/sdk'
18
+ If you'd like to contribute, feel free to visit our [Slack channel](https://signalwire.community/) and read our developer section to get the code running in your local environment.
22
19
 
23
- Signalwire::Sdk.configure do |config|
24
- config.hostname = "your_subdomain.signalwire.com"
25
- end
26
- ```
20
+ ## Developers
27
21
 
28
- Then, setup a client to make requests, your `PROJECT_KEY` and `TOKEN` can be found within your Signalwire account, under Settings -> API Credentials
22
+ The Ruby SDK is a gem built from the [signalwire-ruby](https://github.com/signalwire/signalwire-ruby) repository. To setup the dev environment follow these steps:
29
23
 
30
- ### Making a call
24
+ 1. Install Ruby, Bundler and Rubygems. [RVM](https://rvm.io/) is an easy to use Ruby installer and environment manager.
25
+ 2. Fork the [signalwire-ruby](https://github.com/signalwire/signalwire-ruby) repository and clone it.
26
+ 3. Create a new branch from `master` for your change.
27
+ 4. Run `bundle install` to install global dependencies.
28
+ 5. Run `bundle exec guard -c` to start watching your files and specs.
29
+ 6. Make changes!
31
30
 
32
- ```ruby
33
- @client = Signalwire::REST::Client.new PROJECT_KEY, TOKEN, signalwire_space_url: "your_subdomain.signalwire.com"
31
+ ## Versioning
34
32
 
35
- @call = @client.calls.create(
36
- from: '+15551234567',
37
- to: '+15557654321',
38
- url: "https://cdn.signalwire.com/default-music/playlist.xml",
39
- method: "GET"
40
- )
41
- ```
33
+ Relay SDK forRuby follows Semantic Versioning 2.0 as defined at <http://semver.org>.
42
34
 
43
- ### Sending a text message
35
+ ## License
44
36
 
45
- ```ruby
46
- @message = @client.messages.create(
47
- from: '+15551234567',
48
- to: '+15557654321',
49
- body: 'This is a message from the Signalwire-Ruby library!'
50
- )
51
- ```
52
-
53
- ## Generating a LAML response
54
-
55
- ```
56
- require 'signalwire/sdk'
57
-
58
- response = Signalwire::Sdk::VoiceResponse.new do |r|
59
- r.say(message: 'hello there', voice: 'alice')
60
- r.dial(caller_id: '+14159992222') do |d|
61
- d.client 'jenny'
62
- end
63
- end
64
-
65
- # print the result
66
- puts response.to_s
67
- ```
68
-
69
- ```
70
- <?xml version="1.0" encoding="UTF-8"?>
71
- <Response>
72
- <Say voice="alice">hello there</Say>
73
- <Dial callerId="+14159992222">
74
- <Client>jenny</Client>
75
- </Dial>
76
- </Response>
77
- ```
78
-
79
- ## Tests
80
-
81
- A `Dockerfile` is provided for your testing convenience.
82
-
83
- Run `docker run -it $(docker build -q .)` to execute the specs, or `docker run -it $(docker build -q .) sh` to get a shell.
84
-
85
- ## Contributing to signalwire-client-ruby
86
-
87
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
88
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
89
- * Fork the project.
90
- * Start a feature/bugfix branch.
91
- * Commit and push until you are happy with your contribution.
92
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
93
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
94
-
95
- ## Copyright
96
-
97
- Copyright (c) 2018 SignalWire Inc. See LICENSE.txt for
98
- further details.
37
+ Relay SDK for Ruby is copyright © 2018-2019
38
+ [SignalWire](http://signalwire.com). It is free software, and may be redistributed under the terms specified in the [MIT-LICENSE](https://github.com//signalwire/signalwire-ruby/blob/master/LICENSE) file.
data/Rakefile CHANGED
@@ -10,23 +10,6 @@ rescue Bundler::BundlerError => e
10
10
  exit e.status_code
11
11
  end
12
12
  require 'rake'
13
- require 'juwelier'
14
- Juwelier::Tasks.new do |gem|
15
- gem.name = 'signalwire'
16
- gem.homepage = 'http://github.com/signalwire/signalwire-ruby'
17
- gem.license = 'MIT'
18
- gem.summary = %(Ruby client for Signalwire)
19
- gem.email = 'open.source@signalwire.com'
20
- gem.authors = ['SignalWire Team']
21
-
22
- # dependencies defined in Gemfile
23
- end
24
- Juwelier::RubygemsDotOrgTasks.new
25
- require 'rspec/core'
26
- require 'rspec/core/rake_task'
27
- RSpec::Core::RakeTask.new(:spec) do |spec|
28
- spec.pattern = FileList['spec/**/*_spec.rb']
29
- end
30
13
 
31
14
  desc 'Code coverage detail'
32
15
  task :simplecov do
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
4
+ %w[
5
+ bundler/setup
6
+ signalwire
7
+ ].each { |f| require f }
8
+
9
+ # Setup your ENV with:
10
+ # SIGNALWIRE_ACCOUNT=YOUR_SIGNALWIRE_ACCOUNT_ID
11
+ # SIGNALWIRE_TOKEN=YOUR_SIGNALWIRE_ACCOUNT_TOKEN
12
+ #
13
+ Signalwire::Logger.logger.level = ::Logger::DEBUG
14
+
15
+ class MyConsumer < Signalwire::Relay::Consumer
16
+ contexts ['incoming']
17
+
18
+ def on_incoming_call(call)
19
+ call.answer
20
+ call.play_tts 'the quick brown fox jumps over the lazy dog'
21
+
22
+ call.hangup
23
+ end
24
+ end
25
+
26
+ MyConsumer.new.run
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
4
+ %w[
5
+ bundler/setup
6
+ signalwire
7
+ ].each { |f| require f }
8
+
9
+ # Setup your ENV with:
10
+ # SIGNALWIRE_ACCOUNT=YOUR_SIGNALWIRE_ACCOUNT_ID
11
+ # SIGNALWIRE_TOKEN=YOUR_SIGNALWIRE_ACCOUNT_TOKEN
12
+ #
13
+ # Set logging to debug for testing
14
+ Signalwire::Logger.logger.level = ::Logger::DEBUG
15
+
16
+ class MyConsumer < Signalwire::Relay::Consumer
17
+ contexts ['incoming']
18
+
19
+ def on_incoming_call(call)
20
+ call.answer
21
+ call.play_tts 'connecting you to the clock service'
22
+ call.connect [[{ type: 'phone', params: { to_number: '+12027621401', from_number: ENV['FROM_NUMBER'], timeout: 30 } }]]
23
+ sleep 20
24
+ call.hangup
25
+ end
26
+ end
27
+
28
+ MyConsumer.new.run
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
4
+ %w[
5
+ bundler/setup
6
+ signalwire
7
+ ].each { |f| require f }
8
+
9
+ # Set logging to debug for testing
10
+ Signalwire::Logger.logger.level = ::Logger::DEBUG
11
+
12
+ class OutboundConsumer < Signalwire::Relay::Consumer
13
+ def ready
14
+ dial_result = client.calling.new_call(from: ENV['FROM_NUMBER'], to: ENV['TO_NUMBER']).dial
15
+ collect_params = { "initial_timeout": 10.0, "digits": { "max": 1, "digit_timeout": 5.0 } }
16
+ result = dial_result.call.prompt_tts( collect_params, 'how many hamburgers would you like to order?')
17
+
18
+ dial_result.call.play_tts "You ordered #{result.result} hamburgers. Thank you!"
19
+ dial_result.call.hangup
20
+ # this makes it so the errors don't stop the process
21
+ rescue StandardError => e
22
+ logger.error e.inspect
23
+ logger.error e.backtrace
24
+ end
25
+ end
26
+
27
+ OutboundConsumer.new.run
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
4
+ %w[
5
+ bundler/setup
6
+ signalwire
7
+ ].each { |f| require f }
8
+
9
+ # Set logging to debug for testing
10
+ Signalwire::Logger.logger.level = ::Logger::DEBUG
11
+
12
+ class OutboundConsumer < Signalwire::Relay::Consumer
13
+ def ready
14
+ logger.info 'Dialing out'
15
+ call = client.calling.new_call(from: ENV['FROM_NUMBER'], to: ENV['TO_NUMBER'])
16
+ call.dial
17
+ call.play_tts 'the quick brown fox jumps over the lazy dog', 'en-US', 'male'
18
+ call.hangup
19
+ end
20
+ end
21
+
22
+ OutboundConsumer.new.run