| 1 | package Webservice::OVH::Order::Cart; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | =encoding utf-8 | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | Webservice::OVH::Order::Cart | ||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | use Webservice::OVH; | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | my $ovh = Webservice::OVH->new_from_json("credentials.json"); | ||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | my $cart = $ovh->order->new_cart(ovh_subsidiary => 'DE'); | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | $cart->add_domain('www.domain.com'); | ||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | $cart->delete; | ||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | =head1 DESCRIPTION | ||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | Provides methods to manage shopping carts. | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | =head1 METHODS | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | =cut | ||||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 36 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 30 | 36 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 31 | 36 | ▶ | use Carp qw{ carp croak }; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 36 | our $VERSION = 0.48; | |||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | 36 | ▶ | use Webservice::OVH::Order::Cart::Item; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | =head2 _new_existing | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | Internal Method to create the Cart object. | ||||||||||||||||||||
| 40 | This method is not ment to be called directly. | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | =over | ||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | =item * Parameter: $api_wrapper - ovh api wrapper object, $module - root object, $cart_id - api id | ||||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | =item * Return: L<Webservice::OVH::Order::Cart> | ||||||||||||||||||||
| 47 | |||||||||||||||||||||
| 48 | =item * Synopsis: Webservice::OVH::Order::Cart->_new($ovh_api_wrapper, $cart_id, $module); | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | =back | ||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | =cut | ||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 0 | ▶ | sub _new_existing { | ||||||||||||||||||
|
Subroutine
_new_existing: not called CC=6 SCAR=37.4
| |||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | 0 | my ( $class, %params ) = @_; | |||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 0 | ▶ | die "Missing module" unless $params{module}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 59 | 0 | ▶ | die "Missing wrapper" unless $params{wrapper}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 60 | 0 | ▶ | die "Missing id" unless $params{id}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 0 | my $module = $params{module}; | |||||||||||||||||||
| 63 | 0 | my $api_wrapper = $params{wrapper}; | |||||||||||||||||||
| 64 | 0 | my $cart_id = $params{id}; | |||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 0 | my $response = $api_wrapper->rawCall( method => 'get', path => "/order/cart/$cart_id", noSignature => 0 ); | |||||||||||||||||||
| 67 | 0 | ▶ | carp $response->error if $response->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 0 | ▶ | if ( !$response->error ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | 0 | my $properties = $response->content; | |||||||||||||||||||
| 72 | 0 | my $self = bless { _module => $module, _valid => 1, _api_wrapper => $api_wrapper, _id => $cart_id, _properties => $properties, _items => {} }, $class; | |||||||||||||||||||
| 73 | |||||||||||||||||||||
| 74 | 0 | return $self; | |||||||||||||||||||
| 75 | |||||||||||||||||||||
| 76 | } else { | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | 0 | return undef; | |||||||||||||||||||
| 79 | } | ||||||||||||||||||||
| 80 | } | ||||||||||||||||||||
| 81 | |||||||||||||||||||||
| 82 | =head2 _new_existing | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | Internal Method to create the Cart object. | ||||||||||||||||||||
| 85 | This method is not ment to be called directly. | ||||||||||||||||||||
| 86 | |||||||||||||||||||||
| 87 | =over | ||||||||||||||||||||
| 88 | |||||||||||||||||||||
| 89 | =item * Parameter: $api_wrapper - ovh api wrapper object, $module - root object - api id | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | =item * Return: L<Webservice::OVH::Order::Cart> | ||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | =item * Synopsis: Webservice::OVH::Order::Cart->_new($ovh_api_wrapper, $module, ovhSubsidiary => 'DE', decription => 'Shopping'); | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | =back | ||||||||||||||||||||
| 96 | |||||||||||||||||||||
| 97 | =cut | ||||||||||||||||||||
| 98 | |||||||||||||||||||||
| 99 | 0 | ▶ | sub _new { | ||||||||||||||||||
|
Subroutine
_new: not called CC=8 SCAR=42.8
| |||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | 0 | my ( $class, %params ) = @_; | |||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | 0 | ▶ | die "Missing module" unless $params{module}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 104 | 0 | ▶ | die "Missing wrapper" unless $params{wrapper}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 105 | |||||||||||||||||||||
| 106 | 0 | my $module = $params{module}; | |||||||||||||||||||
| 107 | 0 | my $api_wrapper = $params{wrapper}; | |||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | 0 | ▶ | croak "Missing ovh_subsidiary" unless exists $params{ovh_subsidiary}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 110 | 0 | my $body = {}; | |||||||||||||||||||
| 111 | 0 | ▶ | $body->{description} = $params{description} if exists $params{description}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 112 | 0 | ▶ | $body->{expire} = $params{expire} if exists $params{expire}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 113 | 0 | $body->{ovhSubsidiary} = $params{ovh_subsidiary}; | |||||||||||||||||||
| 114 | 0 | my $response = $api_wrapper->rawCall( method => 'post', path => "/order/cart", body => $body, noSignature => 0 ); | |||||||||||||||||||
| 115 | 0 | ▶ | croak $response->error if $response->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | 0 | my $cart_id = $response->content->{cartId}; | |||||||||||||||||||
| 118 | 0 | my $properties = $response->content; | |||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | 0 | my $response_assign = $api_wrapper->rawCall( method => 'post', path => "/order/cart/$cart_id/assign", body => {}, noSignature => 0 ); | |||||||||||||||||||
| 121 | 0 | ▶ | croak $response_assign->error if $response_assign->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 122 | |||||||||||||||||||||
| 123 | 0 | my $self = bless { _module => $module, _valid => 1, _api_wrapper => $api_wrapper, _id => $cart_id, _properties => $properties, _items => {} }, $class; | |||||||||||||||||||
| 124 | |||||||||||||||||||||
| 125 | 0 | return $self; | |||||||||||||||||||
| 126 | } | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | =head2 properties | ||||||||||||||||||||
| 129 | |||||||||||||||||||||
| 130 | Retrieves properties. | ||||||||||||||||||||
| 131 | This method updates the intern property variable. | ||||||||||||||||||||
| 132 | |||||||||||||||||||||
| 133 | =over | ||||||||||||||||||||
| 134 | |||||||||||||||||||||
| 135 | =item * Return: HASH | ||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | =item * Synopsis: my $properties = $cart->properties; | ||||||||||||||||||||
| 138 | |||||||||||||||||||||
| 139 | =back | ||||||||||||||||||||
| 140 | |||||||||||||||||||||
| 141 | =cut | ||||||||||||||||||||
| 142 | |||||||||||||||||||||
| 143 | 0 | ▶ | sub properties { | ||||||||||||||||||
|
Subroutine
properties: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 144 | |||||||||||||||||||||
| 145 | 0 | my ($self) = @_; | |||||||||||||||||||
| 146 | |||||||||||||||||||||
| 147 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||
| 148 | 0 | my $cart_id = $self->id; | |||||||||||||||||||
| 149 | 0 | my $response = $api->rawCall( method => 'get', path => "/order/cart/$cart_id", noSignature => 0 ); | |||||||||||||||||||
| 150 | 0 | ▶ | croak $response->error if $response->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 151 | |||||||||||||||||||||
| 152 | 0 | $self->{_properties} = $response->content; | |||||||||||||||||||
| 153 | 0 | return $self->{_properties}; | |||||||||||||||||||
| 154 | } | ||||||||||||||||||||
| 155 | |||||||||||||||||||||
| 156 | =head2 description | ||||||||||||||||||||
| 157 | |||||||||||||||||||||
| 158 | Exposed property value. | ||||||||||||||||||||
| 159 | |||||||||||||||||||||
| 160 | =over | ||||||||||||||||||||
| 161 | |||||||||||||||||||||
| 162 | =item * Return: VALUE | ||||||||||||||||||||
| 163 | |||||||||||||||||||||
| 164 | =item * Synopsis: my $description = $cart->description; | ||||||||||||||||||||
| 165 | |||||||||||||||||||||
| 166 | =back | ||||||||||||||||||||
| 167 | |||||||||||||||||||||
| 168 | =cut | ||||||||||||||||||||
| 169 | |||||||||||||||||||||
| 170 | 0 | ▶ | sub description { | ||||||||||||||||||
|
Subroutine
description: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 171 | |||||||||||||||||||||
| 172 | 0 | my ($self) = @_; | |||||||||||||||||||
| 173 | |||||||||||||||||||||
| 174 | 0 | return $self->{_properties}->{description}; | |||||||||||||||||||
| 175 | } | ||||||||||||||||||||
| 176 | |||||||||||||||||||||
| 177 | =head2 expire | ||||||||||||||||||||
| 178 | |||||||||||||||||||||
| 179 | Exposed property value. | ||||||||||||||||||||
| 180 | |||||||||||||||||||||
| 181 | =over | ||||||||||||||||||||
| 182 | |||||||||||||||||||||
| 183 | =item * Return: VALUE | ||||||||||||||||||||
| 184 | |||||||||||||||||||||
| 185 | =item * Synopsis: my $expire = $cart->expire; | ||||||||||||||||||||
| 186 | |||||||||||||||||||||
| 187 | =back | ||||||||||||||||||||
| 188 | |||||||||||||||||||||
| 189 | =cut | ||||||||||||||||||||
| 190 | |||||||||||||||||||||
| 191 | 0 | ▶ | sub expire { | ||||||||||||||||||
|
Subroutine
expire: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 192 | |||||||||||||||||||||
| 193 | 0 | my ($self) = @_; | |||||||||||||||||||
| 194 | |||||||||||||||||||||
| 195 | 0 | return $self->{_properties}->{expire}; | |||||||||||||||||||
| 196 | } | ||||||||||||||||||||
| 197 | |||||||||||||||||||||
| 198 | =head2 read_only | ||||||||||||||||||||
| 199 | |||||||||||||||||||||
| 200 | Exposed property value. | ||||||||||||||||||||
| 201 | |||||||||||||||||||||
| 202 | =over | ||||||||||||||||||||
| 203 | |||||||||||||||||||||
| 204 | =item * Return: VALUE | ||||||||||||||||||||
| 205 | |||||||||||||||||||||
| 206 | =item * Synopsis: my $read_only = $cart->read_only; | ||||||||||||||||||||
| 207 | |||||||||||||||||||||
| 208 | =back | ||||||||||||||||||||
| 209 | |||||||||||||||||||||
| 210 | =cut | ||||||||||||||||||||
| 211 | |||||||||||||||||||||
| 212 | 0 | ▶ | sub read_only { | ||||||||||||||||||
|
Subroutine
read_only: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 213 | |||||||||||||||||||||
| 214 | 0 | my ($self) = @_; | |||||||||||||||||||
| 215 | |||||||||||||||||||||
| 216 | 0 | ▶ | return $self->{_properties}->{readOnly} ? 1 : 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 217 | } | ||||||||||||||||||||
| 218 | |||||||||||||||||||||
| 219 | =head2 change | ||||||||||||||||||||
| 220 | |||||||||||||||||||||
| 221 | Exposed property value. | ||||||||||||||||||||
| 222 | |||||||||||||||||||||
| 223 | =over | ||||||||||||||||||||
| 224 | |||||||||||||||||||||
| 225 | =item * Parameter: %params - key => value description expire | ||||||||||||||||||||
| 226 | |||||||||||||||||||||
| 227 | =item * Synopsis: my $change = $cart->change(description => 'Shopping!'); | ||||||||||||||||||||
| 228 | |||||||||||||||||||||
| 229 | =back | ||||||||||||||||||||
| 230 | |||||||||||||||||||||
| 231 | =cut | ||||||||||||||||||||
| 232 | |||||||||||||||||||||
| 233 | 0 | ▶ | sub change { | ||||||||||||||||||
|
Subroutine
change: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||
| 234 | |||||||||||||||||||||
| 235 | 0 | my ( $self, %params ) = @_; | |||||||||||||||||||
| 236 | |||||||||||||||||||||
| 237 | 0 | ▶ | return unless $self->_is_valid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 238 | |||||||||||||||||||||
| 239 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||
| 240 | 0 | my $cart_id = $self->id; | |||||||||||||||||||
| 241 | |||||||||||||||||||||
| 242 | 0 | ▶ | croak "Missing Parameter description" unless exists $params{description}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 243 | 0 | ▶ | croak "Missing Parameter description" unless exists $params{expire}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 244 | |||||||||||||||||||||
| 245 | 0 | my $body = {}; | |||||||||||||||||||
| 246 | 0 | ▶ | $body->{description} = $params{description} if $params{description}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 247 | 0 | ▶ | $body->{expire} = $params{expire} if $params{expire}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 248 | |||||||||||||||||||||
| 249 | 0 | my $response = $api->rawCall( method => 'put', path => "/order/cart/$cart_id", body => $body, noSignature => 0 ); | |||||||||||||||||||
| 250 | 0 | ▶ | croak $response->error if $response->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 251 | |||||||||||||||||||||
| 252 | 0 | $self->properties; | |||||||||||||||||||
| 253 | } | ||||||||||||||||||||
| 254 | |||||||||||||||||||||
| 255 | =head2 is_valid | ||||||||||||||||||||
| 256 | |||||||||||||||||||||
| 257 | When this cart is deleted on the api side, this method returns 0. | ||||||||||||||||||||
| 258 | |||||||||||||||||||||
| 259 | =over | ||||||||||||||||||||
| 260 | |||||||||||||||||||||
| 261 | =item * Return: VALUE | ||||||||||||||||||||
| 262 | |||||||||||||||||||||
| 263 | =item * Synopsis: print "Valid" if $cart->is_valid; | ||||||||||||||||||||
| 264 | |||||||||||||||||||||
| 265 | =back | ||||||||||||||||||||
| 266 | |||||||||||||||||||||
| 267 | =cut | ||||||||||||||||||||
| 268 | |||||||||||||||||||||
| 269 | 0 | ▶ | sub is_valid { | ||||||||||||||||||
|
Subroutine
is_valid: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 270 | |||||||||||||||||||||
| 271 | 0 | my ($self) = @_; | |||||||||||||||||||
| 272 | |||||||||||||||||||||
| 273 | 0 | return $self->{_valid}; | |||||||||||||||||||
| 274 | } | ||||||||||||||||||||
| 275 | |||||||||||||||||||||
| 276 | =head2 _is_valid | ||||||||||||||||||||
| 277 | |||||||||||||||||||||
| 278 | Intern method to check validity. | ||||||||||||||||||||
| 279 | Difference is that this method carps an error. | ||||||||||||||||||||
| 280 | |||||||||||||||||||||
| 281 | =over | ||||||||||||||||||||
| 282 | |||||||||||||||||||||
| 283 | =item * Return: VALUE | ||||||||||||||||||||
| 284 | |||||||||||||||||||||
| 285 | =item * Synopsis: $cart->_is_valid; | ||||||||||||||||||||
| 286 | |||||||||||||||||||||
| 287 | =back | ||||||||||||||||||||
| 288 | |||||||||||||||||||||
| 289 | =cut | ||||||||||||||||||||
| 290 | |||||||||||||||||||||
| 291 | 0 | ▶ | sub _is_valid { | ||||||||||||||||||
|
Subroutine
_is_valid: not called CC=2 SCAR=17.9
| |||||||||||||||||||||
| 292 | |||||||||||||||||||||
| 293 | 0 | my ($self) = @_; | |||||||||||||||||||
| 294 | |||||||||||||||||||||
| 295 | 0 | my $cart_id = $self->id; | |||||||||||||||||||
| 296 | 0 | ▶ | carp "Cart $cart_id is not valid anymore" unless $self->is_valid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 297 | 0 | return $self->is_valid; | |||||||||||||||||||
| 298 | } | ||||||||||||||||||||
| 299 | |||||||||||||||||||||
| 300 | =head2 delete | ||||||||||||||||||||
| 301 | |||||||||||||||||||||
| 302 | Deletes the cart api sided and sets this object invalid. | ||||||||||||||||||||
| 303 | |||||||||||||||||||||
| 304 | =over | ||||||||||||||||||||
| 305 | |||||||||||||||||||||
| 306 | =item * Synopsis: $cart->delete; | ||||||||||||||||||||
| 307 | |||||||||||||||||||||
| 308 | =back | ||||||||||||||||||||
| 309 | |||||||||||||||||||||
| 310 | =cut | ||||||||||||||||||||
| 311 | |||||||||||||||||||||
| 312 | 0 | ▶ | sub delete { | ||||||||||||||||||
|
Subroutine
delete: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 313 | |||||||||||||||||||||
| 314 | 0 | my ($self) = @_; | |||||||||||||||||||
| 315 | |||||||||||||||||||||
| 316 | 0 | ▶ | return unless $self->_is_valid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 317 | |||||||||||||||||||||
| 318 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||
| 319 | 0 | my $cart_id = $self->id; | |||||||||||||||||||
| 320 | |||||||||||||||||||||
| 321 | 0 | my $response = $api->rawCall( method => 'delete', path => "/order/cart/$cart_id", noSignature => 0 ); | |||||||||||||||||||
| 322 | 0 | ▶ | croak $response->error if $response->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 323 | |||||||||||||||||||||
| 324 | 0 | $self->{_valid} = 0; | |||||||||||||||||||
| 325 | } | ||||||||||||||||||||
| 326 | |||||||||||||||||||||
| 327 | =head2 id | ||||||||||||||||||||
| 328 | |||||||||||||||||||||
| 329 | Returns the api id. | ||||||||||||||||||||
| 330 | |||||||||||||||||||||
| 331 | =over | ||||||||||||||||||||
| 332 | |||||||||||||||||||||
| 333 | =item * Return: VALUE | ||||||||||||||||||||
| 334 | |||||||||||||||||||||
| 335 | =item * Synopsis: my $id = $cart->id; | ||||||||||||||||||||
| 336 | |||||||||||||||||||||
| 337 | =back | ||||||||||||||||||||
| 338 | |||||||||||||||||||||
| 339 | =cut | ||||||||||||||||||||
| 340 | |||||||||||||||||||||
| 341 | 0 | ▶ | sub id { | ||||||||||||||||||
|
Subroutine
id: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 342 | |||||||||||||||||||||
| 343 | 0 | my ($self) = @_; | |||||||||||||||||||
| 344 | |||||||||||||||||||||
| 345 | 0 | return $self->{_id},; | |||||||||||||||||||
| 346 | } | ||||||||||||||||||||
| 347 | |||||||||||||||||||||
| 348 | =head2 offers_domain | ||||||||||||||||||||
| 349 | |||||||||||||||||||||
| 350 | Returns an Array of hashs with offers. | ||||||||||||||||||||
| 351 | |||||||||||||||||||||
| 352 | =over | ||||||||||||||||||||
| 353 | |||||||||||||||||||||
| 354 | =item * Parameter: $domain - domain name | ||||||||||||||||||||
| 355 | |||||||||||||||||||||
| 356 | =item * Return: L<ARRAY> | ||||||||||||||||||||
| 357 | |||||||||||||||||||||
| 358 | =item * Synopsis: my $offers = $cart->offers_domain('mydomain.de'); | ||||||||||||||||||||
| 359 | |||||||||||||||||||||
| 360 | =back | ||||||||||||||||||||
| 361 | |||||||||||||||||||||
| 362 | =cut | ||||||||||||||||||||
| 363 | |||||||||||||||||||||
| 364 | 0 | ▶ | sub offers_domain { | ||||||||||||||||||
|
Subroutine
offers_domain: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 365 | |||||||||||||||||||||
| 366 | 0 | my ( $self, $domain ) = @_; | |||||||||||||||||||
| 367 | |||||||||||||||||||||
| 368 | 0 | ▶ | return unless $self->_is_valid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 369 | |||||||||||||||||||||
| 370 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||
| 371 | 0 | my $cart_id = $self->id; | |||||||||||||||||||
| 372 | |||||||||||||||||||||
| 373 | 0 | my $response = $api->rawCall( method => 'get', path => sprintf( "/order/cart/%s/domain?domain=%s", $cart_id, $domain ), noSignature => 0 ); | |||||||||||||||||||
| 374 | 0 | ▶ | croak $response->error if $response->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 375 | |||||||||||||||||||||
| 376 | 0 | return $response->content; | |||||||||||||||||||
| 377 | } | ||||||||||||||||||||
| 378 | |||||||||||||||||||||
| 379 | =head2 add_domain | ||||||||||||||||||||
| 380 | |||||||||||||||||||||
| 381 | Adds a domain request to a cart. | ||||||||||||||||||||
| 382 | |||||||||||||||||||||
| 383 | =over | ||||||||||||||||||||
| 384 | |||||||||||||||||||||
| 385 | =item * Parameter: $domain - domain name, %params - key => value duration offer_id quantity | ||||||||||||||||||||
| 386 | |||||||||||||||||||||
| 387 | =item * Return: L<Webservice::OVH::Order::Cart::Item> | ||||||||||||||||||||
| 388 | |||||||||||||||||||||
| 389 | =item * Synopsis: my $item = $cart->add_domain('mydomain.de'); | ||||||||||||||||||||
| 390 | |||||||||||||||||||||
| 391 | =back | ||||||||||||||||||||
| 392 | |||||||||||||||||||||
| 393 | =cut | ||||||||||||||||||||
| 394 | |||||||||||||||||||||
| 395 | 0 | ▶ | sub add_domain { | ||||||||||||||||||
|
Subroutine
add_domain: not called CC=16 SCAR=56.1
Pod
documented
| |||||||||||||||||||||
| 396 | |||||||||||||||||||||
| 397 | 0 | my ( $self, $domain, %params ) = @_; | |||||||||||||||||||
| 398 | |||||||||||||||||||||
| 399 | 0 | ▶ | return unless $self->_is_valid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 400 | |||||||||||||||||||||
| 401 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||
| 402 | 0 | my $cart_id = $self->id; | |||||||||||||||||||
| 403 | |||||||||||||||||||||
| 404 | 0 | ▶ | croak "Missing domain parameter" unless $domain; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 405 | |||||||||||||||||||||
| 406 | 0 | my $body = {}; | |||||||||||||||||||
| 407 | 0 | ▶ | $body->{duration} = $params{duration} if exists $params{duration}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 408 | 0 | ▶ | $body->{offerId} = $params{offer_id} if exists $params{offer_id}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 409 | 0 | ▶ | $body->{quantity} = $params{quantity} if exists $params{quantity}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 410 | 0 | $body->{domain} = $domain; | |||||||||||||||||||
| 411 | |||||||||||||||||||||
| 412 | 0 | my $response = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/domain", body => $body, noSignature => 0 ); | |||||||||||||||||||
| 413 | 0 | ▶ | croak $response->error if $response->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 414 | |||||||||||||||||||||
| 415 | 0 | my $item_id = $response->content->{itemId}; | |||||||||||||||||||
| 416 | 0 | my $item = Webservice::OVH::Order::Cart::Item->_new( wrapper => $api, cart => $self, id => $item_id, module => $self->{_module} ); | |||||||||||||||||||
| 417 | |||||||||||||||||||||
| 418 | 0 | my $owner = $params{owner_contact}; | |||||||||||||||||||
| 419 | 0 | my $admin = $params{admin_account}; | |||||||||||||||||||
| 420 | 0 | my $tech = $params{tech_account}; | |||||||||||||||||||
| 421 | |||||||||||||||||||||
| 422 | 0 | ▶ | if ($owner) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 423 | 0 | my $config_preset_owner = { label => "OWNER_CONTACT", value => $owner }; | |||||||||||||||||||
| 424 | 0 | my $response_product_set_config_owner = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_owner, noSignature => 0 ); | |||||||||||||||||||
| 425 | 0 | ▶ | my $config2 = $response_product_set_config_owner->content unless $response_product_set_config_owner->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 426 | 0 | ▶ | croak $response_product_set_config_owner->error if $response_product_set_config_owner->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 427 | } | ||||||||||||||||||||
| 428 | |||||||||||||||||||||
| 429 | 0 | ▶ | if ($admin) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 430 | |||||||||||||||||||||
| 431 | 0 | my $config_preset_admin = { label => "ADMIN_ACCOUNT", value => $admin }; | |||||||||||||||||||
| 432 | 0 | my $response_product_set_config_admin = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_admin, noSignature => 0 ); | |||||||||||||||||||
| 433 | 0 | ▶ | my $config3 = $response_product_set_config_admin->content unless $response_product_set_config_admin->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 434 | 0 | ▶ | croak $response_product_set_config_admin->error if $response_product_set_config_admin->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 435 | } | ||||||||||||||||||||
| 436 | |||||||||||||||||||||
| 437 | 0 | ▶ | if ($tech) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 438 | |||||||||||||||||||||
| 439 | 0 | my $config_preset_tech = { label => "TECH_ACCOUNT", value => $tech }; | |||||||||||||||||||
| 440 | 0 | my $response_product_set_config_tech = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_tech, noSignature => 0 ); | |||||||||||||||||||
| 441 | 0 | ▶ | my $config4 = $response_product_set_config_tech->content unless $response_product_set_config_tech->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 442 | 0 | ▶ | croak $response_product_set_config_tech->error if $response_product_set_config_tech->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 443 | } | ||||||||||||||||||||
| 444 | |||||||||||||||||||||
| 445 | 0 | return $item; | |||||||||||||||||||
| 446 | } | ||||||||||||||||||||
| 447 | |||||||||||||||||||||
| 448 | =head2 offer_dns | ||||||||||||||||||||
| 449 | |||||||||||||||||||||
| 450 | Returns an Hash with information for dns Zone pricing | ||||||||||||||||||||
| 451 | A Domain must be added before requestion info | ||||||||||||||||||||
| 452 | |||||||||||||||||||||
| 453 | =over | ||||||||||||||||||||
| 454 | |||||||||||||||||||||
| 455 | =item * Parameter: $dns - domain name | ||||||||||||||||||||
| 456 | |||||||||||||||||||||
| 457 | =item * Return: L<HASHREF> | ||||||||||||||||||||
| 458 | |||||||||||||||||||||
| 459 | =item * Synopsis: my $offer = $cart->offers_dns; | ||||||||||||||||||||
| 460 | |||||||||||||||||||||
| 461 | =back | ||||||||||||||||||||
| 462 | |||||||||||||||||||||
| 463 | =cut | ||||||||||||||||||||
| 464 | |||||||||||||||||||||
| 465 | 0 | ▶ | sub offer_dns { | ||||||||||||||||||
|
Subroutine
offer_dns: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 466 | |||||||||||||||||||||
| 467 | 0 | my ( $self, $domain ) = @_; | |||||||||||||||||||
| 468 | |||||||||||||||||||||
| 469 | 0 | ▶ | return unless $self->_is_valid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 470 | |||||||||||||||||||||
| 471 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||
| 472 | 0 | my $cart_id = $self->id; | |||||||||||||||||||
| 473 | |||||||||||||||||||||
| 474 | 0 | my $response = $api->rawCall( method => 'get', path => sprintf( "/order/cart/%s/dns?domain=%s", $cart_id, $domain ), noSignature => 0 ); | |||||||||||||||||||
| 475 | 0 | ▶ | croak $response->error if $response->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 476 | |||||||||||||||||||||
| 477 | 0 | return $response->content; | |||||||||||||||||||
| 478 | } | ||||||||||||||||||||
| 479 | |||||||||||||||||||||
| 480 | =head2 add_dns | ||||||||||||||||||||
| 481 | |||||||||||||||||||||
| 482 | Adds a dns Zone to a cart. | ||||||||||||||||||||
| 483 | |||||||||||||||||||||
| 484 | =over | ||||||||||||||||||||
| 485 | |||||||||||||||||||||
| 486 | =item * Return: L<Webservice::OVH::Order::Cart::Item> | ||||||||||||||||||||
| 487 | |||||||||||||||||||||
| 488 | =item * Synopsis: my $item = $cart->add_dns; | ||||||||||||||||||||
| 489 | |||||||||||||||||||||
| 490 | =back | ||||||||||||||||||||
| 491 | |||||||||||||||||||||
| 492 | =cut | ||||||||||||||||||||
| 493 | |||||||||||||||||||||
| 494 | 0 | ▶ | sub add_dns { | ||||||||||||||||||
|
Subroutine
add_dns: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||
| 495 | |||||||||||||||||||||
| 496 | 0 | my ( $self, $domain, %params ) = @_; | |||||||||||||||||||
| 497 | |||||||||||||||||||||
| 498 | 0 | ▶ | return unless $self->_is_valid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 499 | |||||||||||||||||||||
| 500 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||
| 501 | 0 | my $cart_id = $self->id; | |||||||||||||||||||
| 502 | |||||||||||||||||||||
| 503 | 0 | my $body = {}; | |||||||||||||||||||
| 504 | 0 | ▶ | $body->{duration} = $params{duration} if exists $params{duration}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 505 | 0 | ▶ | $body->{planCode} = $params{plan_code} if exists $params{plan_code}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 506 | 0 | ▶ | $body->{pricingMode} = $params{pricing_mode} if exists $params{pricing_mode}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 507 | 0 | ▶ | $body->{quantity} = $params{quantity} if exists $params{quantity}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 508 | 0 | $body->{domain} = $domain; | |||||||||||||||||||
| 509 | |||||||||||||||||||||
| 510 | 0 | my $response = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/dns", body => $body, noSignature => 0 ); | |||||||||||||||||||
| 511 | 0 | ▶ | croak $response->error if $response->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 512 | |||||||||||||||||||||
| 513 | 0 | my $item_id = $response->content->{itemId}; | |||||||||||||||||||
| 514 | 0 | my $item = Webservice::OVH::Order::Cart::Item->_new( wrapper => $api, cart => $self, id => $item_id, module => $self->{_module} ); | |||||||||||||||||||
| 515 | |||||||||||||||||||||
| 516 | 0 | return $item; | |||||||||||||||||||
| 517 | } | ||||||||||||||||||||
| 518 | |||||||||||||||||||||
| 519 | |||||||||||||||||||||
| 520 | =head2 offers_domain_transfer | ||||||||||||||||||||
| 521 | |||||||||||||||||||||
| 522 | Returns an Array of hashes with offers. | ||||||||||||||||||||
| 523 | |||||||||||||||||||||
| 524 | =over | ||||||||||||||||||||
| 525 | |||||||||||||||||||||
| 526 | =item * Parameter: $domain - domain name | ||||||||||||||||||||
| 527 | |||||||||||||||||||||
| 528 | =item * Return: L<ARRAY> | ||||||||||||||||||||
| 529 | |||||||||||||||||||||
| 530 | =item * Synopsis: my $offers = $cart->offers_domain_transfer('mydomain.de'); | ||||||||||||||||||||
| 531 | |||||||||||||||||||||
| 532 | =back | ||||||||||||||||||||
| 533 | |||||||||||||||||||||
| 534 | =cut | ||||||||||||||||||||
| 535 | |||||||||||||||||||||
| 536 | 0 | ▶ | sub offers_domain_transfer { | ||||||||||||||||||
|
Subroutine
offers_domain_transfer: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 537 | |||||||||||||||||||||
| 538 | 0 | my ( $self, $domain ) = @_; | |||||||||||||||||||
| 539 | |||||||||||||||||||||
| 540 | 0 | ▶ | return unless $self->_is_valid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 541 | |||||||||||||||||||||
| 542 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||
| 543 | 0 | my $cart_id = $self->id; | |||||||||||||||||||
| 544 | |||||||||||||||||||||
| 545 | 0 | my $response = $api->rawCall( method => 'get', path => sprintf( "/order/cart/%s/domainTransfer?domain=%s", $cart_id, $domain ), noSignature => 0 ); | |||||||||||||||||||
| 546 | 0 | ▶ | croak $response->error if $response->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 547 | |||||||||||||||||||||
| 548 | 0 | return $response->content; | |||||||||||||||||||
| 549 | } | ||||||||||||||||||||
| 550 | |||||||||||||||||||||
| 551 | =head2 offers_domain | ||||||||||||||||||||
| 552 | |||||||||||||||||||||
| 553 | Adds a domain transfer request to a cart. | ||||||||||||||||||||
| 554 | |||||||||||||||||||||
| 555 | =over | ||||||||||||||||||||
| 556 | |||||||||||||||||||||
| 557 | =item * Parameter: $domain - domain name, %params - key => value duration offer_id quantity | ||||||||||||||||||||
| 558 | |||||||||||||||||||||
| 559 | =item * Return: L<Webservice::OVH::Order::Cart::Item> | ||||||||||||||||||||
| 560 | |||||||||||||||||||||
| 561 | =item * Synopsis: my $item = $cart->add_transfer('mydomain.de'); | ||||||||||||||||||||
| 562 | |||||||||||||||||||||
| 563 | =back | ||||||||||||||||||||
| 564 | |||||||||||||||||||||
| 565 | =cut | ||||||||||||||||||||
| 566 | |||||||||||||||||||||
| 567 | 0 | ▶ | sub add_transfer { | ||||||||||||||||||
|
Subroutine
add_transfer: not called CC=20 SCAR=60.4
Pod
documented
| |||||||||||||||||||||
| 568 | |||||||||||||||||||||
| 569 | 0 | my ( $self, $domain, %params ) = @_; | |||||||||||||||||||
| 570 | |||||||||||||||||||||
| 571 | 0 | ▶ | return unless $self->_is_valid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 572 | |||||||||||||||||||||
| 573 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||
| 574 | 0 | my $cart_id = $self->id; | |||||||||||||||||||
| 575 | |||||||||||||||||||||
| 576 | 0 | ▶ | croak "Missing domain parameter" unless $domain; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 577 | 0 | ▶ | croak "Missing auth_info" unless exists $params{auth_info}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 578 | |||||||||||||||||||||
| 579 | 0 | my $body = {}; | |||||||||||||||||||
| 580 | 0 | ▶ | $body->{duration} = $params{duration} if exists $params{duration}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 581 | 0 | ▶ | $body->{offerId} = $params{offer_id} if exists $params{offer_id}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 582 | 0 | ▶ | $body->{quantity} = $params{quantity} if exists $params{quantity}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 583 | 0 | $body->{domain} = $domain; | |||||||||||||||||||
| 584 | |||||||||||||||||||||
| 585 | 0 | my $response = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/domainTransfer", body => $body, noSignature => 0 ); | |||||||||||||||||||
| 586 | 0 | ▶ | croak $response->error if $response->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 587 | |||||||||||||||||||||
| 588 | 0 | my $item_id = $response->content->{itemId}; | |||||||||||||||||||
| 589 | 0 | my $item = Webservice::OVH::Order::Cart::Item->_new( wrapper => $api, cart => $self, id => $item_id, module => $self->{_module} ); | |||||||||||||||||||
| 590 | |||||||||||||||||||||
| 591 | 0 | ▶ | return unless $item; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 592 | |||||||||||||||||||||
| 593 | 0 | my $auth_info = $params{auth_info}; | |||||||||||||||||||
| 594 | 0 | my $owner = $params{owner_contact}; | |||||||||||||||||||
| 595 | 0 | my $admin = $params{admin_account}; | |||||||||||||||||||
| 596 | 0 | my $tech = $params{tech_account}; | |||||||||||||||||||
| 597 | |||||||||||||||||||||
| 598 | 0 | my $config_preset = { label => "AUTH_INFO", value => $auth_info }; | |||||||||||||||||||
| 599 | 0 | my $response_product_set_config = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset, noSignature => 0 ); | |||||||||||||||||||
| 600 | 0 | ▶ | my $config1 = $response_product_set_config->content unless $response_product_set_config->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 601 | 0 | ▶ | croak $response_product_set_config->error if $response_product_set_config->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 602 | |||||||||||||||||||||
| 603 | 0 | ▶ | if ($owner) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 604 | 0 | my $config_preset_owner = { label => "OWNER_CONTACT", value => $owner }; | |||||||||||||||||||
| 605 | 0 | my $response_product_set_config_owner = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_owner, noSignature => 0 ); | |||||||||||||||||||
| 606 | 0 | ▶ | my $config2 = $response_product_set_config_owner->content unless $response_product_set_config_owner->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 607 | 0 | ▶ | croak $response_product_set_config_owner->error if $response_product_set_config_owner->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 608 | } | ||||||||||||||||||||
| 609 | |||||||||||||||||||||
| 610 | 0 | ▶ | if ($admin) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 611 | 0 | my $config_preset_admin = { label => "ADMIN_ACCOUNT", value => $admin }; | |||||||||||||||||||
| 612 | 0 | my $response_product_set_config_admin = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_admin, noSignature => 0 ); | |||||||||||||||||||
| 613 | 0 | ▶ | my $config3 = $response_product_set_config_admin->content unless $response_product_set_config_admin->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 614 | 0 | ▶ | croak $response_product_set_config_admin->error if $response_product_set_config_admin->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 615 | } | ||||||||||||||||||||
| 616 | |||||||||||||||||||||
| 617 | 0 | ▶ | if ($tech) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 618 | 0 | my $config_preset_tech = { label => "TECH_ACCOUNT", value => $tech }; | |||||||||||||||||||
| 619 | 0 | my $response_product_set_config_tech = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_tech, noSignature => 0 ); | |||||||||||||||||||
| 620 | 0 | ▶ | my $config4 = $response_product_set_config_tech->content unless $response_product_set_config_tech->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 621 | 0 | ▶ | croak $response_product_set_config_tech->error if $response_product_set_config_tech->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 622 | } | ||||||||||||||||||||
| 623 | |||||||||||||||||||||
| 624 | 0 | return $item; | |||||||||||||||||||
| 625 | } | ||||||||||||||||||||
| 626 | |||||||||||||||||||||
| 627 | 0 | ▶ | sub add_transfer_new { | ||||||||||||||||||
|
Subroutine
add_transfer_new: not called CC=20 SCAR=60.4
Pod
undocumented
| |||||||||||||||||||||
| 628 | |||||||||||||||||||||
| 629 | 0 | my ( $self, $domain, %params ) = @_; | |||||||||||||||||||
| 630 | |||||||||||||||||||||
| 631 | 0 | ▶ | return unless $self->_is_valid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 632 | |||||||||||||||||||||
| 633 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||
| 634 | 0 | my $cart_id = $self->id; | |||||||||||||||||||
| 635 | |||||||||||||||||||||
| 636 | 0 | ▶ | croak "Missing domain parameter" unless $domain; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 637 | 0 | ▶ | croak "Missing auth_info" unless exists $params{auth_info}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 638 | |||||||||||||||||||||
| 639 | 0 | my $body = {}; | |||||||||||||||||||
| 640 | 0 | ▶ | $body->{duration} = $params{duration} if exists $params{duration}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 641 | 0 | ▶ | $body->{offerId} = $params{offer_id} if exists $params{offer_id}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 642 | 0 | ▶ | $body->{quantity} = $params{quantity} if exists $params{quantity}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 643 | 0 | $body->{domain} = $domain; | |||||||||||||||||||
| 644 | |||||||||||||||||||||
| 645 | 0 | my $response = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/domain", body => $body, noSignature => 0 ); | |||||||||||||||||||
| 646 | 0 | ▶ | croak $response->error if $response->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 647 | |||||||||||||||||||||
| 648 | 0 | my $item_id = $response->content->{itemId}; | |||||||||||||||||||
| 649 | 0 | my $item = Webservice::OVH::Order::Cart::Item->_new( wrapper => $api, cart => $self, id => $item_id, module => $self->{_module} ); | |||||||||||||||||||
| 650 | |||||||||||||||||||||
| 651 | 0 | ▶ | return unless $item; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 652 | |||||||||||||||||||||
| 653 | 0 | my $auth_info = $params{auth_info}; | |||||||||||||||||||
| 654 | 0 | my $owner = $params{owner_contact}; | |||||||||||||||||||
| 655 | 0 | my $admin = $params{admin_account}; | |||||||||||||||||||
| 656 | 0 | my $tech = $params{tech_account}; | |||||||||||||||||||
| 657 | |||||||||||||||||||||
| 658 | 0 | my $config_preset = { label => "AUTH_INFO", value => $auth_info }; | |||||||||||||||||||
| 659 | 0 | my $response_product_set_config = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset, noSignature => 0 ); | |||||||||||||||||||
| 660 | 0 | ▶ | my $config1 = $response_product_set_config->content unless $response_product_set_config->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 661 | 0 | ▶ | croak $response_product_set_config->error if $response_product_set_config->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 662 | |||||||||||||||||||||
| 663 | 0 | ▶ | if ($owner) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 664 | 0 | my $config_preset_owner = { label => "OWNER_CONTACT", value => $owner }; | |||||||||||||||||||
| 665 | 0 | my $response_product_set_config_owner = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_owner, noSignature => 0 ); | |||||||||||||||||||
| 666 | 0 | ▶ | my $config2 = $response_product_set_config_owner->content unless $response_product_set_config_owner->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 667 | 0 | ▶ | croak $response_product_set_config_owner->error if $response_product_set_config_owner->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 668 | } | ||||||||||||||||||||
| 669 | |||||||||||||||||||||
| 670 | 0 | ▶ | if ($admin) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 671 | 0 | my $config_preset_admin = { label => "ADMIN_ACCOUNT", value => $admin }; | |||||||||||||||||||
| 672 | 0 | my $response_product_set_config_admin = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_admin, noSignature => 0 ); | |||||||||||||||||||
| 673 | 0 | ▶ | my $config3 = $response_product_set_config_admin->content unless $response_product_set_config_admin->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 674 | 0 | ▶ | croak $response_product_set_config_admin->error if $response_product_set_config_admin->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 675 | } | ||||||||||||||||||||
| 676 | |||||||||||||||||||||
| 677 | 0 | ▶ | if ($tech) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 678 | 0 | my $config_preset_tech = { label => "TECH_ACCOUNT", value => $tech }; | |||||||||||||||||||
| 679 | 0 | my $response_product_set_config_tech = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/item/$item_id/configuration", body => $config_preset_tech, noSignature => 0 ); | |||||||||||||||||||
| 680 | 0 | ▶ | my $config4 = $response_product_set_config_tech->content unless $response_product_set_config_tech->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 681 | 0 | ▶ | croak $response_product_set_config_tech->error if $response_product_set_config_tech->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 682 | } | ||||||||||||||||||||
| 683 | |||||||||||||||||||||
| 684 | 0 | return $item; | |||||||||||||||||||
| 685 | } | ||||||||||||||||||||
| 686 | |||||||||||||||||||||
| 687 | =head2 info_checkout | ||||||||||||||||||||
| 688 | |||||||||||||||||||||
| 689 | Returns checkout without generating an order. | ||||||||||||||||||||
| 690 | |||||||||||||||||||||
| 691 | =over | ||||||||||||||||||||
| 692 | |||||||||||||||||||||
| 693 | =item * Return: HASH | ||||||||||||||||||||
| 694 | |||||||||||||||||||||
| 695 | =item * Synopsis: my $checkout = $cart->info_checkout; | ||||||||||||||||||||
| 696 | |||||||||||||||||||||
| 697 | =back | ||||||||||||||||||||
| 698 | |||||||||||||||||||||
| 699 | =cut | ||||||||||||||||||||
| 700 | |||||||||||||||||||||
| 701 | 0 | ▶ | sub info_checkout { | ||||||||||||||||||
|
Subroutine
info_checkout: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 702 | |||||||||||||||||||||
| 703 | 0 | my ($self) = @_; | |||||||||||||||||||
| 704 | |||||||||||||||||||||
| 705 | 0 | ▶ | return unless $self->_is_valid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 706 | |||||||||||||||||||||
| 707 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||
| 708 | 0 | my $cart_id = $self->id; | |||||||||||||||||||
| 709 | |||||||||||||||||||||
| 710 | 0 | my $response = $api->rawCall( method => 'get', path => "/order/cart/$cart_id/checkout", noSignature => 0 ); | |||||||||||||||||||
| 711 | 0 | ▶ | croak $response->error if $response->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 712 | |||||||||||||||||||||
| 713 | 0 | return $response->content; | |||||||||||||||||||
| 714 | } | ||||||||||||||||||||
| 715 | |||||||||||||||||||||
| 716 | =head2 checkout | ||||||||||||||||||||
| 717 | |||||||||||||||||||||
| 718 | Generates an order. Makes the cart invalid. Returns the order. | ||||||||||||||||||||
| 719 | |||||||||||||||||||||
| 720 | =over | ||||||||||||||||||||
| 721 | |||||||||||||||||||||
| 722 | =item * Return: L<Webservice::OVH::Me::Order> | ||||||||||||||||||||
| 723 | |||||||||||||||||||||
| 724 | =item * Synopsis: my $order = $cart->checkout; | ||||||||||||||||||||
| 725 | |||||||||||||||||||||
| 726 | =back | ||||||||||||||||||||
| 727 | |||||||||||||||||||||
| 728 | =cut | ||||||||||||||||||||
| 729 | |||||||||||||||||||||
| 730 | 0 | ▶ | sub checkout { | ||||||||||||||||||
|
Subroutine
checkout: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 731 | |||||||||||||||||||||
| 732 | 0 | my ($self) = @_; | |||||||||||||||||||
| 733 | |||||||||||||||||||||
| 734 | 0 | ▶ | return unless $self->_is_valid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 735 | |||||||||||||||||||||
| 736 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||
| 737 | 0 | my $cart_id = $self->id; | |||||||||||||||||||
| 738 | |||||||||||||||||||||
| 739 | 0 | my $response = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/checkout", body => {}, noSignature => 0 ); | |||||||||||||||||||
| 740 | 0 | ▶ | croak $response->error if $response->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 741 | |||||||||||||||||||||
| 742 | 0 | my $order_id = $response->content->{orderId}; | |||||||||||||||||||
| 743 | 0 | my $order = Webservice::OVH::Me::Order->_new( wrapper => $api, id => $order_id, module => $self->{_module} ); | |||||||||||||||||||
| 744 | |||||||||||||||||||||
| 745 | 0 | return $order; | |||||||||||||||||||
| 746 | } | ||||||||||||||||||||
| 747 | |||||||||||||||||||||
| 748 | =head2 items | ||||||||||||||||||||
| 749 | |||||||||||||||||||||
| 750 | Produces an Array of Item Objects. | ||||||||||||||||||||
| 751 | |||||||||||||||||||||
| 752 | =over | ||||||||||||||||||||
| 753 | |||||||||||||||||||||
| 754 | =item * Return: L<ARRAY> | ||||||||||||||||||||
| 755 | |||||||||||||||||||||
| 756 | =item * Synopsis: my $items = $cart->items; | ||||||||||||||||||||
| 757 | |||||||||||||||||||||
| 758 | =back | ||||||||||||||||||||
| 759 | |||||||||||||||||||||
| 760 | =cut | ||||||||||||||||||||
| 761 | |||||||||||||||||||||
| 762 | 0 | ▶ | sub items { | ||||||||||||||||||
|
Subroutine
items: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||
| 763 | |||||||||||||||||||||
| 764 | 0 | my ($self) = @_; | |||||||||||||||||||
| 765 | |||||||||||||||||||||
| 766 | 0 | ▶ | return unless $self->_is_valid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 767 | |||||||||||||||||||||
| 768 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||
| 769 | 0 | my $cart_id = $self->id; | |||||||||||||||||||
| 770 | 0 | my $response = $api->rawCall( method => 'get', path => "/order/cart/$cart_id/item", noSignature => 0 ); | |||||||||||||||||||
| 771 | 0 | ▶ | croak $response->error if $response->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 772 | |||||||||||||||||||||
| 773 | 0 | my $item_ids = $response->content; | |||||||||||||||||||
| 774 | 0 | my $items = []; | |||||||||||||||||||
| 775 | |||||||||||||||||||||
| 776 | 0 | foreach my $item_id (@$item_ids) { | |||||||||||||||||||
| 777 | |||||||||||||||||||||
| 778 | 0 | ▶ | my $item = $self->{_items}{$item_id} = $self->{_items}{$item_id} || Webservice::OVH::Order::Cart::Item->_new( wrapper => $api, cart => $self, id => $item_id, module => $self->{_module} ); | ||||||||||||||||||
|
Condition0%0/3
$self->{'_items'}{$item_id} || 'Webservice::OVH::Order::Cart::Item'->_new('wrapper', $api, 'cart', $self, 'id', $item_id, 'module', $self->{'_module'})
MC/DC0%0/2
$self->{'_items'}{$item_id} || 'Webservice::OVH::Order::Cart::Item'->_new('wrapper', $api, 'cart', $self, 'id', $item_id, 'module', $self->{'_module'})
$self->{'_items'}{$item_id}
'Webservice::OVH::Order::Cart::Item'->_new('wrapper', $api, 'cart', $self, 'id', $item_id, 'module', $self->{'_module'})
Truth table0%0/3
A || B
A= $self->{'_items'}{$item_id}B= 'Webservice::OVH::Order::Cart::Item'->_new('wrapper', $api, 'cart', $self, 'id', $item_id, 'module', $self->{'_module'})
| |||||||||||||||||||||
| 779 | 0 | push @$items, $item; | |||||||||||||||||||
| 780 | } | ||||||||||||||||||||
| 781 | |||||||||||||||||||||
| 782 | 0 | return $items; | |||||||||||||||||||
| 783 | } | ||||||||||||||||||||
| 784 | |||||||||||||||||||||
| 785 | =head2 item | ||||||||||||||||||||
| 786 | |||||||||||||||||||||
| 787 | Returns a single item by id | ||||||||||||||||||||
| 788 | |||||||||||||||||||||
| 789 | =over | ||||||||||||||||||||
| 790 | |||||||||||||||||||||
| 791 | =item * Parameter: $item_id - api id | ||||||||||||||||||||
| 792 | |||||||||||||||||||||
| 793 | =item * Return: L<Webservice::OVH::Order::Cart::Item> | ||||||||||||||||||||
| 794 | |||||||||||||||||||||
| 795 | =item * Synopsis: my $item = $ovh->order->cart->item(123456); | ||||||||||||||||||||
| 796 | |||||||||||||||||||||
| 797 | =back | ||||||||||||||||||||
| 798 | |||||||||||||||||||||
| 799 | =cut | ||||||||||||||||||||
| 800 | |||||||||||||||||||||
| 801 | 0 | ▶ | sub item { | ||||||||||||||||||
|
Subroutine
item: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 802 | |||||||||||||||||||||
| 803 | 0 | my ( $self, $item_id ) = @_; | |||||||||||||||||||
| 804 | |||||||||||||||||||||
| 805 | 0 | ▶ | return unless $self->_is_valid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 806 | |||||||||||||||||||||
| 807 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||
| 808 | 0 | ▶ | my $item = $self->{_items}{$item_id} = $self->{_items}{$item_id} || Webservice::OVH::Order::Cart::Item->_new( wrapper => $api, cart => $self, id => $item_id, module => $self->{_module} ); | ||||||||||||||||||
|
Condition0%0/3
$self->{'_items'}{$item_id} || 'Webservice::OVH::Order::Cart::Item'->_new('wrapper', $api, 'cart', $self, 'id', $item_id, 'module', $self->{'_module'})
MC/DC0%0/2
$self->{'_items'}{$item_id} || 'Webservice::OVH::Order::Cart::Item'->_new('wrapper', $api, 'cart', $self, 'id', $item_id, 'module', $self->{'_module'})
$self->{'_items'}{$item_id}
'Webservice::OVH::Order::Cart::Item'->_new('wrapper', $api, 'cart', $self, 'id', $item_id, 'module', $self->{'_module'})
Truth table0%0/3
A || B
A= $self->{'_items'}{$item_id}B= 'Webservice::OVH::Order::Cart::Item'->_new('wrapper', $api, 'cart', $self, 'id', $item_id, 'module', $self->{'_module'})
| |||||||||||||||||||||
| 809 | 0 | return $item; | |||||||||||||||||||
| 810 | } | ||||||||||||||||||||
| 811 | |||||||||||||||||||||
| 812 | =head2 item | ||||||||||||||||||||
| 813 | |||||||||||||||||||||
| 814 | Deletes all items from the cart. | ||||||||||||||||||||
| 815 | |||||||||||||||||||||
| 816 | =over | ||||||||||||||||||||
| 817 | |||||||||||||||||||||
| 818 | =item * Synopsis: $cart->clear; | ||||||||||||||||||||
| 819 | |||||||||||||||||||||
| 820 | =back | ||||||||||||||||||||
| 821 | |||||||||||||||||||||
| 822 | =cut | ||||||||||||||||||||
| 823 | |||||||||||||||||||||
| 824 | 0 | ▶ | sub clear { | ||||||||||||||||||
|
Subroutine
clear: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 825 | |||||||||||||||||||||
| 826 | 0 | my ($self) = @_; | |||||||||||||||||||
| 827 | |||||||||||||||||||||
| 828 | 0 | ▶ | return unless $self->_is_valid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 829 | |||||||||||||||||||||
| 830 | 0 | my $items = $self->items; | |||||||||||||||||||
| 831 | |||||||||||||||||||||
| 832 | 0 | foreach my $item (@$items) { | |||||||||||||||||||
| 833 | |||||||||||||||||||||
| 834 | 0 | $item->delete; | |||||||||||||||||||
| 835 | } | ||||||||||||||||||||
| 836 | } | ||||||||||||||||||||
| 837 | |||||||||||||||||||||
| 838 | =head2 assign | ||||||||||||||||||||
| 839 | |||||||||||||||||||||
| 840 | Assign a shopping cart to an loggedin client | ||||||||||||||||||||
| 841 | |||||||||||||||||||||
| 842 | =over | ||||||||||||||||||||
| 843 | |||||||||||||||||||||
| 844 | =item * Synopsis: $cart->assign; | ||||||||||||||||||||
| 845 | |||||||||||||||||||||
| 846 | =back | ||||||||||||||||||||
| 847 | |||||||||||||||||||||
| 848 | =cut | ||||||||||||||||||||
| 849 | |||||||||||||||||||||
| 850 | 0 | ▶ | sub assign { | ||||||||||||||||||
|
Subroutine
assign: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||
| 851 | |||||||||||||||||||||
| 852 | 0 | my ($self) = @_; | |||||||||||||||||||
| 853 | |||||||||||||||||||||
| 854 | 0 | ▶ | return unless $self->_is_valid; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 855 | |||||||||||||||||||||
| 856 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||
| 857 | 0 | my $cart_id = $self->id; | |||||||||||||||||||
| 858 | 0 | my $response = $api->rawCall( method => 'post', path => "/order/cart/$cart_id/assign", noSignature => 0 ); | |||||||||||||||||||
| 859 | 0 | ▶ | croak $response->error if $response->error; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 860 | } | ||||||||||||||||||||
| 861 | |||||||||||||||||||||
| 862 | |||||||||||||||||||||
| 863 | |||||||||||||||||||||
| 864 | |||||||||||||||||||||
| 865 | |||||||||||||||||||||
| 866 | |||||||||||||||||||||
| 867 | 36 | 1; | |||||||||||||||||||
| 868 | |||||||||||||||||||||