| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
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
|
|
|
36
|
|
284
|
use strict; |
|
|
36
|
|
|
|
|
80
|
|
|
|
36
|
|
|
|
|
1163
|
|
|
34
|
36
|
|
|
36
|
|
196
|
use warnings; |
|
|
36
|
|
|
|
|
76
|
|
|
|
36
|
|
|
|
|
1112
|
|
|
35
|
36
|
|
|
36
|
|
187
|
use Carp qw{ carp croak }; |
|
|
36
|
|
|
|
|
78
|
|
|
|
36
|
|
|
|
|
2442
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
our $VERSION = 0.46; |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# sub modules |
|
40
|
36
|
|
|
36
|
|
19217
|
use Webservice::OVH::Order::Cart; |
|
|
36
|
|
|
|
|
176
|
|
|
|
36
|
|
|
|
|
1495
|
|
|
41
|
36
|
|
|
36
|
|
19325
|
use Webservice::OVH::Order::Hosting; |
|
|
36
|
|
|
|
|
107
|
|
|
|
36
|
|
|
|
|
1211
|
|
|
42
|
36
|
|
|
36
|
|
16437
|
use Webservice::OVH::Order::Email; |
|
|
36
|
|
|
|
|
105
|
|
|
|
36
|
|
|
|
|
1177
|
|
|
43
|
36
|
|
|
36
|
|
16141
|
use Webservice::OVH::Order::Domain; |
|
|
36
|
|
|
|
|
96
|
|
|
|
36
|
|
|
|
|
19444
|
|
|
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
|
|
|
|
|
|
|
sub _new { |
|
63
|
|
|
|
|
|
|
|
|
64
|
0
|
|
|
0
|
|
|
my ( $class, %params ) = @_; |
|
65
|
|
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
die "Missing module" unless $params{module}; |
|
67
|
0
|
0
|
|
|
|
|
die "Missing wrapper" unless $params{wrapper}; |
|
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
|
|
|
|
|
|
|
sub new_cart { |
|
99
|
|
|
|
|
|
|
|
|
100
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub carts { |
|
122
|
|
|
|
|
|
|
|
|
123
|
0
|
|
|
0
|
1
|
|
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
|
0
|
|
|
|
|
croak $response->error if $response->error; |
|
128
|
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
my $card_ids = $response->content; |
|
130
|
0
|
|
|
|
|
|
my $cards = []; |
|
131
|
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
foreach my $card_id (@$card_ids) { |
|
133
|
|
|
|
|
|
|
|
|
134
|
0
|
|
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} ); |
|
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
|
|
|
|
|
|
|
sub cart { |
|
158
|
|
|
|
|
|
|
|
|
159
|
0
|
|
|
0
|
1
|
|
my ( $self, $card_id ) = @_; |
|
160
|
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
my $api = $self->{_api_wrapper}; |
|
162
|
0
|
0
|
0
|
|
|
|
my $from_array_card = $self->{_cards}{$card_id} if $self->{_cards}{$card_id} && $self->{_cards}{$card_id}->is_valid; |
|
163
|
0
|
|
0
|
|
|
|
my $card = $self->{_cards}{$card_id} = $from_array_card || 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
|
|
|
|
|
|
|
sub hosting { |
|
182
|
|
|
|
|
|
|
|
|
183
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub email { |
|
203
|
|
|
|
|
|
|
|
|
204
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub domain { |
|
224
|
|
|
|
|
|
|
|
|
225
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
226
|
|
|
|
|
|
|
|
|
227
|
0
|
|
|
|
|
|
return $self->{_domain}; |
|
228
|
|
|
|
|
|
|
} |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
1; |