| 1 | package WebService::Xero::Organisation; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use 5.006; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | WebService::Xero::Organisation - Object encapulates Organisation data returned by API | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =head1 VERSION | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | Version 0.11 | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =cut | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 4 | our $VERSION = '0.11'; | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 4 | our @PROPERTIES = qw/APIKey Name LegalName PaysTax Version BaseCurrency CountryCode IsDemoCompany OrganisationStatus | |||||||||||||||||||||||||||
| 21 | RegistrationNumber TaxNumber FinancialYearEndDay FinancialYearEndMonth | ||||||||||||||||||||||||||||
| 22 | SalesTaxBasis SalesTaxPeriod DefaultSalesTax DefaultPurchasesTax PeriodLockDate EndOfYearLockDate | ||||||||||||||||||||||||||||
| 23 | CreatedDateUTC OrganisationEntityType OrganisationType Timezone ShortCode LineOfBusiness | ||||||||||||||||||||||||||||
| 24 | Addresses Phones ExternalLinks PaymentTerms | ||||||||||||||||||||||||||||
| 25 | /; | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | ## ValidationErrors Warnings | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | Object to describe an Organisation record as specified by Xero API and the associated DTD at | ||||||||||||||||||||||||||||
| 32 | L<https://github.com/XeroAPI/XeroAPI-Schemas/blob/master/src/main/resources/XeroSchemas/v2.00/Organisation.xsd>. | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | Perhaps a little code snippet. | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | use WebService::Xero::Organisation; | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | my $org = WebService::Xero::Organisation->new(); | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | or | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | my $org = $xero_agent->api_account_organisation(); | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | =head1 METHODS | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | =head2 new() | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =cut | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | sub new | ||||||||||||||||||||||||||||
| 52 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.1
Pod
documented
| |||||||||||||||||||||||||||||
| 53 | 1 | my ( $class, %params ) = @_; | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | my $self = bless | ||||||||||||||||||||||||||||
| 56 | { | ||||||||||||||||||||||||||||
| 57 | API_URL => 'https://api.xero.com/api.xro/2.0/organisation', | ||||||||||||||||||||||||||||
| 58 | debug => $params{debug} ## NOT REALLY USED YET | ||||||||||||||||||||||||||||
| 59 | 1 | }, $class; | |||||||||||||||||||||||||||
| 60 | 1 | foreach my $key (@PROPERTIES) { | |||||||||||||||||||||||||||
| 61 | ## $self->{$key} = $params{$key} || '' | ||||||||||||||||||||||||||||
| 62 | 29 | ▶ | $self->{$key} = defined $params{$key} ? $params{$key} : ''; ## thanks to https://metacpan.org/author/STEVEB | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 1 | return $self; #->_validate_agent(); ## derived classes will validate this | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | =head2 new_from_api_data() | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | creates a new instance from the data provided by querying the API organisation end point | ||||||||||||||||||||||||||||
| 73 | ( typically handled by WebService::Xero::Agent->api_account_organisation() which calls this method ) | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =cut | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | sub new_from_api_data | ||||||||||||||||||||||||||||
| 78 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
new_from_api_data: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 79 | 0 | my ( $self, $data ) = @_; | |||||||||||||||||||||||||||
| 80 | 0 | ▶ | return $self->new( %{$data->{Organisations}[0]} ) if ( ref($data->{Organisations}) eq 'ARRAY' and scalar(@{$data->{Organisations}})==1 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $data->{"Organisations"} eq "ARRAY" and scalar @{$data->{"Organisations"};} == 1
MC/DC0%0/2
ref $data->{"Organisations"} eq "ARRAY" and scalar @{$data->{"Organisations"};} == 1
ref $data->{"Organisations"} eq "ARRAY"
scalar @{$data->{"Organisations"};} == 1
Truth table0%0/3
A and B
A= ref $data->{"Organisations"} eq "ARRAY"B= scalar @{$data->{"Organisations"};} == 1
| |||||||||||||||||||||||||||||
| 81 | 0 | return $self->new( debug=> $data ); | |||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =head2 as_text() | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | Returns a string with Carriage returns of each unique( non hash or array ) | ||||||||||||||||||||||||||||
| 88 | property - useful for debugging. NB - doesn't include Array or Hash properties | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =cut | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | sub as_text | ||||||||||||||||||||||||||||
| 94 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
as_text: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 95 | 1 | my ( $self ) = @_; | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | # return join("\n", map { "$_ : $self->{$_}" if (defined $self->{$_} and $_ !~ /Addresses|Phones|ExternalLinks|PaymentTerms/m ) } @PROPERTIES); ## this works ok | ||||||||||||||||||||||||||||
| 99 | 1 | ▶ | return "Organisation:\n" . join("\n", map { "$_ : $self->{$_}" if (defined $self->{$_} and ref($self->{$_}) !~ /ARRAY|HASH/m ) } @PROPERTIES); ## this looks a little better? | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $self->{$_} and not ref($self->{$_}) =~ /ARRAY|HASH/m
MC/DC50%1/2
defined $self->{$_} and not ref($self->{$_}) =~ /ARRAY|HASH/m
defined $self->{$_}
not ref($self->{$_}) =~ /ARRAY|HASH/m
Truth table66%2/3
A and not(B)
A= defined $self->{$_}B= not ref($self->{$_}) =~ /ARRAY|HASH/m
| |||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head1 TODO | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | consider inclusion of Locale modules - Locale::Currency and Locale::Country | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | Peter Scott, C<< <peter at computerpros.com.au> >> | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =head1 REFERENCE | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =head1 BUGS | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | Please report any bugs or feature requests to C<bug-ccp-xero at rt.cpan.org>, or through | ||||||||||||||||||||||||||||
| 120 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CCP-Xero>. I will be notified, and then you'll | ||||||||||||||||||||||||||||
| 121 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | perldoc WebService::Xero::Organisation | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | You can also look for information at: | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | =over 4 | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | =item * Xero Developer API Docs | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | L<https://developer.xero.com/documentation/api/organisation/> | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | =item * Xero API Schemas | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | L<https://github.com/XeroAPI/XeroAPI-Schemas> | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | =item * Xero API Schema Organisation | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | L<https://github.com/XeroAPI/XeroAPI-Schemas/blob/master/src/main/resources/XeroSchemas/v2.00/Organisation.xsd> | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | =back | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | Copyright 2016 Peter Scott. | ||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||
| 159 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 160 | under the terms of the the Artistic License (2.0). You may obtain a | ||||||||||||||||||||||||||||
| 161 | copy of the full license at: | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | Any use, modification, and distribution of the Standard or Modified | ||||||||||||||||||||||||||||
| 166 | Versions is governed by this Artistic License. By using, modifying or | ||||||||||||||||||||||||||||
| 167 | distributing the Package, you accept this license. Do not use, modify, | ||||||||||||||||||||||||||||
| 168 | or distribute the Package, if you do not accept this license. | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | If your Modified Version has been derived from a Modified Version made | ||||||||||||||||||||||||||||
| 171 | by someone other than you, you are nevertheless required to ensure that | ||||||||||||||||||||||||||||
| 172 | your Modified Version complies with the requirements of this license. | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | This license does not grant you the right to use any trademark, service | ||||||||||||||||||||||||||||
| 175 | mark, tradename, or logo of the Copyright Holder. | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | This license includes the non-exclusive, worldwide, free-of-charge | ||||||||||||||||||||||||||||
| 178 | patent license to make, have made, use, offer to sell, sell, import and | ||||||||||||||||||||||||||||
| 179 | otherwise transfer the Package with respect to any patent claims | ||||||||||||||||||||||||||||
| 180 | licensable by the Copyright Holder that are necessarily infringed by the | ||||||||||||||||||||||||||||
| 181 | Package. If you institute patent litigation (including a cross-claim or | ||||||||||||||||||||||||||||
| 182 | counterclaim) against any party alleging that the Package constitutes | ||||||||||||||||||||||||||||
| 183 | direct or contributory patent infringement, then this Artistic License | ||||||||||||||||||||||||||||
| 184 | to you shall terminate on the date that such litigation is filed. | ||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER | ||||||||||||||||||||||||||||
| 187 | AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. | ||||||||||||||||||||||||||||
| 188 | THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||||||||||||||||||||||||||||
| 189 | PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY | ||||||||||||||||||||||||||||
| 190 | YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR | ||||||||||||||||||||||||||||
| 191 | CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR | ||||||||||||||||||||||||||||
| 192 | CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, | ||||||||||||||||||||||||||||
| 193 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | =cut | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | 4 | 1; # End of WebService::Xero | |||||||||||||||||||||||||||