| 1 | package Net::Simplify::Tax; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | Net::Simplify::Tax - A Simplify Commerce Tax object | ||
| 6 | |||
| 7 | =head1 SYNOPSIS | ||
| 8 | |||
| 9 | use Net::Simplify; | ||
| 10 | |||
| 11 | |||
| 12 | $Net::Simplify::public_key = 'YOUR PUBLIC KEY'; | ||
| 13 | $Net::Simplify::private_key = 'YOUR PRIVATE KEY'; | ||
| 14 | |||
| 15 | # Create a new Tax. | ||
| 16 | my $tax = Net::Simplify::Tax->create{ {...}); | ||
| 17 | |||
| 18 | # Retrieve a Tax given its ID. | ||
| 19 | my $tax = Net::Simplify::Tax->find('a7e41'); | ||
| 20 | |||
| 21 | # Delete | ||
| 22 | my $tax = Net::Simplify::Tax->find('a7e41'); | ||
| 23 | $tax->delete(); | ||
| 24 | |||
| 25 | # Retrieve a list of objects | ||
| 26 | my $taxs = Net::Simplify::Tax->list({max => 10}); | ||
| 27 | foreach my $v ($taxs->list) { | ||
| 28 | # ... | ||
| 29 | } | ||
| 30 | |||
| 31 | =head1 DESCRIPTION | ||
| 32 | |||
| 33 | =head2 METHODS | ||
| 34 | |||
| 35 | =head3 create(%params, $auth) | ||
| 36 | |||
| 37 | Creates a C<Net::Simplify::Tax> object. The parameters are: | ||
| 38 | |||
| 39 | =over 4 | ||
| 40 | |||
| 41 | =item C<%params> | ||
| 42 | |||
| 43 | Hash map containing initial values for the object. Valid keys are: | ||
| 44 | |||
| 45 | =over 4 | ||
| 46 | |||
| 47 | =item label | ||
| 48 | |||
| 49 | The label of the tax object. [max length: 255] (B<required>) | ||
| 50 | |||
| 51 | =item rate | ||
| 52 | |||
| 53 | The tax rate. Decimal value up three decimal places. e.g 12.501. [max length: 6] (B<required>) | ||
| 54 | |||
| 55 | |||
| 56 | =back | ||
| 57 | |||
| 58 | =item C<$auth> | ||
| 59 | |||
| 60 | Authentication object for accessing the API. If no value is passed the global keys | ||
| 61 | C<$Net::Simplify::public_key> and C<$Net::Simplify::private_key> are used. | ||
| 62 | |||
| 63 | =back | ||
| 64 | |||
| 65 | |||
| 66 | |||
| 67 | |||
| 68 | =head3 delete() | ||
| 69 | |||
| 70 | Deletes the C<Net::Simplify::Tax> object. Authentication is done using the same credentials used when the AccessToken was created. | ||
| 71 | |||
| 72 | |||
| 73 | |||
| 74 | =head3 list(%criteria, $auth) | ||
| 75 | |||
| 76 | Retrieve a list of C<Net::Simplify::Tax> objects. The parameters are: | ||
| 77 | |||
| 78 | =over 4 | ||
| 79 | |||
| 80 | =item C<%criteria> | ||
| 81 | |||
| 82 | Hash map representing the criteria to limit the results of the list operation. Valid keys are: | ||
| 83 | |||
| 84 | =over 4 | ||
| 85 | |||
| 86 | =item C<filter> | ||
| 87 | |||
| 88 | <table class="filter_list"><tr><td>filter.id</td><td>Filter by the Id of the tax</td></tr><tr><td>filter.label</td><td>Filter by the label(name) of the tax</td></tr></table> | ||
| 89 | |||
| 90 | |||
| 91 | |||
| 92 | =item C<max> | ||
| 93 | |||
| 94 | Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] | ||
| 95 | |||
| 96 | |||
| 97 | |||
| 98 | =item C<offset> | ||
| 99 | |||
| 100 | Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] | ||
| 101 | |||
| 102 | |||
| 103 | |||
| 104 | =item C<sorting> | ||
| 105 | |||
| 106 | Allows for ascending or descending sorting of the list. | ||
| 107 | The value maps properties to the sort direction (either C<asc> for ascending or C<desc> for descending). Sortable properties are: | ||
| 108 | |||
| 109 | =over 4 | ||
| 110 | |||
| 111 | =item C<id> | ||
| 112 | |||
| 113 | =item C<label> | ||
| 114 | |||
| 115 | |||
| 116 | =back | ||
| 117 | |||
| 118 | |||
| 119 | |||
| 120 | |||
| 121 | =back | ||
| 122 | |||
| 123 | =back | ||
| 124 | |||
| 125 | |||
| 126 | |||
| 127 | =head3 find($id, $auth) | ||
| 128 | |||
| 129 | Retrieve a C<Net::Simplify::Tax> object from the API. Parameters are: | ||
| 130 | |||
| 131 | =over 4 | ||
| 132 | |||
| 133 | =item C<$id> | ||
| 134 | |||
| 135 | Identifier of the object to retrieve. | ||
| 136 | |||
| 137 | =item C<$auth> | ||
| 138 | |||
| 139 | Authentication object for accessing the API. If no value is passed the global keys | ||
| 140 | C<$Net::Simplify::public_key> and C<$Net::Simplify::private_key> are used. | ||
| 141 | |||
| 142 | =back | ||
| 143 | |||
| 144 | |||
| 145 | |||
| 146 | |||
| 147 | |||
| 148 | =head1 SEE ALSO | ||
| 149 | |||
| 150 | L<Net::Simplify>, | ||
| 151 | L<Net::Simplify::Domain>, | ||
| 152 | L<Net::Simplify::DomainList>, | ||
| 153 | L<Net::Simplify::Authentication>, | ||
| 154 | L<Net::Simplify::ApiException>, | ||
| 155 | L<http://www.simplify.com> | ||
| 156 | |||
| 157 | =head1 VERSION | ||
| 158 | |||
| 159 | 1.6.0 | ||
| 160 | |||
| 161 | =head1 LICENSE | ||
| 162 | |||
| 163 | Copyright (c) 2013 - 2022 MasterCard International Incorporated | ||
| 164 | All rights reserved. | ||
| 165 | |||
| 166 | Redistribution and use in source and binary forms, with or without modification, are | ||
| 167 | permitted provided that the following conditions are met: | ||
| 168 | |||
| 169 | Redistributions of source code must retain the above copyright notice, this list of | ||
| 170 | conditions and the following disclaimer. | ||
| 171 | Redistributions in binary form must reproduce the above copyright notice, this list of | ||
| 172 | conditions and the following disclaimer in the documentation and/or other materials | ||
| 173 | provided with the distribution. | ||
| 174 | Neither the name of the MasterCard International Incorporated nor the names of its | ||
| 175 | contributors may be used to endorse or promote products derived from this software | ||
| 176 | without specific prior written permission. | ||
| 177 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY | ||
| 178 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||
| 179 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT | ||
| 180 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
| 181 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | ||
| 182 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | ||
| 183 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER | ||
| 184 | IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
| 185 | IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||
| 186 | SUCH DAMAGE. | ||
| 187 | |||
| 188 | =head1 SEE ALSO | ||
| 189 | |||
| 190 | =cut | ||
| 191 | |||
| 192 | use 5.006; | ||
| 193 | use strict; | ||
| 194 | use warnings FATAL => 'all'; | ||
| 195 | |||
| 196 | use Net::Simplify::Domain; | ||
| 197 | use Net::Simplify::DomainList; | ||
| 198 | |||
| 199 | our @ISA = qw(Net::Simplify::Domain); | ||
| 200 | |||
| 201 | sub create { | ||
| 202 | |||
| 203 | my ($class, $params, $auth) = @_; | ||
| 204 | |||
| 205 | $auth = Net::Simplify::SimplifyApi->get_authentication($auth); | ||
| 206 | my $result = Net::Simplify::SimplifyApi->send_api_request("tax", 'create', $params, $auth); | ||
| 207 | |||
| 208 | $class->SUPER::new($result, $auth); | ||
| 209 | } | ||
| 210 | |||
| 211 | sub delete { | ||
| 212 | |||
| 213 | my ($self) = @_; | ||
| 214 | |||
| 215 | my $auth = Net::Simplify::SimplifyApi->get_authentication($self->{_authentication}); | ||
| 216 | |||
| 217 | my $id = $self->{id}; | ||
| 218 | $self->merge(Net::Simplify::SimplifyApi->send_api_request("tax", 'delete', {id => $id}, $auth)); | ||
| 219 | } | ||
| 220 | |||
| 221 | sub list { | ||
| 222 | my ($class, $criteria, $auth) = @_; | ||
| 223 | |||
| 224 | $auth = Net::Simplify::SimplifyApi->get_authentication($auth); | ||
| 225 | my $result = Net::Simplify::SimplifyApi->send_api_request("tax", 'list', $criteria, $auth); | ||
| 226 | |||
| 227 | Net::Simplify::DomainList->new($result, $class, $auth); | ||
| 228 | } | ||
| 229 | |||
| 230 | sub find { | ||
| 231 | my ($class, $id, $auth) = @_; | ||
| 232 | |||
| 233 | $auth = Net::Simplify::SimplifyApi->get_authentication($auth); | ||
| 234 | my $result = Net::Simplify::SimplifyApi->send_api_request("tax", 'find', { id => $id }, $auth); | ||
| 235 | |||
| 236 | $class->SUPER::new($result, $auth); | ||
| 237 | } | ||
| 238 | |||
| 239 | |||
| 240 | 1; |