File Coverage

blib/lib/Business/cXML/Transport.pm
Criterion Covered Total %
statement 33 33 100.0
branch 4 4 100.0
condition n/a
subroutine 10 10 100.0
pod 2 2 100.0
total 49 49 100.0


line stmt bran cond sub pod time code
1             =encoding utf-8
2              
3             =head1 NAME
4              
5             Business::cXML::Transport - cXML transport information
6              
7             =head1 SYNOPSIS
8              
9             use Business::cXML::Transport;
10              
11             =head1 DESCRIPTION
12              
13             Object representation of a cXML transport information.
14              
15             =head1 METHODS
16              
17             See L<Business::cXML::Object/COMMON METHODS>.
18              
19             =head1 PROPERTY METHODS
20              
21             See L<Business::cXML::Object/PROPERTY METHODS> for how the following operate.
22              
23             =over
24              
25             =cut
26              
27 7     7   147 use 5.014;
  7         17  
28 7     7   32 use strict;
  7         14  
  7         197  
29              
30             use base qw(Business::cXML::Object);
31 7     7   30  
  7         13  
  7         435  
32             use constant NODENAME => 'TransportInformation';
33 7     7   40 use constant PROPERTIES => (
  7         60  
  7         422  
34 7         408 method => 'unknown',
35             means => undef,
36             start => undef,
37             end => undef,
38             contacts => [],
39             contract => undef,
40             instructions => undef,
41             );
42 7     7   38 use constant OBJ_PROPERTIES => (
  7         15  
43 7         287 contacts => 'Business::cXML::Contact',
44             instructions => 'Business::cXML::Description',
45             );
46 7     7   36  
  7         13  
47             use Business::cXML::Contact;
48 7     7   397 use XML::LibXML::Ferry;
  7         14  
  7         151  
49 7     7   32  
  7         21  
  7         1353  
50             my ($self, $el) = @_;
51              
52 10     10 1 28 $el->ferry($self, {
53             Route => {
54 10         111 startDate => 'start',
55             endDate => 'end',
56             Contact => [ 'contacts', 'Business::cXML::Contact' ],
57             },
58             ShippingContractNumber => 'contract',
59             ShippingInstructions => {
60             Description => [ 'instructions', 'Business::cXML::Description' ],
61             },
62             }
63             );
64             }
65              
66             my ($self, $doc) = @_;
67             my $node = $doc->create($self->{_nodeName});
68             my $route = $node->add('Route', undef,
69 6     6 1 1835 method => $self->{method},
70 6         22 means => $self->{means},
71             startDate => $self->{start},
72             endDate => $self->{end},
73             );
74             $route->add($_->to_node($node)) foreach (@{ $self->{contacts} });
75             $node->add('ShippingContractNumber', $self->{contract}) if defined $self->{contract};
76 6         109 $node->add('ShippingInstructions')->add($self->{instructions}->to_node($node)) if defined $self->{instructions};
77 6         426  
  6         20  
78 6 100       32 return $node;
79 6 100       195 }
80              
81 6         84 =item C<B<method>>
82              
83             Mandatory, one of: C<air>, C<motor>, C<rail>, C<ship>, C<mail>, C<multimodal>,
84             C<fixedTransport>, C<inlandWater>, C<unknown> (default), C<custom>
85              
86             =item C<B<means>>
87              
88             Optional, particular vessel
89              
90             =item C<B<start>>
91              
92             Optional, start date with timezone
93              
94             =item C<B<stop>>
95              
96             Optional, end date with timezone
97              
98             =item C<B<contacts>[]>
99              
100             Optional, L<Business::cXML::Contact> objects
101              
102             =item C<B<contract>>
103              
104             Optional, number or description of shipping contract
105              
106             =item C<B<instructions>>
107              
108             Optional, shipping instructions in a L<Business::cXML::Description> object
109              
110             =back
111              
112             =head1 AUTHOR
113              
114             Stéphane Lavergne L<https://github.com/vphantom>
115              
116             =head1 ACKNOWLEDGEMENTS
117              
118             Graph X Design Inc. L<https://www.gxd.ca/> sponsored this project.
119              
120             =head1 COPYRIGHT & LICENSE
121              
122             Copyright (c) 2017-2018 Stéphane Lavergne L<https://github.com/vphantom>
123              
124             Permission is hereby granted, free of charge, to any person obtaining a copy
125             of this software and associated documentation files (the "Software"), to deal
126             in the Software without restriction, including without limitation the rights
127             to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
128             copies of the Software, and to permit persons to whom the Software is
129             furnished to do so, subject to the following conditions:
130              
131             The above copyright notice and this permission notice shall be included in all
132             copies or substantial portions of the Software.
133              
134             THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
135             IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
136             FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
137             AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
138             LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
139             OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
140             SOFTWARE.
141              
142             =cut
143              
144             1;