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