| 1 | package Net::Simplify::InvoiceItem; | ||
| 2 | |||
| 3 | =head1 NAME | ||
| 4 | |||
| 5 | Net::Simplify::InvoiceItem - A Simplify Commerce InvoiceItem 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 InvoiceItem. | ||
| 16 | my $invoice_item = Net::Simplify::InvoiceItem->create{ {...}); | ||
| 17 | |||
| 18 | # Retrieve a InvoiceItem given its ID. | ||
| 19 | my $invoice_item = Net::Simplify::InvoiceItem->find('a7e41'); | ||
| 20 | |||
| 21 | # Update existing InvoiceItem. | ||
| 22 | my $invoice_item = Net::Simplify::InvoiceItem->find('a7e41'); | ||
| 23 | $invoice_item->{PROPERTY} = "NEW VALUE"; | ||
| 24 | $invoice_item->update(); | ||
| 25 | |||
| 26 | # Delete | ||
| 27 | my $invoice_item = Net::Simplify::InvoiceItem->find('a7e41'); | ||
| 28 | $invoice_item->delete(); | ||
| 29 | |||
| 30 | =head1 DESCRIPTION | ||
| 31 | |||
| 32 | =head2 METHODS | ||
| 33 | |||
| 34 | =head3 create(%params, $auth) | ||
| 35 | |||
| 36 | Creates a C<Net::Simplify::InvoiceItem> object. The parameters are: | ||
| 37 | |||
| 38 | =over 4 | ||
| 39 | |||
| 40 | =item C<%params> | ||
| 41 | |||
| 42 | Hash map containing initial values for the object. Valid keys are: | ||
| 43 | |||
| 44 | =over 4 | ||
| 45 | |||
| 46 | =item amount | ||
| 47 | |||
| 48 | Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00 (B<required>) | ||
| 49 | |||
| 50 | =item description | ||
| 51 | |||
| 52 | Individual items of an invoice [max length: 1024] | ||
| 53 | |||
| 54 | =item invoice | ||
| 55 | |||
| 56 | The ID of the invoice this item belongs to. | ||
| 57 | |||
| 58 | =item product | ||
| 59 | |||
| 60 | Product ID this item relates to. | ||
| 61 | |||
| 62 | =item quantity | ||
| 63 | |||
| 64 | Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999, default: 1] | ||
| 65 | |||
| 66 | =item reference | ||
| 67 | |||
| 68 | User defined reference field. [max length: 255] | ||
| 69 | |||
| 70 | =item tax | ||
| 71 | |||
| 72 | The tax ID of the tax charge in the invoice item. | ||
| 73 | |||
| 74 | |||
| 75 | =back | ||
| 76 | |||
| 77 | =item C<$auth> | ||
| 78 | |||
| 79 | Authentication object for accessing the API. If no value is passed the global keys | ||
| 80 | C<$Net::Simplify::public_key> and C<$Net::Simplify::private_key> are used. | ||
| 81 | |||
| 82 | =back | ||
| 83 | |||
| 84 | |||
| 85 | |||
| 86 | |||
| 87 | =head3 delete() | ||
| 88 | |||
| 89 | Deletes the C<Net::Simplify::InvoiceItem> object. Authentication is done using the same credentials used when the AccessToken was created. | ||
| 90 | |||
| 91 | |||
| 92 | =head3 find($id, $auth) | ||
| 93 | |||
| 94 | Retrieve a C<Net::Simplify::InvoiceItem> object from the API. Parameters are: | ||
| 95 | |||
| 96 | =over 4 | ||
| 97 | |||
| 98 | =item C<$id> | ||
| 99 | |||
| 100 | Identifier of the object to retrieve. | ||
| 101 | |||
| 102 | =item C<$auth> | ||
| 103 | |||
| 104 | Authentication object for accessing the API. If no value is passed the global keys | ||
| 105 | C<$Net::Simplify::public_key> and C<$Net::Simplify::private_key> are used. | ||
| 106 | |||
| 107 | =back | ||
| 108 | |||
| 109 | |||
| 110 | |||
| 111 | |||
| 112 | =head3 update() | ||
| 113 | |||
| 114 | Update C<Net::Simplify::InvoiceItem> object. | ||
| 115 | The properties that can be updated are: | ||
| 116 | |||
| 117 | =over 4 | ||
| 118 | |||
| 119 | |||
| 120 | =item C<amount> | ||
| 121 | |||
| 122 | Amount of the invoice item in the smallest unit of your currency. Example: 100 = $1.00 [min value: 1] | ||
| 123 | |||
| 124 | =item C<description> | ||
| 125 | |||
| 126 | Individual items of an invoice | ||
| 127 | |||
| 128 | |||
| 129 | =item C<quantity> | ||
| 130 | |||
| 131 | Quantity of the item. This total amount of the invoice item is the amount * quantity. [min value: 1, max value: 999999] | ||
| 132 | |||
| 133 | =item C<reference> | ||
| 134 | |||
| 135 | User defined reference field. | ||
| 136 | |||
| 137 | =item C<tax> | ||
| 138 | |||
| 139 | The tax ID of the tax charge in the invoice item. | ||
| 140 | |||
| 141 | Authentication is done using the same credentials used when the AccessToken was created. | ||
| 142 | |||
| 143 | =back | ||
| 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("invoiceItem", '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("invoiceItem", 'delete', {id => $id}, $auth)); | ||
| 219 | } | ||
| 220 | |||
| 221 | sub find { | ||
| 222 | my ($class, $id, $auth) = @_; | ||
| 223 | |||
| 224 | $auth = Net::Simplify::SimplifyApi->get_authentication($auth); | ||
| 225 | my $result = Net::Simplify::SimplifyApi->send_api_request("invoiceItem", 'find', { id => $id }, $auth); | ||
| 226 | |||
| 227 | $class->SUPER::new($result, $auth); | ||
| 228 | } | ||
| 229 | |||
| 230 | sub update { | ||
| 231 | |||
| 232 | my ($self) = @_; | ||
| 233 | |||
| 234 | my $auth = Net::Simplify::SimplifyApi->get_authentication($self->{_authentication}); | ||
| 235 | my $params = { %$self }; | ||
| 236 | delete $params->{_authentication}; | ||
| 237 | |||
| 238 | $self->merge(Net::Simplify::SimplifyApi->send_api_request("invoiceItem", 'update', $params, $auth)); | ||
| 239 | } | ||
| 240 | |||
| 241 | |||
| 242 | 1; |