Twilio/Rest/Memory/V1/Observation.pm

filter: Statementstmt 88.2% 113 / 128 Branchbran 100% 6 / 6 Conditioncond 57.1% 4 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 85.7% 42 / 49 Podpod n/a totaltotal 85.0% 165 / 194 CC 7 SCAR 3.2
CC
7
Cov
87%
create
3.0
page
2.0
new
2.0
CRAP 1.4
« Twilio/Rest/Memory/V1/ConversationSummary.pm ↑ Summary Twilio/Rest/Messaging/V1.pm »
1 # Generated by tools/generate.pl from Twilio's OpenAPI specs. Do not edit this file.
2 package Twilio::Rest::Memory::V1::Observation;
3  
4 2 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '2.001';
8  
9 package Twilio::Rest::Memory::V1::ObservationList;
10  
11 2 ▶use parent 'Twilio::ListResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 8 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
16 8 my ($class, $version, $store_id, $profile_id) = @_;
17 8 my $self = $class->SUPER::new($version);
18 8 $self->{solution} = { store_id => $store_id, profile_id => $profile_id };
19 8 $self->{uri} = join q{}, '/Stores/', Twilio::Serialize::path_segment($store_id), '/Profiles/',
20 Twilio::Serialize::path_segment($profile_id), '/Observations';
21 8 return $self;
22 }
23  
24 2 ▶sub create {
Subroutine create: called CC=3 SCAR=11.0
25 2 my ($self, $body, $options) = @_;
26 2 ▶ $options //= {};
Condition50%1/2
$options //= {}
l!l
20
MC/DC0%0/1
$options //= {}
$options
Truth table50%1/2
A
A= $options
Aresult
11
00
27  
28 2 my $data = Twilio::Serialize::json_body($body, {});
29  
30 my $response = $self->{version}->handle_request(
31 'POST',
32 $self->{uri},
33 'create',
34 {
35 data => $data,
36 headers => {
37 'Content-Type' => 'application/json',
38 'Accept-Encoding' => $options->{accept_encoding},
39 'Content-Encoding' => $options->{content_encoding},
40 }
41 }
42 2 );
43 2 my $status = $response->get_status_code;
44 return Twilio::Rest::Memory::V1::CreateProfileObservation308ResponseInstance->new(
45 2 ▶ $self->{version}, $response->get_content)
Branch: 1 branch
BranchTrueFalseTotal
if $status == 308 1 1 2
46 if $status == 308;
47 return Twilio::Rest::Memory::V1::ObservationCreatedResponseInstance->new($self->{version},
48 1 $response->get_content);
49 }
50  
51 0 ▶sub read {
Subroutine read: not called CC=1 SCAR=6.9
52 0 my ($self, @arguments) = @_;
53 0 return $self->read_records(@arguments);
54 }
55  
56 0 ▶sub stream {
Subroutine stream: not called CC=1 SCAR=6.9
57 0 my ($self, @arguments) = @_;
58 0 return $self->stream_records(@arguments);
59 }
60  
61 1 ▶sub page {
Subroutine page: called CC=2 SCAR=7.0
62 1 my ($self, $options, $page_size, $page_token) = @_;
63 1 ▶ $options //= {};
Condition50%1/2
$options //= {}
l!l
10
MC/DC0%0/1
$options //= {}
$options
Truth table50%1/2
A
A= $options
Aresult
11
00
64  
65 my $params = {
66 conversationId => $options->{conversation_id},
67 createdAfter => Twilio::Serialize::iso8601_date_time($options->{created_after}),
68 createdBefore => Twilio::Serialize::iso8601_date_time($options->{created_before}),
69 orderBy => $options->{order_by},
70 source => $options->{source},
71 1 pageSize => $page_size,
72 pageToken => $page_token,
73 };
74  
75 my $response = $self->{version}->page(
76 'GET',
77 $self->{uri},
78 {
79 params => $params,
80 headers => { 'Accept-Encoding' => $options->{accept_encoding}, }
81 }
82 1 );
83 1 return $self->_build_page($response);
84 }
85  
86 0 ▶sub get_page {
Subroutine get_page: not called CC=1 SCAR=6.9
87 0 my ($self, $target_url) = @_;
88 0 my $client = $self->{version}->get_domain->get_client;
89 0 return $self->_build_page($client->request('GET', $target_url));
90 }
91  
92 1 ▶sub _build_page {
Subroutine _build_page: called CC=1 SCAR=0.0
93 1 my ($self, $response) = @_;
94 return Twilio::Rest::Memory::V1::ObservationPage->new($self->{version}, $response,
95 1 $self->{solution});
96 }
97  
98 5 ▶sub get_context {
Subroutine get_context: called CC=1 SCAR=0.0
99 5 my ($self, $observation_id) = @_;
100 return Twilio::Rest::Memory::V1::ObservationContext->new(
101 $self->{version},
102 $self->{solution}{store_id},
103 $self->{solution}{profile_id},
104 5 $observation_id
105 );
106 }
107  
108 package Twilio::Rest::Memory::V1::ObservationPage;
109  
110 2 ▶use parent 'Twilio::TokenPaginationPage';
Subroutine BEGIN: called CC=1 SCAR=0.0
111  
112 1 ▶sub records_key { return 'observations' }
Subroutine records_key: called CC=1 SCAR=0.0
113  
114 1 ▶sub build_instance {
Subroutine build_instance: called CC=1 SCAR=0.0
115 1 my ($self, $payload) = @_;
116 return Twilio::Rest::Memory::V1::ObservationInstance->new(
117 $self->{version}, $payload,
118 $self->{solution}{store_id},
119 $self->{solution}{profile_id}
120 1 );
121 }
122  
123 package Twilio::Rest::Memory::V1::ObservationContext;
124  
125 2 ▶use parent 'Twilio::InstanceContext';
Subroutine BEGIN: called CC=1 SCAR=0.0
126  
127 2 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
128  
129 5 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
130 5 my ($class, $version, $store_id, $profile_id, $observation_id) = @_;
131 5 my $self = $class->SUPER::new($version);
132 $self->{solution} =
133 5 { store_id => $store_id, profile_id => $profile_id, observation_id => $observation_id };
134 5 $self->{uri} = join q{}, '/Stores/', Twilio::Serialize::path_segment($store_id), '/Profiles/',
135 Twilio::Serialize::path_segment($profile_id), '/Observations/',
136 Twilio::Serialize::path_segment($observation_id);
137 5 return $self;
138 }
139  
140 2 ▶sub delete {
Subroutine delete: called CC=2 SCAR=6.9
141 2 my ($self) = @_;
142 2 my $response = $self->{version}->handle_request('DELETE', $self->{uri}, 'delete');
143 2 my $status = $response->get_status_code;
144 return Twilio::Rest::Memory::V1::CreateProfileObservation308ResponseInstance->new(
145 2 ▶ $self->{version}, $response->get_content)
Branch: 1 branch
BranchTrueFalseTotal
if $status == 308 1 1 2
146 if $status == 308;
147 return Twilio::Rest::Memory::V1::DeleteProfileObservation202ResponseInstance->new(
148 1 $self->{version}, $response->get_content);
149 }
150  
151 1 ▶sub fetch {
Subroutine fetch: called CC=1 SCAR=0.0
152 1 my ($self) = @_;
153  
154 1 my $response = $self->{version}->handle_request('GET', $self->{uri}, 'fetch');
155 1 return $self->_build_instance($response);
156 }
157  
158 2 ▶sub patch {
Subroutine patch: called CC=2 SCAR=6.9
159 2 my ($self, $body) = @_;
160  
161 2 my $data = Twilio::Serialize::json_body($body, { 'occurredAt' => 'iso8601_date_time' });
162  
163 my $response = $self->{version}->handle_request(
164 'PATCH',
165 $self->{uri},
166 2 'patch',
167 {
168 data => $data,
169 headers => { 'Content-Type' => 'application/json', }
170 }
171 );
172 2 my $status = $response->get_status_code;
173 return Twilio::Rest::Memory::V1::CreateProfileObservation308ResponseInstance->new(
174 2 ▶ $self->{version}, $response->get_content)
Branch: 1 branch
BranchTrueFalseTotal
if $status == 308 1 1 2
175 if $status == 308;
176 return Twilio::Rest::Memory::V1::PatchProfileObservation202ResponseInstance->new($self->{version},
177 1 $response->get_content);
178 }
179  
180 1 ▶sub _build_instance {
Subroutine _build_instance: called CC=1 SCAR=0.0
181 1 my ($self, $response) = @_;
182 return Twilio::Rest::Memory::V1::ObservationInstance->new(
183 $self->{version}, $response->get_content,
184 $self->{solution}{store_id},
185 $self->{solution}{profile_id},
186 $self->{solution}{observation_id}
187 1 );
188 }
189  
190 package Twilio::Rest::Memory::V1::ObservationInstance;
191  
192 2 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
193  
194 2 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
195  
196 2 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
197 2 my ($class, $version, $payload, $store_id, $profile_id, $observation_id) = @_;
198 2 my $self = $class->SUPER::new($version, $payload);
199 $self->{solution} = {
200 store_id => $store_id,
201 profile_id => $profile_id,
202 observation_id => $observation_id // $self->{properties}{id}
203 2 ▶ };
Condition66%2/3
$observation_id // $self->{"properties"}{"id"}
l!l&&r!l&&!r
110
MC/DC0%0/2
$observation_id // $self->{"properties"}{"id"}
$observation_id $self->{"properties"}{"id"}
Truth table66%2/3
A // B
A= $observation_idB= $self->{"properties"}{"id"}
ABresult
1X1
011
000
204 2 return $self;
205 }
206  
207 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
208 0 my ($self, @arguments) = @_;
209 0 return $self->_context->delete(@arguments);
210 }
211  
212 0 ▶sub fetch {
Subroutine fetch: not called CC=1 SCAR=6.9
213 0 my ($self, @arguments) = @_;
214 0 return $self->_context->fetch(@arguments);
215 }
216  
217 0 ▶sub patch {
Subroutine patch: not called CC=1 SCAR=6.9
218 0 my ($self, @arguments) = @_;
219 0 return $self->_context->patch(@arguments);
220 }
221  
222 0 ▶sub _context {
Subroutine _context: not called CC=1 SCAR=6.9
223 0 my ($self) = @_;
224 return Twilio::Rest::Memory::V1::ObservationContext->new(
225 $self->{version}, $self->{solution}{store_id},
226 $self->{solution}{profile_id}, $self->{solution}{observation_id}
227 0 );
228 }
229  
230 2 ▶sub content { return $_[0]{properties}{content} }
Subroutine content: called CC=1 SCAR=0.0
231 2 ▶sub conversation_ids { return $_[0]{properties}{conversationIds} }
Subroutine conversation_ids: called CC=1 SCAR=0.0
232 2 ▶sub created_at { return Twilio::Deserialize::date_time($_[0]{properties}{createdAt}) }
Subroutine created_at: called CC=1 SCAR=0.0
233 2 ▶sub id { return $_[0]{properties}{id} }
Subroutine id: called CC=1 SCAR=0.0
234 2 ▶sub occurred_at { return Twilio::Deserialize::date_time($_[0]{properties}{occurredAt}) }
Subroutine occurred_at: called CC=1 SCAR=0.0
235 2 ▶sub source { return $_[0]{properties}{source} }
Subroutine source: called CC=1 SCAR=0.0
236 2 ▶sub updated_at { return Twilio::Deserialize::date_time($_[0]{properties}{updatedAt}) }
Subroutine updated_at: called CC=1 SCAR=0.0
237  
238 package Twilio::Rest::Memory::V1::ObservationCreatedResponseInstance;
239  
240 2 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
241  
242 2 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
243  
244 1 ▶sub message { return $_[0]{properties}{message} }
Subroutine message: called CC=1 SCAR=0.0
245  
246 package Twilio::Rest::Memory::V1::CreateProfileObservation308ResponseInstance;
247  
248 2 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
249  
250 2 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
251  
252 3 ▶sub message { return $_[0]{properties}{message} }
Subroutine message: called CC=1 SCAR=0.0
253 3 ▶sub uri { return $_[0]{properties}{uri} }
Subroutine uri: called CC=1 SCAR=0.0
254  
255 package Twilio::Rest::Memory::V1::PatchProfileObservation202ResponseInstance;
256  
257 2 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
258  
259 2 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
260  
261 1 ▶sub message { return $_[0]{properties}{message} }
Subroutine message: called CC=1 SCAR=0.0
262  
263 package Twilio::Rest::Memory::V1::DeleteProfileObservation202ResponseInstance;
264  
265 2 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
266  
267 2 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
268  
269 1 ▶sub message { return $_[0]{properties}{message} }
Subroutine message: called CC=1 SCAR=0.0
270  
271 2 1;
272  
273 __END__
« Twilio/Rest/Memory/V1/ConversationSummary.pm ↑ Summary Twilio/Rest/Messaging/V1.pm »