File Coverage

lib/Net/API/Stripe/Event/Data.pm
Criterion Covered Total %
statement 19 28 67.8
branch 0 2 0.0
condition 0 4 0.0
subroutine 7 10 70.0
pod 2 2 100.0
total 28 46 60.8


line stmt bran cond sub pod time code
1             ##----------------------------------------------------------------------------
2             ## Stripe API - ~/lib/Net/API/Stripe/Event/Data.pm
3             ## Version v0.100.0
4             ## Copyright(c) 2019 DEGUEST Pte. Ltd.
5             ## Author: Jacques Deguest <jack@deguest.jp>
6             ## Created 2019/11/02
7             ## Modified 2020/05/15
8             ##
9             ##----------------------------------------------------------------------------
10             ## Object of the resources relevant to the event, e.g. balance, or invoice
11             ## This must be processed by callbacks to set the right object
12             BEGIN
13             {
14             use strict;
15 2     2   24030214 use warnings;
  2         15  
  2         64  
16 2     2   16 use parent qw( Net::API::Stripe::Generic );
  2         2  
  2         64  
17 2     2   9 use vars qw( $VERSION );
  2         4  
  2         10  
18 2     2   138 our( $VERSION ) = 'v0.100.0';
  2         4  
  2         111  
19 2     2   40 };
20              
21             use strict;
22 2     2   11 use warnings;
  2         4  
  2         43  
23 2     2   10  
  2         3  
  2         367  
24             {
25             my $self = shift( @_ );
26             if( @_ )
27 0     0 1   {
28 0 0         my $ref = shift( @_ );
29             ## This is not a type, there is an object property that contains a hash
30 0           my $type = $ref->{object} || return( $self->error( "No object type could be found for field $self->{_field} in hash: ", sub{ $self->dumper( $ref ) } ) );
31             my $class = $self->_object_type_to_class( $type ) ||
32 0   0 0     return( $self->error( "No class found for object type $type" ) );
  0            
33 0   0       return( $self->_set_get_object( 'object', $class, $ref ) );
34             }
35 0           return( $self->{object} );
36             }
37 0            
38              
39             1;
40 0     0 1    
41              
42             =encoding utf8
43              
44             =head1 NAME
45              
46             Net::API::Stripe::Event::Data - A Stripe Event Data Object
47              
48             =head1 SYNOPSIS
49              
50             my $event_data = $stripe->event->data({
51             # The type of object is variable. In this example we use an invoice object
52             object => $invoice_object,
53             });
54              
55             =head1 VERSION
56              
57             v0.100.0
58              
59             =head1 DESCRIPTION
60              
61             This is a Stripe Event Data Object.
62              
63             This is instantiated by the method B<data> in module L<Net::API::Stripe::Event>
64              
65             =head1 CONSTRUCTOR
66              
67             =head2 new( %ARG )
68              
69             Creates a new L<Net::API::Stripe::Event::Data> object.
70             It may also take an hash like arguments, that also are method of the same name.
71              
72             =head1 METHODS
73              
74             =head2 object hash
75              
76             Object containing the API resource relevant to the event. For example, an invoice.created event will have a full invoice object as the value of the object key.
77              
78             =head2 previous_attributes hash
79              
80             Object containing the names of the attributes that have changed, and their previous values (sent along only with *.updated events).
81              
82             =head1 API SAMPLE
83              
84             {
85             "id": "evt_fake123456789",
86             "object": "event",
87             "api_version": "2017-02-14",
88             "created": 1528914645,
89             "data": {
90             "object": {
91             "object": "balance",
92             "available": [
93             {
94             "currency": "jpy",
95             "amount": 1025751,
96             "source_types": {
97             "card": 1025751
98             }
99             }
100             ],
101             "connect_reserved": [
102             {
103             "currency": "jpy",
104             "amount": 0
105             }
106             ],
107             "livemode": false,
108             "pending": [
109             {
110             "currency": "jpy",
111             "amount": 0,
112             "source_types": {
113             "card": 0
114             }
115             }
116             ]
117             }
118             },
119             "livemode": false,
120             "pending_webhooks": 0,
121             "request": {
122             "id": null,
123             "idempotency_key": null
124             },
125             "type": "balance.available"
126             }
127              
128             =head1 HISTORY
129              
130             =head2 v0.1
131              
132             Initial version
133              
134             =head1 AUTHOR
135              
136             Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>
137              
138             =head1 SEE ALSO
139              
140             Stripe API documentation:
141              
142             L<https://stripe.com/docs/api/events/object>
143              
144             =head1 COPYRIGHT & LICENSE
145              
146             Copyright (c) 2019-2020 DEGUEST Pte. Ltd.
147              
148             You can use, copy, modify and redistribute this package and associated
149             files under the same terms as Perl itself.
150              
151             =cut