signalwire 1.4.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +55 -0
- data/.rubocop.yml +14 -2
- data/AUTHORS.md +1 -0
- data/CHANGELOG.md +30 -5
- data/Gemfile +4 -18
- data/LICENSE +21 -0
- data/README.md +22 -82
- data/Rakefile +0 -17
- data/examples/relay/inbound_consumer.rb +26 -0
- data/examples/relay/inbound_dial.rb +28 -0
- data/examples/relay/outbound_collect.rb +27 -0
- data/examples/relay/outbound_consumer.rb +22 -0
- data/examples/relay/outbound_record.rb +25 -0
- data/lib/signalwire.rb +13 -0
- data/lib/signalwire/blade.rb +12 -0
- data/lib/signalwire/blade/connection.rb +200 -0
- data/lib/signalwire/blade/event_handler.rb +15 -0
- data/lib/signalwire/blade/message.rb +38 -0
- data/lib/signalwire/blade/message/connect.rb +18 -0
- data/lib/signalwire/blade/message/execute.rb +16 -0
- data/lib/signalwire/blade/message/subscribe.rb +15 -0
- data/lib/signalwire/common.rb +6 -0
- data/lib/signalwire/logger.rb +27 -0
- data/lib/signalwire/relay.rb +40 -0
- data/lib/signalwire/relay/calling.rb +82 -0
- data/lib/signalwire/relay/calling/action.rb +16 -0
- data/lib/signalwire/relay/calling/action/connect_action.rb +11 -0
- data/lib/signalwire/relay/calling/action/play_action.rb +15 -0
- data/lib/signalwire/relay/calling/action/prompt_action.rb +15 -0
- data/lib/signalwire/relay/calling/action/record_action.rb +15 -0
- data/lib/signalwire/relay/calling/call.rb +210 -0
- data/lib/signalwire/relay/calling/call_convenience_methods.rb +79 -0
- data/lib/signalwire/relay/calling/component.rb +115 -0
- data/lib/signalwire/relay/calling/component/answer.rb +27 -0
- data/lib/signalwire/relay/calling/component/await.rb +20 -0
- data/lib/signalwire/relay/calling/component/connect.rb +45 -0
- data/lib/signalwire/relay/calling/component/dial.rb +34 -0
- data/lib/signalwire/relay/calling/component/hangup.rb +41 -0
- data/lib/signalwire/relay/calling/component/play.rb +46 -0
- data/lib/signalwire/relay/calling/component/prompt.rb +62 -0
- data/lib/signalwire/relay/calling/component/record.rb +53 -0
- data/lib/signalwire/relay/calling/control_component.rb +35 -0
- data/lib/signalwire/relay/calling/result.rb +16 -0
- data/lib/signalwire/relay/calling/result/answer_result.rb +6 -0
- data/lib/signalwire/relay/calling/result/connect_result.rb +9 -0
- data/lib/signalwire/relay/calling/result/dial_result.rb +7 -0
- data/lib/signalwire/relay/calling/result/hangup_result.rb +7 -0
- data/lib/signalwire/relay/calling/result/play_result.rb +6 -0
- data/lib/signalwire/relay/calling/result/prompt_result.rb +11 -0
- data/lib/signalwire/relay/calling/result/record_result.rb +7 -0
- data/lib/signalwire/relay/client.rb +147 -0
- data/lib/signalwire/relay/constants.rb +109 -0
- data/lib/signalwire/relay/consumer.rb +88 -0
- data/lib/signalwire/relay/event.rb +41 -0
- data/lib/signalwire/relay/request.rb +6 -0
- data/lib/signalwire/rest/client.rb +5 -5
- data/lib/signalwire/sdk/fax_response.rb +3 -3
- data/lib/signalwire/sdk/messaging_response.rb +0 -2
- data/lib/signalwire/sdk/twilio_set_fax.rb +9 -8
- data/lib/signalwire/sdk/twilio_set_host.rb +8 -3
- data/lib/signalwire/version.rb +5 -0
- data/signalwire.gemspec +36 -106
- metadata +173 -76
- data/LICENSE.txt +0 -20
- data/VERSION +0 -1
- data/spec/signalwire/rest/client_spec.rb +0 -30
- data/spec/signalwire/rest/integration_spec.rb +0 -102
- data/spec/signalwire/sdk/configuration_spec.rb +0 -28
- data/spec/signalwire/sdk/fax_response_spec.rb +0 -26
- data/spec/signalwire/sdk/messaging_response_spec.rb +0 -18
- data/spec/signalwire/sdk/voice_response_spec.rb +0 -20
- data/spec/signalwire/sdk_spec.rb +0 -27
- data/spec/spec_helper.rb +0 -119
- data/spec/vcr_cassettes/accounts.yml +0 -27
- data/spec/vcr_cassettes/applications.yml +0 -29
- data/spec/vcr_cassettes/get_fax.yml +0 -25
- data/spec/vcr_cassettes/get_fax_media_instance.yml +0 -27
- data/spec/vcr_cassettes/get_fax_media_list.yml +0 -47
- data/spec/vcr_cassettes/list_faxes.yml +0 -25
- data/spec/vcr_cassettes/local_numbers.yml +0 -26
- data/spec/vcr_cassettes/recordings.yml +0 -27
- data/spec/vcr_cassettes/send_fax.yml +0 -27
- data/spec/vcr_cassettes/toll_free_numbers.yml +0 -34
- data/spec/vcr_cassettes/transcriptions.yml +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d68736f7bf37f324c9f85a604165cd994d45974d73741c90cd9290e4ef63b4c
|
4
|
+
data.tar.gz: f47bcfe838a3ce0576d7f2ba199f415ab5a36f23d07feef554ad3c340c20d015
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 782c53f901d1bf44cb4bf9dd523a6268bf4bd6c165aa39223e054501f75092524e47a92ce97acb6b247cf2ad89f311fb44722bb27c5db82fbf6da7c9e88cd65e
|
7
|
+
data.tar.gz: 0ace788a9baf5c7c9aee04bcae89478777bdbbd7f107040da98687e5bb211d0ecccc8222fb11e6ce97037c8d773c61914538df43ab40eeb0360a1aab7358ccca
|
data/.gitignore
ADDED
@@ -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
|
data/.rubocop.yml
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion: 2.3
|
3
2
|
Exclude:
|
4
3
|
- 'bin/**/*'
|
5
|
-
- 'signalwire
|
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
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,39 @@
|
|
1
1
|
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
2
3
|
|
3
|
-
|
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
|
-
|
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
|
-
|
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
|
-
#
|
1
|
+
# SignalWire Ruby
|
2
2
|
|
3
|
-
This gem provides a client for the Signalwire LAML and REST services.
|
4
3
|
|
5
|
-
|
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
|
-
|
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
|
-
|
8
|
+
## Getting Started
|
10
9
|
|
11
|
-
|
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
|
-
|
12
|
+
---
|
14
13
|
|
15
|
-
##
|
14
|
+
## Contributing
|
16
15
|
|
17
|
-
|
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
|
-
|
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
|
-
|
24
|
-
config.hostname = "your_subdomain.signalwire.com"
|
25
|
-
end
|
26
|
-
```
|
20
|
+
## Developers
|
27
21
|
|
28
|
-
|
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
|
-
|
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
|
-
|
33
|
-
@client = Signalwire::REST::Client.new PROJECT_KEY, TOKEN, signalwire_space_url: "your_subdomain.signalwire.com"
|
31
|
+
## Versioning
|
34
32
|
|
35
|
-
|
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
|
-
|
35
|
+
## License
|
44
36
|
|
45
|
-
|
46
|
-
|
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
|