File Coverage

blib/lib/WWW/LogicBoxes/DomainRequest/Registration.pm
Criterion Covered Total %
statement 18 20 90.0
branch 0 4 0.0
condition n/a
subroutine 6 7 85.7
pod 1 1 100.0
total 25 32 78.1


line stmt bran cond sub pod time code
1             package WWW::LogicBoxes::DomainRequest::Registration;
2              
3 40     40   445015 use strict;
  40         121  
  40         1500  
4 40     40   250 use warnings;
  40         101  
  40         1170  
5              
6 40     40   820 use Moose;
  40         178617  
  40         339  
7 40     40   288540 use MooseX::StrictConstructor;
  40         47926  
  40         404  
8 40     40   153993 use namespace::autoclean;
  40         114  
  40         464  
9              
10 40     40   4907 use WWW::LogicBoxes::Types qw( Int );
  40         110  
  40         378  
11              
12             extends 'WWW::LogicBoxes::DomainRequest';
13              
14             our $VERSION = '1.11.0'; # VERSION
15             # ABSTRACT: Domain Registration Request
16              
17             has years => (
18             is => 'ro',
19             isa => Int,
20             required => 1,
21             );
22              
23             sub construct_request {
24 0     0 1   my $self = shift;
25              
26             return {
27 0 0         'domain-name' => $self->name,
    0          
28             years => $self->years,
29             ns => $self->ns,
30             'customer-id' => $self->customer_id,
31             'reg-contact-id' => $self->registrant_contact_id,
32             'admin-contact-id' => $self->admin_contact_id,
33             'tech-contact-id' => $self->technical_contact_id,
34             'billing-contact-id' => $self->has_billing_contact_id ? $self->billing_contact_id : -1,
35             'invoice-option' => $self->invoice_option,
36             $self->is_private ? (
37             'protect-privacy' => 'true',
38             'purchase-privacy' => 'true',
39             ) : ( ),
40             };
41             }
42              
43             __PACKAGE__->meta->make_immutable;
44             1;
45              
46             __END__
47             =pod
48              
49             =head1 NAME
50              
51             WWW::LogicBoxes::DomainRequest::Registration - Representation of Domain Registration Request
52              
53             =head1 SYNOPSIS
54              
55             use WWW::LogicBoxes;
56             use WWW::LogicBoxes::Customer;
57             use WWW::LogicBoxes::Contact;
58             use WWW::LogicBoxes::Domain;
59             use WWW::LogicBoxes::DomainRequest::Registration;
60              
61             my $logic_boxes = WWW::LogicBoxes->new( ... );
62             my $customer = WWW:::LogicBoxes::Customer->new( ... ); # Valid LogicBoxes Customer
63              
64             my $registrant_contact = WWW::LogicBoxes::Contact->new( ... ); # Valid LogicBoxes Contact
65             my $admin_contact = WWW::LogicBoxes::Contact->new( ... ); # Valid LogicBoxes Contact
66             my $technical_contact = WWW::LogicBoxes::Contact->new( ... ); # Valid LogicBoxes Contact
67             my $billing_contact = WWW::LogicBoxes::Contact->new( ... ); # Valid LogicBoxes Contact
68              
69             my $registration_request = WWW::LogicBoxes::DomainRequest::Registration->new(
70             name => 'test-domain.com',
71             years => 1,
72             customer_id => $customer->id,
73             ns => [ 'ns1.logicboxes.com', 'ns2.logicboxes.com' ],
74             registrant_contact_id => $registrant_contact->id,
75             admin_contact_id => $admin_contact->id,
76             technical_contact_id => $technical_contact->id,
77             billing_contact_id => $billing_contact->id,
78             invoice_option => 'NoInvoice',
79             );
80              
81             my $registered_domain = $logic_boxes->register_domain( request => $registration_request );
82              
83             =head1 EXTENDS
84              
85             L<WWW::LogicBoxes::DomainRequest>
86              
87             =head1 DESCRIPTION
88              
89             WWW::LogicBoxes::DomainRequest::Registration is a representation of all the data needed in order to complete a domain registration. It is used when requesting a new registration from L<LogicBoxes|http://www.logicboxes.com>.
90              
91             =head1 ATTRIBUTES
92              
93             All of the existing L<WWW::LogicBoxes::DomainRequest> attributes remain unchanged with one addition attribute.
94              
95             =head2 B<years>
96              
97             The number of years to register this L<domain|WWW::LogicBoxes::Domain> for.
98              
99             =head1 METHODS
100              
101             This method is used internally, it's fairly unlikely that consumers will ever call it directly.
102              
103             =head2 construct_request
104              
105             my $logic_boxes = WWW::LogicBoxes->new( ... );
106             my $registration_request = WWW::LogicBoxes::DomainRequest::Registration->new( ... );
107              
108             my $response = $logic_boxes->submit({
109             method => 'domains__register',
110             params => $registration_request->consturct_request(),
111             });
112              
113             Converts $self into a HashRef suitable for requesting a domain registration with L<LogicBoxes|http://www.logicboxes.com>.
114              
115             =cut