| 1 | package Net::Safari::Response::Author; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | =head1 NAME | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | Net::Safari::Response::Author- Author node returned by Safari | ||||||||||||||||||||
| 6 | |||||||||||||||||||||
| 7 | =head1 SYNOPSIS | ||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | use Net::Safari::Response::Author; | ||||||||||||||||||||
| 10 | my $book = Net::Safari::Response::Author->new(%author_ref); | ||||||||||||||||||||
| 11 | |||||||||||||||||||||
| 12 | my @authors = $response->book->authors; | ||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | print $author->firstname; | ||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | =head1 DESCRIPTION | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | See Net::Safari for general usage info. | ||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | In most cases this object is created for you by Net::Safari::Response after a Net::Safari->search() call. | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | =head1 ACCESSORS | ||||||||||||||||||||
| 23 | The accessor descriptions are mostly pulled from the official spec: | ||||||||||||||||||||
| 24 | http://safari.oreilly.com/affiliates/?p=response | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | =head2 firstname() | ||||||||||||||||||||
| 27 | |||||||||||||||||||||
| 28 | Author firstname. | ||||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | =head2 lastname() | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | Author lastname. | ||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | =head2 fullname() | ||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | Firstname + Lastname. Just for kicks, otherwise this would be a really boring | ||||||||||||||||||||
| 37 | module. | ||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | =cut | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 13 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 13 | our $VERSION = 0.01; | |||||||||||||||||||
| 45 | |||||||||||||||||||||
| 46 | 13 | ▶ | use LWP::UserAgent; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 47 | 13 | ▶ | use URI::Escape; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 48 | 13 | ▶ | use Class::Accessor; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 49 | 13 | ▶ | use Class::Fields; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 50 | 13 | ▶ | use Data::Dumper; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 13 | ▶ | use base qw(Class::Accessor Class::Fields); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 53 | |||||||||||||||||||||
| 54 | 13 | our @BASIC_FIELDS = qw( | |||||||||||||||||||
| 55 | firstname | ||||||||||||||||||||
| 56 | lastname | ||||||||||||||||||||
| 57 | ); | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 13 | ▶ | use fields @BASIC_FIELDS; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 60 | 13 | Net::Safari::Response::Author->mk_accessors(@BASIC_FIELDS); | |||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | =head1 METHODS | ||||||||||||||||||||
| 63 | |||||||||||||||||||||
| 64 | =head2 new() | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | $book = Net::Safari::Response::Section->new($ref); | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | Takes a hash represenation of the XML returned by Safari. Normally this is | ||||||||||||||||||||
| 69 | taken care of by Net::Safari::Response::Book. | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | =cut | ||||||||||||||||||||
| 72 | |||||||||||||||||||||
| 73 | sub new | ||||||||||||||||||||
| 74 | 0 | ▶ | { | ||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||
| 75 | 0 | my ($class, %args) = @_; | |||||||||||||||||||
| 76 | |||||||||||||||||||||
| 77 | 0 | ▶ | my $self = bless ({}, ref ($class) || $class); | ||||||||||||||||||
|
Condition0%0/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table0%0/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 0 | $self->_init(%args); | |||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | 0 | return ($self); | |||||||||||||||||||
| 82 | } | ||||||||||||||||||||
| 83 | |||||||||||||||||||||
| 84 | 0 | ▶ | sub _init { | ||||||||||||||||||
|
Subroutine
_init: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 85 | 0 | my $self = shift; | |||||||||||||||||||
| 86 | 0 | my %args = @_; | |||||||||||||||||||
| 87 | |||||||||||||||||||||
| 88 | #Firstname | ||||||||||||||||||||
| 89 | 0 | $self->firstname($args{firstname}); | |||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | #Lastname | ||||||||||||||||||||
| 92 | 0 | $self->lastname($args{lastname}); | |||||||||||||||||||
| 93 | } | ||||||||||||||||||||
| 94 | |||||||||||||||||||||
| 95 | 0 | ▶ | sub fullname { | ||||||||||||||||||
|
Subroutine
fullname: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 96 | 0 | my $self = shift; | |||||||||||||||||||
| 97 | |||||||||||||||||||||
| 98 | 0 | return $self->firstname . " " . $self->lastname; | |||||||||||||||||||
| 99 | } | ||||||||||||||||||||
| 100 | |||||||||||||||||||||
| 101 | =head1 BUGS | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | None yet. | ||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | =head1 SUPPORT | ||||||||||||||||||||
| 106 | |||||||||||||||||||||
| 107 | If you find a bug in the code or find that the code doesn't match Safari API, please send me a line. | ||||||||||||||||||||
| 108 | |||||||||||||||||||||
| 109 | If the Safari API is down or has bugs, please contact Safari directly: | ||||||||||||||||||||
| 110 | affiliates@safaribooksonline.com | ||||||||||||||||||||
| 111 | |||||||||||||||||||||
| 112 | =head1 ACKNOWLEDGMENTS | ||||||||||||||||||||
| 113 | |||||||||||||||||||||
| 114 | Adapted from the design of Net::Amazon by Mike Schilli. | ||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | Some documentation based on the source Safari documentation: | ||||||||||||||||||||
| 117 | http://safari.oreilly.com/affiliates/?p=web_services | ||||||||||||||||||||
| 118 | |||||||||||||||||||||
| 119 | =head1 AUTHOR | ||||||||||||||||||||
| 120 | |||||||||||||||||||||
| 121 | Tony Stubblebine | ||||||||||||||||||||
| 122 | tonys@oreilly.com | ||||||||||||||||||||
| 123 | |||||||||||||||||||||
| 124 | =head1 COPYRIGHT | ||||||||||||||||||||
| 125 | |||||||||||||||||||||
| 126 | Copyright 2004 by Tony Stubblebine (tonys@oreilly.com) | ||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | This program is free software; you can redistribute | ||||||||||||||||||||
| 129 | it and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||
| 130 | |||||||||||||||||||||
| 131 | The full text of the license can be found in the | ||||||||||||||||||||
| 132 | LICENSE file included with this module. | ||||||||||||||||||||
| 133 | |||||||||||||||||||||
| 134 | |||||||||||||||||||||
| 135 | =head1 SEE ALSO | ||||||||||||||||||||
| 136 | |||||||||||||||||||||
| 137 | perl(1). | ||||||||||||||||||||
| 138 | |||||||||||||||||||||
| 139 | =cut | ||||||||||||||||||||
| 140 | |||||||||||||||||||||
| 141 | |||||||||||||||||||||
| 142 | |||||||||||||||||||||
| 143 | 13 | 1; #this line is important and will help the module return a true value | |||||||||||||||||||
| 144 | __END__ | ||||||||||||||||||||