File: Seller.pm

package info (click to toggle)
libnet-amazon-perl 0.35-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 908 kB
  • ctags: 160
  • sloc: xml: 4,821; perl: 2,055; makefile: 46
file content (78 lines) | stat: -rw-r--r-- 2,129 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#############################################
package Net::Amazon::Response::Seller;
#############################################
use base qw(Net::Amazon::Response);

use Net::Amazon::Result::Seller;
use Data::Dumper;
use Log::Log4perl qw(:easy);

##############################
sub new {
##############################
    my($class, %options) = @_;
   
    my $self = $class->SUPER::new(%options);
    bless $self, $class;   # reconsecrate
}

##################################################
sub result {
##################################################
    my($self) = @_;

    if($self->is_success()) {
        DEBUG "Calling Seller constructor with ", Dumper($self);
        return Net::Amazon::Result::Seller->new(
            xmlref => $self->{xmlref}->{SellerSearchDetails}->[0],
        );
    }

    return undef;
}

##################################################
sub properties {
##################################################
    my($self) = @_;

    die "properties() not defined in ", __PACKAGE__, ". Use result() instead";
}

##################################################
sub as_string {
##################################################
    my($self) = @_;

    return $self->result()->as_string();
}

##################################################
sub xmlref_add {
##################################################
    my($self, $xmlref) = @_;

    my $nof_items_added = 0;

    unless(ref($self->{xmlref}) eq "HASH" &&
        ref($self->{xmlref}->{SellerSearchDetails}) eq "ARRAY") {
        $self->{xmlref}->{Details} = [];
    }

    if(ref($xmlref->{SellerSearchDetails}) eq "ARRAY") {
            # Is it an array of items?
        push @{$self->{xmlref}->{SellerSearchDetails}},
             @{$xmlref->{SellerSearchDetails}};
        $nof_items_added = scalar @{$xmlref->{SellerSearchDetails}};
    } else {
            # It is a single item
        push @{$self->{xmlref}->{SellerSearchDetails}},
             $xmlref->{SellerSearchDetails};
        $nof_items_added = 1;
    }

    #DEBUG("xmlref_add (after):", Data::Dumper::Dumper($self));
    return $nof_items_added;
} 

1;