| 1 | package Webservice::OVH::Order; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | =encoding utf-8 | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | =head1 NAME | ||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | Webservice::OVH::Order | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | use Webservice::OVH; | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | my $ovh = Webservice::OVH->new_from_json("credentials.json"); | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | my $carts = $ovh->order->carts; | ||||||||||||||||||||||||||||
| 16 | my $cart_id = $carts->[0]->id; | ||||||||||||||||||||||||||||
| 17 | my $cart = $ovh->order->cart($cart_id); | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | my $new_cart = $ovh->order->new_cart(ovh_subsidiary => 'DE'); | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | $ovh->order->hosting->web; | ||||||||||||||||||||||||||||
| 22 | $ovh->order->email->domain; | ||||||||||||||||||||||||||||
| 23 | $ovh->order->domain->zone; | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | Module that support carts and domain/transfer orders at the moment | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =head1 METHODS | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | =cut | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 36 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 34 | 36 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 35 | 36 | ▶ | use Carp qw{ carp croak }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 36 | our $VERSION = 0.48; | |||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # sub modules | ||||||||||||||||||||||||||||
| 40 | 36 | ▶ | use Webservice::OVH::Order::Cart; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 41 | 36 | ▶ | use Webservice::OVH::Order::Hosting; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 42 | 36 | ▶ | use Webservice::OVH::Order::Email; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 43 | 36 | ▶ | use Webservice::OVH::Order::Domain; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | =head2 _new | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | Internal Method to create the order object. | ||||||||||||||||||||||||||||
| 48 | This method is not ment to be called external. | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | =over | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =item * Parameter: $api_wrapper - ovh api wrapper object, $module - root object | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =item * Return: L<Webservice::OVH::Order> | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =item * Synopsis: Webservice::OVH::Order->_new($ovh_api_wrapper, $self); | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | =back | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | =cut | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub _new { | ||||||||||||||||||||||||||
|
Subroutine
_new: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 0 | my ( $class, %params ) = @_; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | die "Missing module" unless $params{module}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | ▶ | die "Missing wrapper" unless $params{wrapper}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | my $module = $params{module}; | |||||||||||||||||||||||||||
| 70 | 0 | my $api_wrapper = $params{wrapper}; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | my $hosting = Webservice::OVH::Order::Hosting->_new( wrapper => $api_wrapper, module => $module ); | |||||||||||||||||||||||||||
| 73 | 0 | my $email = Webservice::OVH::Order::Email->_new( wrapper => $api_wrapper, module => $module ); | |||||||||||||||||||||||||||
| 74 | 0 | my $domain = Webservice::OVH::Order::Domain->_new( wrapper => $api_wrapper, module => $module ); | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | my $self = bless { _module => $module, _api_wrapper => $api_wrapper, _cards => {}, _hosting => $hosting, _email => $email, _domain => $domain }, $class; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | return $self; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =head2 new_cart | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | Creates a new 'shopping' cart. | ||||||||||||||||||||||||||||
| 84 | Items can be put into it, to create orders. | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =over | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =item * Parameter: %params - key => value (required) ovh_subsidiary => 'DE' (optional) expire => DateTime-str description => "shopping" | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =item * Return: L<Webservice::OVH::Order::Cart> | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =item * Synopsis: my $cart = $ovh->order->new_cart(ovh_subsidiary => 'DE'); | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =back | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =cut | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 0 | ▶ | sub new_cart { | ||||||||||||||||||||||||||
|
Subroutine
new_cart: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 0 | my ( $self, %params ) = @_; | |||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||||||||||
| 103 | 0 | my $cart = Webservice::OVH::Order::Cart->_new( wrapper => $api, module => $self->{_module}, %params ); | |||||||||||||||||||||||||||
| 104 | 0 | return $cart; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | =head2 carts | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | Produces an array of all available carts that are connected to the used account. | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | =over | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =item * Return: ARRAY | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | =item * Synopsis: my $carts = $ovh->order->carts(); | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =back | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =cut | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 0 | ▶ | sub carts { | ||||||||||||||||||||||||||
|
Subroutine
carts: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||||||||||
| 126 | 0 | my $response = $api->rawCall( method => 'get', path => "/order/cart", noSignature => 0 ); | |||||||||||||||||||||||||||
| 127 | 0 | ▶ | croak $response->error if $response->error; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | my $card_ids = $response->content; | |||||||||||||||||||||||||||
| 130 | 0 | my $cards = []; | |||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 0 | foreach my $card_id (@$card_ids) { | |||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | 0 | ▶ | my $card = $self->{_cards}{$card_id} = $self->{_cards}{$card_id} || Webservice::OVH::Order::Cart->_new_existing( wrapper => $api, id => $card_id, module => $self->{_module} ); | ||||||||||||||||||||||||||
|
Condition0%0/3
$self->{'_cards'}{$card_id} || 'Webservice::OVH::Order::Cart'->_new_existing('wrapper', $api, 'id', $card_id, 'module', $self->{'_module'})
MC/DC0%0/2
$self->{'_cards'}{$card_id} || 'Webservice::OVH::Order::Cart'->_new_existing('wrapper', $api, 'id', $card_id, 'module', $self->{'_module'})
$self->{'_cards'}{$card_id}
'Webservice::OVH::Order::Cart'->_new_existing('wrapper', $api, 'id', $card_id, 'module', $self->{'_module'})
Truth table0%0/3
A || B
A= $self->{'_cards'}{$card_id}B= 'Webservice::OVH::Order::Cart'->_new_existing('wrapper', $api, 'id', $card_id, 'module', $self->{'_module'})
| |||||||||||||||||||||||||||||
| 135 | 0 | push @$cards, $card; | |||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 0 | return $cards; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | =head2 cart | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | Returns a single cart by id | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | =over | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | =item * Parameter: cart_id - cart id | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | =item * Return: L<Webservice::OVH::Order::Cart> | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | =item * Synopsis: my $cart = $ovh->order->cart(1234567); | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | =back | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | =cut | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub cart { | ||||||||||||||||||||||||||
|
Subroutine
cart: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | 0 | my ( $self, $card_id ) = @_; | |||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | 0 | my $api = $self->{_api_wrapper}; | |||||||||||||||||||||||||||
| 162 | 0 | ▶ | my $from_array_card = $self->{_cards}{$card_id} if $self->{_cards}{$card_id} && $self->{_cards}{$card_id}->is_valid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"_cards"}{$card_id} and $self->{"_cards"}{$card_id}->is_valid
MC/DC0%0/2
$self->{"_cards"}{$card_id} and $self->{"_cards"}{$card_id}->is_valid
$self->{"_cards"}{$card_id}
$self->{"_cards"}{$card_id}->is_valid
Truth table0%0/3
A and B
A= $self->{"_cards"}{$card_id}B= $self->{"_cards"}{$card_id}->is_valid
| |||||||||||||||||||||||||||||
| 163 | 0 | ▶ | my $card = $self->{_cards}{$card_id} = $from_array_card || Webservice::OVH::Order::Cart->_new_existing( wrapper => $api, id => $card_id, module => $self->{_module} ); | ||||||||||||||||||||||||||
|
Condition0%0/3
$from_array_card || 'Webservice::OVH::Order::Cart'->_new_existing('wrapper', $api, 'id', $card_id, 'module', $self->{'_module'})
MC/DC0%0/2
$from_array_card || 'Webservice::OVH::Order::Cart'->_new_existing('wrapper', $api, 'id', $card_id, 'module', $self->{'_module'})
$from_array_card
'Webservice::OVH::Order::Cart'->_new_existing('wrapper', $api, 'id', $card_id, 'module', $self->{'_module'})
Truth table0%0/3
A || B
A= $from_array_cardB= 'Webservice::OVH::Order::Cart'->_new_existing('wrapper', $api, 'id', $card_id, 'module', $self->{'_module'})
| |||||||||||||||||||||||||||||
| 164 | 0 | return $card; | |||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | =head2 hosting | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | Gives Acces to the /order/hosting/ methods of the ovh api | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | =over | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | =item * Return: L<Webservice::OVH::Order::Hosting> | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | =item * Synopsis: $ovh->order->hosting | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | =back | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | =cut | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 0 | ▶ | sub hosting { | ||||||||||||||||||||||||||
|
Subroutine
hosting: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 0 | return $self->{_hosting}; | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | =head2 email | ||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | Gives Acces to the /order/email/ methods of the ovh api | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | =over | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | =item * Return: L<Webservice::OVH::Order::Email> | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | =item * Synopsis: $ovh->order->email | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | =back | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | =cut | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 0 | ▶ | sub email { | ||||||||||||||||||||||||||
|
Subroutine
email: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | 0 | return $self->{_email}; | |||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | =head2 domain | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | Gives Acces to the /order/domain/ methods of the ovh api | ||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||
| 213 | =over | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | =item * Return: L<Webservice::OVH::Order::Domain> | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | =item * Synopsis: $ovh->order->domain | ||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||
| 219 | =back | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | =cut | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 0 | ▶ | sub domain { | ||||||||||||||||||||||||||
|
Subroutine
domain: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 0 | return $self->{_domain}; | |||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 36 | 1; | |||||||||||||||||||||||||||