File Coverage

lib/WebService/Shippo/CarrierAccount.pm
Criterion Covered Total %
statement 22 46 47.8
branch 0 24 0.0
condition 0 24 0.0
subroutine 8 12 66.6
pod 0 4 0.0
total 30 110 27.2


line stmt bran cond sub pod time code
1 7     7   33 use strict;
  7         13  
  7         166  
2 7     7   35 use warnings;
  7         10  
  7         174  
3 7     7   30 use MRO::Compat 'c3';
  7         12  
  7         200  
4              
5             package WebService::Shippo::CarrierAccount;
6 7     7   32 use Carp ( 'confess' );
  7         12  
  7         301  
7 7     7   33 use Scalar::Util ( 'blessed' );
  7         14  
  7         312  
8 7         4117 use base qw(
9             WebService::Shippo::Resource
10             WebService::Shippo::Create
11             WebService::Shippo::Fetch
12             WebService::Shippo::Update
13 7     7   34 );
  7         14  
14              
15             sub api_resource () { 'carrier_accounts' }
16              
17             sub collection_class () { 'WebService::Shippo::CarrierAccounts' }
18              
19             sub item_class () { __PACKAGE__ }
20              
21             sub activate
22             {
23 0     0 0   my ( $invocant, $object_id ) = @_;
24             $object_id = $invocant->{object_id}
25 0 0 0       if blessed( $invocant ) && !$object_id;
26 0 0         confess 'Expected an object id'
27             unless $object_id;
28 0           my $upd = __PACKAGE__->update( $object_id, active => 1 );
29 0 0 0       return $upd
30             unless blessed( $invocant ) && $invocant->id eq $object_id;
31 0           $invocant->refresh_from( $upd );
32             }
33              
34             sub deactivate
35             {
36 0     0 0   my ( $invocant, $object_id ) = @_;
37             $object_id = $invocant->{object_id}
38 0 0 0       if blessed( $invocant ) && !$object_id;
39 0 0         confess 'Expected an object id'
40             unless $object_id;
41 0           my $upd = __PACKAGE__->update( $object_id, active => 0 );
42 0 0 0       return $upd
43             unless blessed( $invocant ) && $invocant->id eq $object_id;
44 0           $invocant->refresh_from( $upd );
45             }
46              
47             sub enable_test_mode
48             {
49 0     0 0   my ( $invocant, $object_id ) = @_;
50             $object_id = $invocant->{object_id}
51 0 0 0       if blessed( $invocant ) && !$object_id;
52 0 0         confess 'Expected an object id'
53             unless $object_id;
54 0           my $upd = __PACKAGE__->update( $object_id, test => 1 );
55 0 0 0       return $upd
56             unless blessed( $invocant ) && $invocant->id eq $object_id;
57 0           return $invocant->refresh_from( $upd );
58             }
59              
60             sub enable_production_mode
61             {
62 0     0 0   my ( $invocant, $object_id ) = @_;
63             $object_id = $invocant->{object_id}
64 0 0 0       if blessed( $invocant ) && !$object_id;
65 0 0         confess 'Expected an object id'
66             unless $object_id;
67 0           my $upd = __PACKAGE__->update( $object_id, test => 0 );
68 0 0 0       return $upd
69             unless blessed( $invocant ) && $invocant->id eq $object_id;
70 0           return $invocant->refresh_from( $upd );
71             }
72              
73             BEGIN {
74 7     7   40 no warnings 'once';
  7         14  
  7         282  
75 7     7   189 *Shippo::CarrierAccount:: = *WebService::Shippo::CarrierAccount::;
76             }
77              
78             1;
79              
80             =pod
81              
82             =encoding utf8
83              
84             =head1 NAME
85              
86             WebService::Shippo::CarrierAccount - Carrier Account class
87              
88             =head1 VERSION
89              
90             version 0.0.19
91              
92             =head1 DESCRIPTION
93              
94             Carrier accounts are used as credentials to retrieve shipping rates
95             and purchase labels from a shipping provider.
96              
97             =head1 API DOCUMENTATION
98              
99             For more information about Carrier Accounts, consult the Shippo API
100             documentation:
101              
102             =over 2
103              
104             =item * L
105              
106             =back
107              
108             =head1 REPOSITORY
109              
110             =over 2
111              
112             =item * L
113              
114             =item * L
115              
116             =back
117              
118             =head1 AUTHOR
119              
120             Iain Campbell
121              
122             =head1 COPYRIGHT AND LICENSE
123              
124             This software is copyright (c) 2015 by Iain Campbell.
125              
126             You may distribute this software under the terms of either the GNU General
127             Public License or the Artistic License, as specified in the Perl README
128             file.
129              
130             =cut