didww-v3 6.2.0 → 7.0.0
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/.github/workflows/tests.yml +8 -6
- data/.rubocop.yml +0 -110
- data/CHANGELOG.md +65 -0
- data/FILTERS.md +36 -12
- data/Gemfile +0 -2
- data/README.md +431 -58
- data/didww-v3.gemspec +11 -8
- data/docs/resource_relationships.md +35 -15
- data/examples/README.md +54 -61
- data/examples/capacity_pools.rb +28 -10
- data/examples/countries.rb +1 -1
- data/examples/did_groups.rb +1 -1
- data/examples/did_reservations.rb +35 -37
- data/examples/did_sms_routing.rb +91 -0
- data/examples/did_trunk_assignment.rb +106 -80
- data/examples/emergency_calling_services.rb +3 -3
- data/examples/emergency_requirements.rb +3 -3
- data/examples/emergency_scenario.rb +11 -11
- data/examples/emergency_verifications.rb +7 -5
- data/examples/exports.rb +1 -1
- data/examples/exports_sms.rb +72 -0
- data/examples/identity_address_proofs.rb +118 -0
- data/examples/includes.rb +65 -0
- data/examples/orders.rb +8 -6
- data/examples/orders_all_item_types.rb +63 -125
- data/examples/orders_emergency.rb +3 -3
- data/examples/{orders_by_sku.rb → orders_sku.rb} +12 -10
- data/examples/prices_download.rb +45 -0
- data/examples/prices_lookup.rb +43 -0
- data/examples/regions.rb +1 -1
- data/examples/sample.pdf +14 -0
- data/examples/sender_id_verifications.rb +63 -0
- data/examples/shared_capacity_groups.rb +44 -35
- data/examples/sms_trunk_groups.rb +71 -0
- data/examples/sms_trunks.rb +84 -0
- data/examples/test_readme.rb +1216 -0
- data/examples/trunks.rb +115 -0
- data/examples/upload_file.rb +44 -0
- data/examples/voice_in_trunk_groups.rb +57 -33
- data/examples/voice_in_trunk_sip_registration.rb +4 -1
- data/examples/voice_out_trunks.rb +11 -1
- data/examples/webhook.rb +51 -0
- data/lib/didww/auth/bearer_middleware.rb +74 -0
- data/lib/didww/auth/memory_store.rb +40 -0
- data/lib/didww/auth/token.rb +45 -0
- data/lib/didww/auth/token_provider.rb +215 -0
- data/lib/didww/base_middleware.rb +7 -8
- data/lib/didww/callback/request_validator.rb +7 -5
- data/lib/didww/client.rb +122 -13
- data/lib/didww/complex_objects/authentication_methods/generic.rb +6 -0
- data/lib/didww/complex_objects/configurations/base.rb +0 -18
- data/lib/didww/complex_objects/configurations/pstn_configuration.rb +0 -4
- data/lib/didww/complex_objects/configurations/sip_configuration.rb +86 -38
- data/lib/didww/complex_objects/emergency_order_item.rb +1 -1
- data/lib/didww/complex_objects/export_filters.rb +72 -6
- data/lib/didww/complex_objects/generic_order_item.rb +15 -0
- data/lib/didww/complex_objects/sms_trunk_configuration.rb +33 -0
- data/lib/didww/complex_objects/sms_trunk_configurations/base.rb +26 -0
- data/lib/didww/complex_objects/sms_trunk_configurations/generic.rb +32 -0
- data/lib/didww/complex_objects/sms_trunk_configurations/http_in.rb +75 -0
- data/lib/didww/complex_objects/sms_trunk_configurations/http_out.rb +35 -0
- data/lib/didww/complex_objects/sms_trunk_configurations/smpp_esme.rb +37 -0
- data/lib/didww/complex_objects/sms_trunk_configurations/smpp_smsc.rb +56 -0
- data/lib/didww/complex_objects/sms_trunk_configurations/sms_to_email.rb +27 -0
- data/lib/didww/errors.rb +103 -0
- data/lib/didww/http.rb +34 -0
- data/lib/didww/prices/lookup_result.rb +37 -0
- data/lib/didww/prices/price.rb +56 -0
- data/lib/didww/prices/price_file.rb +51 -0
- data/lib/didww/prices/service.rb +248 -0
- data/lib/didww/prices/sms_in_price.rb +43 -0
- data/lib/didww/prices/sms_out_price.rb +52 -0
- data/lib/didww/prices/voice_in_price.rb +48 -0
- data/lib/didww/prices/voice_out_price.rb +88 -0
- data/lib/didww/prices.rb +82 -0
- data/lib/didww/resource/address_requirement.rb +13 -3
- data/lib/didww/resource/base.rb +5 -2
- data/lib/didww/resource/concerns/number_types.rb +24 -0
- data/lib/didww/resource/did.rb +42 -3
- data/lib/didww/resource/did_group.rb +12 -1
- data/lib/didww/resource/emergency_calling_service.rb +10 -5
- data/lib/didww/resource/emergency_requirement.rb +27 -14
- data/lib/didww/resource/encrypted_file.rb +19 -6
- data/lib/didww/resource/export.rb +59 -12
- data/lib/didww/resource/identity.rb +9 -4
- data/lib/didww/resource/order.rb +1 -0
- data/lib/didww/resource/proof_type.rb +1 -1
- data/lib/didww/resource/sender_id_verification.rb +114 -0
- data/lib/didww/resource/sms_trunk.rb +76 -0
- data/lib/didww/resource/sms_trunk_group.rb +31 -0
- data/lib/didww/resource/sms_trunk_regenerate_credential.rb +16 -0
- data/lib/didww/resource/voice_in_trunk.rb +24 -1
- data/lib/didww/resource/voice_out_trunk.rb +72 -0
- data/lib/didww/types/ip_addresses.rb +1 -1
- data/lib/didww/types/strings.rb +1 -1
- data/lib/didww/types.rb +3 -1
- data/lib/didww/version.rb +1 -1
- data/lib/didww.rb +7 -0
- metadata +63 -25
- data/examples/identities_and_proofs.rb +0 -67
- data/examples/voice_in_trunks.rb +0 -108
- data/lib/didww/resource/did_group_type.rb +0 -10
- data/lib/didww/resource/exclusive_relationship.rb +0 -54
- data/lib/didww/resource/pop.rb +0 -10
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: didww-v3
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 7.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alex Korobeinikov
|
|
@@ -30,75 +30,75 @@ dependencies:
|
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
31
|
version: '9'
|
|
32
32
|
- !ruby/object:Gem::Dependency
|
|
33
|
-
name:
|
|
33
|
+
name: csv
|
|
34
34
|
requirement: !ruby/object:Gem::Requirement
|
|
35
35
|
requirements:
|
|
36
36
|
- - "~>"
|
|
37
37
|
- !ruby/object:Gem::Version
|
|
38
|
-
version: '
|
|
38
|
+
version: '3.0'
|
|
39
39
|
type: :runtime
|
|
40
40
|
prerelease: false
|
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
|
42
42
|
requirements:
|
|
43
43
|
- - "~>"
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: '
|
|
45
|
+
version: '3.0'
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
|
-
name: faraday
|
|
47
|
+
name: faraday
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
|
49
49
|
requirements:
|
|
50
50
|
- - "~>"
|
|
51
51
|
- !ruby/object:Gem::Version
|
|
52
|
-
version: '
|
|
52
|
+
version: '2.5'
|
|
53
53
|
type: :runtime
|
|
54
54
|
prerelease: false
|
|
55
55
|
version_requirements: !ruby/object:Gem::Requirement
|
|
56
56
|
requirements:
|
|
57
57
|
- - "~>"
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
|
-
version: '
|
|
59
|
+
version: '2.5'
|
|
60
60
|
- !ruby/object:Gem::Dependency
|
|
61
|
-
name:
|
|
61
|
+
name: faraday-net_http
|
|
62
62
|
requirement: !ruby/object:Gem::Requirement
|
|
63
63
|
requirements:
|
|
64
|
-
- - "
|
|
64
|
+
- - ">="
|
|
65
65
|
- !ruby/object:Gem::Version
|
|
66
|
-
version: '
|
|
66
|
+
version: '3.0'
|
|
67
67
|
type: :runtime
|
|
68
68
|
prerelease: false
|
|
69
69
|
version_requirements: !ruby/object:Gem::Requirement
|
|
70
70
|
requirements:
|
|
71
|
-
- - "
|
|
71
|
+
- - ">="
|
|
72
72
|
- !ruby/object:Gem::Version
|
|
73
|
-
version: '
|
|
73
|
+
version: '3.0'
|
|
74
74
|
- !ruby/object:Gem::Dependency
|
|
75
|
-
name:
|
|
75
|
+
name: faraday-multipart
|
|
76
76
|
requirement: !ruby/object:Gem::Requirement
|
|
77
77
|
requirements:
|
|
78
78
|
- - "~>"
|
|
79
79
|
- !ruby/object:Gem::Version
|
|
80
|
-
version: '
|
|
80
|
+
version: '1.0'
|
|
81
81
|
type: :runtime
|
|
82
82
|
prerelease: false
|
|
83
83
|
version_requirements: !ruby/object:Gem::Requirement
|
|
84
84
|
requirements:
|
|
85
85
|
- - "~>"
|
|
86
86
|
- !ruby/object:Gem::Version
|
|
87
|
-
version: '
|
|
87
|
+
version: '1.0'
|
|
88
88
|
- !ruby/object:Gem::Dependency
|
|
89
|
-
name:
|
|
89
|
+
name: json_api_client
|
|
90
90
|
requirement: !ruby/object:Gem::Requirement
|
|
91
91
|
requirements:
|
|
92
92
|
- - "~>"
|
|
93
93
|
- !ruby/object:Gem::Version
|
|
94
|
-
version: '
|
|
94
|
+
version: '1.23'
|
|
95
95
|
type: :runtime
|
|
96
96
|
prerelease: false
|
|
97
97
|
version_requirements: !ruby/object:Gem::Requirement
|
|
98
98
|
requirements:
|
|
99
99
|
- - "~>"
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
|
-
version: '
|
|
101
|
+
version: '1.23'
|
|
102
102
|
- !ruby/object:Gem::Dependency
|
|
103
103
|
name: openssl-oaep
|
|
104
104
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -146,6 +146,7 @@ files:
|
|
|
146
146
|
- examples/did_groups.rb
|
|
147
147
|
- examples/did_history.rb
|
|
148
148
|
- examples/did_reservations.rb
|
|
149
|
+
- examples/did_sms_routing.rb
|
|
149
150
|
- examples/did_trunk_assignment.rb
|
|
150
151
|
- examples/dids.rb
|
|
151
152
|
- examples/emergency_calling_services.rb
|
|
@@ -154,22 +155,37 @@ files:
|
|
|
154
155
|
- examples/emergency_scenario.rb
|
|
155
156
|
- examples/emergency_verifications.rb
|
|
156
157
|
- examples/exports.rb
|
|
157
|
-
- examples/
|
|
158
|
+
- examples/exports_sms.rb
|
|
159
|
+
- examples/identity_address_proofs.rb
|
|
160
|
+
- examples/includes.rb
|
|
158
161
|
- examples/orders.rb
|
|
159
162
|
- examples/orders_all_item_types.rb
|
|
160
163
|
- examples/orders_available_dids.rb
|
|
161
|
-
- examples/orders_by_sku.rb
|
|
162
164
|
- examples/orders_capacity.rb
|
|
163
165
|
- examples/orders_emergency.rb
|
|
164
166
|
- examples/orders_nanpa.rb
|
|
165
167
|
- examples/orders_reservation_dids.rb
|
|
168
|
+
- examples/orders_sku.rb
|
|
169
|
+
- examples/prices_download.rb
|
|
170
|
+
- examples/prices_lookup.rb
|
|
166
171
|
- examples/regions.rb
|
|
172
|
+
- examples/sample.pdf
|
|
173
|
+
- examples/sender_id_verifications.rb
|
|
167
174
|
- examples/shared_capacity_groups.rb
|
|
175
|
+
- examples/sms_trunk_groups.rb
|
|
176
|
+
- examples/sms_trunks.rb
|
|
177
|
+
- examples/test_readme.rb
|
|
178
|
+
- examples/trunks.rb
|
|
179
|
+
- examples/upload_file.rb
|
|
168
180
|
- examples/voice_in_trunk_groups.rb
|
|
169
181
|
- examples/voice_in_trunk_sip_registration.rb
|
|
170
|
-
- examples/voice_in_trunks.rb
|
|
171
182
|
- examples/voice_out_trunks.rb
|
|
183
|
+
- examples/webhook.rb
|
|
172
184
|
- lib/didww.rb
|
|
185
|
+
- lib/didww/auth/bearer_middleware.rb
|
|
186
|
+
- lib/didww/auth/memory_store.rb
|
|
187
|
+
- lib/didww/auth/token.rb
|
|
188
|
+
- lib/didww/auth/token_provider.rb
|
|
173
189
|
- lib/didww/base_middleware.rb
|
|
174
190
|
- lib/didww/callback/const.rb
|
|
175
191
|
- lib/didww/callback/request_validator.rb
|
|
@@ -189,8 +205,28 @@ files:
|
|
|
189
205
|
- lib/didww/complex_objects/did_order_item.rb
|
|
190
206
|
- lib/didww/complex_objects/emergency_order_item.rb
|
|
191
207
|
- lib/didww/complex_objects/export_filters.rb
|
|
208
|
+
- lib/didww/complex_objects/generic_order_item.rb
|
|
209
|
+
- lib/didww/complex_objects/sms_trunk_configuration.rb
|
|
210
|
+
- lib/didww/complex_objects/sms_trunk_configurations/base.rb
|
|
211
|
+
- lib/didww/complex_objects/sms_trunk_configurations/generic.rb
|
|
212
|
+
- lib/didww/complex_objects/sms_trunk_configurations/http_in.rb
|
|
213
|
+
- lib/didww/complex_objects/sms_trunk_configurations/http_out.rb
|
|
214
|
+
- lib/didww/complex_objects/sms_trunk_configurations/smpp_esme.rb
|
|
215
|
+
- lib/didww/complex_objects/sms_trunk_configurations/smpp_smsc.rb
|
|
216
|
+
- lib/didww/complex_objects/sms_trunk_configurations/sms_to_email.rb
|
|
192
217
|
- lib/didww/encrypt.rb
|
|
218
|
+
- lib/didww/errors.rb
|
|
219
|
+
- lib/didww/http.rb
|
|
193
220
|
- lib/didww/jsonapi_middleware.rb
|
|
221
|
+
- lib/didww/prices.rb
|
|
222
|
+
- lib/didww/prices/lookup_result.rb
|
|
223
|
+
- lib/didww/prices/price.rb
|
|
224
|
+
- lib/didww/prices/price_file.rb
|
|
225
|
+
- lib/didww/prices/service.rb
|
|
226
|
+
- lib/didww/prices/sms_in_price.rb
|
|
227
|
+
- lib/didww/prices/sms_out_price.rb
|
|
228
|
+
- lib/didww/prices/voice_in_price.rb
|
|
229
|
+
- lib/didww/prices/voice_out_price.rb
|
|
194
230
|
- lib/didww/resource/address.rb
|
|
195
231
|
- lib/didww/resource/address_requirement.rb
|
|
196
232
|
- lib/didww/resource/address_requirement_validation.rb
|
|
@@ -202,10 +238,10 @@ files:
|
|
|
202
238
|
- lib/didww/resource/capacity_pool.rb
|
|
203
239
|
- lib/didww/resource/city.rb
|
|
204
240
|
- lib/didww/resource/concerns/has_status_helpers.rb
|
|
241
|
+
- lib/didww/resource/concerns/number_types.rb
|
|
205
242
|
- lib/didww/resource/country.rb
|
|
206
243
|
- lib/didww/resource/did.rb
|
|
207
244
|
- lib/didww/resource/did_group.rb
|
|
208
|
-
- lib/didww/resource/did_group_type.rb
|
|
209
245
|
- lib/didww/resource/did_history.rb
|
|
210
246
|
- lib/didww/resource/did_reservation.rb
|
|
211
247
|
- lib/didww/resource/emergency_calling_service.rb
|
|
@@ -213,19 +249,21 @@ files:
|
|
|
213
249
|
- lib/didww/resource/emergency_requirement_validation.rb
|
|
214
250
|
- lib/didww/resource/emergency_verification.rb
|
|
215
251
|
- lib/didww/resource/encrypted_file.rb
|
|
216
|
-
- lib/didww/resource/exclusive_relationship.rb
|
|
217
252
|
- lib/didww/resource/export.rb
|
|
218
253
|
- lib/didww/resource/identity.rb
|
|
219
254
|
- lib/didww/resource/nanpa_prefix.rb
|
|
220
255
|
- lib/didww/resource/order.rb
|
|
221
256
|
- lib/didww/resource/permanent_supporting_document.rb
|
|
222
|
-
- lib/didww/resource/pop.rb
|
|
223
257
|
- lib/didww/resource/proof.rb
|
|
224
258
|
- lib/didww/resource/proof_type.rb
|
|
225
259
|
- lib/didww/resource/public_key.rb
|
|
226
260
|
- lib/didww/resource/qty_based_pricing.rb
|
|
227
261
|
- lib/didww/resource/region.rb
|
|
262
|
+
- lib/didww/resource/sender_id_verification.rb
|
|
228
263
|
- lib/didww/resource/shared_capacity_group.rb
|
|
264
|
+
- lib/didww/resource/sms_trunk.rb
|
|
265
|
+
- lib/didww/resource/sms_trunk_group.rb
|
|
266
|
+
- lib/didww/resource/sms_trunk_regenerate_credential.rb
|
|
229
267
|
- lib/didww/resource/stock_keeping_unit.rb
|
|
230
268
|
- lib/didww/resource/supporting_document_template.rb
|
|
231
269
|
- lib/didww/resource/voice_in_trunk.rb
|
|
@@ -254,7 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
254
292
|
- !ruby/object:Gem::Version
|
|
255
293
|
version: '0'
|
|
256
294
|
requirements: []
|
|
257
|
-
rubygems_version: 3.
|
|
295
|
+
rubygems_version: 3.6.9
|
|
258
296
|
specification_version: 4
|
|
259
297
|
summary: Ruby client for DIDWW API v3
|
|
260
298
|
test_files: []
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
# Lists identities, addresses, and proofs. Demonstrates compliance workflow.
|
|
3
|
-
#
|
|
4
|
-
# Usage: DIDWW_API_KEY=your_api_key ruby examples/identities_and_proofs.rb
|
|
5
|
-
|
|
6
|
-
require 'bundler/setup'
|
|
7
|
-
require 'didww'
|
|
8
|
-
|
|
9
|
-
DIDWW::Client.configure do |client|
|
|
10
|
-
client.api_key = ENV.fetch('DIDWW_API_KEY') { abort 'Please set DIDWW_API_KEY' }
|
|
11
|
-
client.api_mode = :sandbox
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
# List identities (include country + birth_country, 2026-04-16 adds birth_country)
|
|
15
|
-
puts '=== Identities ==='
|
|
16
|
-
identities = DIDWW::Client.identities
|
|
17
|
-
.includes(:country, :birth_country)
|
|
18
|
-
.all
|
|
19
|
-
puts "Found #{identities.size} identities"
|
|
20
|
-
|
|
21
|
-
identities.first(10).each do |identity|
|
|
22
|
-
puts "\nIdentity: #{identity.id}"
|
|
23
|
-
puts " Name: #{identity.first_name} #{identity.last_name}"
|
|
24
|
-
puts " Phone: #{identity.phone_number}"
|
|
25
|
-
puts " Type: #{identity.identity_type}"
|
|
26
|
-
puts " Country: #{identity.country&.name}"
|
|
27
|
-
puts " Birth Country: #{identity.birth_country&.name}" # 2026-04-16
|
|
28
|
-
puts " Birth Date: #{identity.birth_date}"
|
|
29
|
-
puts " Verified: #{identity.verified}"
|
|
30
|
-
puts " Created: #{identity.created_at}"
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# List addresses
|
|
34
|
-
puts "\n=== Addresses ==="
|
|
35
|
-
addresses = DIDWW::Client.addresses
|
|
36
|
-
.includes(:identity)
|
|
37
|
-
.all
|
|
38
|
-
|
|
39
|
-
puts "Found #{addresses.size} addresses"
|
|
40
|
-
|
|
41
|
-
addresses.first(10).each do |address|
|
|
42
|
-
puts "\nAddress: #{address.id}"
|
|
43
|
-
puts " Street: #{address.address}"
|
|
44
|
-
puts " City: #{address.city_name}"
|
|
45
|
-
puts " Postal Code: #{address.postal_code}"
|
|
46
|
-
puts " Verified: #{address.verified}"
|
|
47
|
-
if address.identity
|
|
48
|
-
puts " Identity: #{address.identity.first_name} #{address.identity.last_name}"
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
# List proof types
|
|
53
|
-
puts "\n=== Proof Types ==="
|
|
54
|
-
proof_types = DIDWW::Client.proof_types.all
|
|
55
|
-
puts "Found #{proof_types.size} proof types"
|
|
56
|
-
|
|
57
|
-
proof_types.first(10).each do |pt|
|
|
58
|
-
puts "#{pt.name} (#{pt.entity_type})"
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
puts "\n=== Identities and Proofs Workflow ==="
|
|
62
|
-
puts '1. Create an identity with personal information'
|
|
63
|
-
puts '2. Create an address linked to the identity'
|
|
64
|
-
puts '3. Encrypt and upload identity/address documents'
|
|
65
|
-
puts '4. Create proofs attached to identity/address with uploaded files'
|
|
66
|
-
puts '5. Monitor verification status'
|
|
67
|
-
puts "\nNote: Creating and uploading encrypted files requires additional SDK setup."
|
data/examples/voice_in_trunks.rb
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
# Lists voice in trunks and their configurations.
|
|
3
|
-
#
|
|
4
|
-
# Usage: DIDWW_API_KEY=your_api_key ruby examples/voice_in_trunks.rb
|
|
5
|
-
|
|
6
|
-
require 'bundler/setup'
|
|
7
|
-
require 'didww'
|
|
8
|
-
|
|
9
|
-
DIDWW::Client.configure do |client|
|
|
10
|
-
client.api_key = ENV.fetch('DIDWW_API_KEY') { abort 'Please set DIDWW_API_KEY' }
|
|
11
|
-
client.api_mode = :sandbox
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
# List voice in trunks with included relationships
|
|
15
|
-
puts '=== Existing Trunks ==='
|
|
16
|
-
trunks = DIDWW::Client.voice_in_trunks
|
|
17
|
-
.includes(:pop, :voice_in_trunk_group)
|
|
18
|
-
.all
|
|
19
|
-
|
|
20
|
-
puts "Found #{trunks.size} trunks"
|
|
21
|
-
trunks.first(10).each do |trunk|
|
|
22
|
-
config_type = trunk.configuration ? trunk.configuration.class.name.split('::').last : 'unknown'
|
|
23
|
-
puts "#{trunk.name} [#{config_type}]"
|
|
24
|
-
puts " ID: #{trunk.id}"
|
|
25
|
-
puts " Priority: #{trunk.priority}"
|
|
26
|
-
puts " Weight: #{trunk.weight}"
|
|
27
|
-
puts " CLI Format: #{trunk.cli_format}"
|
|
28
|
-
puts " Ringing Timeout: #{trunk.ringing_timeout}"
|
|
29
|
-
if trunk.pop
|
|
30
|
-
puts " POP: #{trunk.pop.name}"
|
|
31
|
-
end
|
|
32
|
-
puts ''
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# Find a specific trunk by ID
|
|
36
|
-
if !trunks.empty?
|
|
37
|
-
puts "\n=== Specific Trunk Details ==="
|
|
38
|
-
specific_trunk = DIDWW::Client.voice_in_trunks.find(trunks.first.id).first
|
|
39
|
-
puts "Trunk: #{specific_trunk.name}"
|
|
40
|
-
puts " ID: #{specific_trunk.id}"
|
|
41
|
-
puts " Description: #{specific_trunk.description}"
|
|
42
|
-
puts " Created at: #{specific_trunk.created_at}"
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# 2026-04-16 — surface the API 2026-04-16 SIP-registration-related attributes when
|
|
46
|
-
# the trunk uses a SIP configuration. `incoming_auth_username` /
|
|
47
|
-
# `incoming_auth_password` are server-generated and only present when
|
|
48
|
-
# `enabled_sip_registration` is true.
|
|
49
|
-
sip_trunk = trunks.find { |t| t.configuration.is_a?(DIDWW::ComplexObject::SipConfiguration) }
|
|
50
|
-
if sip_trunk
|
|
51
|
-
puts "\n=== SIP Configuration (2026-04-16 attributes) ==="
|
|
52
|
-
config = sip_trunk.configuration
|
|
53
|
-
puts "Trunk: #{sip_trunk.name}"
|
|
54
|
-
puts " enabled_sip_registration: #{config.enabled_sip_registration.inspect}"
|
|
55
|
-
puts " use_did_in_ruri: #{config.use_did_in_ruri.inspect}"
|
|
56
|
-
puts " network_protocol_priority: #{config.network_protocol_priority.inspect}"
|
|
57
|
-
puts " diversion_relay_policy: #{config.diversion_relay_policy.inspect}"
|
|
58
|
-
puts " diversion_inject_mode: #{config.diversion_inject_mode.inspect}"
|
|
59
|
-
puts " cnam_lookup: #{config.cnam_lookup.inspect}"
|
|
60
|
-
if config.enabled_sip_registration
|
|
61
|
-
puts " incoming_auth_username: #{config.incoming_auth_username.inspect}"
|
|
62
|
-
puts " incoming_auth_password: #{config.incoming_auth_password.inspect}"
|
|
63
|
-
else
|
|
64
|
-
puts ' (incoming_auth credentials only appear when SIP registration is enabled)'
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
# Example: create a new SIP trunk with SIP registration enabled. The server
|
|
69
|
-
# generates `incoming_auth_username` / `incoming_auth_password` and returns
|
|
70
|
-
# them in the response. They are READ-ONLY — sending them on POST/PATCH
|
|
71
|
-
# returns 400 Param not allowed; the SDK strips them from write payloads.
|
|
72
|
-
#
|
|
73
|
-
# Server-side rules to keep in mind:
|
|
74
|
-
# * When `enabled_sip_registration: true`, `host` and `port` MUST be left
|
|
75
|
-
# blank (the server will register inbound and pick the host itself).
|
|
76
|
-
# * When DISABLING SIP registration on an existing trunk, you must
|
|
77
|
-
# simultaneously set `host` to a non-blank value and `use_did_in_ruri`
|
|
78
|
-
# to `false` in the same PATCH — otherwise the server returns 422.
|
|
79
|
-
#
|
|
80
|
-
# Uncomment to actually create a trunk in your sandbox account:
|
|
81
|
-
#
|
|
82
|
-
# new_trunk = DIDWW::Resource::VoiceInTrunk.new(
|
|
83
|
-
# name: "SIP-registration trunk #{Time.now.to_i}",
|
|
84
|
-
# priority: 1,
|
|
85
|
-
# weight: 100,
|
|
86
|
-
# cli_format: 'e164',
|
|
87
|
-
# ringing_timeout: 30,
|
|
88
|
-
# configuration: DIDWW::ComplexObject::SipConfiguration.new(
|
|
89
|
-
# # NOTE: do NOT set `host` here — the server requires it to be blank
|
|
90
|
-
# # when enabled_sip_registration is true.
|
|
91
|
-
# enabled_sip_registration: true,
|
|
92
|
-
# use_did_in_ruri: true,
|
|
93
|
-
# cnam_lookup: false,
|
|
94
|
-
# diversion_relay_policy: 'as_is',
|
|
95
|
-
# diversion_inject_mode: 'did_number',
|
|
96
|
-
# network_protocol_priority: 'prefer_ipv4',
|
|
97
|
-
# codec_ids: [9, 7],
|
|
98
|
-
# transport_protocol_id: 1
|
|
99
|
-
# )
|
|
100
|
-
# )
|
|
101
|
-
# created = new_trunk.save
|
|
102
|
-
# if created
|
|
103
|
-
# puts "Created trunk #{new_trunk.id}"
|
|
104
|
-
# puts " incoming_auth_username: #{new_trunk.configuration.incoming_auth_username}"
|
|
105
|
-
# puts " incoming_auth_password: #{new_trunk.configuration.incoming_auth_password}"
|
|
106
|
-
# else
|
|
107
|
-
# puts "Errors: #{new_trunk.errors.full_messages}"
|
|
108
|
-
# end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
module DIDWW
|
|
3
|
-
module Resource
|
|
4
|
-
module ExclusiveRelationship
|
|
5
|
-
class Relations < JsonApiClient::Relationships::Relations
|
|
6
|
-
def initialize(record_class, relations, exclusions)
|
|
7
|
-
@exclusions = exclusions
|
|
8
|
-
@_initializing = true
|
|
9
|
-
super(record_class, relations)
|
|
10
|
-
@_initializing = false
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def set_attribute(name, value)
|
|
14
|
-
super
|
|
15
|
-
return if @_initializing
|
|
16
|
-
exclusive = @exclusions[name.to_s]
|
|
17
|
-
if exclusive && !value.nil?
|
|
18
|
-
super(exclusive, nil)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def self.included(base)
|
|
24
|
-
base.extend(ClassMethods)
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
module ClassMethods
|
|
28
|
-
def exclusive_relationships(mapping)
|
|
29
|
-
full_mapping = {}
|
|
30
|
-
mapping.each do |a, b|
|
|
31
|
-
full_mapping[a.to_s] = b.to_s
|
|
32
|
-
full_mapping[b.to_s] = a.to_s
|
|
33
|
-
end
|
|
34
|
-
full_mapping.freeze
|
|
35
|
-
|
|
36
|
-
define_method(:_exclusive_relationship_mapping) { full_mapping }
|
|
37
|
-
|
|
38
|
-
define_method(:relationships) do
|
|
39
|
-
@relationships ||= Relations.new(self.class, {}, full_mapping)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
define_method(:relationships=) do |rels|
|
|
43
|
-
attrs = case rels
|
|
44
|
-
when JsonApiClient::Relationships::Relations then rels.attributes
|
|
45
|
-
when Hash then rels
|
|
46
|
-
else rels || {}
|
|
47
|
-
end
|
|
48
|
-
@relationships = Relations.new(self.class, attrs, full_mapping)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|