line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::Xero::Contact; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
1571
|
use 5.006; |
|
2
|
|
|
|
|
5
|
|
4
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
36
|
|
5
|
2
|
|
|
2
|
|
6
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
51
|
|
6
|
2
|
|
|
2
|
|
14
|
use Carp; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
103
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
8
|
use Data::Dumper; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
689
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
WebService::Xero::Contact - encapsulates a Xero API Contact record |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 0.10 |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our @PARAMS = qw/ContactID ContactStatus Name FirstName LastName EmailAddress BankAccountDetails UpdatedDateUTC IsCustomer IsSupplier HasAttachments HasValidationErrors |
22
|
|
|
|
|
|
|
Addresses Phones ContactGroups ContactPersons |
23
|
|
|
|
|
|
|
/; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 SYNOPSIS |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Object to describe an Contact record as specified by Xero API and the associated DTD at |
31
|
|
|
|
|
|
|
L. |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Mostly a wrapper for Xero Contact data structure. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Perhaps a little code snippet. |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
use WebService::Xero::Contact; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $foo = WebService::Xero::Contact->new(); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 METHODS |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 new() |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=cut |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub new |
50
|
|
|
|
|
|
|
{ |
51
|
1
|
|
|
1
|
1
|
3
|
my ( $class, %params ) = @_; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
my $self = bless |
54
|
|
|
|
|
|
|
{ |
55
|
|
|
|
|
|
|
debug => $params{debug}, |
56
|
1
|
|
|
|
|
3
|
API_URL => 'https://api.xero.com/api.xro/2.0/Contacts', |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
}, $class; |
59
|
1
|
50
|
|
|
|
2
|
foreach my $key (@PARAMS) { $self->{$key} = defined $params{$key} ? $params{$key} : ''; } |
|
16
|
|
|
|
|
33
|
|
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
3
|
return $self; #->_validate_agent(); ## derived classes will validate this |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 new_from_api_data() |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
creates a new instance from the data provided by querying the API organisation end point |
69
|
|
|
|
|
|
|
( typically handled by WebService::Xero::Agent->do_xero_api_call() ) |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Example Contact Queries using Xero Agent that return Data consumable by this method: |
72
|
|
|
|
|
|
|
https://api.xero.com/api.xro/2.0/Contacts |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Returns undef, a single object instance or an array of object instances depending on the data input provided. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub new_from_api_data |
80
|
|
|
|
|
|
|
{ |
81
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $data ) = @_; |
82
|
0
|
0
|
0
|
|
|
0
|
return WebService::Xero::Contact->new( %{$data->{Contacts}[0]} ) if ( ref($data->{Contacts}) eq 'ARRAY' and scalar(@{$data->{Contacts}})==1 ); |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
83
|
0
|
|
|
|
|
0
|
return WebService::Xero::Contact->new( debug=> $data ); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 as_text() |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
mostly for debugging. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub as_text |
95
|
|
|
|
|
|
|
{ |
96
|
1
|
|
|
1
|
1
|
2
|
my ( $self ) = @_; |
97
|
|
|
|
|
|
|
|
98
|
1
|
|
|
|
|
2
|
return join("\n", map { "$_ : $self->{$_}" } @PARAMS); |
|
16
|
|
|
|
|
34
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 AUTHOR |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Peter Scott, C<< >> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 REFERENCE |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head1 BUGS |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
114
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
115
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 TODO |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 SUPPORT |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
perldoc WebService::Xero::Contact |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
You can also look for information at: |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=over 4 |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item * Xero Developer API Docs |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
L |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=back |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Copyright 2016 Peter Scott. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
148
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
149
|
|
|
|
|
|
|
copy of the full license at: |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
L |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
154
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
155
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
156
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
159
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
160
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
163
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
166
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
167
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
168
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
169
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
170
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
171
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
172
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
175
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
176
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
177
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
178
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
179
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
180
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
181
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=cut |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
1; # End of WebService::Xero |