/wp-content/plugins/woocommerce/includes/gateways/simplify-commerce/includes/Simplify/Webhook.php

https://gitlab.com/hunt9310/ras · PHP · 138 lines · 42 code · 27 blank · 69 comment · 0 complexity · b52f7d63cc1459bec2ca1513a035ec5d MD5 · raw file

  1. <?php
  2. /*
  3. * Copyright (c) 2013 - 2015 MasterCard International Incorporated
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification, are
  7. * permitted provided that the following conditions are met:
  8. *
  9. * Redistributions of source code must retain the above copyright notice, this list of
  10. * conditions and the following disclaimer.
  11. * Redistributions in binary form must reproduce the above copyright notice, this list of
  12. * conditions and the following disclaimer in the documentation and/or other materials
  13. * provided with the distribution.
  14. * Neither the name of the MasterCard International Incorporated nor the names of its
  15. * contributors may be used to endorse or promote products derived from this software
  16. * without specific prior written permission.
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
  18. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  19. * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
  20. * SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  21. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  22. * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  23. * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
  24. * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  25. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  26. * SUCH DAMAGE.
  27. */
  28. class Simplify_Webhook extends Simplify_Object {
  29. /**
  30. * Creates an Simplify_Webhook object
  31. * @param array $hash a map of parameters; valid keys are:<dl style="padding-left:10px;">
  32. * <dt><tt>url</tt></dt> <dd>Endpoint URL <strong>required </strong></dd></dl>
  33. * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.<i/>
  34. * @return Webhook a Webhook object.
  35. */
  36. static public function createWebhook($hash, $authentication = null) {
  37. $args = func_get_args();
  38. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
  39. $instance = new Simplify_Webhook();
  40. $instance->setAll($hash);
  41. $object = Simplify_PaymentsApi::createObject($instance, $authentication);
  42. return $object;
  43. }
  44. /**
  45. * Deletes an Simplify_Webhook object.
  46. *
  47. * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
  48. */
  49. public function deleteWebhook($authentication = null) {
  50. $args = func_get_args();
  51. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
  52. $obj = Simplify_PaymentsApi::deleteObject($this, $authentication);
  53. $this->properties = null;
  54. return true;
  55. }
  56. /**
  57. * Retrieve Simplify_Webhook objects.
  58. * @param array criteria a map of parameters; valid keys are:<dl style="padding-left:10px;">
  59. * <dt><tt>filter</tt></dt> <dd>Filters to apply to the list. </dd>
  60. * <dt><tt>max</tt></dt> <dd>Allows up to a max of 50 list items to return. [min value: 0, max value: 50, default: 20] </dd>
  61. * <dt><tt>offset</tt></dt> <dd>Used in paging of the list. This is the start offset of the page. [min value: 0, default: 0] </dd>
  62. * <dt><tt>sorting</tt></dt> <dd>Allows for ascending or descending sorting of the list. The value maps properties to the sort direction (either <tt>asc</tt> for ascending or <tt>desc</tt> for descending). Sortable properties are: <tt> dateCreated</tt>.</dd></dl>
  63. * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
  64. * @return ResourceList a ResourceList object that holds the list of Webhook objects and the total
  65. * number of Webhook objects available for the given criteria.
  66. * @see ResourceList
  67. */
  68. static public function listWebhook($criteria = null, $authentication = null) {
  69. $args = func_get_args();
  70. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
  71. $val = new Simplify_Webhook();
  72. $list = Simplify_PaymentsApi::listObject($val, $criteria, $authentication);
  73. return $list;
  74. }
  75. /**
  76. * Retrieve a Simplify_Webhook object from the API
  77. *
  78. * @param string id the id of the Webhook object to retrieve
  79. * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
  80. * @return Webhook a Webhook object
  81. */
  82. static public function findWebhook($id, $authentication = null) {
  83. $args = func_get_args();
  84. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 2);
  85. $val = new Simplify_Webhook();
  86. $val->id = $id;
  87. $obj = Simplify_PaymentsApi::findObject($val, $authentication);
  88. return $obj;
  89. }
  90. /**
  91. * Updates an Simplify_Webhook object.
  92. *
  93. * The properties that can be updated:
  94. * <dl style="padding-left:10px;">
  95. * <dt><tt>url</tt></dt> <dd>Endpoint URL <strong>required </strong></dd></dl>
  96. * @param $authentication - information used for the API call. If no value is passed the global keys Simplify::public_key and Simplify::private_key are used. <i>For backwards compatibility the public and private keys may be passed instead of the authentication object.</i>
  97. * @return Webhook a Webhook object.
  98. */
  99. public function updateWebhook($authentication = null) {
  100. $args = func_get_args();
  101. $authentication = Simplify_PaymentsApi::buildAuthenticationObject($authentication, $args, 1);
  102. $object = Simplify_PaymentsApi::updateObject($this, $authentication);
  103. return $object;
  104. }
  105. /**
  106. * @ignore
  107. */
  108. public function getClazz() {
  109. return "Webhook";
  110. }
  111. }