blib/lib/SignalWire/REST/Namespaces/Fabric.pm

filter: Statementstmt 67.0% 120 / 179 Branchbran 0.0% 0 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 63.0% 41 / 65 Podpod 0.0% 0 / 26 totaltotal 56.2% 161 / 286 CC 9 SCAR 8.4
CC
9
Cov
62%
list_addresses
6.0
list_addresses
6.0
list_versions
6.0
CRAP 2.3
« blib/lib/SignalWire/REST/Namespaces/PhoneNumbers.pm ↑ Summary blib/lib/SignalWire/Skills/Builtin/Math.pm »
1 package SignalWire::REST::Namespaces::Fabric;
2 6 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 6 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # --- Fabric Resource (PATCH updates) ---
8 package SignalWire::REST::Namespaces::Fabric::Resource;
9 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 6 extends 'SignalWire::REST::Namespaces::CrudResource';
11  
12 0 ▶sub list_addresses {
Subroutine list_addresses: not called CC=2 SCAR=17.9
Pod undocumented
13 0 my ($self, $resource_id, %params) = @_;
14 0 ▶ my $p = %params ? \%params : undef;
Branch: 1 branch
BranchTrueFalseTotal
%params ? : 0 0 0
15 0 return $self->_http->get($self->_path($resource_id, 'addresses'), params => $p);
16 }
17  
18 # --- AutoMaterializedWebhook: webhook Fabric resources that are normally
19 # auto-created by phone_numbers->set_*_webhook. Direct create() still
20 # works for backcompat but emits a deprecation warning pointing at
21 # the correct helper. list/get/update/delete are unchanged.
22 package SignalWire::REST::Namespaces::Fabric::AutoMaterializedWebhook;
23 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
24 6 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
25 6 extends 'SignalWire::REST::Namespaces::Fabric::Resource';
26  
27 has '_auto_helper_name' => (
28 is => 'ro',
29 0 ▶ default => sub { 'phone_numbers->set_*_webhook' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
30 6 );
31  
32 2 ▶sub create {
Subroutine create: called CC=1 SCAR=0.0
Pod undocumented
33 2 my ($self, %kwargs) = @_;
34 2 my $helper = $self->_auto_helper_name;
35 2 Carp::carp(
36 "DEPRECATED: creating a webhook Fabric resource directly produces "
37 . "an orphan not bound to any phone number. Use $helper instead; "
38 . "it updates the phone number and the server auto-materializes "
39 . "the resource. See porting-sdk's phone-binding.md."
40 );
41 2 return $self->_http->post($self->_base_path, body => \%kwargs);
42 }
43  
44 # --- SwmlWebhooks and CxmlWebhooks — concrete subclasses with specific
45 # helper names in their deprecation message.
46 package SignalWire::REST::Namespaces::Fabric::SwmlWebhooks;
47 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 6 extends 'SignalWire::REST::Namespaces::Fabric::AutoMaterializedWebhook';
49 has '+_auto_helper_name' => (
50 5 ▶ default => sub { 'phone_numbers->set_swml_webhook($sid, url => ...)' },
Subroutine __ANON__: called CC=1 SCAR=0.0
51 6 );
52  
53 package SignalWire::REST::Namespaces::Fabric::CxmlWebhooks;
54 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 6 extends 'SignalWire::REST::Namespaces::Fabric::AutoMaterializedWebhook';
56 has '+_auto_helper_name' => (
57 4 ▶ default => sub { 'phone_numbers->set_cxml_webhook($sid, url => ...)' },
Subroutine __ANON__: called CC=1 SCAR=0.0
58 6 );
59  
60 # --- Fabric Resource with PUT updates ---
61 package SignalWire::REST::Namespaces::Fabric::ResourcePUT;
62 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 6 extends 'SignalWire::REST::Namespaces::Fabric::Resource';
64 17 ▶has '+_update_method' => ( default => sub { 'PUT' } );
Subroutine __ANON__: called CC=1 SCAR=0.0
65  
66 # --- CallFlows ---
67 package SignalWire::REST::Namespaces::Fabric::CallFlows;
68 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
69 6 extends 'SignalWire::REST::Namespaces::Fabric::ResourcePUT';
70  
71 0 ▶sub list_addresses {
Subroutine list_addresses: not called CC=2 SCAR=17.9
Pod undocumented
72 0 my ($self, $resource_id, %params) = @_;
73 0 (my $path = $self->_base_path) =~ s/call_flows/call_flow/;
74 0 ▶ my $p = %params ? \%params : undef;
Branch: 1 branch
BranchTrueFalseTotal
%params ? : 0 0 0
75 0 return $self->_http->get("$path/$resource_id/addresses", params => $p);
76 }
77  
78 0 ▶sub list_versions {
Subroutine list_versions: not called CC=2 SCAR=17.9
Pod undocumented
79 0 my ($self, $resource_id, %params) = @_;
80 0 (my $path = $self->_base_path) =~ s/call_flows/call_flow/;
81 0 ▶ my $p = %params ? \%params : undef;
Branch: 1 branch
BranchTrueFalseTotal
%params ? : 0 0 0
82 0 return $self->_http->get("$path/$resource_id/versions", params => $p);
83 }
84  
85 0 ▶sub deploy_version {
Subroutine deploy_version: not called CC=1 SCAR=6.9
Pod undocumented
86 0 my ($self, $resource_id, %kwargs) = @_;
87 0 (my $path = $self->_base_path) =~ s/call_flows/call_flow/;
88 0 return $self->_http->post("$path/$resource_id/versions", body => \%kwargs);
89 }
90  
91 # --- ConferenceRooms ---
92 package SignalWire::REST::Namespaces::Fabric::ConferenceRooms;
93 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
94 6 extends 'SignalWire::REST::Namespaces::Fabric::ResourcePUT';
95  
96 0 ▶sub list_addresses {
Subroutine list_addresses: not called CC=2 SCAR=17.9
Pod undocumented
97 0 my ($self, $resource_id, %params) = @_;
98 0 (my $path = $self->_base_path) =~ s/conference_rooms/conference_room/;
99 0 ▶ my $p = %params ? \%params : undef;
Branch: 1 branch
BranchTrueFalseTotal
%params ? : 0 0 0
100 0 return $self->_http->get("$path/$resource_id/addresses", params => $p);
101 }
102  
103 # --- Subscribers ---
104 package SignalWire::REST::Namespaces::Fabric::Subscribers;
105 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
106 6 extends 'SignalWire::REST::Namespaces::Fabric::ResourcePUT';
107  
108 0 ▶sub list_sip_endpoints {
Subroutine list_sip_endpoints: not called CC=2 SCAR=17.9
Pod undocumented
109 0 my ($self, $subscriber_id, %params) = @_;
110 0 ▶ my $p = %params ? \%params : undef;
Branch: 1 branch
BranchTrueFalseTotal
%params ? : 0 0 0
111 0 return $self->_http->get($self->_path($subscriber_id, 'sip_endpoints'), params => $p);
112 }
113  
114 0 ▶sub create_sip_endpoint {
Subroutine create_sip_endpoint: not called CC=1 SCAR=6.9
Pod undocumented
115 0 my ($self, $subscriber_id, %kwargs) = @_;
116 0 return $self->_http->post($self->_path($subscriber_id, 'sip_endpoints'), body => \%kwargs);
117 }
118  
119 0 ▶sub get_sip_endpoint {
Subroutine get_sip_endpoint: not called CC=1 SCAR=6.9
Pod undocumented
120 0 my ($self, $subscriber_id, $endpoint_id) = @_;
121 0 return $self->_http->get($self->_path($subscriber_id, 'sip_endpoints', $endpoint_id));
122 }
123  
124 0 ▶sub update_sip_endpoint {
Subroutine update_sip_endpoint: not called CC=1 SCAR=6.9
Pod undocumented
125 0 my ($self, $subscriber_id, $endpoint_id, %kwargs) = @_;
126 0 return $self->_http->patch($self->_path($subscriber_id, 'sip_endpoints', $endpoint_id), body => \%kwargs);
127 }
128  
129 0 ▶sub delete_sip_endpoint {
Subroutine delete_sip_endpoint: not called CC=1 SCAR=6.9
Pod undocumented
130 0 my ($self, $subscriber_id, $endpoint_id) = @_;
131 0 return $self->_http->delete_request($self->_path($subscriber_id, 'sip_endpoints', $endpoint_id));
132 }
133  
134 # --- CxmlApplications (no create) ---
135 package SignalWire::REST::Namespaces::Fabric::CxmlApplications;
136 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
137 6 extends 'SignalWire::REST::Namespaces::Fabric::ResourcePUT';
138  
139 2 ▶sub create {
Subroutine create: called CC=1 SCAR=0.0
Pod undocumented
140 2 my ($self, %kwargs) = @_;
141 2 die "cXML applications cannot be created via this API";
142 }
143  
144 # --- GenericResources ---
145 package SignalWire::REST::Namespaces::Fabric::GenericResources;
146 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
147 6 extends 'SignalWire::REST::Namespaces::Base';
148  
149 0 ▶sub list {
Subroutine list: not called CC=2 SCAR=17.9
Pod undocumented
150 0 my ($self, %params) = @_;
151 0 ▶ my $p = %params ? \%params : undef;
Branch: 1 branch
BranchTrueFalseTotal
%params ? : 0 0 0
152 0 return $self->_http->get($self->_base_path, params => $p);
153 }
154  
155 0 ▶sub get {
Subroutine get: not called CC=1 SCAR=6.9
Pod undocumented
156 0 my ($self, $resource_id) = @_;
157 0 return $self->_http->get($self->_path($resource_id));
158 }
159  
160 0 ▶sub delete_resource {
Subroutine delete_resource: not called CC=1 SCAR=6.9
Pod undocumented
161 0 my ($self, $resource_id) = @_;
162 0 return $self->_http->delete_request($self->_path($resource_id));
163 }
164  
165 # Python parity alias.
166 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
Pod undocumented
167 0 my ($self, $resource_id) = @_;
168 0 return $self->_http->delete_request($self->_path($resource_id));
169 }
170  
171 0 ▶sub list_addresses {
Subroutine list_addresses: not called CC=2 SCAR=17.9
Pod undocumented
172 0 my ($self, $resource_id, %params) = @_;
173 0 ▶ my $p = %params ? \%params : undef;
Branch: 1 branch
BranchTrueFalseTotal
%params ? : 0 0 0
174 0 return $self->_http->get($self->_path($resource_id, 'addresses'), params => $p);
175 }
176  
177 1 ▶sub assign_phone_route {
Subroutine assign_phone_route: called CC=1 SCAR=0.0
Pod undocumented
178 1 my ($self, $resource_id, %kwargs) = @_;
179 1 Carp::carp(
180 "DEPRECATED: assign_phone_route does not bind phone numbers to "
181 . "swml_webhook/cxml_webhook/ai_agent resources — those are "
182 . "configured via phone_numbers->set_swml_webhook / set_cxml_webhook "
183 . "/ set_ai_agent. This method applies only to a narrow set of "
184 . "legacy resource types. See porting-sdk's phone-binding.md."
185 );
186 1 return $self->_http->post($self->_path($resource_id, 'phone_routes'), body => \%kwargs);
187 }
188  
189 0 ▶sub assign_domain_application {
Subroutine assign_domain_application: not called CC=1 SCAR=6.9
Pod undocumented
190 0 my ($self, $resource_id, %kwargs) = @_;
191 0 return $self->_http->post($self->_path($resource_id, 'domain_applications'), body => \%kwargs);
192 }
193  
194 # --- FabricAddresses (read-only) ---
195 package SignalWire::REST::Namespaces::Fabric::Addresses;
196 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
197 6 extends 'SignalWire::REST::Namespaces::Base';
198  
199 0 ▶sub list {
Subroutine list: not called CC=2 SCAR=17.9
Pod undocumented
200 0 my ($self, %params) = @_;
201 0 ▶ my $p = %params ? \%params : undef;
Branch: 1 branch
BranchTrueFalseTotal
%params ? : 0 0 0
202 0 return $self->_http->get($self->_base_path, params => $p);
203 }
204  
205 0 ▶sub get {
Subroutine get: not called CC=1 SCAR=6.9
Pod undocumented
206 0 my ($self, $address_id) = @_;
207 0 return $self->_http->get($self->_path($address_id));
208 }
209  
210 # --- FabricTokens ---
211 package SignalWire::REST::Namespaces::Fabric::Tokens;
212 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
213 6 extends 'SignalWire::REST::Namespaces::Base';
214  
215 0 ▶sub create_subscriber_token {
Subroutine create_subscriber_token: not called CC=1 SCAR=6.9
Pod undocumented
216 0 my ($self, %kwargs) = @_;
217 0 return $self->_http->post($self->_path('subscribers', 'tokens'), body => \%kwargs);
218 }
219  
220 0 ▶sub refresh_subscriber_token {
Subroutine refresh_subscriber_token: not called CC=1 SCAR=6.9
Pod undocumented
221 0 my ($self, %kwargs) = @_;
222 0 return $self->_http->post($self->_path('subscribers', 'tokens', 'refresh'), body => \%kwargs);
223 }
224  
225 0 ▶sub create_invite_token {
Subroutine create_invite_token: not called CC=1 SCAR=6.9
Pod undocumented
226 0 my ($self, %kwargs) = @_;
227 0 return $self->_http->post($self->_path('subscriber', 'invites'), body => \%kwargs);
228 }
229  
230 0 ▶sub create_guest_token {
Subroutine create_guest_token: not called CC=1 SCAR=6.9
Pod undocumented
231 0 my ($self, %kwargs) = @_;
232 0 return $self->_http->post($self->_path('guests', 'tokens'), body => \%kwargs);
233 }
234  
235 0 ▶sub create_embed_token {
Subroutine create_embed_token: not called CC=1 SCAR=6.9
Pod undocumented
236 0 my ($self, %kwargs) = @_;
237 0 return $self->_http->post($self->_path('embeds', 'tokens'), body => \%kwargs);
238 }
239  
240 # --- FabricNamespace (top-level grouping) ---
241 package SignalWire::REST::Namespaces::Fabric;
242 6 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
243  
244 6 has '_http' => ( is => 'ro', required => 1 );
245  
246 6 has 'swml_scripts' => ( is => 'lazy' );
247 6 has 'relay_applications' => ( is => 'lazy' );
248 6 has 'call_flows' => ( is => 'lazy' );
249 6 has 'conference_rooms' => ( is => 'lazy' );
250 6 has 'freeswitch_connectors' => ( is => 'lazy' );
251 6 has 'subscribers' => ( is => 'lazy' );
252 6 has 'sip_endpoints' => ( is => 'lazy' );
253 6 has 'cxml_scripts' => ( is => 'lazy' );
254 6 has 'cxml_applications' => ( is => 'lazy' );
255 6 has 'swml_webhooks' => ( is => 'lazy' );
256 6 has 'ai_agents' => ( is => 'lazy' );
257 6 has 'sip_gateways' => ( is => 'lazy' );
258 6 has 'cxml_webhooks' => ( is => 'lazy' );
259 6 has 'resources' => ( is => 'lazy' );
260 6 has 'addresses' => ( is => 'lazy' );
261 6 has 'tokens' => ( is => 'lazy' );
262  
263 6 my $base = '/api/fabric/resources';
264  
265 2 ▶sub _build_swml_scripts { $_[0]->_mk('ResourcePUT', "$base/swml_scripts") }
Subroutine _build_swml_scripts: called CC=1 SCAR=0.0
266 2 ▶sub _build_relay_applications { $_[0]->_mk('ResourcePUT', "$base/relay_applications") }
Subroutine _build_relay_applications: called CC=1 SCAR=0.0
267 2 ▶sub _build_call_flows { SignalWire::REST::Namespaces::Fabric::CallFlows->new(_http => $_[0]->_http, _base_path => "$base/call_flows") }
Subroutine _build_call_flows: called CC=1 SCAR=0.0
268 2 ▶sub _build_conference_rooms { SignalWire::REST::Namespaces::Fabric::ConferenceRooms->new(_http => $_[0]->_http, _base_path => "$base/conference_rooms") }
Subroutine _build_conference_rooms: called CC=1 SCAR=0.0
269 1 ▶sub _build_freeswitch_connectors { $_[0]->_mk('ResourcePUT', "$base/freeswitch_connectors") }
Subroutine _build_freeswitch_connectors: called CC=1 SCAR=0.0
270 2 ▶sub _build_subscribers { SignalWire::REST::Namespaces::Fabric::Subscribers->new(_http => $_[0]->_http, _base_path => "$base/subscribers") }
Subroutine _build_subscribers: called CC=1 SCAR=0.0
271 2 ▶sub _build_sip_endpoints { $_[0]->_mk('ResourcePUT', "$base/sip_endpoints") }
Subroutine _build_sip_endpoints: called CC=1 SCAR=0.0
272 2 ▶sub _build_cxml_scripts { $_[0]->_mk('ResourcePUT', "$base/cxml_scripts") }
Subroutine _build_cxml_scripts: called CC=1 SCAR=0.0
273 2 ▶sub _build_cxml_applications { SignalWire::REST::Namespaces::Fabric::CxmlApplications->new(_http => $_[0]->_http, _base_path => "$base/cxml_applications") }
Subroutine _build_cxml_applications: called CC=1 SCAR=0.0
274 # swml_webhooks and cxml_webhooks are normally auto-materialized by
275 # phone_numbers->set_swml_webhook / set_cxml_webhook. Direct create still
276 # works for backcompat but emits a deprecation warning.
277 3 ▶sub _build_swml_webhooks { SignalWire::REST::Namespaces::Fabric::SwmlWebhooks->new(_http => $_[0]->_http, _base_path => "$base/swml_webhooks") }
Subroutine _build_swml_webhooks: called CC=1 SCAR=0.0
278 2 ▶sub _build_ai_agents { $_[0]->_mk('Resource', "$base/ai_agents") }
Subroutine _build_ai_agents: called CC=1 SCAR=0.0
279 2 ▶sub _build_sip_gateways { $_[0]->_mk('Resource', "$base/sip_gateways") }
Subroutine _build_sip_gateways: called CC=1 SCAR=0.0
280 3 ▶sub _build_cxml_webhooks { SignalWire::REST::Namespaces::Fabric::CxmlWebhooks->new(_http => $_[0]->_http, _base_path => "$base/cxml_webhooks") }
Subroutine _build_cxml_webhooks: called CC=1 SCAR=0.0
281 2 ▶sub _build_resources { SignalWire::REST::Namespaces::Fabric::GenericResources->new(_http => $_[0]->_http, _base_path => $base) }
Subroutine _build_resources: called CC=1 SCAR=0.0
282 2 ▶sub _build_addresses { SignalWire::REST::Namespaces::Fabric::Addresses->new(_http => $_[0]->_http, _base_path => '/api/fabric/addresses') }
Subroutine _build_addresses: called CC=1 SCAR=0.0
283 2 ▶sub _build_tokens { SignalWire::REST::Namespaces::Fabric::Tokens->new(_http => $_[0]->_http, _base_path => '/api/fabric') }
Subroutine _build_tokens: called CC=1 SCAR=0.0
284  
285 13 ▶sub _mk {
Subroutine _mk: called CC=1 SCAR=0.0
286 13 my ($self, $type, $path) = @_;
287 13 my $class = "SignalWire::REST::Namespaces::Fabric::$type";
288 13 return $class->new(_http => $self->_http, _base_path => $path);
289 }
290  
291 6 1;
« blib/lib/SignalWire/REST/Namespaces/PhoneNumbers.pm ↑ Summary blib/lib/SignalWire/Skills/Builtin/Math.pm »