File Coverage

blib/lib/Regru/API/Service.pm
Criterion Covered Total %
statement 13 13 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 18 18 100.0


line stmt bran cond sub pod time code
1              
2             # ABSTRACT: REG.API v2 service management
3              
4             use strict;
5 1     1   569 use warnings;
  1         2  
  1         24  
6 1     1   4 use Moo;
  1         2  
  1         20  
7 1     1   4 use namespace::autoclean;
  1         2  
  1         6  
8 1     1   2431  
  1         2  
  1         4  
9             our $VERSION = '0.052'; # VERSION
10             our $AUTHORITY = 'cpan:CHIM'; # AUTHORITY
11              
12             with 'Regru::API::Role::Client';
13              
14             has '+namespace' => (
15             default => sub { 'service' },
16             );
17              
18             nop
19 1     1   5 get_prices
20             get_servtype_details
21             create
22             delete
23             get_info
24             get_list
25             get_folders
26             get_details
27             get_dedicated_server_list
28             update
29             renew
30             get_bills
31             set_autorenew_flag
32             suspend
33             resume
34             get_depreciated_period
35             upgrade
36             partcontrol_grant
37             partcontrol_revoke
38             resend_mail
39             refill
40             )]}
41              
42             __PACKAGE__->namespace_methods;
43             __PACKAGE__->meta->make_immutable;
44              
45             1; # End of Regru::API::Service
46              
47              
48             =pod
49              
50             =encoding UTF-8
51              
52             =head1 NAME
53              
54             Regru::API::Service - REG.API v2 service management
55              
56             =head1 VERSION
57              
58             version 0.052
59              
60             =head1 DESCRIPTION
61              
62             REG.API service management methods such as create/remove/suspend/resume services, get information, grant/revoke access to
63             a service to other users, retrieve list of invoices on service and many others.
64              
65             =head1 ATTRIBUTES
66              
67             =head2 namespace
68              
69             Always returns the name of category: C<service>. For internal uses only.
70              
71             =head1 REG.API METHODS
72              
73             =head2 nop
74              
75             For testing purposes. Scope: B<clients>. Typical usage:
76              
77             $resp = $client->service->nop(
78             dname => 'kavorka.lv',
79             );
80              
81             Answer will contains a field C<services> with a list of results for each involved to this operation services (domain names,
82             hosting plans, certificates, etc) or error otherwise.
83              
84             More info at L<Service management: nop|https://www.reg.com/support/help/api2#service_nop>.
85              
86             =head2 get_prices
87              
88             Gets a service registration/renewal pricing. Scope: B<everyone>. Typical usage:
89              
90             $resp = $client->service->get_prices(
91             currency => 'USD', # default in RUR. also valid UAH and EUR
92             );
93              
94             Answer will contains a field C<prices> with a list of all available services, their names, types, billing term and price.
95              
96             More info at L<Service management: get_prices|https://www.reg.com/support/help/api2#service_get_prices>.
97              
98             =head2 get_servtype_details
99              
100             Gets detailed information about service. Scope: B<clients>. Typical usage:
101              
102             $resp = $client->service->get_servtype_details(
103             servtype => 'srv_vps,srv_hosting_plesk',
104             );
105              
106             $details = $resp->answer;
107              
108             Answer will contains a list of all available plans and parameters for requested types of services, their names,
109             types, billing term and prices for registration and renewal.
110              
111             More info at L<Service management: get_servtype_details|https://www.reg.com/support/help/api2#service_get_servtype_details>.
112              
113             =head2 create
114              
115             Orders a new service. Scope: B<clients>. Typical usage:
116              
117             $resp = $client->service->create(
118             # common options
119             domain_name => 'kramerica.com',
120             forder_name => 'kramerica-industries', # put newly created service to folder
121             period => 3, # for 3 months
122              
123             # service related options
124             servtype => 'srv_hosting_plesk',
125             subtype => 'Host-2-0311', # service plan
126             contype => 'hosting_org', # organization or hosting_pp for person
127             email => 'info@kramerica.com',
128             country => 'US',
129             code => '', # empty for non RU-redidents only
130             org_r => 'Limited Liability Company "Kramerica Industries"',
131             );
132              
133             # or
134             $csreq = <<CSR;
135             -----BEGIN CERTIFICATE REQUEST-----
136             ...
137             TwGJ9/LuG771Ehq41X/IunqqZ9+lAObxqJ9XAwNAielSPdVhx4NrPjaIGdFhdPeL
138             ...
139             w9n2/G9Q8gcSGg2HG09fLyvjcFMC0cnASS26EAbfOmrcFhCp2cXddmeIlpc=
140             -----END CERTIFICATE REQUEST-----
141             CSR
142              
143             $resp = $client->service->create(
144             # common options
145             domain_name => 'kramerica.com',
146             forder_name => 'kramerica-industries', # put newly created service to folder
147             period => 2, # SSL sectificate for 2 years
148              
149             # service related options
150             servtype => 'srv_ssl_sertificate',
151             subtype => 'sslwebserver', # Thawte SSL Web Server
152             server_type => 'apachessl', # server software
153             csr_string => $csreq, # certificate request as string
154             approver_email => 'webmaster@kramerica.com', # email for confirmation
155              
156             # organization
157             org_org_name => 'Kramerica Industries',
158             org_address => '129 West 81st Street, apt. 5B',
159             org_city => 'New York',
160             org_state => 'NY',
161             org_postal_code => '10024',
162             org_country => 'US',
163             org_phone => '+1.212.5553455',
164              
165             # administrative contact
166             admin_first_name => 'Cosmo',
167             admin_last_name => 'Kramer',
168             admin_title => 'Mr.',
169             # rest of required admin_* fields
170             ...
171              
172             # billing contact
173             billing_* => ...,
174              
175             # technical contact
176             tech_* => ...,
177             );
178              
179             Successful answer will contains a newly created service and invoice indentifiers, description of order and total
180             amount of charges or error otherwise.
181              
182             More info at L<Service management: create|https://www.reg.com/support/help/api2#service_create>.
183              
184             =head2 delete
185              
186             Refuses from using active service. Scope: B<clients>. Typical usage:
187              
188             $resp = $client->service->delete(
189             domain_name => 'buck-naked.xxx',
190             servtype => 'srv_vps',
191             );
192              
193             Returns a success response or error if any.
194              
195             More info at L<Service management: delete|https://www.reg.com/support/help/api2#service_delete>.
196              
197             =head2 get_info
198              
199             Obtains a detailed information about service(s) by domain name(s). Scope: B<clients>. Typical usage:
200              
201             $resp = $client->service->get_info(
202             show_folders => 1, # include folders
203             domains => [
204             { dname => 'monks.com' },
205             { dname => 'reggies.com' },
206             ],
207             );
208              
209             Answer will contains a field C<services> with a list of services, their subtypes, states, dates of creation and
210             dates of expiration. Also a list of folders accociated with services might be included.
211              
212             More info at L<Service management: get_info|https://www.reg.com/support/help/api2#service_get_info>.
213              
214             =head2 get_list
215              
216             Obtains an information about active service(s) by type. Scope: B<clients>. Typical usage:
217              
218             $resp = $client->service->get_list(
219             servtype => 'srv_webfwd',
220             );
221              
222             In case of C<servtype> is not defined the full list of active services will be returned.
223              
224             Answer will contains a field C<services> with a list of services, their subtypes, states, dates of creation and
225             dates of expiration.
226              
227             More info at L<Service management: get_list|https://www.reg.com/support/help/api2#service_get_list>.
228              
229             =head2 get_folders
230              
231             Returns a list of folders associated with a service. Scope: B<clients>. Typical usage:
232              
233             $resp = $client->service->get_folders(
234             service_id => 1744688,
235             );
236              
237             # or
238             $resp = $client->service->get_folders(
239             domain_name => 'bob.sacamano.name',
240             );
241              
242             Answer will contains a field C<folders> with a list of folder associated with service or empty list if no those folders.
243              
244             More info at L<Service management: get_folders|https://www.reg.com/support/help/api2#service_get_folders>.
245              
246             =head2 get_details
247              
248             Gets a detailed information about the services including contact data for domains, account settings for hosting services, etc.
249             Scope: B<clients>. Typical usage:
250              
251             $resp = $client->service->get_details(
252             services => [
253             { dname => 'bubble-boy.net' },
254             { service_id => 5177993 },
255             ],
256             );
257              
258             Answer will contains a field C<services> with a list of detailed information for each services or error otherwise.
259              
260             More info at L<Service management: get_details|https://www.reg.com/support/help/api2#service_get_details>.
261              
262             =head2 get_dedicated_server_list
263              
264             Gets a dedicated servers' list avaliable for order. Scope: B<clients>. Typical usage:
265              
266             $resp = $client->service->get_dedicated_server_list;
267              
268             Answer will contains a field C<server_list> with a list of dedicated configurations available for order.
269              
270             More info at L<Service management: get_dedicated_server_list|https://www.reg.com/support/help/api2#service_get_dedicated_server_list>.
271              
272             =head2 update
273              
274             Updates service configuration. Scope: B<clients>. Typical usage:
275              
276             $resp = $client->service->update(
277             domain_name => 'jambalaya.net',
278             servtype => 'srv_webfwd', # web forwarding
279             subtask => 'addfwd', # add rule
280             fwd_type => 'frames', # framing content
281              
282             # http://jambalaya.net/this -> http://mulligatawny.com/that
283             fwdfrom => '/this',
284             fwdto => 'http://mulligatawny.com/that',
285             );
286              
287             This one is similar to method L</create>. Answer will contains a field C<descr> with a description of the order
288             or error otherwise.
289              
290             More info at L<Service management: update|https://www.reg.com/support/help/api2#service_update>.
291              
292             =head2 renew
293              
294             Renewals the service(s) (domain name, hosting, SSL certificate, etc). Scope: B<clients>. Typical usage:
295              
296             $resp = $client->service->renew(
297             service_id => 2674890,
298             period => 2, # service's billing term
299             );
300              
301             # or
302             $resp = $client->service->renew(
303             period => 3, # 3 years (for domain names)
304             domains => [
305             { dname => 'schmoopie.com' },
306             { dname => 'schmoopie.net' },
307             ],
308             );
309              
310             Answer will contains a set of fields like renewal period, invoice identifier, currency and amount of charges,.. for each of
311             services or error otherwise.
312              
313             More info at L<Service management: renew|https://www.reg.com/support/help/api2#service_renew>.
314              
315             =head2 get_bills
316              
317             Gets a list of invoices associated with service(s). Scope: B<partners>. Typical usage:
318              
319             $resp = $client->service->get_bills(
320             domains => [
321             { dname => 'giddyup.com' },
322             ],
323             );
324              
325             Answer will contains a field C<services> with a list of services, their types, id and list of invoices (field C<bills>)
326             or error otherwise.
327              
328             More info at L<Service management: get_bills|https://www.reg.com/support/help/api2#service_get_bills>.
329              
330             =head2 set_autorenew_flag
331              
332             Manages automatic service renewals. Scope: B<clients>. Typical usage:
333              
334             $resp = $client->service->set_autorenew_flag(
335             service_id => 86478,
336             flag_value => 1, # 1/0 - enable/disable autorenew feature
337             );
338              
339             Returns just a successful/error response.
340              
341             More info at L<Service management: set_autorenew_flag|https://www.reg.com/support/help/api2#service_set_autorenew_flag>.
342              
343             =head2 suspend
344              
345             Suspends service usage. Scope: B<clients>. Typical usage:
346              
347             $resp = $client->service->suspend(
348             domain_name => 'festivus.org',
349             );
350              
351             For domain names means a suspending delegation of the. Returns just a successful/error response.
352              
353             More info at L<Service management: suspend|https://www.reg.com/support/help/api2#service_suspend>.
354              
355             =head2 resume
356              
357             Resumes service usage. Scope: B<clients>. Typical usage:
358              
359             $resp = $client->service->resume(
360             domain_name => 'festivus.org',
361             );
362              
363             For domain names means a resuming delegation of the. Returns just a successful/error response.
364              
365             More info at L<Service management: resume|https://www.reg.com/support/help/api2#service_resume>.
366              
367             =head2 get_depreciated_period
368              
369             Gets the number of billing terms till the service expiration date. Scope: B<clients>. Typical usage:
370              
371             $resp = $client->service->get_depreciated_period(
372             domain_name => 'kavorka.net',
373             servtype => 'srv_hosting_ispmgr',
374             );
375              
376             Answer will contains a field C<depreciated_period> with a number of terms or error otherwise.
377              
378             More info at L<Service management: get_depreciated_period|https://www.reg.com/support/help/api2#service_get_depreciated_period>.
379              
380             =head2 upgrade
381              
382             Upgrades service plans for services such as virtual hosting (C<srv_hosting_ispmgr>), VPS servers (C<srv_vps>) and additional
383             disk space (C<srv_disk_space>). Scope: B<clients>. Typical usage:
384              
385             $resp = $client->service->upgrade(
386             domain_name => 'beef-a-reeno.com',
387             servtype => 'srv_vps',
388             subtype => 'VPS-4-1011',
389             period => 3,
390             );
391              
392             Answer will contains a withdrawal amount and a new service identifier or error otherwise.
393              
394             More info at L<Service management: upgrade |https://www.reg.com/support/help/api2#service_upgrade>.
395              
396             =head2 partcontrol_grant
397              
398             Grants service management to other user. Scope: B<clients>. Typical usage:
399              
400             $resp = $client->service->partcontrol_grant(
401             domain_name => 'mulva.org',
402             newlogin => 'Dolores',
403             );
404              
405             Answer will contains a field user login (C<newlogin>)to whom the right were granted and the service identifier C<service_id>
406             or error otherwise.
407              
408             More info at L<Service management: partcontrol_grant|https://www.reg.com/support/help/api2#service_partcontrol_grant>.
409              
410             =head2 partcontrol_revoke
411              
412             Revokes service management from other user. Scope: B<clients>. Typical usage:
413              
414             $resp = $client->service->partcontrol_revoke(
415             service_id => 2865903,
416             );
417              
418             Answer will contains a service identifier C<service_id> or error otherwise.
419              
420             More info at L<Service management: partcontrol_revoke|https://www.reg.com/support/help/api2#service_partcontrol_revoke>.
421              
422             =head2 resend_mail
423              
424             Resends an email to user. Applicable only for hosting services and SSL certificates. Scope: B<clients>. Typical usage:
425              
426             $resp = $client->service->resend_mail(
427             domain_name => 'jujyfruits.net',
428             servtype => 'srv_ssl_certificate',
429             mailtype => 'approver_email', # or 'certificate_email'
430             );
431              
432             Answer will contains a domain name and service identifier or error otherwise.
433              
434             More info at L<Service management: resend_mail|https://www.reg.com/support/help/api2#service_resend_mail>.
435              
436             =head2 refill
437              
438             For Jelastic service only. Tranfers specified amount from the user account to the Jelastic account,
439             associated with the specified service_id. Scope: B<clients>. Typical usage:
440              
441             $resp = $client->service->refill(
442             service_id => 13726302,
443             amount => 2,
444             currency => 'USD'
445             );
446              
447             Answer will contain information about created invoice, such as invoice currency, charged sum, bill number.
448             More info at L<Service management: refill|https://www.reg.com/support/help/api2#service_refill>.
449              
450             =head1 SEE ALSO
451              
452             L<Regru::API>
453              
454             L<Regru::API::Role::Client>
455              
456             L<REG.API Service management|https://www.reg.com/support/help/api2#service_functions>
457              
458             L<REG.API Common error codes|https://www.reg.com/support/help/api2#common_errors>
459              
460             =head1 BUGS
461              
462             Please report any bugs or feature requests on the bugtracker website
463             L<https://github.com/regru/regru-api-perl/issues>
464              
465             When submitting a bug or request, please include a test-file or a
466             patch to an existing test-file that illustrates the bug or desired
467             feature.
468              
469             =head1 AUTHORS
470              
471             =over 4
472              
473             =item *
474              
475             Polina Shubina <shubina@reg.ru>
476              
477             =item *
478              
479             Anton Gerasimov <a.gerasimov@reg.ru>
480              
481             =back
482              
483             =head1 COPYRIGHT AND LICENSE
484              
485             This software is copyright (c) 2013 by REG.RU LLC.
486              
487             This is free software; you can redistribute it and/or modify it under
488             the same terms as the Perl 5 programming language system itself.
489              
490             =cut