« blib/lib/SignalWire/Agents/Prefabs/Receptionist.pm
↑ Summary
blib/lib/SignalWire/Agents/Skills/Builtin/PlayBackgroundFile.pm »
| 1 | package SignalWire::Agents::REST::Namespaces::Fabric; | ||||||||||
| 2 | 4 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 4 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | # --- Fabric Resource (PATCH updates) --- | ||||||||||
| 7 | package SignalWire::Agents::REST::Namespaces::Fabric::Resource; | ||||||||||
| 8 | 4 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 4 | extends 'SignalWire::Agents::REST::Namespaces::CrudResource'; | |||||||||
| 10 | |||||||||||
| 11 | 0 | ▶ | sub list_addresses { | ||||||||
|
Subroutine
list_addresses: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 12 | 0 | my ($self, $resource_id, %params) = @_; | |||||||||
| 13 | 0 | ▶ | my $p = %params ? \%params : undef; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | 0 | return $self->_http->get($self->_path($resource_id, 'addresses'), params => $p); | |||||||||
| 15 | } | ||||||||||
| 16 | |||||||||||
| 17 | # --- Fabric Resource with PUT updates --- | ||||||||||
| 18 | package SignalWire::Agents::REST::Namespaces::Fabric::ResourcePUT; | ||||||||||
| 19 | 4 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 4 | extends 'SignalWire::Agents::REST::Namespaces::Fabric::Resource'; | |||||||||
| 21 | 17 | ▶ | has '+_update_method' => ( default => sub { 'PUT' } ); | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 22 | |||||||||||
| 23 | # --- CallFlows --- | ||||||||||
| 24 | package SignalWire::Agents::REST::Namespaces::Fabric::CallFlows; | ||||||||||
| 25 | 4 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 26 | 4 | extends 'SignalWire::Agents::REST::Namespaces::Fabric::ResourcePUT'; | |||||||||
| 27 | |||||||||||
| 28 | 0 | ▶ | sub list_addresses { | ||||||||
|
Subroutine
list_addresses: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 29 | 0 | my ($self, $resource_id, %params) = @_; | |||||||||
| 30 | 0 | (my $path = $self->_base_path) =~ s/call_flows/call_flow/; | |||||||||
| 31 | 0 | ▶ | my $p = %params ? \%params : undef; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | 0 | return $self->_http->get("$path/$resource_id/addresses", params => $p); | |||||||||
| 33 | } | ||||||||||
| 34 | |||||||||||
| 35 | 0 | ▶ | sub list_versions { | ||||||||
|
Subroutine
list_versions: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 36 | 0 | my ($self, $resource_id, %params) = @_; | |||||||||
| 37 | 0 | (my $path = $self->_base_path) =~ s/call_flows/call_flow/; | |||||||||
| 38 | 0 | ▶ | my $p = %params ? \%params : undef; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 39 | 0 | return $self->_http->get("$path/$resource_id/versions", params => $p); | |||||||||
| 40 | } | ||||||||||
| 41 | |||||||||||
| 42 | 0 | ▶ | sub deploy_version { | ||||||||
|
Subroutine
deploy_version: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 43 | 0 | my ($self, $resource_id, %kwargs) = @_; | |||||||||
| 44 | 0 | (my $path = $self->_base_path) =~ s/call_flows/call_flow/; | |||||||||
| 45 | 0 | return $self->_http->post("$path/$resource_id/versions", body => \%kwargs); | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | # --- ConferenceRooms --- | ||||||||||
| 49 | package SignalWire::Agents::REST::Namespaces::Fabric::ConferenceRooms; | ||||||||||
| 50 | 4 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 51 | 4 | extends 'SignalWire::Agents::REST::Namespaces::Fabric::ResourcePUT'; | |||||||||
| 52 | |||||||||||
| 53 | 0 | ▶ | sub list_addresses { | ||||||||
|
Subroutine
list_addresses: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 54 | 0 | my ($self, $resource_id, %params) = @_; | |||||||||
| 55 | 0 | (my $path = $self->_base_path) =~ s/conference_rooms/conference_room/; | |||||||||
| 56 | 0 | ▶ | my $p = %params ? \%params : undef; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 0 | return $self->_http->get("$path/$resource_id/addresses", params => $p); | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | # --- Subscribers --- | ||||||||||
| 61 | package SignalWire::Agents::REST::Namespaces::Fabric::Subscribers; | ||||||||||
| 62 | 4 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 63 | 4 | extends 'SignalWire::Agents::REST::Namespaces::Fabric::ResourcePUT'; | |||||||||
| 64 | |||||||||||
| 65 | 0 | ▶ | sub list_sip_endpoints { | ||||||||
|
Subroutine
list_sip_endpoints: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 66 | 0 | my ($self, $subscriber_id, %params) = @_; | |||||||||
| 67 | 0 | ▶ | my $p = %params ? \%params : undef; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | 0 | return $self->_http->get($self->_path($subscriber_id, 'sip_endpoints'), params => $p); | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 0 | ▶ | sub create_sip_endpoint { | ||||||||
|
Subroutine
create_sip_endpoint: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 72 | 0 | my ($self, $subscriber_id, %kwargs) = @_; | |||||||||
| 73 | 0 | return $self->_http->post($self->_path($subscriber_id, 'sip_endpoints'), body => \%kwargs); | |||||||||
| 74 | } | ||||||||||
| 75 | |||||||||||
| 76 | 0 | ▶ | sub get_sip_endpoint { | ||||||||
|
Subroutine
get_sip_endpoint: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 77 | 0 | my ($self, $subscriber_id, $endpoint_id) = @_; | |||||||||
| 78 | 0 | return $self->_http->get($self->_path($subscriber_id, 'sip_endpoints', $endpoint_id)); | |||||||||
| 79 | } | ||||||||||
| 80 | |||||||||||
| 81 | 0 | ▶ | sub update_sip_endpoint { | ||||||||
|
Subroutine
update_sip_endpoint: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 82 | 0 | my ($self, $subscriber_id, $endpoint_id, %kwargs) = @_; | |||||||||
| 83 | 0 | return $self->_http->patch($self->_path($subscriber_id, 'sip_endpoints', $endpoint_id), body => \%kwargs); | |||||||||
| 84 | } | ||||||||||
| 85 | |||||||||||
| 86 | 0 | ▶ | sub delete_sip_endpoint { | ||||||||
|
Subroutine
delete_sip_endpoint: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 87 | 0 | my ($self, $subscriber_id, $endpoint_id) = @_; | |||||||||
| 88 | 0 | return $self->_http->delete_request($self->_path($subscriber_id, 'sip_endpoints', $endpoint_id)); | |||||||||
| 89 | } | ||||||||||
| 90 | |||||||||||
| 91 | # --- CxmlApplications (no create) --- | ||||||||||
| 92 | package SignalWire::Agents::REST::Namespaces::Fabric::CxmlApplications; | ||||||||||
| 93 | 4 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 94 | 4 | extends 'SignalWire::Agents::REST::Namespaces::Fabric::ResourcePUT'; | |||||||||
| 95 | |||||||||||
| 96 | 2 | ▶ | sub create { | ||||||||
|
Subroutine
create: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 97 | 2 | die "cXML applications cannot be created via this API"; | |||||||||
| 98 | } | ||||||||||
| 99 | |||||||||||
| 100 | # --- GenericResources --- | ||||||||||
| 101 | package SignalWire::Agents::REST::Namespaces::Fabric::GenericResources; | ||||||||||
| 102 | 4 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 103 | 4 | extends 'SignalWire::Agents::REST::Namespaces::Base'; | |||||||||
| 104 | |||||||||||
| 105 | 0 | ▶ | sub list { | ||||||||
|
Subroutine
list: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 106 | 0 | my ($self, %params) = @_; | |||||||||
| 107 | 0 | ▶ | my $p = %params ? \%params : undef; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 108 | 0 | return $self->_http->get($self->_base_path, params => $p); | |||||||||
| 109 | } | ||||||||||
| 110 | |||||||||||
| 111 | 0 | ▶ | sub get { | ||||||||
|
Subroutine
get: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 112 | 0 | my ($self, $resource_id) = @_; | |||||||||
| 113 | 0 | return $self->_http->get($self->_path($resource_id)); | |||||||||
| 114 | } | ||||||||||
| 115 | |||||||||||
| 116 | 0 | ▶ | sub delete_resource { | ||||||||
|
Subroutine
delete_resource: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 117 | 0 | my ($self, $resource_id) = @_; | |||||||||
| 118 | 0 | return $self->_http->delete_request($self->_path($resource_id)); | |||||||||
| 119 | } | ||||||||||
| 120 | |||||||||||
| 121 | 0 | ▶ | sub list_addresses { | ||||||||
|
Subroutine
list_addresses: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 122 | 0 | my ($self, $resource_id, %params) = @_; | |||||||||
| 123 | 0 | ▶ | my $p = %params ? \%params : undef; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 124 | 0 | return $self->_http->get($self->_path($resource_id, 'addresses'), params => $p); | |||||||||
| 125 | } | ||||||||||
| 126 | |||||||||||
| 127 | 0 | ▶ | sub assign_phone_route { | ||||||||
|
Subroutine
assign_phone_route: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 128 | 0 | my ($self, $resource_id, %kwargs) = @_; | |||||||||
| 129 | 0 | return $self->_http->post($self->_path($resource_id, 'phone_routes'), body => \%kwargs); | |||||||||
| 130 | } | ||||||||||
| 131 | |||||||||||
| 132 | 0 | ▶ | sub assign_domain_application { | ||||||||
|
Subroutine
assign_domain_application: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 133 | 0 | my ($self, $resource_id, %kwargs) = @_; | |||||||||
| 134 | 0 | return $self->_http->post($self->_path($resource_id, 'domain_applications'), body => \%kwargs); | |||||||||
| 135 | } | ||||||||||
| 136 | |||||||||||
| 137 | # --- FabricAddresses (read-only) --- | ||||||||||
| 138 | package SignalWire::Agents::REST::Namespaces::Fabric::Addresses; | ||||||||||
| 139 | 4 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 140 | 4 | extends 'SignalWire::Agents::REST::Namespaces::Base'; | |||||||||
| 141 | |||||||||||
| 142 | 0 | ▶ | sub list { | ||||||||
|
Subroutine
list: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||
| 143 | 0 | my ($self, %params) = @_; | |||||||||
| 144 | 0 | ▶ | my $p = %params ? \%params : undef; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 145 | 0 | return $self->_http->get($self->_base_path, params => $p); | |||||||||
| 146 | } | ||||||||||
| 147 | |||||||||||
| 148 | 0 | ▶ | sub get { | ||||||||
|
Subroutine
get: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 149 | 0 | my ($self, $address_id) = @_; | |||||||||
| 150 | 0 | return $self->_http->get($self->_path($address_id)); | |||||||||
| 151 | } | ||||||||||
| 152 | |||||||||||
| 153 | # --- FabricTokens --- | ||||||||||
| 154 | package SignalWire::Agents::REST::Namespaces::Fabric::Tokens; | ||||||||||
| 155 | 4 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 156 | 4 | extends 'SignalWire::Agents::REST::Namespaces::Base'; | |||||||||
| 157 | |||||||||||
| 158 | 0 | ▶ | sub create_subscriber_token { | ||||||||
|
Subroutine
create_subscriber_token: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 159 | 0 | my ($self, %kwargs) = @_; | |||||||||
| 160 | 0 | return $self->_http->post($self->_path('subscribers', 'tokens'), body => \%kwargs); | |||||||||
| 161 | } | ||||||||||
| 162 | |||||||||||
| 163 | 0 | ▶ | sub refresh_subscriber_token { | ||||||||
|
Subroutine
refresh_subscriber_token: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 164 | 0 | my ($self, %kwargs) = @_; | |||||||||
| 165 | 0 | return $self->_http->post($self->_path('subscribers', 'tokens', 'refresh'), body => \%kwargs); | |||||||||
| 166 | } | ||||||||||
| 167 | |||||||||||
| 168 | 0 | ▶ | sub create_invite_token { | ||||||||
|
Subroutine
create_invite_token: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 169 | 0 | my ($self, %kwargs) = @_; | |||||||||
| 170 | 0 | return $self->_http->post($self->_path('subscriber', 'invites'), body => \%kwargs); | |||||||||
| 171 | } | ||||||||||
| 172 | |||||||||||
| 173 | 0 | ▶ | sub create_guest_token { | ||||||||
|
Subroutine
create_guest_token: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 174 | 0 | my ($self, %kwargs) = @_; | |||||||||
| 175 | 0 | return $self->_http->post($self->_path('guests', 'tokens'), body => \%kwargs); | |||||||||
| 176 | } | ||||||||||
| 177 | |||||||||||
| 178 | 0 | ▶ | sub create_embed_token { | ||||||||
|
Subroutine
create_embed_token: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 179 | 0 | my ($self, %kwargs) = @_; | |||||||||
| 180 | 0 | return $self->_http->post($self->_path('embeds', 'tokens'), body => \%kwargs); | |||||||||
| 181 | } | ||||||||||
| 182 | |||||||||||
| 183 | # --- FabricNamespace (top-level grouping) --- | ||||||||||
| 184 | package SignalWire::Agents::REST::Namespaces::Fabric; | ||||||||||
| 185 | 4 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 186 | |||||||||||
| 187 | 4 | has '_http' => ( is => 'ro', required => 1 ); | |||||||||
| 188 | |||||||||||
| 189 | 4 | has 'swml_scripts' => ( is => 'lazy' ); | |||||||||
| 190 | 4 | has 'relay_applications' => ( is => 'lazy' ); | |||||||||
| 191 | 4 | has 'call_flows' => ( is => 'lazy' ); | |||||||||
| 192 | 4 | has 'conference_rooms' => ( is => 'lazy' ); | |||||||||
| 193 | 4 | has 'freeswitch_connectors' => ( is => 'lazy' ); | |||||||||
| 194 | 4 | has 'subscribers' => ( is => 'lazy' ); | |||||||||
| 195 | 4 | has 'sip_endpoints' => ( is => 'lazy' ); | |||||||||
| 196 | 4 | has 'cxml_scripts' => ( is => 'lazy' ); | |||||||||
| 197 | 4 | has 'cxml_applications' => ( is => 'lazy' ); | |||||||||
| 198 | 4 | has 'swml_webhooks' => ( is => 'lazy' ); | |||||||||
| 199 | 4 | has 'ai_agents' => ( is => 'lazy' ); | |||||||||
| 200 | 4 | has 'sip_gateways' => ( is => 'lazy' ); | |||||||||
| 201 | 4 | has 'cxml_webhooks' => ( is => 'lazy' ); | |||||||||
| 202 | 4 | has 'resources' => ( is => 'lazy' ); | |||||||||
| 203 | 4 | has 'addresses' => ( is => 'lazy' ); | |||||||||
| 204 | 4 | has 'tokens' => ( is => 'lazy' ); | |||||||||
| 205 | |||||||||||
| 206 | 4 | my $base = '/api/fabric/resources'; | |||||||||
| 207 | |||||||||||
| 208 | 2 | ▶ | sub _build_swml_scripts { $_[0]->_mk('ResourcePUT', "$base/swml_scripts") } | ||||||||
|
Subroutine
_build_swml_scripts: called CC=1 SCAR=0.0
| |||||||||||
| 209 | 2 | ▶ | sub _build_relay_applications { $_[0]->_mk('ResourcePUT', "$base/relay_applications") } | ||||||||
|
Subroutine
_build_relay_applications: called CC=1 SCAR=0.0
| |||||||||||
| 210 | 2 | ▶ | sub _build_call_flows { SignalWire::Agents::REST::Namespaces::Fabric::CallFlows->new(_http => $_[0]->_http, _base_path => "$base/call_flows") } | ||||||||
|
Subroutine
_build_call_flows: called CC=1 SCAR=0.0
| |||||||||||
| 211 | 2 | ▶ | sub _build_conference_rooms { SignalWire::Agents::REST::Namespaces::Fabric::ConferenceRooms->new(_http => $_[0]->_http, _base_path => "$base/conference_rooms") } | ||||||||
|
Subroutine
_build_conference_rooms: called CC=1 SCAR=0.0
| |||||||||||
| 212 | 1 | ▶ | sub _build_freeswitch_connectors { $_[0]->_mk('ResourcePUT', "$base/freeswitch_connectors") } | ||||||||
|
Subroutine
_build_freeswitch_connectors: called CC=1 SCAR=0.0
| |||||||||||
| 213 | 2 | ▶ | sub _build_subscribers { SignalWire::Agents::REST::Namespaces::Fabric::Subscribers->new(_http => $_[0]->_http, _base_path => "$base/subscribers") } | ||||||||
|
Subroutine
_build_subscribers: called CC=1 SCAR=0.0
| |||||||||||
| 214 | 2 | ▶ | sub _build_sip_endpoints { $_[0]->_mk('ResourcePUT', "$base/sip_endpoints") } | ||||||||
|
Subroutine
_build_sip_endpoints: called CC=1 SCAR=0.0
| |||||||||||
| 215 | 2 | ▶ | sub _build_cxml_scripts { $_[0]->_mk('ResourcePUT', "$base/cxml_scripts") } | ||||||||
|
Subroutine
_build_cxml_scripts: called CC=1 SCAR=0.0
| |||||||||||
| 216 | 2 | ▶ | sub _build_cxml_applications { SignalWire::Agents::REST::Namespaces::Fabric::CxmlApplications->new(_http => $_[0]->_http, _base_path => "$base/cxml_applications") } | ||||||||
|
Subroutine
_build_cxml_applications: called CC=1 SCAR=0.0
| |||||||||||
| 217 | 2 | ▶ | sub _build_swml_webhooks { $_[0]->_mk('Resource', "$base/swml_webhooks") } | ||||||||
|
Subroutine
_build_swml_webhooks: called CC=1 SCAR=0.0
| |||||||||||
| 218 | 2 | ▶ | sub _build_ai_agents { $_[0]->_mk('Resource', "$base/ai_agents") } | ||||||||
|
Subroutine
_build_ai_agents: called CC=1 SCAR=0.0
| |||||||||||
| 219 | 2 | ▶ | sub _build_sip_gateways { $_[0]->_mk('Resource', "$base/sip_gateways") } | ||||||||
|
Subroutine
_build_sip_gateways: called CC=1 SCAR=0.0
| |||||||||||
| 220 | 2 | ▶ | sub _build_cxml_webhooks { $_[0]->_mk('Resource', "$base/cxml_webhooks") } | ||||||||
|
Subroutine
_build_cxml_webhooks: called CC=1 SCAR=0.0
| |||||||||||
| 221 | 2 | ▶ | sub _build_resources { SignalWire::Agents::REST::Namespaces::Fabric::GenericResources->new(_http => $_[0]->_http, _base_path => $base) } | ||||||||
|
Subroutine
_build_resources: called CC=1 SCAR=0.0
| |||||||||||
| 222 | 2 | ▶ | sub _build_addresses { SignalWire::Agents::REST::Namespaces::Fabric::Addresses->new(_http => $_[0]->_http, _base_path => '/api/fabric/addresses') } | ||||||||
|
Subroutine
_build_addresses: called CC=1 SCAR=0.0
| |||||||||||
| 223 | 2 | ▶ | sub _build_tokens { SignalWire::Agents::REST::Namespaces::Fabric::Tokens->new(_http => $_[0]->_http, _base_path => '/api/fabric') } | ||||||||
|
Subroutine
_build_tokens: called CC=1 SCAR=0.0
| |||||||||||
| 224 | |||||||||||
| 225 | 17 | ▶ | sub _mk { | ||||||||
|
Subroutine
_mk: called CC=1 SCAR=0.0
| |||||||||||
| 226 | 17 | my ($self, $type, $path) = @_; | |||||||||
| 227 | 17 | my $class = "SignalWire::Agents::REST::Namespaces::Fabric::$type"; | |||||||||
| 228 | 17 | return $class->new(_http => $self->_http, _base_path => $path); | |||||||||
| 229 | } | ||||||||||
| 230 | |||||||||||
| 231 | 4 | 1; | |||||||||