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