Simplify/Event.pm untested

filter: Statementstmt 0.0% 0 / 17 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 23 CC 1 SCAR 6.9
CC
1
Cov
0%
create
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Net::Simplify::Event;
2  
3 =head1 NAME
4  
5 Net::Simplify::Event - Simplify Commerce webhook event class
6  
7 =head1 SYNOPSIS
8  
9 use Net::Simplify;
10  
11 $Net::Simplify::public_key = 'YOUR PUBLIC KEY';
12 $Net::Simplify::private_key = 'YOUR PRIVATE KEY';
13  
14 my $payload = 'YOUR WEBHOOK EVENT PAYLOAD';
15 my $event = Net::Simplify::Event->create({payload => $payload});
16 printf "event name %s\n", $event->{name};
17  
18 my $data = $event->{data};
19  
20 =head1 DESCRIPTION
21  
22 =head2 METHODS
23  
24 =head3 create(%params, $auth)
25  
26 Creates an Event object from a payload sent to a webhook endpoint. The parameters are:
27  
28 =over 4
29  
30 =item C<%params>
31  
32 Parameters for constructing the event object. Valid keys are:
33  
34 =over 4
35  
36 =item C<payload>
37  
38 The JWS message payload posted to your webhook endpoint (required)
39  
40 =item C<url>
41  
42 The URL for the webhook (optional, if present it must match the URL registered for the webhook).
43  
44 =back
45  
46 =item C<$auth>
47  
48 Authentication object for accessing the API. If no value is passed the global keys
49 C<$Net::Simplify::public_key> and C<$Net::Simplify::private_key> are used.
50  
51 =back
52  
53 =head1 SEE ALSO
54  
55 L<Net::Simplify>,
56 L<Net::Simplify::Authentication>,
57 L<http://www.simplify.com>
58  
59 =head1 VERSION
60  
61 1.6.0
62  
63 =head1 LICENSE
64  
65 Copyright (c) 2013 - 2022 MasterCard International Incorporated
66 All rights reserved.
67  
68 Redistribution and use in source and binary forms, with or without modification, are
69 permitted provided that the following conditions are met:
70  
71 Redistributions of source code must retain the above copyright notice, this list of
72 conditions and the following disclaimer.
73 Redistributions in binary form must reproduce the above copyright notice, this list of
74 conditions and the following disclaimer in the documentation and/or other materials
75 provided with the distribution.
76 Neither the name of the MasterCard International Incorporated nor the names of its
77 contributors may be used to endorse or promote products derived from this software
78 without specific prior written permission.
79 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
80 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
81 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
82 SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
83 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
84 TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
85 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
86 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
87 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
88 SUCH DAMAGE.
89  
90 =cut
91  
92 use 5.006;
93 use strict;
94 use warnings FATAL => 'all';
95  
96 use Net::Simplify::Domain;
97  
98 our @ISA = qw(Net::Simplify::Domain);
99  
100 sub create {
101 my ($class, $params, $auth) = @_;
102  
103 $auth = Net::Simplify::SimplifyApi->get_authentication($auth);
104 my $result = Net::Simplify::SimplifyApi->decode_event($params, $auth);
105  
106 $class->SUPER::new($result->{event}, $auth);
107 }
108  
109  
110 1;