Twilio/Rest/Events/V1/Subscription.pm

filter: Statementstmt 83.0% 83 / 100 Branchbran 100% 2 / 2 Conditioncond 57.1% 4 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 79.4% 31 / 39 Podpod n/a totaltotal 78.9% 120 / 152 CC 5 SCAR 3.2
CC
5
Cov
82%
page
2.0
update
2.0
new
2.0
CRAP 1.4
« Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapItem.pm ↑ Summary Twilio/Rest/Verify/V2/Service/Entity.pm »
1 # Generated by tools/generate.pl from Twilio's OpenAPI specs. Do not edit this file.
2 package Twilio::Rest::Events::V1::Subscription;
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::Events::V1::SubscriptionList;
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 12 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
16 12 my ($class, $version) = @_;
17 12 my $self = $class->SUPER::new($version);
18 12 $self->{solution} = {};
19 12 $self->{uri} = '/Subscriptions';
20 12 return $self;
21 }
22  
23 2 ▶sub create {
Subroutine create: called CC=1 SCAR=0.0
24 2 my ($self, $description, $sink_sid, $types) = @_;
25  
26 2 my $data = {
27 Description => $description,
28 SinkSid => $sink_sid,
29 Types => Twilio::Serialize::map_values($types, \&Twilio::Serialize::json_object),
30 };
31  
32 my $response =
33 2 $self->{version}->handle_request('POST', $self->{uri}, 'create', { data => $data });
34 return Twilio::Rest::Events::V1::SubscriptionInstance->new($self->{version},
35 2 $response->get_content);
36 }
37  
38 0 ▶sub read {
Subroutine read: not called CC=1 SCAR=6.9
39 0 my ($self, @arguments) = @_;
40 0 return $self->read_records(@arguments);
41 }
42  
43 0 ▶sub stream {
Subroutine stream: not called CC=1 SCAR=6.9
44 0 my ($self, @arguments) = @_;
45 0 return $self->stream_records(@arguments);
46 }
47  
48 1 ▶sub page {
Subroutine page: called CC=2 SCAR=7.0
49 1 my ($self, $options, $page_size, $page_token, $page_number) = @_;
50 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
51  
52 my $params = {
53 SinkSid => $options->{sink_sid},
54 1 PageToken => $page_token,
55 Page => $page_number,
56 PageSize => $page_size,
57 };
58  
59 1 my $response = $self->{version}->page('GET', $self->{uri}, { params => $params });
60 1 return $self->_build_page($response);
61 }
62  
63 0 ▶sub get_page {
Subroutine get_page: not called CC=1 SCAR=6.9
64 0 my ($self, $target_url) = @_;
65 0 my $client = $self->{version}->get_domain->get_client;
66 0 return $self->_build_page($client->request('GET', $target_url));
67 }
68  
69 1 ▶sub _build_page {
Subroutine _build_page: called CC=1 SCAR=0.0
70 1 my ($self, $response) = @_;
71 return Twilio::Rest::Events::V1::SubscriptionPage->new($self->{version}, $response,
72 1 $self->{solution});
73 }
74  
75 9 ▶sub get_context {
Subroutine get_context: called CC=1 SCAR=0.0
76 9 my ($self, $sid) = @_;
77 9 return Twilio::Rest::Events::V1::SubscriptionContext->new($self->{version}, $sid);
78 }
79  
80 package Twilio::Rest::Events::V1::SubscriptionPage;
81  
82 3 ▶use parent 'Twilio::Page';
Subroutine BEGIN: called CC=1 SCAR=0.0
83  
84 1 ▶sub records_key { return 'subscriptions' }
Subroutine records_key: called CC=1 SCAR=0.0
85  
86 1 ▶sub build_instance {
Subroutine build_instance: called CC=1 SCAR=0.0
87 1 my ($self, $payload) = @_;
88 1 return Twilio::Rest::Events::V1::SubscriptionInstance->new($self->{version}, $payload);
89 }
90  
91 package Twilio::Rest::Events::V1::SubscriptionContext;
92  
93 3 ▶use parent 'Twilio::InstanceContext';
Subroutine BEGIN: called CC=1 SCAR=0.0
94  
95 3 ▶use Twilio::Serialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
96  
97 9 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
98 9 my ($class, $version, $sid) = @_;
99 9 my $self = $class->SUPER::new($version);
100 9 $self->{solution} = { sid => $sid };
101 9 $self->{uri} = join q{}, '/Subscriptions/', Twilio::Serialize::path_segment($sid);
102 9 return $self;
103 }
104  
105 1 ▶sub delete {
Subroutine delete: called CC=1 SCAR=0.0
106 1 my ($self) = @_;
107 1 $self->{version}->handle_request('DELETE', $self->{uri}, 'delete');
108 1 return 1;
109 }
110  
111 1 ▶sub fetch {
Subroutine fetch: called CC=1 SCAR=0.0
112 1 my ($self) = @_;
113  
114 1 my $response = $self->{version}->handle_request('GET', $self->{uri}, 'fetch');
115 1 return $self->_build_instance($response);
116 }
117  
118 1 ▶sub update {
Subroutine update: called CC=2 SCAR=7.0
119 1 my ($self, $options) = @_;
120 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
121  
122 1 my $data = { Description => $options->{description}, };
123  
124 my $response =
125 1 $self->{version}->handle_request('POST', $self->{uri}, 'update', { data => $data });
126 1 return $self->_build_instance($response);
127 }
128  
129 2 ▶sub _build_instance {
Subroutine _build_instance: called CC=1 SCAR=0.0
130 2 my ($self, $response) = @_;
131 return Twilio::Rest::Events::V1::SubscriptionInstance->new($self->{version},
132 2 $response->get_content, $self->{solution}{sid});
133 }
134  
135 6 ▶sub subscribed_events {
Subroutine subscribed_events: called CC=2 SCAR=6.9
136 6 my ($self, $type) = @_;
137 6 require Twilio::Rest::Events::V1::Subscription::SubscribedEvent;
138 my $list = Twilio::Rest::Events::V1::Subscription::SubscribedEventList->new($self->{version},
139 6 $self->{solution}{sid});
140 6 ▶ return defined $type ? $list->get_context($type) : $list;
Branch: 1 branch
BranchTrueFalseTotal
defined $type ? : 3 3 6
141 }
142  
143 package Twilio::Rest::Events::V1::SubscriptionInstance;
144  
145 3 ▶use parent 'Twilio::InstanceResource';
Subroutine BEGIN: called CC=1 SCAR=0.0
146  
147 3 ▶use Twilio::Deserialize;
Subroutine BEGIN: called CC=1 SCAR=0.0
148  
149 5 ▶sub new {
Subroutine new: called CC=2 SCAR=7.0
150 5 my ($class, $version, $payload, $sid) = @_;
151 5 my $self = $class->SUPER::new($version, $payload);
152 5 ▶ $self->{solution} = { sid => $sid // $self->{properties}{sid} };
Condition66%2/3
$sid // $self->{"properties"}{"sid"}
l!l&&r!l&&!r
230
MC/DC0%0/2
$sid // $self->{"properties"}{"sid"}
$sid $self->{"properties"}{"sid"}
Truth table66%2/3
A // B
A= $sidB= $self->{"properties"}{"sid"}
ABresult
1X1
011
000
153 5 return $self;
154 }
155  
156 0 ▶sub delete {
Subroutine delete: not called CC=1 SCAR=6.9
157 0 my ($self, @arguments) = @_;
158 0 return $self->_context->delete(@arguments);
159 }
160  
161 0 ▶sub fetch {
Subroutine fetch: not called CC=1 SCAR=6.9
162 0 my ($self, @arguments) = @_;
163 0 return $self->_context->fetch(@arguments);
164 }
165  
166 0 ▶sub update {
Subroutine update: not called CC=1 SCAR=6.9
167 0 my ($self, @arguments) = @_;
168 0 return $self->_context->update(@arguments);
169 }
170  
171 0 ▶sub subscribed_events {
Subroutine subscribed_events: not called CC=1 SCAR=6.9
172 0 my ($self, @arguments) = @_;
173 0 return $self->_context->subscribed_events(@arguments);
174 }
175  
176 0 ▶sub _context {
Subroutine _context: not called CC=1 SCAR=6.9
177 0 my ($self) = @_;
178 return Twilio::Rest::Events::V1::SubscriptionContext->new($self->{version},
179 0 $self->{solution}{sid});
180 }
181  
182 4 ▶sub account_sid { return $_[0]{properties}{account_sid} }
Subroutine account_sid: called CC=1 SCAR=0.0
183 4 ▶sub date_created { return Twilio::Deserialize::date_time($_[0]{properties}{date_created}) }
Subroutine date_created: called CC=1 SCAR=0.0
184 4 ▶sub date_updated { return Twilio::Deserialize::date_time($_[0]{properties}{date_updated}) }
Subroutine date_updated: called CC=1 SCAR=0.0
185 4 ▶sub description { return $_[0]{properties}{description} }
Subroutine description: called CC=1 SCAR=0.0
186 4 ▶sub links { return $_[0]{properties}{links} }
Subroutine links: called CC=1 SCAR=0.0
187 4 ▶sub sid { return $_[0]{properties}{sid} }
Subroutine sid: called CC=1 SCAR=0.0
188 4 ▶sub sink_sid { return $_[0]{properties}{sink_sid} }
Subroutine sink_sid: called CC=1 SCAR=0.0
189 4 ▶sub url { return $_[0]{properties}{url} }
Subroutine url: called CC=1 SCAR=0.0
190  
191 3 1;
192  
193 __END__
« Twilio/Rest/Sync/V1/Service/SyncMap/SyncMapItem.pm ↑ Summary Twilio/Rest/Verify/V2/Service/Entity.pm »