| 1 | package WebService::PayPal::PaymentsAdvanced::Mocker::Helper; | ||||||||||||
| 2 | |||||||||||||
| 3 | 7 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | 7 | ▶ | use namespace::autoclean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | |||||||||||||
| 7 | 7 | our $VERSION = '0.000028'; | |||||||||||
| 8 | |||||||||||||
| 9 | 7 | ▶ | use Data::GUID (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 7 | ▶ | use DateTime (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 7 | ▶ | use DateTime::Format::MySQL (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | 7 | ▶ | use DateTime::TimeZone (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 13 | 7 | ▶ | use Types::Standard qw( InstanceOf ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | |||||||||||||
| 15 | has _time_zone => ( | ||||||||||||
| 16 | is => 'lazy', | ||||||||||||
| 17 | isa => InstanceOf ['DateTime::TimeZone'], | ||||||||||||
| 18 | default => | ||||||||||||
| 19 | 16 | ▶ | sub { DateTime::TimeZone->new( name => 'America/Los_Angeles' ) }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 20 | 7 | ); | |||||||||||
| 21 | |||||||||||||
| 22 | 4 | ▶ | sub baid { | ||||||||||
|
Subroutine
baid: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 23 | 4 | my $self = shift; | |||||||||||
| 24 | 4 | return 'B-' . $self->unique_id(17); | |||||||||||
| 25 | } | ||||||||||||
| 26 | |||||||||||||
| 27 | 26 | ▶ | sub correlationid { | ||||||||||
|
Subroutine
correlationid: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 28 | 26 | return lc shift->unique_id(13); | |||||||||||
| 29 | } | ||||||||||||
| 30 | |||||||||||||
| 31 | 27 | ▶ | sub pnref { | ||||||||||
|
Subroutine
pnref: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 32 | 27 | return shift->unique_id(12); | |||||||||||
| 33 | } | ||||||||||||
| 34 | |||||||||||||
| 35 | 26 | ▶ | sub ppref { | ||||||||||
|
Subroutine
ppref: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 36 | 26 | return shift->unique_id(17); | |||||||||||
| 37 | } | ||||||||||||
| 38 | |||||||||||||
| 39 | 17 | ▶ | sub secure_token { | ||||||||||
|
Subroutine
secure_token: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 40 | 17 | return shift->unique_id(25); | |||||||||||
| 41 | } | ||||||||||||
| 42 | |||||||||||||
| 43 | 2 | ▶ | sub token { | ||||||||||
|
Subroutine
token: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 44 | 2 | return 'EC-' . shift->unique_id(17); | |||||||||||
| 45 | } | ||||||||||||
| 46 | |||||||||||||
| 47 | 28 | ▶ | sub transtime { | ||||||||||
|
Subroutine
transtime: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 48 | 28 | return DateTime::Format::MySQL->format_datetime( shift->datetime_now ); | |||||||||||
| 49 | } | ||||||||||||
| 50 | |||||||||||||
| 51 | 102 | ▶ | sub unique_id { | ||||||||||
|
Subroutine
unique_id: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||
| 52 | 102 | my $self = shift; | |||||||||||
| 53 | 102 | ▶ | my $length = shift || die 'length param required'; | ||||||||||
|
Condition50%1/2
shift() || die('length param required')
MC/DC0%0/1
shift() || die('length param required')
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||
| 54 | |||||||||||||
| 55 | 102 | my $id = Data::GUID->new->as_string; | |||||||||||
| 56 | 102 | $id =~ s{-}{}g; | |||||||||||
| 57 | 102 | return substr( $id, 0, $length ); | |||||||||||
| 58 | } | ||||||||||||
| 59 | |||||||||||||
| 60 | 28 | ▶ | sub datetime_now { | ||||||||||
|
Subroutine
datetime_now: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 61 | 28 | return DateTime->now( time_zone => shift->_time_zone ); | |||||||||||
| 62 | } | ||||||||||||
| 63 | |||||||||||||
| 64 | 7 | 1; | |||||||||||
| 65 | |||||||||||||
| 66 | =pod | ||||||||||||
| 67 | |||||||||||||
| 68 | =encoding UTF-8 | ||||||||||||
| 69 | |||||||||||||
| 70 | =head1 NAME | ||||||||||||
| 71 | |||||||||||||
| 72 | WebService::PayPal::PaymentsAdvanced::Mocker::Helper - Helper methods used when mocking PayPal web services | ||||||||||||
| 73 | |||||||||||||
| 74 | =head1 VERSION | ||||||||||||
| 75 | |||||||||||||
| 76 | version 0.000028 | ||||||||||||
| 77 | |||||||||||||
| 78 | =head1 SYNOPSIS | ||||||||||||
| 79 | |||||||||||||
| 80 | use WebService::PayPal::PaymentsAdvanced::Mocker::Helper; | ||||||||||||
| 81 | my $helper = WebService::PayPal::PaymentsAdvanced::Mocker::Helper->new; | ||||||||||||
| 82 | |||||||||||||
| 83 | print $helper->transtime; | ||||||||||||
| 84 | |||||||||||||
| 85 | =head2 baid | ||||||||||||
| 86 | |||||||||||||
| 87 | Returns a new, unique BAID | ||||||||||||
| 88 | |||||||||||||
| 89 | =head2 correlationid | ||||||||||||
| 90 | |||||||||||||
| 91 | Returns a new, unique CORRELATIONID | ||||||||||||
| 92 | |||||||||||||
| 93 | =head2 pnref | ||||||||||||
| 94 | |||||||||||||
| 95 | Returns a new, unique PNREF | ||||||||||||
| 96 | |||||||||||||
| 97 | =head2 ppref | ||||||||||||
| 98 | |||||||||||||
| 99 | Returns a new, unique PPREF | ||||||||||||
| 100 | |||||||||||||
| 101 | =head2 secure_token | ||||||||||||
| 102 | |||||||||||||
| 103 | Returns a new, unique SECURETOKEN | ||||||||||||
| 104 | |||||||||||||
| 105 | =head2 token | ||||||||||||
| 106 | |||||||||||||
| 107 | Returns a new, unique SECURETOKENID | ||||||||||||
| 108 | |||||||||||||
| 109 | =head2 transtime | ||||||||||||
| 110 | |||||||||||||
| 111 | Returns a TRANSTIME based on the current time | ||||||||||||
| 112 | |||||||||||||
| 113 | =head2 unique_id( $length ) | ||||||||||||
| 114 | |||||||||||||
| 115 | A generic method for creating unique ids. | ||||||||||||
| 116 | |||||||||||||
| 117 | =head2 datetime_now | ||||||||||||
| 118 | |||||||||||||
| 119 | Returns a new DateTime object with the current time, using the same time zone | ||||||||||||
| 120 | which the PayPal services use. | ||||||||||||
| 121 | |||||||||||||
| 122 | =head1 DESCRIPTION | ||||||||||||
| 123 | |||||||||||||
| 124 | Helper methods used when mocking PayPal web | ||||||||||||
| 125 | |||||||||||||
| 126 | =head1 SUPPORT | ||||||||||||
| 127 | |||||||||||||
| 128 | Bugs may be submitted through L<https://github.com/maxmind/webservice-paypal-paymentsadvanced/issues>. | ||||||||||||
| 129 | |||||||||||||
| 130 | =head1 AUTHOR | ||||||||||||
| 131 | |||||||||||||
| 132 | Olaf Alders <olaf@wundercounter.com> | ||||||||||||
| 133 | |||||||||||||
| 134 | =head1 COPYRIGHT AND LICENSE | ||||||||||||
| 135 | |||||||||||||
| 136 | This software is copyright (c) 2022 by MaxMind, Inc. | ||||||||||||
| 137 | |||||||||||||
| 138 | This is free software; you can redistribute it and/or modify it under | ||||||||||||
| 139 | the same terms as the Perl 5 programming language system itself. | ||||||||||||
| 140 | |||||||||||||
| 141 | =cut | ||||||||||||
| 142 | |||||||||||||
| 143 | __END__ | ||||||||||||