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