whoosh-ruby 0.1.1 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/README.md +16 -182
- data/lib/twilio-ruby/version.rb +1 -1
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f501c74c65546910b75412215ac07c87cda36ce583a7fdf3bc768e180058d37
|
4
|
+
data.tar.gz: 3e8723fd10d7db49ae9cc0691ee9f38f7ec69f06c65da5b7fc3419060f4972b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2e957be92ed0a4d848d43564fcbae2e85b50f5ac7f187f51d0d6af731e64b0c0eff460ef9206a4cc7f0a71877a3fcac258185e765c311819bdc42ce42923f7f
|
7
|
+
data.tar.gz: c409f5a87c1ba9d0d0233812922ed61fea971cdf6b680c70310904420ab7853fdb0ffafe910dcb6d7ed260bb248a8b81f466a0527485551f22b77a64a3b95a6e
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (C) 2023, Totogi LLC. <help@totogi.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
10
|
+
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,8 +1,4 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
## Versions
|
4
|
-
|
5
|
-
`twilio-ruby` uses a modified version of [Semantic Versioning](https://semver.org) for all changes. [See this document](VERSIONS.md) for details.
|
1
|
+
# whoosh-ruby
|
6
2
|
|
7
3
|
### Supported Ruby Versions
|
8
4
|
|
@@ -20,36 +16,24 @@ This library supports the following Ruby implementations:
|
|
20
16
|
* JRuby 9.3
|
21
17
|
* JRuby 9.4
|
22
18
|
|
23
|
-
### Migrating from 5.x
|
24
|
-
|
25
|
-
[Upgrade Guide][upgrade]
|
26
|
-
|
27
19
|
## Installation
|
28
20
|
|
29
21
|
To install using [Bundler][bundler] grab the latest stable version:
|
30
22
|
|
31
23
|
```ruby
|
32
|
-
gem '
|
33
|
-
```
|
34
|
-
|
35
|
-
To manually install `twilio-ruby` via [Rubygems][rubygems] simply gem install:
|
36
|
-
|
37
|
-
```bash
|
38
|
-
gem install twilio-ruby -v 6.0.0
|
24
|
+
gem 'whoosh-ruby', '~> 0.1.0'
|
39
25
|
```
|
40
26
|
|
41
|
-
To
|
27
|
+
To manually install `whoosh-ruby` via [Rubygems][rubygems] simply gem install:
|
42
28
|
|
43
29
|
```bash
|
44
|
-
|
45
|
-
cd twilio-ruby
|
46
|
-
make install
|
30
|
+
gem install whoosh-ruby -v 0.1.0
|
47
31
|
```
|
48
32
|
|
49
33
|
> **Info**
|
50
34
|
> If the command line gives you an error message that says Permission Denied, try running the above commands with sudo.
|
51
35
|
>
|
52
|
-
> For example: `sudo gem install
|
36
|
+
> For example: `sudo gem install whoosh-ruby`
|
53
37
|
|
54
38
|
### Test your installation
|
55
39
|
|
@@ -58,7 +42,7 @@ To make sure the installation was successful, try sending yourself an SMS messag
|
|
58
42
|
```rb
|
59
43
|
require "twilio-ruby"
|
60
44
|
|
61
|
-
# Your Account SID and Auth Token from console.
|
45
|
+
# Your Account SID and Auth Token from console.whoosh.totogidemos.com
|
62
46
|
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
|
63
47
|
auth_token = "your_auth_token"
|
64
48
|
|
@@ -66,7 +50,7 @@ auth_token = "your_auth_token"
|
|
66
50
|
message = @client.messages.create(
|
67
51
|
body: "Hello from Ruby",
|
68
52
|
to: "+12345678901", # Text this number
|
69
|
-
from: "+15005550006", # From a valid
|
53
|
+
from: "+15005550006", # From a valid Whoosh number
|
70
54
|
)
|
71
55
|
|
72
56
|
puts message.sid
|
@@ -82,54 +66,12 @@ puts message.sid
|
|
82
66
|
```ruby
|
83
67
|
require 'twilio-ruby'
|
84
68
|
|
85
|
-
# Your Account SID and Auth Token from console.
|
69
|
+
# Your Account SID and Auth Token from console.whoosh.totogidemos.com
|
86
70
|
account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
87
71
|
auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
|
88
72
|
|
89
|
-
# Initialize the
|
90
|
-
@client = Twilio::REST::Client.new account_sid, auth_token
|
91
|
-
```
|
92
|
-
|
93
|
-
### Use An API Key
|
94
|
-
|
95
|
-
```ruby
|
96
|
-
require 'twilio-ruby'
|
97
|
-
|
98
|
-
# Your Account SID from console.twilio.com
|
99
|
-
account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
100
|
-
# API Key from twilio.com/console/project/api-keys
|
101
|
-
api_key_sid = 'zzzzzzzzzzzzzzzzzzzzzz'
|
102
|
-
api_key_secret = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
|
103
|
-
|
104
|
-
# set up a client to talk to the Twilio REST API using an API Key
|
105
|
-
@client = Twilio::REST::Client.new api_key_sid, api_key_secret, account_sid
|
106
|
-
```
|
107
|
-
|
108
|
-
### Specify a Region and/or Edge
|
109
|
-
|
110
|
-
To take advantage of Twilio's [Global Infrastructure](https://www.twilio.com/docs/global-infrastructure), specify the target Region and/or Edge for the client:
|
111
|
-
|
112
|
-
```ruby
|
113
|
-
# set up a client to talk to the Twilio REST API over a specific region and edge
|
114
|
-
@client = Twilio::REST::Client.new account_sid, auth_token, nil, 'au1'
|
115
|
-
@client.edge = 'sydney'
|
116
|
-
|
117
|
-
# you may also specify the region and/or edge after client creation
|
73
|
+
# Initialize the Whoosh Client with your credentials
|
118
74
|
@client = Twilio::REST::Client.new account_sid, auth_token
|
119
|
-
@client.region = 'au1'
|
120
|
-
@client.edge = 'sydney'
|
121
|
-
```
|
122
|
-
|
123
|
-
This will result in the `hostname` transforming from `api.twilio.com` to `api.sydney.au1.twilio.com`.
|
124
|
-
|
125
|
-
### Make a Call
|
126
|
-
|
127
|
-
```ruby
|
128
|
-
@client.calls.create(
|
129
|
-
from: '+14159341234',
|
130
|
-
to: '+16105557069',
|
131
|
-
url: 'http://example.com'
|
132
|
-
)
|
133
75
|
```
|
134
76
|
|
135
77
|
### Send an SMS
|
@@ -158,45 +100,15 @@ message_sid = 'SMxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
|
158
100
|
|
159
101
|
### Iterate through records
|
160
102
|
|
161
|
-
The library automatically handles paging for you. Collections, such as `
|
103
|
+
The library automatically handles paging for you. Collections, such as `messages`, have `list` and stream methods that page under the hood. With both `list` and `stream`, you can specify the number of records you want to receive (`limit`) and the maximum size you want each page fetch to be (`page_size`). The library will then handle the task for you.
|
162
104
|
|
163
105
|
`list` eagerly fetches all records and returns them as a list, whereas `stream` returns an enumerator and lazily retrieves pages of records as you iterate over the collection. You can also page manually using the `page` method.
|
164
106
|
|
165
107
|
For more information about these methods, view the [auto-generated library docs](https://www.twilio.com/docs/libraries/reference/twilio-ruby).
|
166
108
|
|
167
|
-
```rb
|
168
|
-
require 'twilio-ruby'
|
169
|
-
|
170
|
-
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
171
|
-
auth_token = 'your_auth_token'
|
172
|
-
|
173
|
-
@client = Twilio::REST::Client.new(account_sid, auth_token)
|
174
|
-
|
175
|
-
@client.calls.list
|
176
|
-
.each do |call|
|
177
|
-
puts call.direction
|
178
|
-
end
|
179
|
-
```
|
180
|
-
|
181
|
-
### Enable Debug logging
|
182
|
-
|
183
|
-
In order to enable debug logging, pass in a 'logger' instance to the client with the level set to at least 'DEBUG'
|
184
|
-
|
185
|
-
```ruby
|
186
|
-
@client = Twilio::REST::Client.new account_sid, auth_token
|
187
|
-
myLogger = Logger.new(STDOUT)
|
188
|
-
myLogger.level = Logger::DEBUG
|
189
|
-
@client.logger = myLogger
|
190
|
-
|
191
|
-
@client = Twilio::REST::Client.new account_sid, auth_token
|
192
|
-
myLogger = Logger.new('my_log.log')
|
193
|
-
myLogger.level = Logger::DEBUG
|
194
|
-
@client.logger = myLogger
|
195
|
-
```
|
196
|
-
|
197
109
|
### Handle Exceptions {#exceptions}
|
198
110
|
|
199
|
-
If the
|
111
|
+
If the Whoosh API returns a 400 or a 500 level HTTP response, the `whoosh-ruby`
|
200
112
|
library will throw a `Twilio::REST::RestError`. 400-level errors are normal
|
201
113
|
during API operation (`“Invalid number”`, `“Cannot deliver SMS to that number”`,
|
202
114
|
for example) and should be handled appropriately.
|
@@ -226,7 +138,7 @@ For example, you can retrieve the status code of the last response like so:
|
|
226
138
|
require 'rubygems' # Not necessary with ruby 1.9 but included for completeness
|
227
139
|
require 'twilio-ruby'
|
228
140
|
|
229
|
-
# Your Account SID and Auth Token from console.
|
141
|
+
# Your Account SID and Auth Token from console.whoosh.totogidemos.com
|
230
142
|
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
|
231
143
|
auth_token = 'your_auth_token'
|
232
144
|
|
@@ -244,7 +156,7 @@ puts @client.http_client.last_response.status_code
|
|
244
156
|
|
245
157
|
### Customize your HTTP Client
|
246
158
|
|
247
|
-
`
|
159
|
+
`whoosh-ruby` uses [Faraday][faraday] to make HTTP requests. You can tell `Twilio::REST::Client` to use any of the Faraday adapters like so:
|
248
160
|
|
249
161
|
```ruby
|
250
162
|
@client.http_client.adapter = :typhoeus
|
@@ -260,86 +172,8 @@ To apply customizations such as middleware, you can use the `configure_connectio
|
|
260
172
|
end
|
261
173
|
```
|
262
174
|
|
263
|
-
### Get started With Client Capability Tokens
|
264
|
-
|
265
|
-
If you just need to generate a Capability Token for use with Twilio Client, you can do this:
|
266
|
-
|
267
|
-
```ruby
|
268
|
-
require 'twilio-ruby'
|
269
|
-
|
270
|
-
# put your own account credentials here:
|
271
|
-
account_sid = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
|
272
|
-
auth_token = 'yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy'
|
273
|
-
|
274
|
-
# set up
|
275
|
-
capability = Twilio::JWT::ClientCapability.new account_sid, auth_token
|
276
|
-
|
277
|
-
# allow outgoing calls to an application
|
278
|
-
outgoing_scope = Twilio::JWT::ClientCapability::OutgoingClientScope.new 'AP11111111111111111111111111111111'
|
279
|
-
capability.add_scope(outgoing_scope)
|
280
|
-
|
281
|
-
# allow incoming calls to 'andrew'
|
282
|
-
incoming_scope = Twilio::JWT::ClientCapability::IncomingClientScope.new 'andrew'
|
283
|
-
capability.add_scope(incoming_scope)
|
284
|
-
|
285
|
-
# generate the token string
|
286
|
-
@token = capability.to_s
|
287
|
-
```
|
288
|
-
|
289
|
-
There is a slightly more detailed document in the [Capability][capability] section of the wiki.
|
290
|
-
|
291
|
-
### Generate TwiML
|
292
|
-
|
293
|
-
To control phone calls, your application needs to output [TwiML][twiml].
|
294
|
-
|
295
|
-
You can construct a TwiML response like this:
|
296
|
-
|
297
|
-
```ruby
|
298
|
-
require 'twilio-ruby'
|
299
|
-
|
300
|
-
response = Twilio::TwiML::VoiceResponse.new do |r|
|
301
|
-
r.say(message: 'hello there', voice: 'alice')
|
302
|
-
r.dial(caller_id: '+14159992222') do |d|
|
303
|
-
d.client 'jenny'
|
304
|
-
end
|
305
|
-
end
|
306
|
-
|
307
|
-
# print the result
|
308
|
-
puts response.to_s
|
309
|
-
```
|
310
|
-
|
311
|
-
This will print the following (except for the whitespace):
|
312
|
-
|
313
|
-
```xml
|
314
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
315
|
-
<Response>
|
316
|
-
<Say voice="alice">hello there</Say>
|
317
|
-
<Dial callerId="+14159992222">
|
318
|
-
<Client>jenny</Client>
|
319
|
-
</Dial>
|
320
|
-
</Response>
|
321
|
-
```
|
322
|
-
|
323
|
-
## Docker Image
|
324
|
-
|
325
|
-
The `Dockerfile` present in this repository and its respective `twilio/twilio-ruby` Docker image are currently used by Twilio for testing purposes only.
|
326
|
-
|
327
175
|
## Getting help
|
328
176
|
|
329
|
-
If you
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
[apidocs]: https://www.twilio.com/docs/api
|
334
|
-
[twiml]: https://www.twilio.com/docs/api/twiml
|
335
|
-
[libdocs]: https://www.twilio.com/docs/libraries/reference/twilio-ruby/
|
336
|
-
[refdocs]: https://twilio.github.io/twilio-ruby
|
337
|
-
[capability]: https://github.com/twilio/twilio-ruby/wiki/JWT-Tokens
|
338
|
-
[wiki]: https://github.com/twilio/twilio-ruby/wiki
|
339
|
-
[bundler]: https://bundler.io
|
340
|
-
[rubygems]: https://rubygems.org
|
341
|
-
[gem]: https://rubygems.org/gems/twilio
|
342
|
-
[github-actions]: https://github.com/twilio/twilio-ruby/actions/workflows/test-and-deploy.yml
|
343
|
-
[upgrade]: https://github.com/twilio/twilio-ruby/wiki/Ruby-Version-5.x-Upgrade-Guide
|
344
|
-
[issues]: https://github.com/twilio/twilio-ruby/issues
|
345
|
-
[faraday]: https://github.com/lostisland/faraday
|
177
|
+
If you've found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!
|
178
|
+
|
179
|
+
[docs]: https://docs.whoosh.totogidemos.com
|
data/lib/twilio-ruby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whoosh-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Totogi
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jwt
|
@@ -189,7 +189,7 @@ dependencies:
|
|
189
189
|
- !ruby/object:Gem::Version
|
190
190
|
version: 1.4.2
|
191
191
|
description: The official library for communicating with the Whoosh REST API
|
192
|
-
email:
|
192
|
+
email:
|
193
193
|
executables: []
|
194
194
|
extensions: []
|
195
195
|
extra_rdoc_files:
|
@@ -202,6 +202,7 @@ files:
|
|
202
202
|
- ".rubocop_todo.yml"
|
203
203
|
- Dockerfile
|
204
204
|
- Gemfile
|
205
|
+
- LICENSE
|
205
206
|
- Makefile
|
206
207
|
- README.md
|
207
208
|
- Rakefile
|
@@ -833,7 +834,7 @@ licenses:
|
|
833
834
|
- MIT
|
834
835
|
metadata:
|
835
836
|
yard.run: yri
|
836
|
-
post_install_message:
|
837
|
+
post_install_message:
|
837
838
|
rdoc_options:
|
838
839
|
- "--line-numbers"
|
839
840
|
- "--inline-source"
|
@@ -854,8 +855,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
854
855
|
- !ruby/object:Gem::Version
|
855
856
|
version: '0'
|
856
857
|
requirements: []
|
857
|
-
rubygems_version: 3.
|
858
|
-
signing_key:
|
858
|
+
rubygems_version: 3.0.3.1
|
859
|
+
signing_key:
|
859
860
|
specification_version: 4
|
860
861
|
summary: The official library for communicating with the Whoosh REST API
|
861
862
|
test_files: []
|