| 1 | # Generated by tools/generate.pl from Twilio's OpenAPI specs. Do not edit this file. | ||||||||||||||||||||
| 2 | package Twilio::Rest::Knowledge::V2::Knowledge; | ||||||||||||||||||||
| 3 | |||||||||||||||||||||
| 4 | 3 | ▶ | use 5.016; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | 3 | our $VERSION = '2.001'; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | package Twilio::Rest::Knowledge::V2::KnowledgeList; | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | 3 | ▶ | use parent 'Twilio::ListResource'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 3 | ▶ | use Twilio::Serialize; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 7 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 16 | 7 | my ($class, $version, $kb_id) = @_; | |||||||||||||||||||
| 17 | 7 | my $self = $class->SUPER::new($version); | |||||||||||||||||||
| 18 | 7 | $self->{solution} = { kb_id => $kb_id }; | |||||||||||||||||||
| 19 | 7 | $self->{uri} = join q{}, '/KnowledgeBases/', Twilio::Serialize::path_segment($kb_id), | |||||||||||||||||||
| 20 | '/Knowledge'; | ||||||||||||||||||||
| 21 | 7 | return $self; | |||||||||||||||||||
| 22 | } | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 1 | ▶ | sub create { | ||||||||||||||||||
|
Subroutine
create: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 25 | 1 | my ($self, $body) = @_; | |||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 1 | my $data = Twilio::Serialize::json_body($body, {}); | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | my $response = $self->{version}->handle_request( | ||||||||||||||||||||
| 30 | 'POST', | ||||||||||||||||||||
| 31 | $self->{uri}, | ||||||||||||||||||||
| 32 | 1 | 'create', | |||||||||||||||||||
| 33 | { | ||||||||||||||||||||
| 34 | data => $data, | ||||||||||||||||||||
| 35 | headers => { 'Content-Type' => 'application/json', } | ||||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||
| 38 | return Twilio::Rest::Knowledge::V2::KnowledgeInstance->new($self->{version}, | ||||||||||||||||||||
| 39 | 1 | $response->get_content, $self->{solution}{kb_id}); | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | ▶ | sub read { | ||||||||||||||||||
|
Subroutine
read: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 43 | 0 | my ($self, @arguments) = @_; | |||||||||||||||||||
| 44 | 0 | return $self->read_records(@arguments); | |||||||||||||||||||
| 45 | } | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 0 | ▶ | sub stream { | ||||||||||||||||||
|
Subroutine
stream: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 48 | 0 | my ($self, @arguments) = @_; | |||||||||||||||||||
| 49 | 0 | return $self->stream_records(@arguments); | |||||||||||||||||||
| 50 | } | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 1 | ▶ | sub page { | ||||||||||||||||||
|
Subroutine
page: called CC=2 SCAR=7.0
| |||||||||||||||||||||
| 53 | 1 | my ($self, $options, $page_size, $page_token) = @_; | |||||||||||||||||||
| 54 | 1 | ▶ | $options //= {}; | ||||||||||||||||||
|
Condition50%1/2
$options //= {}
MC/DC0%0/1
$options //= {}
$options
Truth table50%1/2
A
A= $options
| |||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | my $params = { | ||||||||||||||||||||
| 57 | page => $options->{page}, | ||||||||||||||||||||
| 58 | 1 | pageSize => $page_size, | |||||||||||||||||||
| 59 | pageToken => $page_token, | ||||||||||||||||||||
| 60 | }; | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 1 | my $response = $self->{version}->page('GET', $self->{uri}, { params => $params }); | |||||||||||||||||||
| 63 | 1 | return $self->_build_page($response); | |||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 0 | ▶ | sub get_page { | ||||||||||||||||||
|
Subroutine
get_page: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 67 | 0 | my ($self, $target_url) = @_; | |||||||||||||||||||
| 68 | 0 | my $client = $self->{version}->get_domain->get_client; | |||||||||||||||||||
| 69 | 0 | return $self->_build_page($client->request('GET', $target_url)); | |||||||||||||||||||
| 70 | } | ||||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 1 | ▶ | sub _build_page { | ||||||||||||||||||
|
Subroutine
_build_page: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 73 | 1 | my ($self, $response) = @_; | |||||||||||||||||||
| 74 | return Twilio::Rest::Knowledge::V2::KnowledgePage->new($self->{version}, $response, | ||||||||||||||||||||
| 75 | 1 | $self->{solution}); | |||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | 5 | ▶ | sub get_context { | ||||||||||||||||||
|
Subroutine
get_context: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 79 | 5 | my ($self, $knowledge_id) = @_; | |||||||||||||||||||
| 80 | return Twilio::Rest::Knowledge::V2::KnowledgeContext->new($self->{version}, | ||||||||||||||||||||
| 81 | $self->{solution}{kb_id}, | ||||||||||||||||||||
| 82 | 5 | $knowledge_id); | |||||||||||||||||||
| 83 | } | ||||||||||||||||||||
| 84 | |||||||||||||||||||||
| 85 | package Twilio::Rest::Knowledge::V2::KnowledgePage; | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | 3 | ▶ | use parent 'Twilio::TokenPaginationPage'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | 1 | ▶ | sub records_key { return 'knowledge' } | ||||||||||||||||||
|
Subroutine
records_key: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | 1 | ▶ | sub build_instance { | ||||||||||||||||||
|
Subroutine
build_instance: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 92 | 1 | my ($self, $payload) = @_; | |||||||||||||||||||
| 93 | return Twilio::Rest::Knowledge::V2::KnowledgeInstance->new($self->{version}, $payload, | ||||||||||||||||||||
| 94 | 1 | $self->{solution}{kb_id}); | |||||||||||||||||||
| 95 | } | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | package Twilio::Rest::Knowledge::V2::KnowledgeContext; | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | 3 | ▶ | use parent 'Twilio::InstanceContext'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | 3 | ▶ | use Twilio::Serialize; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | 5 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 104 | 5 | my ($class, $version, $kb_id, $knowledge_id) = @_; | |||||||||||||||||||
| 105 | 5 | my $self = $class->SUPER::new($version); | |||||||||||||||||||
| 106 | 5 | $self->{solution} = { kb_id => $kb_id, knowledge_id => $knowledge_id }; | |||||||||||||||||||
| 107 | 5 | $self->{uri} = join q{}, '/KnowledgeBases/', Twilio::Serialize::path_segment($kb_id), | |||||||||||||||||||
| 108 | '/Knowledge/', Twilio::Serialize::path_segment($knowledge_id); | ||||||||||||||||||||
| 109 | 5 | return $self; | |||||||||||||||||||
| 110 | } | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | 1 | ▶ | sub delete { | ||||||||||||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 113 | 1 | my ($self) = @_; | |||||||||||||||||||
| 114 | 1 | $self->{version}->handle_request('DELETE', $self->{uri}, 'delete'); | |||||||||||||||||||
| 115 | 1 | return 1; | |||||||||||||||||||
| 116 | } | ||||||||||||||||||||
| 117 | |||||||||||||||||||||
| 118 | 1 | ▶ | sub fetch { | ||||||||||||||||||
|
Subroutine
fetch: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 119 | 1 | my ($self) = @_; | |||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | 1 | my $response = $self->{version}->handle_request('GET', $self->{uri}, 'fetch'); | |||||||||||||||||||
| 122 | 1 | return $self->_build_instance($response); | |||||||||||||||||||
| 123 | } | ||||||||||||||||||||
| 124 | |||||||||||||||||||||
| 125 | 4 | ▶ | sub update { | ||||||||||||||||||
|
Subroutine
update: called CC=3 SCAR=11.0
| |||||||||||||||||||||
| 126 | 4 | my ($self, $body, $options) = @_; | |||||||||||||||||||
| 127 | 4 | ▶ | $options //= {}; | ||||||||||||||||||
|
Condition100%2/2
$options //= {}
MC/DC100%1/1
$options //= {}
$options
Truth table100%2/2
A
A= $options
| |||||||||||||||||||||
| 128 | |||||||||||||||||||||
| 129 | 4 | my $data = Twilio::Serialize::json_body($body, {}); | |||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | my $response = $self->{version}->handle_request( | ||||||||||||||||||||
| 132 | 'PATCH', | ||||||||||||||||||||
| 133 | $self->{uri}, | ||||||||||||||||||||
| 134 | 'update', | ||||||||||||||||||||
| 135 | { | ||||||||||||||||||||
| 136 | data => $data, | ||||||||||||||||||||
| 137 | 4 | params => { refresh => Twilio::Serialize::boolean_to_string($options->{refresh}), }, | |||||||||||||||||||
| 138 | headers => { 'Content-Type' => 'application/json', } | ||||||||||||||||||||
| 139 | } | ||||||||||||||||||||
| 140 | ); | ||||||||||||||||||||
| 141 | 4 | my $status = $response->get_status_code; | |||||||||||||||||||
| 142 | return Twilio::Rest::Knowledge::V2::UpdateKnowledge202ResponseInstance->new($self->{version}, | ||||||||||||||||||||
| 143 | 4 | ▶ | $response->get_content) | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 144 | if $status == 202; | ||||||||||||||||||||
| 145 | 2 | return $self->_build_instance($response); | |||||||||||||||||||
| 146 | } | ||||||||||||||||||||
| 147 | |||||||||||||||||||||
| 148 | 3 | ▶ | sub _build_instance { | ||||||||||||||||||
|
Subroutine
_build_instance: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 149 | 3 | my ($self, $response) = @_; | |||||||||||||||||||
| 150 | return Twilio::Rest::Knowledge::V2::KnowledgeInstance->new( | ||||||||||||||||||||
| 151 | $self->{version}, $response->get_content, | ||||||||||||||||||||
| 152 | $self->{solution}{kb_id}, $self->{solution}{knowledge_id} | ||||||||||||||||||||
| 153 | 3 | ); | |||||||||||||||||||
| 154 | } | ||||||||||||||||||||
| 155 | |||||||||||||||||||||
| 156 | package Twilio::Rest::Knowledge::V2::KnowledgeInstance; | ||||||||||||||||||||
| 157 | |||||||||||||||||||||
| 158 | 3 | ▶ | use parent 'Twilio::InstanceResource'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | 3 | ▶ | use Twilio::Deserialize; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 161 | |||||||||||||||||||||
| 162 | 5 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
| |||||||||||||||||||||
| 163 | 5 | my ($class, $version, $payload, $kb_id, $knowledge_id) = @_; | |||||||||||||||||||
| 164 | 5 | my $self = $class->SUPER::new($version, $payload); | |||||||||||||||||||
| 165 | 5 | ▶ | $self->{solution} = { kb_id => $kb_id, knowledge_id => $knowledge_id // $self->{properties}{id} }; | ||||||||||||||||||
|
Condition66%2/3
$knowledge_id // $self->{"properties"}{"id"}
MC/DC0%0/2
$knowledge_id // $self->{"properties"}{"id"}
$knowledge_id
$self->{"properties"}{"id"}
Truth table66%2/3
A // B
A= $knowledge_idB= $self->{"properties"}{"id"}
| |||||||||||||||||||||
| 166 | 5 | return $self; | |||||||||||||||||||
| 167 | } | ||||||||||||||||||||
| 168 | |||||||||||||||||||||
| 169 | 0 | ▶ | sub delete { | ||||||||||||||||||
|
Subroutine
delete: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 170 | 0 | my ($self, @arguments) = @_; | |||||||||||||||||||
| 171 | 0 | return $self->_context->delete(@arguments); | |||||||||||||||||||
| 172 | } | ||||||||||||||||||||
| 173 | |||||||||||||||||||||
| 174 | 0 | ▶ | sub fetch { | ||||||||||||||||||
|
Subroutine
fetch: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 175 | 0 | my ($self, @arguments) = @_; | |||||||||||||||||||
| 176 | 0 | return $self->_context->fetch(@arguments); | |||||||||||||||||||
| 177 | } | ||||||||||||||||||||
| 178 | |||||||||||||||||||||
| 179 | 0 | ▶ | sub update { | ||||||||||||||||||
|
Subroutine
update: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 180 | 0 | my ($self, @arguments) = @_; | |||||||||||||||||||
| 181 | 0 | return $self->_context->update(@arguments); | |||||||||||||||||||
| 182 | } | ||||||||||||||||||||
| 183 | |||||||||||||||||||||
| 184 | 0 | ▶ | sub _context { | ||||||||||||||||||
|
Subroutine
_context: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 185 | 0 | my ($self) = @_; | |||||||||||||||||||
| 186 | return Twilio::Rest::Knowledge::V2::KnowledgeContext->new( | ||||||||||||||||||||
| 187 | $self->{version}, | ||||||||||||||||||||
| 188 | $self->{solution}{kb_id}, | ||||||||||||||||||||
| 189 | $self->{solution}{knowledge_id} | ||||||||||||||||||||
| 190 | 0 | ); | |||||||||||||||||||
| 191 | } | ||||||||||||||||||||
| 192 | |||||||||||||||||||||
| 193 | 4 | ▶ | sub created_at { return Twilio::Deserialize::date_time($_[0]{properties}{createdAt}) } | ||||||||||||||||||
|
Subroutine
created_at: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 194 | 4 | ▶ | sub description { return $_[0]{properties}{description} } | ||||||||||||||||||
|
Subroutine
description: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 195 | 4 | ▶ | sub id { return $_[0]{properties}{id} } | ||||||||||||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 196 | 5 | ▶ | sub name { return $_[0]{properties}{name} } | ||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 197 | 4 | ▶ | sub source { return $_[0]{properties}{source} } | ||||||||||||||||||
|
Subroutine
source: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 198 | 4 | ▶ | sub status { return $_[0]{properties}{status} } | ||||||||||||||||||
|
Subroutine
status: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 199 | 4 | ▶ | sub updated_at { return Twilio::Deserialize::date_time($_[0]{properties}{updatedAt}) } | ||||||||||||||||||
|
Subroutine
updated_at: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 200 | |||||||||||||||||||||
| 201 | package Twilio::Rest::Knowledge::V2::UpdateKnowledge202ResponseInstance; | ||||||||||||||||||||
| 202 | |||||||||||||||||||||
| 203 | 3 | ▶ | use parent 'Twilio::InstanceResource'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 204 | |||||||||||||||||||||
| 205 | 3 | ▶ | use Twilio::Deserialize; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 206 | |||||||||||||||||||||
| 207 | 1 | ▶ | sub message { return $_[0]{properties}{message} } | ||||||||||||||||||
|
Subroutine
message: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 208 | |||||||||||||||||||||
| 209 | 3 | 1; | |||||||||||||||||||
| 210 | |||||||||||||||||||||
| 211 | __END__ | ||||||||||||||||||||