voicetel 2.2.17 β 2.2.21
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/README.md +23 -17
- data/lib/voicetel/api_error.rb +4 -0
- data/lib/voicetel/internal/transport.rb +53 -9
- data/lib/voicetel/models/e911.rb +4 -3
- data/lib/voicetel/models/fax.rb +65 -0
- data/lib/voicetel/models/i_numbering.rb +14 -6
- data/lib/voicetel/models/lookups.rb +27 -0
- data/lib/voicetel/models/messaging.rb +18 -5
- data/lib/voicetel/models/numbers.rb +68 -19
- data/lib/voicetel/models.rb +1 -0
- data/lib/voicetel/resources/acl.rb +6 -7
- data/lib/voicetel/resources/fax.rb +110 -0
- data/lib/voicetel/resources/lookups.rb +11 -1
- data/lib/voicetel/resources/numbers.rb +42 -4
- data/lib/voicetel/version.rb +3 -3
- data/lib/voicetel.rb +5 -0
- data/sig/voicetel.rbs +165 -7
- data/voicetel.gemspec +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ec74242f32120f8e9b8002861b0dfedff0b46464696a81e400ca8dfe9d9738a
|
|
4
|
+
data.tar.gz: b5d2fd9ce48440837cc3122ec0cb5ef13637665c6abe3b3b2662ed2954934c16
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5e8631c94d1bcad6996d8166338cd56b6a8eceb7b4c78446d6fce8524ace844456a2438d9fcffcd5b78b0f7245c27885011c294af6974f5a057de7195073fd30
|
|
7
|
+
data.tar.gz: 109200d937b256cbc3770bb22291ad31c43a34e5c35e36af15463a37a0e1c9ea4c4622f54e76f55e64cdc35bdaca799d120eac1d1fb1d4a6c386f02ee70883a9
|
data/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
The official Ruby client for the [VoiceTel REST API](https://voicetel.com/docs/api/v2.2/) β provision numbers, place orders, validate e911, send messages, and manage your account, all with idiomatic Ruby, structured errors, and zero codegen footprint.
|
|
4
4
|
|
|
5
|
-

|
|
6
6
|

|
|
7
7
|

|
|
8
8
|

|
|
@@ -27,7 +27,7 @@ The official Ruby client for the [VoiceTel REST API](https://voicetel.com/docs/a
|
|
|
27
27
|
|
|
28
28
|
### π§± Idiomatic Ruby End-to-End
|
|
29
29
|
- **Resource-style API** β `client.numbers.list`, `client.messaging.send_message(...)`, just like the official SDKs in every other language.
|
|
30
|
-
- **snake_case everywhere**, automatically camelCased on the wire so the spec's `fromNumber` / `toNumber` / `messagingBrandId` look like plain Ruby.
|
|
30
|
+
- **snake_case everywhere**, automatically camelCased on the wire so the spec's `fromNumber` / `toNumber` / `messagingBrandId` look like plain Ruby. (The one exception: the carrier lookup's details keep the upstream carrier's `mobile_country_code`-style snake_case field names, exactly as the API returns them.)
|
|
31
31
|
- **Typed Data models** β every response is an immutable `Data.define` object (`VoiceTel::Models::...`) with snake_case readers; unknown server fields are ignored, so the API can grow without breaking you.
|
|
32
32
|
- **RBS signatures** ship in `sig/` β opt into type-checking with Steep or Sorbet, or ignore them and stay dynamic.
|
|
33
33
|
|
|
@@ -38,13 +38,14 @@ The official Ruby client for the [VoiceTel REST API](https://voicetel.com/docs/a
|
|
|
38
38
|
- **Bearer auth** managed for you; passwordβkey exchange handled by `client.login`.
|
|
39
39
|
- **Structured ApiError** β `:rate_limit`, `:not_found`, `:conflict`, ... pattern-match on a Symbol, or call `err.rate_limit?`.
|
|
40
40
|
|
|
41
|
-
### π Complete API Coverage
|
|
42
|
-
- **Numbers** β list, get, add, remove, route, translate, CNAM, LIDB, fax, forward, SMS, messaging campaigns, port-out PIN, account moves.
|
|
41
|
+
### π Complete API Coverage (88 operations)
|
|
42
|
+
- **Numbers** β list, get, add, remove, route, translate, CNAM, LIDB, fax, forward, SMS, directory listing (411), messaging campaigns, port-out PIN, account moves.
|
|
43
43
|
- **Account** β profile, sub-accounts, CDRs, credits, payments, MRC, registration, password recovery.
|
|
44
44
|
- **e911** β record provisioning, address validation, lookup, removal.
|
|
45
|
+
- **Fax** β fax-capable number listing, sending (multipart, idempotent per `Idempotency-Key` UUID), job history, single-job polling, rendered-PDF download.
|
|
45
46
|
- **Gateways** β list, create, update, delete, view bound numbers.
|
|
46
47
|
- **Messaging** β SMS & MMS sending, message history, 10DLC brand and campaign registration, per-number messaging state, and messaging health (account overview, per-number live check, spam-blocked samples, alert-email setting).
|
|
47
|
-
- **Lookups** β CNAM
|
|
48
|
+
- **Lookups** β CNAM, carrier & line type, LRN dips.
|
|
48
49
|
- **iNumbering** β inventory search, coverage queries, number orders, port-in submissions, port-out availability checks (v2.2.10 LRN + rate-center tier fields).
|
|
49
50
|
- **Support** β ticket create / read / update / delete, threaded messages, replies.
|
|
50
51
|
- **ACL** β IP allowlist management with structured 409 conflict bodies.
|
|
@@ -64,7 +65,7 @@ gem install voicetel
|
|
|
64
65
|
Or in your `Gemfile`:
|
|
65
66
|
|
|
66
67
|
```ruby
|
|
67
|
-
gem "voicetel", "~> 2.2.
|
|
68
|
+
gem "voicetel", "~> 2.2.21"
|
|
68
69
|
```
|
|
69
70
|
|
|
70
71
|
Requires Ruby 3.2 or later. Tested on 3.2, 3.3, and 3.4.
|
|
@@ -121,9 +122,10 @@ key = client.login(username: "1000000001", password: "hunter2")
|
|
|
121
122
|
| `client.acl` | IP allowlist (CIDR entries) | `client.acl.add(acl: [{ cidr: "1.2.3.0/24" }])` |
|
|
122
123
|
| `client.authentication` | SIP/HTTP auth mode + password | `client.authentication.update(auth_type: 1)` |
|
|
123
124
|
| `client.e911` | Records, address validation, provisioning | `client.e911.validate(address1: "...", city: "...", state: "NJ", zip: "07101")` |
|
|
125
|
+
| `client.fax` | Send faxes, history, rendered-PDF download | `client.fax.send_fax(from_number: "2015550123", to_number: "2125550123", documents: [{ name: "contract.pdf", content: pdf }])` |
|
|
124
126
|
| `client.gateways` | Termination routes | `client.gateways.list` |
|
|
125
127
|
| `client.i_numbering` | Inventory, orders, port-ins | `client.i_numbering.search_inventory(tn_mask: "201555*")` |
|
|
126
|
-
| `client.lookups` | CNAM & LRN dips | `client.lookups.
|
|
128
|
+
| `client.lookups` | CNAM, carrier & line type, LRN dips | `client.lookups.carrier("2015550123")` |
|
|
127
129
|
| `client.messaging` | SMS/MMS, 10DLC brands & campaigns, messaging health | `client.messaging.send_message(from_number: "...", to_number: "...", text: "...")` |
|
|
128
130
|
| `client.numbers` | All operations on TNs on the account | `client.numbers.assign_campaign("2015550123", campaign_id: "CABC123")` |
|
|
129
131
|
| `client.support` | Tickets, replies, attachments | `client.support.create(subject: "...", message: "...")` |
|
|
@@ -148,16 +150,18 @@ Responses come back as immutable `Data` model classes (`VoiceTel::Models::...`)
|
|
|
148
150
|
|
|
149
151
|
All HTTP errors raise `VoiceTel::ApiError`. The `kind` attribute is a Symbol; convenience predicates are exposed for readability:
|
|
150
152
|
|
|
151
|
-
| Status | `kind`
|
|
152
|
-
|
|
153
|
-
| 400 | `:bad_request`
|
|
154
|
-
| 401 | `:authentication`
|
|
155
|
-
|
|
|
156
|
-
|
|
|
157
|
-
|
|
|
158
|
-
|
|
|
159
|
-
|
|
|
160
|
-
|
|
|
153
|
+
| Status | `kind` | Predicate |
|
|
154
|
+
|--------|-------------------------|------------------------------|
|
|
155
|
+
| 400 | `:bad_request` | `err.bad_request?` |
|
|
156
|
+
| 401 | `:authentication` | `err.authentication?` |
|
|
157
|
+
| 402 | `:insufficient_balance` | `err.insufficient_balance?` |
|
|
158
|
+
| 403 | `:permission_denied` | `err.permission_denied?` |
|
|
159
|
+
| 404 | `:not_found` | `err.not_found?` |
|
|
160
|
+
| 409 | `:conflict` | `err.conflict?` |
|
|
161
|
+
| 413 | `:payload_too_large` | `err.payload_too_large?` |
|
|
162
|
+
| 429 | `:rate_limit` | `err.rate_limit?` |
|
|
163
|
+
| 5xx | `:server` | `err.server?` |
|
|
164
|
+
| other | `:unknown` | `err.unknown?` |
|
|
161
165
|
|
|
162
166
|
```ruby
|
|
163
167
|
begin
|
|
@@ -185,6 +189,8 @@ These endpoints are limited to **6 requests per hour per IP**:
|
|
|
185
189
|
|
|
186
190
|
`POST /v2.2/messaging/health/check` is separately limited to **30 checks per hour per account**.
|
|
187
191
|
|
|
192
|
+
`POST /v2.2/faxes` (`client.fax.send_fax`) is limited to **10 sends per minute per account**.
|
|
193
|
+
|
|
188
194
|
The SDK automatically retries 429 responses with `Retry-After` honored (capped at 8s), up to `max_retries` (default `2`). To raise it:
|
|
189
195
|
|
|
190
196
|
```ruby
|
data/lib/voicetel/api_error.rb
CHANGED
|
@@ -10,9 +10,11 @@ module VoiceTel
|
|
|
10
10
|
KINDS = %i[
|
|
11
11
|
bad_request
|
|
12
12
|
authentication
|
|
13
|
+
insufficient_balance
|
|
13
14
|
permission_denied
|
|
14
15
|
not_found
|
|
15
16
|
conflict
|
|
17
|
+
payload_too_large
|
|
16
18
|
rate_limit
|
|
17
19
|
server
|
|
18
20
|
unknown
|
|
@@ -37,9 +39,11 @@ module VoiceTel
|
|
|
37
39
|
case status
|
|
38
40
|
when 400 then :bad_request
|
|
39
41
|
when 401 then :authentication
|
|
42
|
+
when 402 then :insufficient_balance
|
|
40
43
|
when 403 then :permission_denied
|
|
41
44
|
when 404 then :not_found
|
|
42
45
|
when 409 then :conflict
|
|
46
|
+
when 413 then :payload_too_large
|
|
43
47
|
when 429 then :rate_limit
|
|
44
48
|
when 500..599 then :server
|
|
45
49
|
else :unknown
|
|
@@ -21,6 +21,9 @@ module VoiceTel
|
|
|
21
21
|
class Transport
|
|
22
22
|
RETRYABLE_STATUSES = [429, 500, 502, 503, 504].freeze
|
|
23
23
|
|
|
24
|
+
# Line ending for the hand-built multipart/form-data bodies.
|
|
25
|
+
CRLF = "\r\n"
|
|
26
|
+
|
|
24
27
|
# Upper bound (seconds) for any single retry sleep β exponential backoff
|
|
25
28
|
# and server-supplied Retry-After / RateLimit-Reset hints alike.
|
|
26
29
|
MAX_RETRY_DELAY = 8
|
|
@@ -62,7 +65,15 @@ module VoiceTel
|
|
|
62
65
|
# @param query [Hash, nil] query string params, snake_case keys
|
|
63
66
|
# @param body [Hash, nil] request body, snake_case keys (translated to camelCase)
|
|
64
67
|
# @param require_auth [Boolean] false skips the bearer header
|
|
65
|
-
|
|
68
|
+
# @param multipart [Hash, nil] multipart/form-data request β { fields:
|
|
69
|
+
# {String => String}, files: [{ name:, filename:, content:,
|
|
70
|
+
# content_type: }] }. When given, it replaces the JSON body and the
|
|
71
|
+
# boundary/Content-Type are handled here.
|
|
72
|
+
# @param idempotency_key [String, nil] overrides the auto-generated
|
|
73
|
+
# Idempotency-Key on POST/PUT/PATCH (the fax send requires a UUID)
|
|
74
|
+
# @param raw [Boolean] true returns the success body as a raw
|
|
75
|
+
# String (binary downloads) instead of parsing the envelope
|
|
76
|
+
def request(method, path, query: nil, body: nil, require_auth: true, multipart: nil, idempotency_key: nil, raw: false)
|
|
66
77
|
if require_auth && (@api_key.nil? || @api_key.empty?)
|
|
67
78
|
raise ApiError.new(
|
|
68
79
|
"no api key set; call client.login(...) or pass api_key: to Client.new",
|
|
@@ -71,12 +82,18 @@ module VoiceTel
|
|
|
71
82
|
end
|
|
72
83
|
|
|
73
84
|
headers = build_headers(require_auth)
|
|
74
|
-
|
|
75
|
-
|
|
85
|
+
if multipart
|
|
86
|
+
boundary, request_body = build_multipart(multipart)
|
|
87
|
+
headers["Content-Type"] = "multipart/form-data; boundary=#{boundary}"
|
|
88
|
+
else
|
|
89
|
+
request_body = body ? JSON.generate(camelize_keys(body)) : nil
|
|
90
|
+
end
|
|
91
|
+
headers["Idempotency-Key"] = idempotency_key || SecureRandom.uuid if %i[post put patch].include?(method)
|
|
92
|
+
response = @conn.run_request(method, path, request_body, headers) do |req|
|
|
76
93
|
req.params.update(camelize_keys(query)) if query && !query.empty?
|
|
77
94
|
end
|
|
78
95
|
|
|
79
|
-
handle_response(response)
|
|
96
|
+
handle_response(response, raw: raw)
|
|
80
97
|
rescue Faraday::TimeoutError => e
|
|
81
98
|
raise ApiError.new("voicetel: request timed out: #{e.message}", kind: :unknown)
|
|
82
99
|
rescue Faraday::ConnectionFailed => e
|
|
@@ -166,18 +183,45 @@ module VoiceTel
|
|
|
166
183
|
h
|
|
167
184
|
end
|
|
168
185
|
|
|
169
|
-
|
|
186
|
+
# Hand-builds a multipart/form-data body (no multipart middleware in
|
|
187
|
+
# the stack). Returns [boundary, body].
|
|
188
|
+
def build_multipart(multipart)
|
|
189
|
+
boundary = "voicetel-#{SecureRandom.hex(16)}"
|
|
190
|
+
parts = []
|
|
191
|
+
|
|
192
|
+
(multipart[:fields] || {}).each do |name, value|
|
|
193
|
+
parts << "Content-Disposition: form-data; name=\"#{sanitize_header(name)}\"#{CRLF}#{CRLF}#{value}"
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
(multipart[:files] || []).each do |file|
|
|
197
|
+
parts << "Content-Disposition: form-data; name=\"#{sanitize_header(file[:name])}\"; " \
|
|
198
|
+
"filename=\"#{sanitize_header(file[:filename])}\"#{CRLF}" \
|
|
199
|
+
"Content-Type: #{sanitize_header(file[:content_type])}#{CRLF}#{CRLF}#{file[:content]}"
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
[boundary, parts.map { |part| "--#{boundary}#{CRLF}#{part}#{CRLF}" }.join + "--#{boundary}--#{CRLF}"]
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
# Quotes and CR/LF have no business in a Content-Disposition name or
|
|
206
|
+
# filename β drop them so a hostile name can't add headers or parts.
|
|
207
|
+
def sanitize_header(value)
|
|
208
|
+
value.to_s.gsub(/["\r\n]/, "")
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
def handle_response(response, raw: false)
|
|
170
212
|
status = response.status
|
|
171
|
-
|
|
213
|
+
body = decode_body(response)
|
|
172
214
|
|
|
173
215
|
if status >= 200 && status < 300
|
|
174
|
-
return
|
|
216
|
+
return body if raw
|
|
217
|
+
|
|
218
|
+
return nil if body.empty? || status == 204
|
|
175
219
|
|
|
176
|
-
parsed = parse_json(
|
|
220
|
+
parsed = parse_json(body)
|
|
177
221
|
return unwrap(parsed)
|
|
178
222
|
end
|
|
179
223
|
|
|
180
|
-
raise build_error(status,
|
|
224
|
+
raise build_error(status, body)
|
|
181
225
|
end
|
|
182
226
|
|
|
183
227
|
def parse_json(raw)
|
data/lib/voicetel/models/e911.rb
CHANGED
|
@@ -21,7 +21,7 @@ module VoiceTel
|
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
# Body for PUT /v2.2/e911/{dn} β provision using a previously-validated
|
|
24
|
-
# addressid from POST /v2.2/e911/validations.
|
|
24
|
+
# addressid (a hex string) from POST /v2.2/e911/validations.
|
|
25
25
|
E911ProvisionByIdRequest = Data.define(:callername, :addressid) do
|
|
26
26
|
include Request
|
|
27
27
|
end
|
|
@@ -34,8 +34,9 @@ module VoiceTel
|
|
|
34
34
|
extend Base
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
# Validation result from POST /v2.2/e911/validations. addressid is
|
|
38
|
-
# passed to E911ProvisionByIdRequest to provision the
|
|
37
|
+
# Validation result from POST /v2.2/e911/validations. addressid is a
|
|
38
|
+
# hex string; it is passed to E911ProvisionByIdRequest to provision the
|
|
39
|
+
# address.
|
|
39
40
|
E911ValidatedAddress = Data.define(
|
|
40
41
|
:addressid, :address1, :address2, :city, :state, :zip
|
|
41
42
|
) do
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "base"
|
|
4
|
+
require_relative "common"
|
|
5
|
+
|
|
6
|
+
module VoiceTel
|
|
7
|
+
module Models
|
|
8
|
+
# One fax-capable number on the account and the email address faxes to
|
|
9
|
+
# it deliver to (the per-number fax destination, or β destination_id 0 β
|
|
10
|
+
# the account email).
|
|
11
|
+
FaxNumberEntry = Data.define(:number, :destination_id, :email) do
|
|
12
|
+
extend Base
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# Data payload from GET /v2.2/numbers/fax.
|
|
16
|
+
FaxNumbersData = Data.define(:numbers) do
|
|
17
|
+
extend Base
|
|
18
|
+
|
|
19
|
+
def self.nested
|
|
20
|
+
{ numbers: FaxNumberEntry }
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Metadata about one uploaded fax document.
|
|
25
|
+
FaxDocumentMeta = Data.define(:name, :size, :content_type) do
|
|
26
|
+
extend Base
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Data payload from POST /v2.2/faxes β the accepted (queued) job.
|
|
30
|
+
FaxSendData = Data.define(:id, :from_number, :to_number, :status, :documents) do
|
|
31
|
+
extend Base
|
|
32
|
+
|
|
33
|
+
def self.nested
|
|
34
|
+
{ documents: FaxDocumentMeta }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# One fax job: its routing, lifecycle timestamps (ISO-8601 UTC or nil),
|
|
39
|
+
# delivery attempts and documents. status is queued / sending /
|
|
40
|
+
# retry_pending / sent / failed. document_available gates
|
|
41
|
+
# GET /v2.2/faxes/{id}/document.
|
|
42
|
+
FaxJob = Data.define(
|
|
43
|
+
:id, :from_number, :to_number, :client_token, :status,
|
|
44
|
+
:submitted_at, :started_at, :completed_at, :attempts, :failure_reason,
|
|
45
|
+
:documents, :document_available, :document_name, :document_size
|
|
46
|
+
) do
|
|
47
|
+
extend Base
|
|
48
|
+
|
|
49
|
+
def self.nested
|
|
50
|
+
{ documents: FaxDocumentMeta }
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Data payload from GET /v2.2/faxes β one page of history, newest
|
|
55
|
+
# first. next_cursor is opaque; pass it back as the next request's
|
|
56
|
+
# cursor (nil on the last page).
|
|
57
|
+
FaxHistoryData = Data.define(:number, :from_ts, :to_ts, :faxes, :next_cursor) do
|
|
58
|
+
extend Base
|
|
59
|
+
|
|
60
|
+
def self.nested
|
|
61
|
+
{ faxes: FaxJob }
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -11,9 +11,10 @@ module VoiceTel
|
|
|
11
11
|
include Request
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
# Per-number routing override inside OrderCreateRequest. route is
|
|
15
|
-
# global route
|
|
16
|
-
# 3 VOICE_BRIDGE, 4 DID (default), 5 T38,
|
|
14
|
+
# Per-number routing override inside OrderCreateRequest. route is a
|
|
15
|
+
# gateway id on this account or a global route for numbers in this
|
|
16
|
+
# order: 1 USER, 2 T30, 3 VOICE_BRIDGE, 4 DID (default), 5 T38,
|
|
17
|
+
# 6 VOICEML, 8 SDN, 9 MOBILE. The API returns 400 for an unknown route.
|
|
17
18
|
OrderNumberSpec = Data.define(:number, :route) do
|
|
18
19
|
include Request
|
|
19
20
|
end
|
|
@@ -99,13 +100,20 @@ module VoiceTel
|
|
|
99
100
|
extend Base
|
|
100
101
|
end
|
|
101
102
|
|
|
103
|
+
# One row in OrderCreateData.routes β the route each ordered number was
|
|
104
|
+
# placed on (a gateway id or a global route).
|
|
105
|
+
OrderRoute = Data.define(:number, :route) do
|
|
106
|
+
extend Base
|
|
107
|
+
end
|
|
108
|
+
|
|
102
109
|
# Data payload from POST /v2.2/orders. amount_charged is the amount
|
|
103
|
-
# deducted from the account balance.
|
|
104
|
-
|
|
110
|
+
# deducted from the account balance. routes reports the route each
|
|
111
|
+
# ordered number was placed on.
|
|
112
|
+
OrderCreateData = Data.define(:order_id, :amount_charged, :numbers_ordered, :failed, :routes) do
|
|
105
113
|
extend Base
|
|
106
114
|
|
|
107
115
|
def self.nested
|
|
108
|
-
{ failed: OrderFailedEntry }
|
|
116
|
+
{ failed: OrderFailedEntry, routes: OrderRoute }
|
|
109
117
|
end
|
|
110
118
|
end
|
|
111
119
|
|
|
@@ -25,5 +25,32 @@ module VoiceTel
|
|
|
25
25
|
{ lrn: LrnData }
|
|
26
26
|
end
|
|
27
27
|
end
|
|
28
|
+
|
|
29
|
+
# Carrier and line-type details. The wire object keeps the upstream
|
|
30
|
+
# carrier lookup's field names β snake_case, not the API's usual
|
|
31
|
+
# camelCase β so the members are pinned with wire_keys.
|
|
32
|
+
CarrierDetails = Data.define(
|
|
33
|
+
:name, :type, :mobile_country_code, :mobile_network_code, :error_code
|
|
34
|
+
) do
|
|
35
|
+
extend Base
|
|
36
|
+
|
|
37
|
+
def self.wire_keys
|
|
38
|
+
{
|
|
39
|
+
mobile_country_code: "mobile_country_code",
|
|
40
|
+
mobile_network_code: "mobile_network_code",
|
|
41
|
+
error_code: "error_code"
|
|
42
|
+
}
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Data payload from GET /v2.2/carrier/{number}. Billed per lookup at the
|
|
47
|
+
# account's CNAM rate.
|
|
48
|
+
CarrierData = Data.define(:number, :carrier) do
|
|
49
|
+
extend Base
|
|
50
|
+
|
|
51
|
+
def self.nested
|
|
52
|
+
{ carrier: CarrierDetails }
|
|
53
|
+
end
|
|
54
|
+
end
|
|
28
55
|
end
|
|
29
56
|
end
|
|
@@ -5,9 +5,11 @@ require_relative "base"
|
|
|
5
5
|
module VoiceTel
|
|
6
6
|
module Models
|
|
7
7
|
# ------------------------------------------------------------- requests ---
|
|
8
|
-
# Body for POST /v2.2/messages β send an SMS or MMS.
|
|
9
|
-
#
|
|
10
|
-
#
|
|
8
|
+
# Body for POST /v2.2/messages β send an SMS or MMS. text may be omitted
|
|
9
|
+
# for a media-only MMS (max 2048 chars for MMS). subject is deprecated
|
|
10
|
+
# (still accepted). media_urls switches the message type to MMS and must
|
|
11
|
+
# be a non-empty array of http(s) URLs. Note the wire field names
|
|
12
|
+
# fromNumber / toNumber.
|
|
11
13
|
MessageSendRequest = Data.define(
|
|
12
14
|
:from_number, :to_number, :text, :subject, :media_urls
|
|
13
15
|
) do
|
|
@@ -35,11 +37,22 @@ module VoiceTel
|
|
|
35
37
|
# ------------------------------------------------------ response data ---
|
|
36
38
|
# Per-record fields inside MessageRecord. Shape varies by type:
|
|
37
39
|
# sms/mms populate source_number, destination_number, direction, rate,
|
|
38
|
-
# message; dlr populates source_number and
|
|
40
|
+
# message (empty for a media-only MMS); dlr populates source_number and
|
|
41
|
+
# destination_number plus message_text, transaction_guid and (on some
|
|
42
|
+
# multi-part receipts) concatenated_message; mms adds attachments (one
|
|
43
|
+
# object per inbound media file) and subject; outbound sms carries ip,
|
|
44
|
+
# the address the send request came from. transaction_guid keeps the
|
|
45
|
+
# wire's GUID capitalization via wire_keys.
|
|
39
46
|
MessageRecordValue = Data.define(
|
|
40
|
-
:source_number, :destination_number, :direction, :rate, :number, :message
|
|
47
|
+
:source_number, :destination_number, :direction, :rate, :number, :message,
|
|
48
|
+
:message_text, :transaction_guid, :concatenated_message, :attachments,
|
|
49
|
+
:subject, :ip
|
|
41
50
|
) do
|
|
42
51
|
extend Base
|
|
52
|
+
|
|
53
|
+
def self.wire_keys
|
|
54
|
+
{ transaction_guid: "transactionGUID" }
|
|
55
|
+
end
|
|
43
56
|
end
|
|
44
57
|
|
|
45
58
|
# One row in MessageHistoryData.messages. key is a composite range key β
|
|
@@ -5,16 +5,17 @@ require_relative "base"
|
|
|
5
5
|
module VoiceTel
|
|
6
6
|
module Models
|
|
7
7
|
# ------------------------------------------------------------- requests ---
|
|
8
|
-
# Body for POST /v2.2/numbers. route is
|
|
9
|
-
# 2
|
|
10
|
-
# 9 MOBILE.
|
|
8
|
+
# Body for POST /v2.2/numbers. route is a gateway id on this account
|
|
9
|
+
# (GET /v2.2/gateways) or a global route: 1 USER, 2 T30, 3 VOICE_BRIDGE,
|
|
10
|
+
# 4 DID (default), 5 T38, 6 VOICEML, 8 SDN, 9 MOBILE. The API returns
|
|
11
|
+
# 400 for an unknown route.
|
|
11
12
|
NumberAddRequest = Data.define(:number, :route) do
|
|
12
13
|
include Request
|
|
13
14
|
end
|
|
14
15
|
|
|
15
|
-
# Body for PUT /v2.2/numbers/{number}/route. route is
|
|
16
|
-
#
|
|
17
|
-
# 8 SDN, 9 MOBILE.
|
|
16
|
+
# Body for PUT /v2.2/numbers/{number}/route. route is a gateway id on
|
|
17
|
+
# this account or a global route: 1 USER, 2 T30, 3 VOICE_BRIDGE,
|
|
18
|
+
# 4 DID (default), 5 T38, 6 VOICEML, 8 SDN, 9 MOBILE.
|
|
18
19
|
NumberRouteRequest = Data.define(:route) do
|
|
19
20
|
include Request
|
|
20
21
|
end
|
|
@@ -66,12 +67,28 @@ module VoiceTel
|
|
|
66
67
|
end
|
|
67
68
|
|
|
68
69
|
# Body for PATCH /v2.2/numbers/{number} β move to another account. route
|
|
69
|
-
# is
|
|
70
|
-
# 3 VOICE_BRIDGE, 4 DID (default), 5 T38, 6 VOICEML, 8 SDN,
|
|
70
|
+
# is a gateway id on the destination account or a global route: 1 USER,
|
|
71
|
+
# 2 T30, 3 VOICE_BRIDGE, 4 DID (default), 5 T38, 6 VOICEML, 8 SDN,
|
|
72
|
+
# 9 MOBILE.
|
|
71
73
|
NumberMoveRequest = Data.define(:account_id, :route) do
|
|
72
74
|
include Request
|
|
73
75
|
end
|
|
74
76
|
|
|
77
|
+
# Body for PUT /v2.2/numbers/{number}/directory-listing β add or replace
|
|
78
|
+
# the 411 listing. type is "business" (requires name, <=60 chars) or
|
|
79
|
+
# "residence" (requires first_name and last_name, <=30 each); the B / R
|
|
80
|
+
# shorthand is also accepted by the server. city (<=40), state (2-letter
|
|
81
|
+
# US state/territory) and zip (5 digits; ZIP+4 accepted, stored as 5) are
|
|
82
|
+
# required. street_number and street_name come as a pair or not at all;
|
|
83
|
+
# street_suffix and location require street_name. Letters, numbers,
|
|
84
|
+
# spaces and & ' . , # / - are allowed in the text fields.
|
|
85
|
+
DirectoryListingRequest = Data.define(
|
|
86
|
+
:type, :name, :first_name, :last_name, :street_number, :street_name,
|
|
87
|
+
:street_type, :street_suffix, :location, :city, :state, :zip
|
|
88
|
+
) do
|
|
89
|
+
include Request
|
|
90
|
+
end
|
|
91
|
+
|
|
75
92
|
# Body for PATCH /v2.2/numbers/{number}/port-out-pin.
|
|
76
93
|
PortOutPinUpdateRequest = Data.define(:pin) do
|
|
77
94
|
include Request
|
|
@@ -79,9 +96,9 @@ module VoiceTel
|
|
|
79
96
|
|
|
80
97
|
# ------------------------------------------------- entities & data ---
|
|
81
98
|
# Per-number routing / feature state. Returned by GET /v2.2/numbers and
|
|
82
|
-
# GET /v2.2/numbers/{number}. route is
|
|
83
|
-
# 2 T30, 3 VOICE_BRIDGE, 4 DID (default), 5 T38,
|
|
84
|
-
# 9 MOBILE.
|
|
99
|
+
# GET /v2.2/numbers/{number}. route is a gateway id on this account or a
|
|
100
|
+
# global route: 1 USER, 2 T30, 3 VOICE_BRIDGE, 4 DID (default), 5 T38,
|
|
101
|
+
# 6 VOICEML, 8 SDN, 9 MOBILE.
|
|
85
102
|
NumberDetail = Data.define(
|
|
86
103
|
:number, :translated, :route, :gateway, :cnam, :forward, :forward_to, :carrier,
|
|
87
104
|
:sms_enabled, :fax_enabled
|
|
@@ -89,6 +106,17 @@ module VoiceTel
|
|
|
89
106
|
extend Base
|
|
90
107
|
end
|
|
91
108
|
|
|
109
|
+
# A 411 directory listing as published (or, on PUT, as submitted).
|
|
110
|
+
# type is "B" (business β name) or "R" (residence β first_name +
|
|
111
|
+
# last_name); address fields may be empty strings. complex marks a
|
|
112
|
+
# multi-line listing; read-only through the API.
|
|
113
|
+
DirectoryListing = Data.define(
|
|
114
|
+
:type, :name, :first_name, :last_name, :street_number, :street_name,
|
|
115
|
+
:street_type, :street_suffix, :location, :city, :state, :zip, :complex
|
|
116
|
+
) do
|
|
117
|
+
extend Base
|
|
118
|
+
end
|
|
119
|
+
|
|
92
120
|
# The campaign bound to a number, with its CSP-side status.
|
|
93
121
|
CampaignBinding = Data.define(:id, :network, :status, :upstream_cnp_id) do
|
|
94
122
|
extend Base
|
|
@@ -122,9 +150,10 @@ module VoiceTel
|
|
|
122
150
|
end
|
|
123
151
|
end
|
|
124
152
|
|
|
125
|
-
# Data payload from POST /v2.2/numbers. route is the
|
|
126
|
-
#
|
|
127
|
-
# 5 T38, 6 VOICEML, 8 SDN,
|
|
153
|
+
# Data payload from POST /v2.2/numbers. route is the route that was
|
|
154
|
+
# installed: a gateway id on this account or a global route (1 USER,
|
|
155
|
+
# 2 T30, 3 VOICE_BRIDGE, 4 DID (default), 5 T38, 6 VOICEML, 8 SDN,
|
|
156
|
+
# 9 MOBILE).
|
|
128
157
|
NumberAddData = Data.define(:number, :route) do
|
|
129
158
|
extend Base
|
|
130
159
|
end
|
|
@@ -155,16 +184,17 @@ module VoiceTel
|
|
|
155
184
|
extend Base
|
|
156
185
|
end
|
|
157
186
|
|
|
158
|
-
# Data payload from PATCH /v2.2/numbers/{number}. route is the
|
|
159
|
-
#
|
|
160
|
-
# 4 DID (default), 5 T38, 6 VOICEML, 8 SDN, 9 MOBILE.
|
|
187
|
+
# Data payload from PATCH /v2.2/numbers/{number}. route is the route on
|
|
188
|
+
# the destination account: a gateway id or a global route (1 USER, 2 T30,
|
|
189
|
+
# 3 VOICE_BRIDGE, 4 DID (default), 5 T38, 6 VOICEML, 8 SDN, 9 MOBILE).
|
|
161
190
|
NumberMoveData = Data.define(:number, :account_id, :route) do
|
|
162
191
|
extend Base
|
|
163
192
|
end
|
|
164
193
|
|
|
165
194
|
# Data payload from PUT /v2.2/numbers/{number}/route. route echoes the
|
|
166
|
-
# applied
|
|
167
|
-
# (default), 5 T38, 6 VOICEML, 8 SDN,
|
|
195
|
+
# applied route: a gateway id on this account or a global route (1 USER,
|
|
196
|
+
# 2 T30, 3 VOICE_BRIDGE, 4 DID (default), 5 T38, 6 VOICEML, 8 SDN,
|
|
197
|
+
# 9 MOBILE).
|
|
168
198
|
NumberRouteData = Data.define(:number, :route) do
|
|
169
199
|
extend Base
|
|
170
200
|
end
|
|
@@ -286,5 +316,24 @@ module VoiceTel
|
|
|
286
316
|
PortOutPinUpdateData = Data.define(:number, :port_out_pin, :changed) do
|
|
287
317
|
extend Base
|
|
288
318
|
end
|
|
319
|
+
|
|
320
|
+
# Data payload from GET/PUT/DELETE /v2.2/numbers/{number}/directory-listing.
|
|
321
|
+
#
|
|
322
|
+
# PUT and DELETE are accepted (202) and applied in the background:
|
|
323
|
+
# status is "pending" / "removing" (or "not_listed" when a pending add
|
|
324
|
+
# was cancelled β order_id absent) and order_id carries the carrier order
|
|
325
|
+
# reference. GET reports the state as published: status is one of
|
|
326
|
+
# "listed", "not_listed", "pending", "removing", "unavailable"; eligible
|
|
327
|
+
# tells whether a listing can be added; listing is the published listing
|
|
328
|
+
# and pending a submitted listing not yet published (nil when none).
|
|
329
|
+
DirectoryListingData = Data.define(
|
|
330
|
+
:number, :status, :eligible, :listing, :pending, :order_id
|
|
331
|
+
) do
|
|
332
|
+
extend Base
|
|
333
|
+
|
|
334
|
+
def self.nested
|
|
335
|
+
{ listing: DirectoryListing, pending: DirectoryListing }
|
|
336
|
+
end
|
|
337
|
+
end
|
|
289
338
|
end
|
|
290
339
|
end
|
data/lib/voicetel/models.rb
CHANGED
|
@@ -10,6 +10,7 @@ require_relative "models/account"
|
|
|
10
10
|
require_relative "models/acl"
|
|
11
11
|
require_relative "models/authentication"
|
|
12
12
|
require_relative "models/e911"
|
|
13
|
+
require_relative "models/fax"
|
|
13
14
|
require_relative "models/gateways"
|
|
14
15
|
require_relative "models/i_numbering"
|
|
15
16
|
require_relative "models/lookups"
|
|
@@ -26,15 +26,14 @@ module VoiceTel
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
# DELETE /v2.2/acl β remove CIDR entries. Returns 200 with a body,
|
|
29
|
-
# not 204.
|
|
30
|
-
#
|
|
29
|
+
# not 204. Since the server's v2.2.0 rewrite the handler reads the
|
|
30
|
+
# same JSON body as add β { acl: [{ cidr: "..." }]} β and the old
|
|
31
|
+
# `cidrs` query parameter is no longer read.
|
|
31
32
|
#
|
|
32
|
-
# @param
|
|
33
|
-
# ["203.0.113.0/24", "203.0.113.1/32"]) or a comma-separated string
|
|
33
|
+
# @param body [Hash, Models::AclModifyRequest] entries to remove
|
|
34
34
|
# @return [Models::AclRemoveData]
|
|
35
|
-
def remove(
|
|
36
|
-
|
|
37
|
-
Models::AclRemoveData.build(@transport.request(:delete, "/v2.2/acl", query: q))
|
|
35
|
+
def remove(body)
|
|
36
|
+
Models::AclRemoveData.build(@transport.request(:delete, "/v2.2/acl", body: payload(body)))
|
|
38
37
|
end
|
|
39
38
|
end
|
|
40
39
|
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "securerandom"
|
|
4
|
+
|
|
5
|
+
require_relative "base"
|
|
6
|
+
|
|
7
|
+
module VoiceTel
|
|
8
|
+
module Resources
|
|
9
|
+
# Fax β sends faxes from the account's fax-capable numbers and reads
|
|
10
|
+
# their job history and rendered documents.
|
|
11
|
+
#
|
|
12
|
+
# send_fax posts a multipart form and is idempotent per the
|
|
13
|
+
# client-generated UUID Idempotency-Key: resubmitting the same
|
|
14
|
+
# documents with the same key returns the original job instead of
|
|
15
|
+
# sending twice. Limited to 10 sends per minute per account.
|
|
16
|
+
class Fax < Base
|
|
17
|
+
# Extension β MIME type for the accepted fax document types
|
|
18
|
+
# (PDF/DOC/DOCX; the server checks content, not extension).
|
|
19
|
+
CONTENT_TYPES = {
|
|
20
|
+
"pdf" => "application/pdf",
|
|
21
|
+
"doc" => "application/msword",
|
|
22
|
+
"docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
23
|
+
}.freeze
|
|
24
|
+
|
|
25
|
+
# GET /v2.2/numbers/fax β every fax-capable number on the account,
|
|
26
|
+
# with the email address faxes to each number deliver to
|
|
27
|
+
# (destination_id 0 = the account email).
|
|
28
|
+
#
|
|
29
|
+
# @return [Models::FaxNumbersData]
|
|
30
|
+
def numbers
|
|
31
|
+
Models::FaxNumbersData.build(@transport.request(:get, "/v2.2/numbers/fax"))
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# POST /v2.2/faxes β submit a fax for delivery (HTTP 201, queued).
|
|
35
|
+
#
|
|
36
|
+
# @param from_number [String] fax number on this account, 10 digits
|
|
37
|
+
# @param to_number [String] US/CA destination, 10 digits
|
|
38
|
+
# @param documents [Array<Hash, String>] one to ten documents β each
|
|
39
|
+
# either a part Hash ({ name:, content: raw bytes, content_type:
|
|
40
|
+
# optional β guessed from the name when omitted }) or a bare file
|
|
41
|
+
# path
|
|
42
|
+
# @param idempotency_key [String, nil] client-generated UUID; a fresh
|
|
43
|
+
# one is generated when omitted. Pass the same key with the same
|
|
44
|
+
# documents to get the original job back instead of a second send.
|
|
45
|
+
# @return [Models::FaxSendData]
|
|
46
|
+
def send_fax(from_number:, to_number:, documents:, idempotency_key: nil)
|
|
47
|
+
Models::FaxSendData.build(@transport.request(
|
|
48
|
+
:post, "/v2.2/faxes",
|
|
49
|
+
multipart: {
|
|
50
|
+
fields: { "fromNumber" => from_number, "toNumber" => to_number },
|
|
51
|
+
files: documents.map { |document| document_part(document) }
|
|
52
|
+
},
|
|
53
|
+
idempotency_key: idempotency_key || SecureRandom.uuid
|
|
54
|
+
))
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# GET /v2.2/faxes β history for one fax number, newest first.
|
|
58
|
+
#
|
|
59
|
+
# @param number [String] a fax number on the account (required)
|
|
60
|
+
# @param from [Integer, nil] newer edge of the range, unix seconds (defaults to now)
|
|
61
|
+
# @param to [Integer, nil] older edge of the range, unix seconds (defaults to 24h ago)
|
|
62
|
+
# @param limit [Integer, nil] page size, 1..100 (defaults to 50)
|
|
63
|
+
# @param cursor [String, nil] paging cursor from a previous next_cursor
|
|
64
|
+
# @param status [String, nil] all|active|queued|sending|retry_pending|sent|failed
|
|
65
|
+
# @return [Models::FaxHistoryData]
|
|
66
|
+
def history(number:, from: nil, to: nil, limit: nil, cursor: nil, status: nil)
|
|
67
|
+
q = compact_query(
|
|
68
|
+
"number" => number,
|
|
69
|
+
"from" => from,
|
|
70
|
+
"to" => to,
|
|
71
|
+
"limit" => limit,
|
|
72
|
+
"cursor" => cursor,
|
|
73
|
+
"status" => status
|
|
74
|
+
)
|
|
75
|
+
Models::FaxHistoryData.build(@transport.request(:get, "/v2.2/faxes", query: q))
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# GET /v2.2/faxes/{id} β one fax job. Poll until status is "sent" or
|
|
79
|
+
# "failed".
|
|
80
|
+
#
|
|
81
|
+
# @return [Models::FaxJob]
|
|
82
|
+
def get(id)
|
|
83
|
+
Models::FaxJob.build(@transport.request(:get, "/v2.2/faxes/#{escape_path(id)}"))
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# GET /v2.2/faxes/{id}/document β the rendered PDF as raw bytes
|
|
87
|
+
# (binary response, not parsed). Served when the job reports
|
|
88
|
+
# document_available true; 404 otherwise.
|
|
89
|
+
#
|
|
90
|
+
# @return [String]
|
|
91
|
+
def document(id)
|
|
92
|
+
@transport.request(:get, "/v2.2/faxes/#{escape_path(id)}/document", raw: true)
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
private
|
|
96
|
+
|
|
97
|
+
# Normalize one documents argument into a multipart file part.
|
|
98
|
+
def document_part(document)
|
|
99
|
+
document = { name: File.basename(document), content: File.binread(document) } if document.is_a?(String)
|
|
100
|
+
ext = File.extname(document[:name].to_s).delete_prefix(".").downcase
|
|
101
|
+
{
|
|
102
|
+
name: "documents",
|
|
103
|
+
filename: document[:name],
|
|
104
|
+
content: document[:content],
|
|
105
|
+
content_type: document[:content_type] || CONTENT_TYPES.fetch(ext, "application/octet-stream")
|
|
106
|
+
}
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
@@ -4,7 +4,7 @@ require_relative "base"
|
|
|
4
4
|
|
|
5
5
|
module VoiceTel
|
|
6
6
|
module Resources
|
|
7
|
-
# LookupsService β CNAM and LRN dips.
|
|
7
|
+
# LookupsService β CNAM, carrier & line-type, and LRN dips.
|
|
8
8
|
#
|
|
9
9
|
# Each call costs money; meter accordingly.
|
|
10
10
|
class Lookups < Base
|
|
@@ -15,6 +15,16 @@ module VoiceTel
|
|
|
15
15
|
Models::CnamData.build(@transport.request(:get, "/v2.2/cnam/#{escape_path(number)}"))
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
+
# GET /v2.2/carrier/{number} β carrier and line-type dip. Billed per
|
|
19
|
+
# lookup at the account's CNAM rate. The carrier object keeps the
|
|
20
|
+
# upstream lookup's snake_case field names
|
|
21
|
+
# (mobile_country_code / mobile_network_code / error_code).
|
|
22
|
+
#
|
|
23
|
+
# @return [Models::CarrierData]
|
|
24
|
+
def carrier(number)
|
|
25
|
+
Models::CarrierData.build(@transport.request(:get, "/v2.2/carrier/#{escape_path(number)}"))
|
|
26
|
+
end
|
|
27
|
+
|
|
18
28
|
# GET /v2.2/lrn/{number}/{ani} β LRN dip.
|
|
19
29
|
#
|
|
20
30
|
# @return [Models::LrnLookupData]
|
|
@@ -7,10 +7,12 @@ module VoiceTel
|
|
|
7
7
|
# NumbersService β every operation on a TN owned by the account.
|
|
8
8
|
#
|
|
9
9
|
# Most methods take the 10-digit TN as the first argument. Methods that
|
|
10
|
-
# return 204 No Content return nil. The
|
|
11
|
-
#
|
|
12
|
-
# DELETE /v2.2/numbers/messaging-campaign
|
|
13
|
-
#
|
|
10
|
+
# return 204 No Content return nil. The exceptions in this resource β
|
|
11
|
+
# DELETE /v2.2/numbers/{n}/messaging-campaign and
|
|
12
|
+
# DELETE /v2.2/numbers/messaging-campaign (200 with a body) and
|
|
13
|
+
# DELETE /v2.2/numbers/{n}/directory-listing (202, applied in the
|
|
14
|
+
# background) β return a body and are exposed via #unassign_campaign,
|
|
15
|
+
# #bulk_unassign_campaign and #remove_directory_listing.
|
|
14
16
|
class Numbers < Base
|
|
15
17
|
# GET /v2.2/numbers β every TN on the account.
|
|
16
18
|
#
|
|
@@ -215,6 +217,42 @@ module VoiceTel
|
|
|
215
217
|
@transport.request(:patch, "/v2.2/numbers/#{escape_path(number)}/port-out-pin", body: payload(body))
|
|
216
218
|
)
|
|
217
219
|
end
|
|
220
|
+
|
|
221
|
+
# GET /v2.2/numbers/{number}/directory-listing β the 411 listing
|
|
222
|
+
# state as published: status (listed / not_listed / pending /
|
|
223
|
+
# removing / unavailable), eligible, the published listing and any
|
|
224
|
+
# pending submission.
|
|
225
|
+
#
|
|
226
|
+
# @return [Models::DirectoryListingData]
|
|
227
|
+
def get_directory_listing(number)
|
|
228
|
+
Models::DirectoryListingData.build(
|
|
229
|
+
@transport.request(:get, "/v2.2/numbers/#{escape_path(number)}/directory-listing")
|
|
230
|
+
)
|
|
231
|
+
end
|
|
232
|
+
|
|
233
|
+
# PUT /v2.2/numbers/{number}/directory-listing β add or replace the
|
|
234
|
+
# 411 listing. Accepted at once and applied in the background: returns
|
|
235
|
+
# HTTP 202 with status "pending" and the carrier order reference in
|
|
236
|
+
# order_id; poll #get_directory_listing until it settles.
|
|
237
|
+
#
|
|
238
|
+
# @return [Models::DirectoryListingData]
|
|
239
|
+
def set_directory_listing(number, body)
|
|
240
|
+
Models::DirectoryListingData.build(
|
|
241
|
+
@transport.request(:put, "/v2.2/numbers/#{escape_path(number)}/directory-listing", body: payload(body))
|
|
242
|
+
)
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
# DELETE /v2.2/numbers/{number}/directory-listing β remove the
|
|
246
|
+
# published listing, or cancel a pending add. Returns 202 with a body
|
|
247
|
+
# (status "removing" with an order_id, or "not_listed" when a pending
|
|
248
|
+
# add was cancelled), not 204.
|
|
249
|
+
#
|
|
250
|
+
# @return [Models::DirectoryListingData]
|
|
251
|
+
def remove_directory_listing(number)
|
|
252
|
+
Models::DirectoryListingData.build(
|
|
253
|
+
@transport.request(:delete, "/v2.2/numbers/#{escape_path(number)}/directory-listing")
|
|
254
|
+
)
|
|
255
|
+
end
|
|
218
256
|
end
|
|
219
257
|
end
|
|
220
258
|
end
|
data/lib/voicetel/version.rb
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
module VoiceTel
|
|
4
4
|
# The semantic version of the VoiceTel Ruby SDK. This tracks the API version
|
|
5
|
-
# it targets (currently v2.2.
|
|
6
|
-
VERSION = "2.2.
|
|
5
|
+
# it targets (currently v2.2.21).
|
|
6
|
+
VERSION = "2.2.21"
|
|
7
7
|
|
|
8
8
|
# The VoiceTel REST API version this SDK targets.
|
|
9
|
-
API_VERSION = "v2.2.
|
|
9
|
+
API_VERSION = "v2.2.21"
|
|
10
10
|
|
|
11
11
|
# Default production API endpoint.
|
|
12
12
|
DEFAULT_BASE_URL = "https://api.voicetel.com"
|
data/lib/voicetel.rb
CHANGED
|
@@ -8,6 +8,7 @@ require_relative "voicetel/resources/account"
|
|
|
8
8
|
require_relative "voicetel/resources/acl"
|
|
9
9
|
require_relative "voicetel/resources/authentication"
|
|
10
10
|
require_relative "voicetel/resources/e911"
|
|
11
|
+
require_relative "voicetel/resources/fax"
|
|
11
12
|
require_relative "voicetel/resources/gateways"
|
|
12
13
|
require_relative "voicetel/resources/i_numbering"
|
|
13
14
|
require_relative "voicetel/resources/lookups"
|
|
@@ -98,6 +99,10 @@ module VoiceTel
|
|
|
98
99
|
@e911 ||= Resources::E911.new(@transport)
|
|
99
100
|
end
|
|
100
101
|
|
|
102
|
+
def fax
|
|
103
|
+
@fax ||= Resources::Fax.new(@transport)
|
|
104
|
+
end
|
|
105
|
+
|
|
101
106
|
def gateways
|
|
102
107
|
@gateways ||= Resources::Gateways.new(@transport)
|
|
103
108
|
end
|
data/sig/voicetel.rbs
CHANGED
|
@@ -24,9 +24,11 @@ module VoiceTel
|
|
|
24
24
|
|
|
25
25
|
def bad_request?: () -> bool
|
|
26
26
|
def authentication?: () -> bool
|
|
27
|
+
def insufficient_balance?: () -> bool
|
|
27
28
|
def permission_denied?: () -> bool
|
|
28
29
|
def not_found?: () -> bool
|
|
29
30
|
def conflict?: () -> bool
|
|
31
|
+
def payload_too_large?: () -> bool
|
|
30
32
|
def rate_limit?: () -> bool
|
|
31
33
|
def server?: () -> bool
|
|
32
34
|
def unknown?: () -> bool
|
|
@@ -352,8 +354,8 @@ module VoiceTel
|
|
|
352
354
|
|
|
353
355
|
class E911ProvisionByIdRequest
|
|
354
356
|
attr_reader callername: String
|
|
355
|
-
attr_reader addressid:
|
|
356
|
-
def initialize: (callername: String, addressid:
|
|
357
|
+
attr_reader addressid: String
|
|
358
|
+
def initialize: (callername: String, addressid: String) -> void
|
|
357
359
|
def to_payload: () -> Hash[Symbol, untyped]
|
|
358
360
|
end
|
|
359
361
|
|
|
@@ -369,7 +371,7 @@ module VoiceTel
|
|
|
369
371
|
end
|
|
370
372
|
|
|
371
373
|
class E911ValidatedAddress
|
|
372
|
-
attr_reader addressid:
|
|
374
|
+
attr_reader addressid: String
|
|
373
375
|
attr_reader address1: String
|
|
374
376
|
attr_reader address2: String?
|
|
375
377
|
attr_reader city: String
|
|
@@ -393,6 +395,63 @@ module VoiceTel
|
|
|
393
395
|
def self.build: (untyped payload) -> E911ValidateData?
|
|
394
396
|
end
|
|
395
397
|
|
|
398
|
+
# ---- fax ----
|
|
399
|
+
|
|
400
|
+
class FaxNumberEntry
|
|
401
|
+
attr_reader number: String?
|
|
402
|
+
attr_reader destination_id: Integer?
|
|
403
|
+
attr_reader email: String?
|
|
404
|
+
def self.build: (untyped payload) -> FaxNumberEntry?
|
|
405
|
+
end
|
|
406
|
+
|
|
407
|
+
class FaxNumbersData
|
|
408
|
+
attr_reader numbers: Array[FaxNumberEntry]
|
|
409
|
+
def self.build: (untyped payload) -> FaxNumbersData?
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
class FaxDocumentMeta
|
|
413
|
+
attr_reader name: String?
|
|
414
|
+
attr_reader size: Integer?
|
|
415
|
+
attr_reader content_type: String?
|
|
416
|
+
def self.build: (untyped payload) -> FaxDocumentMeta?
|
|
417
|
+
end
|
|
418
|
+
|
|
419
|
+
class FaxSendData
|
|
420
|
+
attr_reader id: String?
|
|
421
|
+
attr_reader from_number: String?
|
|
422
|
+
attr_reader to_number: String?
|
|
423
|
+
attr_reader status: String?
|
|
424
|
+
attr_reader documents: Array[FaxDocumentMeta]
|
|
425
|
+
def self.build: (untyped payload) -> FaxSendData?
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
class FaxJob
|
|
429
|
+
attr_reader id: String?
|
|
430
|
+
attr_reader from_number: String?
|
|
431
|
+
attr_reader to_number: String?
|
|
432
|
+
attr_reader client_token: String?
|
|
433
|
+
attr_reader status: String?
|
|
434
|
+
attr_reader submitted_at: String?
|
|
435
|
+
attr_reader started_at: String?
|
|
436
|
+
attr_reader completed_at: String?
|
|
437
|
+
attr_reader attempts: Integer?
|
|
438
|
+
attr_reader failure_reason: String?
|
|
439
|
+
attr_reader documents: Array[FaxDocumentMeta]
|
|
440
|
+
attr_reader document_available: bool?
|
|
441
|
+
attr_reader document_name: String?
|
|
442
|
+
attr_reader document_size: Integer?
|
|
443
|
+
def self.build: (untyped payload) -> FaxJob?
|
|
444
|
+
end
|
|
445
|
+
|
|
446
|
+
class FaxHistoryData
|
|
447
|
+
attr_reader number: String?
|
|
448
|
+
attr_reader from_ts: Integer?
|
|
449
|
+
attr_reader to_ts: Integer?
|
|
450
|
+
attr_reader faxes: Array[FaxJob]
|
|
451
|
+
attr_reader next_cursor: String?
|
|
452
|
+
def self.build: (untyped payload) -> FaxHistoryData?
|
|
453
|
+
end
|
|
454
|
+
|
|
396
455
|
# ---- gateways ----
|
|
397
456
|
|
|
398
457
|
class GatewayAddRequest
|
|
@@ -583,9 +642,16 @@ module VoiceTel
|
|
|
583
642
|
attr_reader amount_charged: Float
|
|
584
643
|
attr_reader numbers_ordered: Array[String]
|
|
585
644
|
attr_reader failed: Array[OrderFailedEntry]
|
|
645
|
+
attr_reader routes: Array[OrderRoute]
|
|
586
646
|
def self.build: (untyped payload) -> OrderCreateData?
|
|
587
647
|
end
|
|
588
648
|
|
|
649
|
+
class OrderRoute
|
|
650
|
+
attr_reader number: String
|
|
651
|
+
attr_reader route: Integer
|
|
652
|
+
def self.build: (untyped payload) -> OrderRoute?
|
|
653
|
+
end
|
|
654
|
+
|
|
589
655
|
class PortListData
|
|
590
656
|
attr_reader ports: Array[PortSummary]
|
|
591
657
|
def self.build: (untyped payload) -> PortListData?
|
|
@@ -644,15 +710,30 @@ module VoiceTel
|
|
|
644
710
|
def self.build: (untyped payload) -> LrnLookupData?
|
|
645
711
|
end
|
|
646
712
|
|
|
713
|
+
class CarrierDetails
|
|
714
|
+
attr_reader name: String?
|
|
715
|
+
attr_reader type: String?
|
|
716
|
+
attr_reader mobile_country_code: String?
|
|
717
|
+
attr_reader mobile_network_code: String?
|
|
718
|
+
attr_reader error_code: Integer?
|
|
719
|
+
def self.build: (untyped payload) -> CarrierDetails?
|
|
720
|
+
end
|
|
721
|
+
|
|
722
|
+
class CarrierData
|
|
723
|
+
attr_reader number: String
|
|
724
|
+
attr_reader carrier: CarrierDetails
|
|
725
|
+
def self.build: (untyped payload) -> CarrierData?
|
|
726
|
+
end
|
|
727
|
+
|
|
647
728
|
# ---- messaging ----
|
|
648
729
|
|
|
649
730
|
class MessageSendRequest
|
|
650
731
|
attr_reader from_number: String
|
|
651
732
|
attr_reader to_number: String
|
|
652
|
-
attr_reader text: String
|
|
733
|
+
attr_reader text: String?
|
|
653
734
|
attr_reader subject: String?
|
|
654
735
|
attr_reader media_urls: Array[String]?
|
|
655
|
-
def initialize: (from_number: String, to_number: String, text: String
|
|
736
|
+
def initialize: (from_number: String, to_number: String, text: String?, subject: String?,
|
|
656
737
|
media_urls: Array[String]?) -> void
|
|
657
738
|
def to_payload: () -> Hash[Symbol, untyped]
|
|
658
739
|
end
|
|
@@ -684,6 +765,12 @@ module VoiceTel
|
|
|
684
765
|
attr_reader rate: String?
|
|
685
766
|
attr_reader number: String?
|
|
686
767
|
attr_reader message: String?
|
|
768
|
+
attr_reader message_text: String?
|
|
769
|
+
attr_reader transaction_guid: String?
|
|
770
|
+
attr_reader concatenated_message: String?
|
|
771
|
+
attr_reader attachments: Array[Hash[untyped, untyped]]?
|
|
772
|
+
attr_reader subject: String?
|
|
773
|
+
attr_reader ip: String?
|
|
687
774
|
def self.build: (untyped payload) -> MessageRecordValue?
|
|
688
775
|
end
|
|
689
776
|
|
|
@@ -1009,6 +1096,53 @@ module VoiceTel
|
|
|
1009
1096
|
def self.build: (untyped payload) -> PortOutPinUpdateData?
|
|
1010
1097
|
end
|
|
1011
1098
|
|
|
1099
|
+
class DirectoryListingRequest
|
|
1100
|
+
attr_reader type: String
|
|
1101
|
+
attr_reader name: String?
|
|
1102
|
+
attr_reader first_name: String?
|
|
1103
|
+
attr_reader last_name: String?
|
|
1104
|
+
attr_reader street_number: String?
|
|
1105
|
+
attr_reader street_name: String?
|
|
1106
|
+
attr_reader street_type: String?
|
|
1107
|
+
attr_reader street_suffix: String?
|
|
1108
|
+
attr_reader location: String?
|
|
1109
|
+
attr_reader city: String
|
|
1110
|
+
attr_reader state: String
|
|
1111
|
+
attr_reader zip: String
|
|
1112
|
+
def initialize: (type: String, name: String?, first_name: String?, last_name: String?,
|
|
1113
|
+
street_number: String?, street_name: String?, street_type: String?,
|
|
1114
|
+
street_suffix: String?, location: String?, city: String, state: String,
|
|
1115
|
+
zip: String) -> void
|
|
1116
|
+
def to_payload: () -> Hash[Symbol, untyped]
|
|
1117
|
+
end
|
|
1118
|
+
|
|
1119
|
+
class DirectoryListing
|
|
1120
|
+
attr_reader type: String
|
|
1121
|
+
attr_reader name: String?
|
|
1122
|
+
attr_reader first_name: String?
|
|
1123
|
+
attr_reader last_name: String?
|
|
1124
|
+
attr_reader street_number: String?
|
|
1125
|
+
attr_reader street_name: String?
|
|
1126
|
+
attr_reader street_type: String?
|
|
1127
|
+
attr_reader street_suffix: String?
|
|
1128
|
+
attr_reader location: String?
|
|
1129
|
+
attr_reader city: String?
|
|
1130
|
+
attr_reader state: String?
|
|
1131
|
+
attr_reader zip: String?
|
|
1132
|
+
attr_reader complex: bool?
|
|
1133
|
+
def self.build: (untyped payload) -> DirectoryListing?
|
|
1134
|
+
end
|
|
1135
|
+
|
|
1136
|
+
class DirectoryListingData
|
|
1137
|
+
attr_reader number: String
|
|
1138
|
+
attr_reader status: String
|
|
1139
|
+
attr_reader eligible: bool?
|
|
1140
|
+
attr_reader listing: DirectoryListing?
|
|
1141
|
+
attr_reader pending: DirectoryListing?
|
|
1142
|
+
attr_reader order_id: String?
|
|
1143
|
+
def self.build: (untyped payload) -> DirectoryListingData?
|
|
1144
|
+
end
|
|
1145
|
+
|
|
1012
1146
|
# ---- support ----
|
|
1013
1147
|
|
|
1014
1148
|
class TicketCreateRequest
|
|
@@ -1230,7 +1364,8 @@ module VoiceTel
|
|
|
1230
1364
|
|
|
1231
1365
|
def request: (
|
|
1232
1366
|
Symbol method, String path,
|
|
1233
|
-
?query: Hash[untyped, untyped]?, ?body: untyped, ?require_auth: bool
|
|
1367
|
+
?query: Hash[untyped, untyped]?, ?body: untyped, ?require_auth: bool,
|
|
1368
|
+
?multipart: Hash[untyped, untyped]?, ?idempotency_key: String?, ?raw: bool
|
|
1234
1369
|
) -> untyped
|
|
1235
1370
|
|
|
1236
1371
|
def camelize_keys: (untyped) -> untyped
|
|
@@ -1261,7 +1396,7 @@ module VoiceTel
|
|
|
1261
1396
|
class Acl < Base
|
|
1262
1397
|
def list: () -> Models::AclListData
|
|
1263
1398
|
def add: (untyped body) -> Models::AclAddData
|
|
1264
|
-
def remove: (
|
|
1399
|
+
def remove: (untyped body) -> Models::AclRemoveData
|
|
1265
1400
|
end
|
|
1266
1401
|
|
|
1267
1402
|
class Authentication < Base
|
|
@@ -1283,6 +1418,24 @@ module VoiceTel
|
|
|
1283
1418
|
def remove: (String dn) -> nil
|
|
1284
1419
|
end
|
|
1285
1420
|
|
|
1421
|
+
class Fax < Base
|
|
1422
|
+
CONTENT_TYPES: Hash[String, String]
|
|
1423
|
+
|
|
1424
|
+
def numbers: () -> Models::FaxNumbersData
|
|
1425
|
+
def send_fax: (
|
|
1426
|
+
from_number: String, to_number: String,
|
|
1427
|
+
documents: Array[Hash[untyped, untyped] | String],
|
|
1428
|
+
?idempotency_key: String?
|
|
1429
|
+
) -> Models::FaxSendData
|
|
1430
|
+
def history: (
|
|
1431
|
+
number: String,
|
|
1432
|
+
?from: Integer?, ?to: Integer?, ?limit: Integer?,
|
|
1433
|
+
?cursor: String?, ?status: String?
|
|
1434
|
+
) -> Models::FaxHistoryData
|
|
1435
|
+
def get: (String id) -> Models::FaxJob
|
|
1436
|
+
def document: (String id) -> String
|
|
1437
|
+
end
|
|
1438
|
+
|
|
1286
1439
|
class Gateways < Base
|
|
1287
1440
|
def list: () -> Models::GatewaysListData
|
|
1288
1441
|
def add: (untyped body) -> Models::GatewayEntry
|
|
@@ -1310,6 +1463,7 @@ module VoiceTel
|
|
|
1310
1463
|
|
|
1311
1464
|
class Lookups < Base
|
|
1312
1465
|
def cnam: (String number) -> Models::CnamData
|
|
1466
|
+
def carrier: (String number) -> Models::CarrierData
|
|
1313
1467
|
def lrn: (String number, String ani) -> Models::LrnLookupData
|
|
1314
1468
|
end
|
|
1315
1469
|
|
|
@@ -1347,6 +1501,9 @@ module VoiceTel
|
|
|
1347
1501
|
def unassign_campaign: (String number, campaign_id: String) -> Models::NumberMessagingCampaignUnassignData
|
|
1348
1502
|
def bulk_unassign_campaign: (numbers: Array[String], campaign_id: String) -> Models::NumbersMessagingCampaignUnassignData
|
|
1349
1503
|
def set_port_out_pin: (String number, untyped body) -> Models::PortOutPinUpdateData
|
|
1504
|
+
def get_directory_listing: (String number) -> Models::DirectoryListingData
|
|
1505
|
+
def set_directory_listing: (String number, untyped body) -> Models::DirectoryListingData
|
|
1506
|
+
def remove_directory_listing: (String number) -> Models::DirectoryListingData
|
|
1350
1507
|
end
|
|
1351
1508
|
|
|
1352
1509
|
class Support < Base
|
|
@@ -1376,6 +1533,7 @@ module VoiceTel
|
|
|
1376
1533
|
def acl: () -> Resources::Acl
|
|
1377
1534
|
def authentication: () -> Resources::Authentication
|
|
1378
1535
|
def e911: () -> Resources::E911
|
|
1536
|
+
def fax: () -> Resources::Fax
|
|
1379
1537
|
def gateways: () -> Resources::Gateways
|
|
1380
1538
|
def i_numbering: () -> Resources::INumbering
|
|
1381
1539
|
def lookups: () -> Resources::Lookups
|
data/voicetel.gemspec
CHANGED
|
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.authors = ["VoiceTel"]
|
|
9
9
|
spec.email = ["support@voicetel.com"]
|
|
10
10
|
|
|
11
|
-
spec.summary = "Official Ruby SDK for the VoiceTel REST API (v2.2.
|
|
11
|
+
spec.summary = "Official Ruby SDK for the VoiceTel REST API (v2.2.21)."
|
|
12
12
|
spec.description = "Idiomatic Ruby client for the VoiceTel REST API: provision numbers, " \
|
|
13
13
|
"place orders, validate e911, send SMS/MMS, manage 10DLC campaigns, and " \
|
|
14
14
|
"run support tickets, all with typed Data models, structured errors, and " \
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: voicetel
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.2.
|
|
4
|
+
version: 2.2.21
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- VoiceTel
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-11-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -73,6 +73,7 @@ files:
|
|
|
73
73
|
- lib/voicetel/models/base.rb
|
|
74
74
|
- lib/voicetel/models/common.rb
|
|
75
75
|
- lib/voicetel/models/e911.rb
|
|
76
|
+
- lib/voicetel/models/fax.rb
|
|
76
77
|
- lib/voicetel/models/gateways.rb
|
|
77
78
|
- lib/voicetel/models/i_numbering.rb
|
|
78
79
|
- lib/voicetel/models/lookups.rb
|
|
@@ -84,6 +85,7 @@ files:
|
|
|
84
85
|
- lib/voicetel/resources/authentication.rb
|
|
85
86
|
- lib/voicetel/resources/base.rb
|
|
86
87
|
- lib/voicetel/resources/e911.rb
|
|
88
|
+
- lib/voicetel/resources/fax.rb
|
|
87
89
|
- lib/voicetel/resources/gateways.rb
|
|
88
90
|
- lib/voicetel/resources/i_numbering.rb
|
|
89
91
|
- lib/voicetel/resources/lookups.rb
|
|
@@ -121,5 +123,5 @@ requirements: []
|
|
|
121
123
|
rubygems_version: 3.4.19
|
|
122
124
|
signing_key:
|
|
123
125
|
specification_version: 4
|
|
124
|
-
summary: Official Ruby SDK for the VoiceTel REST API (v2.2.
|
|
126
|
+
summary: Official Ruby SDK for the VoiceTel REST API (v2.2.21).
|
|
125
127
|
test_files: []
|