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