| 1 | package VendorAPI::2Checkout::Client; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 9 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 9 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 9 | ▶ | use Params::Validate qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 9 | ▶ | use Carp qw(confess); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 9 | ▶ | use URI; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 9 | ▶ | use URI::QueryParam; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 9 | require UNIVERSAL::require; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | VendorAPI::2Checkout::Client - an OO interface to the 2Checkout.com Vendor API | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | =head1 VERSION | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | Version 0.1502 | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =cut | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 9 | ▶ | use vars qw( $VERSION @ISA ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 25 | 9 | $VERSION = '0.1502'; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | sub _base_uri { 'https://www.2checkout.com/api' }; | ||||||||||||||||||||||||||
|
Subroutine
_base_uri: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 28 | 3 | ▶ | sub _realm { '2CO API' }; | ||||||||||||||||||||||||||
|
Subroutine
_realm: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 3 | ▶ | sub _netloc { 'www.2checkout.com:443' }; | ||||||||||||||||||||||||||
|
Subroutine
_netloc: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 7 | ▶ | sub mime_type { | ||||||||||||||||||||||||||
|
Subroutine
mime_type: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 32 | 7 | my $self = shift; | |||||||||||||||||||||||||||
| 33 | 7 | my $format = shift; | |||||||||||||||||||||||||||
| 34 | 7 | my %mime_types = ( XML => 'application/xml', JSON => 'application/json', ); | |||||||||||||||||||||||||||
| 35 | 7 | ▶ | return $mime_types{$format} || $mime_types{JSON}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$mime_types{$format} || $mime_types{'JSON'}
MC/DC0%0/2
$mime_types{$format} || $mime_types{'JSON'}
$mime_types{$format}
$mime_types{'JSON'}
Truth table33%1/3
A || B
A= $mime_types{$format}B= $mime_types{'JSON'}
| |||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | use VendorAPI::2Checkout::Client; | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | my $tco = VendorAPI::2Checkout::Client->new($username, $password, $format); | ||||||||||||||||||||||||||||
| 43 | $response = $tco->list_sales(); | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | $response = $tco->detail_sale(sale_id => 1234554323); | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | $response = $tco->list_coupons(); | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | $response = $tco->detail_coupon(coupon_code => 'COUPON42'); | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | $response = $tco->list_payments(); | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | $response = $tco->list_products(); | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | $response = $tco->list_options(); | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | ... | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | This module is an OO interface to the 2Checkout.com Vendor API. | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | This modules uses Params::Validate which likes to die() when the parameters do not pass validation, so | ||||||||||||||||||||||||||||
| 64 | wrap your code in evals, etc. | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | Presently implements list_sales(), detail_sale(), list_coupons(), and detail_coupon(), list_payments(), | ||||||||||||||||||||||||||||
| 67 | list_options(), list_products(). | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | Return data is in XML or JSON. | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | Please refer to L<2Checkout's Back Office Admin API Documentation|http://www.2checkout.com/documentation/api> | ||||||||||||||||||||||||||||
| 72 | for input parameters and expexted return values. | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =head1 CONSTRUCTORS AND METHODS | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | =over 4 | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =item $c = VendorAPI::2Checkout::Client->new($username, $password, $format, VAPI_MOOSE) | ||||||||||||||||||||||||||||
| 79 | =item $c = VendorAPI::2Checkout::Client->new($username, $password, $format, VAPI_NO_MOOSE) | ||||||||||||||||||||||||||||
| 80 | =item $c = VendorAPI::2Checkout::Client->new($username, $password, $format) # no moose | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | Contructs a new C<VendorAPI::2Checkout::Client> object to comminuncate with the 2Checkout Back Office Admin API. | ||||||||||||||||||||||||||||
| 83 | You must pass your Vendor API username and password or the constructor will return undef; | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =cut | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 6 | ▶ | sub VAPI_MOOSE { 1; } | ||||||||||||||||||||||||||
|
Subroutine
VAPI_MOOSE: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 88 | 2 | ▶ | sub VAPI_NO_MOOSE { 0; } | ||||||||||||||||||||||||||
|
Subroutine
VAPI_NO_MOOSE: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | 9 | ▶ | sub get_client { | ||||||||||||||||||||||||||
|
Subroutine
get_client: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 91 | 9 | my $class = shift; | |||||||||||||||||||||||||||
| 92 | 9 | my $username = shift; | |||||||||||||||||||||||||||
| 93 | 9 | my $password = shift; | |||||||||||||||||||||||||||
| 94 | 9 | my $format = shift; | |||||||||||||||||||||||||||
| 95 | 9 | my $use_moose = shift; | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 9 | ▶ | unless ( $username && $password) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$username and $password
MC/DC100%2/2
$username and $password
$username
$password
Truth table100%3/3
A and B
A= $usernameB= $password
| |||||||||||||||||||||||||||||
| 98 | 2 | return undef; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 7 | ▶ | unless ( defined $format && $format =~ qr/^(?:XML|JSON)$/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $format and $format =~ qr/^(?:XML|JSON)$/
MC/DC100%2/2
defined $format and $format =~ qr/^(?:XML|JSON)$/
defined $format
$format =~ qr/^(?:XML|JSON)$/
Truth table100%3/3
A and B
A= defined $formatB= $format =~ qr/^(?:XML|JSON)$/
| |||||||||||||||||||||||||||||
| 102 | 2 | return undef; | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 5 | $class = 'VendorAPI::2Checkout::Client::'; | |||||||||||||||||||||||||||
| 106 | 5 | ▶ | if (defined $use_moose && $use_moose == VAPI_MOOSE) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $use_moose and $use_moose == VAPI_MOOSE()
MC/DC100%2/2
defined $use_moose and $use_moose == VAPI_MOOSE()
defined $use_moose
$use_moose == VAPI_MOOSE()
Truth table100%3/3
A and B
A= defined $use_mooseB= $use_moose == VAPI_MOOSE()
| |||||||||||||||||||||||||||||
| 107 | 2 | $class .= 'Moose'; | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | else { | ||||||||||||||||||||||||||||
| 110 | 3 | $class .= 'NoMoose'; | |||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 5 | my $return = $class->require; | |||||||||||||||||||||||||||
| 114 | 5 | ▶ | unless ($return) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 0 | die "require issue: $@"; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | 5 | return $class->new($username, $password, $format); | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | Len Jaffe, C<< <lenjaffe at jaffesystems.com> >> | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | =head1 GITHUB | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | The source code is available at | ||||||||||||||||||||||||||||
| 128 | L<Github|https://github.com/vampirechicken/VendorAPI--2Checkout--Client> | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | =head1 BUGS | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | Please report any bugs or feature requests to C<bug-vendorapi-2checkout-client at rt.cpan.org>, or through | ||||||||||||||||||||||||||||
| 133 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=VendorAPI-2Checkout-Client>. I will be notified, and then you'll | ||||||||||||||||||||||||||||
| 134 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | perldoc VendorAPI::2Checkout::Client | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | You can also look for information at: | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | =over 4 | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=VendorAPI-2Checkout-Client> | ||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||
| 150 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | L<http://annocpan.org/dist/VendorAPI-2Checkout-Client> | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | =item * CPAN Ratings | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | L<http://cpanratings.perl.org/d/VendorAPI-2Checkout-Client> | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | =item * Search CPAN | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | L<http://search.cpan.org/dist/VendorAPI-2Checkout-Client/> | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | =back | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | Copyright 2012 Len Jaffe. | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 171 | under the terms of either: the GNU General Public License as published | ||||||||||||||||||||||||||||
| 172 | by the Free Software Foundation; or the Artistic License. | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | See http://dev.perl.org/licenses/ for more information. | ||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||
| 176 | =cut | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 9 | 1; # End of VendorAPI::2Checkout::Client | |||||||||||||||||||||||||||