« blib/lib/SignalWire/Agents/Skills/Builtin/WikipediaSearch.pm
↑ Summary
blib/lib/SignalWire/Agents/Relay/Constants.pm »
| 1 | package SignalWire::Agents::REST::SignalWireClient; | ||
| 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 | 4 | ▶ | use SignalWire::Agents::REST::HttpClient; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 4 | ▶ | use SignalWire::Agents::REST::Namespaces::Base; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 4 | ▶ | use SignalWire::Agents::REST::Namespaces::Fabric; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 4 | ▶ | use SignalWire::Agents::REST::Namespaces::Calling; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | 4 | ▶ | use SignalWire::Agents::REST::Namespaces::PhoneNumbers; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 4 | ▶ | use SignalWire::Agents::REST::Namespaces::Datasphere; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 4 | ▶ | use SignalWire::Agents::REST::Namespaces::Video; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | 4 | ▶ | use SignalWire::Agents::REST::Namespaces::Compat; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 4 | ▶ | use SignalWire::Agents::REST::Namespaces::Resources; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 4 | ▶ | use SignalWire::Agents::REST::Namespaces::Registry; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | 4 | ▶ | use SignalWire::Agents::REST::Namespaces::Logs; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | 4 | ▶ | use SignalWire::Agents::REST::Namespaces::Project; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 18 | 4 | ▶ | use SignalWire::Agents::REST::Namespaces::PubSub; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 19 | 4 | ▶ | use SignalWire::Agents::REST::Namespaces::Chat; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 20 | |||
| 21 | 4 | has 'project' => ( is => 'ro', required => 1 ); | |
| 22 | 4 | has 'token' => ( is => 'ro', required => 1 ); | |
| 23 | 4 | has 'host' => ( is => 'ro', required => 1 ); | |
| 24 | |||
| 25 | 4 | has '_http' => ( is => 'lazy' ); | |
| 26 | |||
| 27 | # --- Namespaced sub-objects (all 21) --- | ||
| 28 | |||
| 29 | # Fabric API | ||
| 30 | 4 | has 'fabric' => ( is => 'lazy' ); | |
| 31 | |||
| 32 | # Calling API | ||
| 33 | 4 | has 'calling' => ( is => 'lazy' ); | |
| 34 | |||
| 35 | # Relay REST resources | ||
| 36 | 4 | has 'phone_numbers' => ( is => 'lazy' ); | |
| 37 | 4 | has 'addresses' => ( is => 'lazy' ); | |
| 38 | 4 | has 'queues' => ( is => 'lazy' ); | |
| 39 | 4 | has 'recordings' => ( is => 'lazy' ); | |
| 40 | 4 | has 'number_groups' => ( is => 'lazy' ); | |
| 41 | 4 | has 'verified_callers' => ( is => 'lazy' ); | |
| 42 | 4 | has 'sip_profile' => ( is => 'lazy' ); | |
| 43 | 4 | has 'lookup' => ( is => 'lazy' ); | |
| 44 | 4 | has 'short_codes' => ( is => 'lazy' ); | |
| 45 | 4 | has 'imported_numbers' => ( is => 'lazy' ); | |
| 46 | 4 | has 'mfa' => ( is => 'lazy' ); | |
| 47 | 4 | has 'registry' => ( is => 'lazy' ); | |
| 48 | |||
| 49 | # Datasphere API | ||
| 50 | 4 | has 'datasphere' => ( is => 'lazy' ); | |
| 51 | |||
| 52 | # Video API | ||
| 53 | 4 | has 'video' => ( is => 'lazy' ); | |
| 54 | |||
| 55 | # Logs | ||
| 56 | 4 | has 'logs' => ( is => 'lazy' ); | |
| 57 | |||
| 58 | # Project management | ||
| 59 | 4 | has 'project_ns' => ( is => 'lazy' ); | |
| 60 | |||
| 61 | # PubSub & Chat | ||
| 62 | 4 | has 'pubsub' => ( is => 'lazy' ); | |
| 63 | 4 | has 'chat' => ( is => 'lazy' ); | |
| 64 | |||
| 65 | # Compatibility (Twilio-compatible) API | ||
| 66 | 4 | has 'compat' => ( is => 'lazy' ); | |
| 67 | |||
| 68 | # --- Builders --- | ||
| 69 | |||
| 70 | 16 | ▶ | sub _build__http { |
|
Subroutine
_build__http: called CC=1 SCAR=0.0
| |||
| 71 | 16 | my ($self) = @_; | |
| 72 | 16 | return SignalWire::Agents::REST::HttpClient->new( | |
| 73 | project => $self->project, | ||
| 74 | token => $self->token, | ||
| 75 | host => $self->host, | ||
| 76 | ); | ||
| 77 | } | ||
| 78 | |||
| 79 | 4 | ▶ | sub _build_fabric { |
|
Subroutine
_build_fabric: called CC=1 SCAR=0.0
| |||
| 80 | 4 | my ($self) = @_; | |
| 81 | 4 | return SignalWire::Agents::REST::Namespaces::Fabric->new(_http => $self->_http); | |
| 82 | } | ||
| 83 | |||
| 84 | 5 | ▶ | sub _build_calling { |
|
Subroutine
_build_calling: called CC=1 SCAR=0.0
| |||
| 85 | 5 | my ($self) = @_; | |
| 86 | 5 | return SignalWire::Agents::REST::Namespaces::Calling->new( | |
| 87 | _http => $self->_http, | ||
| 88 | _base_path => '/api/calling/calls', | ||
| 89 | ); | ||
| 90 | } | ||
| 91 | |||
| 92 | 4 | ▶ | sub _build_phone_numbers { |
|
Subroutine
_build_phone_numbers: called CC=1 SCAR=0.0
| |||
| 93 | 4 | my ($self) = @_; | |
| 94 | 4 | return SignalWire::Agents::REST::Namespaces::PhoneNumbers->new( | |
| 95 | _http => $self->_http, | ||
| 96 | _base_path => '/api/relay/rest/phone_numbers', | ||
| 97 | ); | ||
| 98 | } | ||
| 99 | |||
| 100 | 2 | ▶ | sub _build_addresses { |
|
Subroutine
_build_addresses: called CC=1 SCAR=0.0
| |||
| 101 | 2 | my ($self) = @_; | |
| 102 | 2 | return SignalWire::Agents::REST::Namespaces::Addresses->new( | |
| 103 | _http => $self->_http, | ||
| 104 | _base_path => '/api/relay/rest/addresses', | ||
| 105 | ); | ||
| 106 | } | ||
| 107 | |||
| 108 | 3 | ▶ | sub _build_queues { |
|
Subroutine
_build_queues: called CC=1 SCAR=0.0
| |||
| 109 | 3 | my ($self) = @_; | |
| 110 | 3 | return SignalWire::Agents::REST::Namespaces::Queues->new( | |
| 111 | _http => $self->_http, | ||
| 112 | _base_path => '/api/relay/rest/queues', | ||
| 113 | ); | ||
| 114 | } | ||
| 115 | |||
| 116 | 2 | ▶ | sub _build_recordings { |
|
Subroutine
_build_recordings: called CC=1 SCAR=0.0
| |||
| 117 | 2 | my ($self) = @_; | |
| 118 | 2 | return SignalWire::Agents::REST::Namespaces::Recordings->new( | |
| 119 | _http => $self->_http, | ||
| 120 | _base_path => '/api/relay/rest/recordings', | ||
| 121 | ); | ||
| 122 | } | ||
| 123 | |||
| 124 | 3 | ▶ | sub _build_number_groups { |
|
Subroutine
_build_number_groups: called CC=1 SCAR=0.0
| |||
| 125 | 3 | my ($self) = @_; | |
| 126 | 3 | return SignalWire::Agents::REST::Namespaces::NumberGroups->new( | |
| 127 | _http => $self->_http, | ||
| 128 | _base_path => '/api/relay/rest/number_groups', | ||
| 129 | ); | ||
| 130 | } | ||
| 131 | |||
| 132 | 3 | ▶ | sub _build_verified_callers { |
|
Subroutine
_build_verified_callers: called CC=1 SCAR=0.0
| |||
| 133 | 3 | my ($self) = @_; | |
| 134 | 3 | return SignalWire::Agents::REST::Namespaces::VerifiedCallers->new( | |
| 135 | _http => $self->_http, | ||
| 136 | _base_path => '/api/relay/rest/verified_caller_ids', | ||
| 137 | ); | ||
| 138 | } | ||
| 139 | |||
| 140 | 3 | ▶ | sub _build_sip_profile { |
|
Subroutine
_build_sip_profile: called CC=1 SCAR=0.0
| |||
| 141 | 3 | my ($self) = @_; | |
| 142 | 3 | return SignalWire::Agents::REST::Namespaces::SipProfile->new( | |
| 143 | _http => $self->_http, | ||
| 144 | _base_path => '/api/relay/rest/sip_profile', | ||
| 145 | ); | ||
| 146 | } | ||
| 147 | |||
| 148 | 3 | ▶ | sub _build_lookup { |
|
Subroutine
_build_lookup: called CC=1 SCAR=0.0
| |||
| 149 | 3 | my ($self) = @_; | |
| 150 | 3 | return SignalWire::Agents::REST::Namespaces::Lookup->new( | |
| 151 | _http => $self->_http, | ||
| 152 | _base_path => '/api/relay/rest/lookup', | ||
| 153 | ); | ||
| 154 | } | ||
| 155 | |||
| 156 | 2 | ▶ | sub _build_short_codes { |
|
Subroutine
_build_short_codes: called CC=1 SCAR=0.0
| |||
| 157 | 2 | my ($self) = @_; | |
| 158 | 2 | return SignalWire::Agents::REST::Namespaces::ShortCodes->new( | |
| 159 | _http => $self->_http, | ||
| 160 | _base_path => '/api/relay/rest/short_codes', | ||
| 161 | ); | ||
| 162 | } | ||
| 163 | |||
| 164 | 3 | ▶ | sub _build_imported_numbers { |
|
Subroutine
_build_imported_numbers: called CC=1 SCAR=0.0
| |||
| 165 | 3 | my ($self) = @_; | |
| 166 | 3 | return SignalWire::Agents::REST::Namespaces::ImportedNumbers->new( | |
| 167 | _http => $self->_http, | ||
| 168 | _base_path => '/api/relay/rest/imported_phone_numbers', | ||
| 169 | ); | ||
| 170 | } | ||
| 171 | |||
| 172 | 3 | ▶ | sub _build_mfa { |
|
Subroutine
_build_mfa: called CC=1 SCAR=0.0
| |||
| 173 | 3 | my ($self) = @_; | |
| 174 | 3 | return SignalWire::Agents::REST::Namespaces::MFA->new( | |
| 175 | _http => $self->_http, | ||
| 176 | _base_path => '/api/relay/rest/mfa', | ||
| 177 | ); | ||
| 178 | } | ||
| 179 | |||
| 180 | 3 | ▶ | sub _build_registry { |
|
Subroutine
_build_registry: called CC=1 SCAR=0.0
| |||
| 181 | 3 | my ($self) = @_; | |
| 182 | 3 | return SignalWire::Agents::REST::Namespaces::Registry->new(_http => $self->_http); | |
| 183 | } | ||
| 184 | |||
| 185 | 3 | ▶ | sub _build_datasphere { |
|
Subroutine
_build_datasphere: called CC=1 SCAR=0.0
| |||
| 186 | 3 | my ($self) = @_; | |
| 187 | 3 | return SignalWire::Agents::REST::Namespaces::Datasphere->new(_http => $self->_http); | |
| 188 | } | ||
| 189 | |||
| 190 | 3 | ▶ | sub _build_video { |
|
Subroutine
_build_video: called CC=1 SCAR=0.0
| |||
| 191 | 3 | my ($self) = @_; | |
| 192 | 3 | return SignalWire::Agents::REST::Namespaces::Video->new(_http => $self->_http); | |
| 193 | } | ||
| 194 | |||
| 195 | 3 | ▶ | sub _build_logs { |
|
Subroutine
_build_logs: called CC=1 SCAR=0.0
| |||
| 196 | 3 | my ($self) = @_; | |
| 197 | 3 | return SignalWire::Agents::REST::Namespaces::Logs->new(_http => $self->_http); | |
| 198 | } | ||
| 199 | |||
| 200 | 3 | ▶ | sub _build_project_ns { |
|
Subroutine
_build_project_ns: called CC=1 SCAR=0.0
| |||
| 201 | 3 | my ($self) = @_; | |
| 202 | 3 | return SignalWire::Agents::REST::Namespaces::Project->new(_http => $self->_http); | |
| 203 | } | ||
| 204 | |||
| 205 | 4 | ▶ | sub _build_pubsub { |
|
Subroutine
_build_pubsub: called CC=1 SCAR=0.0
| |||
| 206 | 4 | my ($self) = @_; | |
| 207 | 4 | return SignalWire::Agents::REST::Namespaces::PubSub->new( | |
| 208 | _http => $self->_http, | ||
| 209 | _base_path => '/api/pubsub/tokens', | ||
| 210 | ); | ||
| 211 | } | ||
| 212 | |||
| 213 | 4 | ▶ | sub _build_chat { |
|
Subroutine
_build_chat: called CC=1 SCAR=0.0
| |||
| 214 | 4 | my ($self) = @_; | |
| 215 | 4 | return SignalWire::Agents::REST::Namespaces::Chat->new( | |
| 216 | _http => $self->_http, | ||
| 217 | _base_path => '/api/chat/tokens', | ||
| 218 | ); | ||
| 219 | } | ||
| 220 | |||
| 221 | 3 | ▶ | sub _build_compat { |
|
Subroutine
_build_compat: called CC=1 SCAR=0.0
| |||
| 222 | 3 | my ($self) = @_; | |
| 223 | 3 | return SignalWire::Agents::REST::Namespaces::Compat->new( | |
| 224 | _http => $self->_http, | ||
| 225 | account_sid => $self->project, | ||
| 226 | ); | ||
| 227 | } | ||
| 228 | |||
| 229 | 4 | 1; | |