line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Amazon::MWS::XML::GenericFeed; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
69
|
use strict; |
|
7
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
245
|
|
4
|
7
|
|
|
7
|
|
49
|
use warnings; |
|
7
|
|
|
|
|
22
|
|
|
7
|
|
|
|
|
465
|
|
5
|
7
|
|
|
7
|
|
52
|
use utf8; |
|
7
|
|
|
|
|
31
|
|
|
7
|
|
|
|
|
55
|
|
6
|
|
|
|
|
|
|
|
7
|
7
|
|
|
7
|
|
261
|
use File::Spec; |
|
7
|
|
|
|
|
32
|
|
|
7
|
|
|
|
|
216
|
|
8
|
7
|
|
|
7
|
|
3964
|
use Data::Dumper; |
|
7
|
|
|
|
|
57755
|
|
|
7
|
|
|
|
|
647
|
|
9
|
|
|
|
|
|
|
|
10
|
7
|
|
|
7
|
|
14301
|
use Moo; |
|
7
|
|
|
|
|
71097
|
|
|
7
|
|
|
|
|
58
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Amazon::MWS::XML::GenericFeed -- base module to create XML feeds for Amazon MWS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 ACCESSORS |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head2 xml_writer |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
The L<XML::Compile::Schema> writer object. You can pass this to build |
21
|
|
|
|
|
|
|
this object manually (usually it's the Uploader who builds the writer). |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $writer = XML::Compile::Schema->new([glob '*.xsd']) |
24
|
|
|
|
|
|
|
->compile(WRITER => 'AmazonEnvelope'); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head2 merchant_id |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Required. The merchant id provided by Amazon. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head2 debug |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Whether to enable debugging or not. |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has xml_writer => (is => 'ro', required => 1); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has debug => (is => 'rw'); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
has merchant_id => (is => 'ro', |
41
|
|
|
|
|
|
|
required => 1, |
42
|
|
|
|
|
|
|
isa => sub { |
43
|
|
|
|
|
|
|
die "the merchant id must be a string" unless $_[0]; |
44
|
|
|
|
|
|
|
}); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 METHODS |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head2 create_feed($operation, \@messages, %options) |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Create a feed of type $operation, with the messages passed. The |
51
|
|
|
|
|
|
|
options are not used yet. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub create_feed { |
56
|
0
|
|
|
0
|
1
|
|
my ($self, $operation, $messages, %options) = @_; |
57
|
0
|
0
|
|
|
|
|
die "Missign operation" unless $operation; |
58
|
0
|
0
|
0
|
|
|
|
return unless $messages && @$messages; |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
|
my $data = { |
61
|
|
|
|
|
|
|
Header => { |
62
|
|
|
|
|
|
|
MerchantIdentifier => $self->merchant_id, |
63
|
|
|
|
|
|
|
DocumentVersion => "1.1", # unclear |
64
|
|
|
|
|
|
|
}, |
65
|
|
|
|
|
|
|
MessageType => $operation, |
66
|
|
|
|
|
|
|
# to be handled with options eventually? |
67
|
|
|
|
|
|
|
# MarketplaceName => "example", |
68
|
|
|
|
|
|
|
# PurgeAndReplace => "false", unclear if "false" works |
69
|
|
|
|
|
|
|
Message => $messages, |
70
|
|
|
|
|
|
|
}; |
71
|
0
|
|
|
|
|
|
my $doc = XML::LibXML::Document->new('1.0', 'UTF-8'); |
72
|
0
|
|
|
|
|
|
my $xml = $self->xml_writer->($doc, $data); |
73
|
0
|
|
|
|
|
|
$doc->setDocumentElement($xml); |
74
|
0
|
|
|
|
|
|
return $doc->toString(1); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |