Webservice/OVH/Me/Order/Detail.pm

filter: Statementstmt 22.9% 11 / 48 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 25.0% 3 / 12 Podpod 100% 8 / 8 totaltotal 27.5% 22 / 80 CC 7 SCAR 27.5
CC
7
Cov
18%
_new
42.0
properties
6.0
order
2.0
CRAP 15.6
« Webservice/OVH/Order/Cart/Item.pm ↑ Summary Webservice/OVH/Email/Domain/Domain/Task/Account.pm »
1 package Webservice::OVH::Me::Order::Detail;
2  
3 =encoding utf-8
4  
5 =head1 NAME
6  
7 Webservice::OVH::Me::Order::Details
8  
9 =head1 SYNOPSIS
10  
11 use Webservice::OVH;
12
13 my $ovh = Webservice::OVH->new_from_json("credentials.json");
14
15 my $order = $ovh->me->orders->[0];
16
17 my $details = $order->details;
18
19 foreach my $detail (@$details) {
20
21 print $detail->unit_price;
22 }
23  
24 =head1 DESCRIPTION
25  
26 Provides access to details for an order entry.
27  
28 =head1 METHODS
29  
30 =cut
31  
32 36 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 36 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 36 ▶use Carp qw{ carp croak };
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 36 our $VERSION = 0.48;
37  
38 =head2 _new
39  
40 Internal Method to create the Detail object.
41 This method is not ment to be called directly.
42  
43 =over
44  
45 =item * Parameter: $api_wrapper - ovh api wrapper object, $module - root object, $detail_id - api id
46  
47 =item * Return: L<Webservice::OVH::Me::Order::Detail>
48  
49 =item * Synopsis: Webservice::OVH::Me::Order::Detail->_new($ovh_api_wrapper, $detail_id, $module);
50  
51 =back
52  
53 =cut
54  
55 0 ▶sub _new {
Subroutine _new: not called CC=6 SCAR=37.4
56  
57 0 my ( $class, %params ) = @_;
58  
59 0 ▶ die "Missing module" unless $params{module};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"module"} 0 0 0
60 0 ▶ die "Missing wrapper" unless $params{wrapper};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"wrapper"} 0 0 0
61 0 ▶ die "Missing id" unless $params{id};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"id"} 0 0 0
62 0 ▶ die "Missing order" unless $params{order};
Branch: 1 branch
BranchTrueFalseTotal
unless $params{"order"} 0 0 0
63  
64 0 my $module = $params{module};
65 0 my $api_wrapper = $params{wrapper};
66 0 my $detail_id = $params{id};
67 0 my $order = $params{order};
68 0 my $order_id = $order->id;
69  
70 0 my $response = $api_wrapper->rawCall( method => 'get', path => "/me/order/$order_id/details/$detail_id", noSignature => 0 );
71 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
72  
73 0 my $porperties = $response->content;
74  
75 0 my $self = bless { _module => $module, _api_wrapper => $api_wrapper, _id => $detail_id, _properties => $porperties, _order => $order }, $class;
76  
77 0 return $self;
78 }
79  
80 =head2 order
81  
82 Returns root Order object.
83  
84 =over
85  
86 =item * Return: L<Webservice::OVH::Me::Order>
87  
88 =item * Synopsis: my $order = $datail->order;
89  
90 =back
91  
92 =cut
93  
94 0 ▶sub order {
Subroutine order: not called CC=1 SCAR=6.9
Pod documented
95  
96 0 my ($self) = @_;
97  
98 0 return $self->{_order};
99 }
100  
101 =head2 id
102  
103 Returns the api id.
104  
105 =over
106  
107 =item * Return: VALUE
108  
109 =item * Synopsis: my $id = $detail->id;
110  
111 =back
112  
113 =cut
114  
115 0 ▶sub id {
Subroutine id: not called CC=1 SCAR=6.9
Pod documented
116  
117 0 my ($self) = @_;
118  
119 0 return $self->{_id};
120 }
121  
122 =head2 properties
123  
124 Retrieves properties.
125 This method updates the intern property variable.
126  
127 =over
128  
129 =item * Return: HASH
130  
131 =item * Synopsis: my $properties = $detail->properties;
132  
133 =back
134  
135 =cut
136  
137 0 ▶sub properties {
Subroutine properties: not called CC=2 SCAR=17.9
Pod documented
138  
139 0 my ($self) = @_;
140  
141 0 my $api = $self->{_api_wrapper};
142 0 my $order_id = $self->{_order}->id;
143 0 my $detail_id = $self->id;
144 0 my $response = $api->rawCall( method => 'get', path => "/me/order/$order_id/details/$detail_id", noSignature => 0 );
145 0 ▶ croak $response->error if $response->error;
Branch: 1 branch
BranchTrueFalseTotal
if $response->error 0 0 0
146  
147 0 $self->{_properties} = $response->content;
148 0 return $self->{_properties};
149 }
150  
151 =head2 description
152  
153 Exposed property value.
154  
155 =over
156  
157 =item * Return: VALUE
158  
159 =item * Synopsis: my $description = $detail->description;
160  
161 =back
162  
163 =cut
164  
165 0 ▶sub description {
Subroutine description: not called CC=1 SCAR=6.9
Pod documented
166  
167 0 my ($self) = @_;
168  
169 0 return $self->{_properties}->{description};
170 }
171  
172 =head2 domain
173  
174 Exposed property value.
175  
176 =over
177  
178 =item * Return: VALUE
179  
180 =item * Synopsis: my $domain = $detail->domain;
181  
182 =back
183  
184 =cut
185  
186 0 ▶sub domain {
Subroutine domain: not called CC=1 SCAR=6.9
Pod documented
187  
188 0 my ($self) = @_;
189  
190 0 return $self->{_properties}->{domain};
191 }
192  
193 =head2 quantity
194  
195 Exposed property value.
196  
197 =over
198  
199 =item * Return: VALUE
200  
201 =item * Synopsis: my $quantity = $detail->quantity;
202  
203 =back
204  
205 =cut
206  
207 0 ▶sub quantity {
Subroutine quantity: not called CC=1 SCAR=6.9
Pod documented
208  
209 0 my ($self) = @_;
210  
211 0 return $self->{_properties}->{quantity};
212 }
213  
214 =head2 total_price
215  
216 Exposed property value.
217  
218 =over
219  
220 =item * Return: VALUE
221  
222 =item * Synopsis: my $total_price = $detail->total_price;
223  
224 =back
225  
226 =cut
227  
228 0 ▶sub total_price {
Subroutine total_price: not called CC=1 SCAR=6.9
Pod documented
229  
230 0 my ($self) = @_;
231  
232 0 return $self->{_properties}->{totalPrice};
233 }
234  
235 =head2 unit_price
236  
237 Exposed property value.
238  
239 =over
240  
241 =item * Return: VALUE
242  
243 =item * Synopsis: my $unit_price = $detail->unit_price;
244  
245 =back
246  
247 =cut
248  
249 0 ▶sub unit_price {
Subroutine unit_price: not called CC=1 SCAR=6.9
Pod documented
250  
251 0 my ($self) = @_;
252  
253 0 return $self->{_properties}->{unitPrice};
254 }
255  
256 36 1;
« Webservice/OVH/Order/Cart/Item.pm ↑ Summary Webservice/OVH/Email/Domain/Domain/Task/Account.pm »