ValueList.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Radar;
  4. /**
  5. * Value lists allow you to group values together which can then be referenced in rules.
  6. *
  7. * Related guide: <a href="https://stripe.com/docs/radar/lists#managing-list-items">Default Stripe lists</a>
  8. *
  9. * @property string $id Unique identifier for the object.
  10. * @property string $object String representing the object's type. Objects of the same type share the same value.
  11. * @property string $alias The name of the value list for use in rules.
  12. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  13. * @property string $created_by The name or email address of the user who created this value list.
  14. * @property string $item_type The type of items in the value list. One of <code>card_fingerprint</code>, <code>us_bank_account_fingerprint</code>, <code>sepa_debit_fingerprint</code>, <code>card_bin</code>, <code>email</code>, <code>ip_address</code>, <code>country</code>, <code>string</code>, <code>case_sensitive_string</code>, or <code>customer_id</code>.
  15. * @property \Stripe\Collection<\Stripe\Radar\ValueListItem> $list_items List of items contained within this value list.
  16. * @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
  17. * @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
  18. * @property string $name The name of the value list.
  19. */
  20. class ValueList extends \Stripe\ApiResource
  21. {
  22. const OBJECT_NAME = 'radar.value_list';
  23. use \Stripe\ApiOperations\Update;
  24. const ITEM_TYPE_CARD_BIN = 'card_bin';
  25. const ITEM_TYPE_CARD_FINGERPRINT = 'card_fingerprint';
  26. const ITEM_TYPE_CASE_SENSITIVE_STRING = 'case_sensitive_string';
  27. const ITEM_TYPE_COUNTRY = 'country';
  28. const ITEM_TYPE_CUSTOMER_ID = 'customer_id';
  29. const ITEM_TYPE_EMAIL = 'email';
  30. const ITEM_TYPE_IP_ADDRESS = 'ip_address';
  31. const ITEM_TYPE_SEPA_DEBIT_FINGERPRINT = 'sepa_debit_fingerprint';
  32. const ITEM_TYPE_STRING = 'string';
  33. const ITEM_TYPE_US_BANK_ACCOUNT_FINGERPRINT = 'us_bank_account_fingerprint';
  34. /**
  35. * Creates a new <code>ValueList</code> object, which can then be referenced in
  36. * rules.
  37. *
  38. * @param null|array $params
  39. * @param null|array|string $options
  40. *
  41. * @throws \Stripe\Exception\ApiErrorException if the request fails
  42. *
  43. * @return \Stripe\Radar\ValueList the created resource
  44. */
  45. public static function create($params = null, $options = null)
  46. {
  47. self::_validateParams($params);
  48. $url = static::classUrl();
  49. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  50. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  51. $obj->setLastResponse($response);
  52. return $obj;
  53. }
  54. /**
  55. * Deletes a <code>ValueList</code> object, also deleting any items contained
  56. * within the value list. To be deleted, a value list must not be referenced in any
  57. * rules.
  58. *
  59. * @param null|array $params
  60. * @param null|array|string $opts
  61. *
  62. * @throws \Stripe\Exception\ApiErrorException if the request fails
  63. *
  64. * @return \Stripe\Radar\ValueList the deleted resource
  65. */
  66. public function delete($params = null, $opts = null)
  67. {
  68. self::_validateParams($params);
  69. $url = $this->instanceUrl();
  70. list($response, $opts) = $this->_request('delete', $url, $params, $opts);
  71. $this->refreshFrom($response, $opts);
  72. return $this;
  73. }
  74. /**
  75. * Returns a list of <code>ValueList</code> objects. The objects are sorted in
  76. * descending order by creation date, with the most recently created object
  77. * appearing first.
  78. *
  79. * @param null|array $params
  80. * @param null|array|string $opts
  81. *
  82. * @throws \Stripe\Exception\ApiErrorException if the request fails
  83. *
  84. * @return \Stripe\Collection<\Stripe\Radar\ValueList> of ApiResources
  85. */
  86. public static function all($params = null, $opts = null)
  87. {
  88. $url = static::classUrl();
  89. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  90. }
  91. /**
  92. * Retrieves a <code>ValueList</code> object.
  93. *
  94. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  95. * @param null|array|string $opts
  96. *
  97. * @throws \Stripe\Exception\ApiErrorException if the request fails
  98. *
  99. * @return \Stripe\Radar\ValueList
  100. */
  101. public static function retrieve($id, $opts = null)
  102. {
  103. $opts = \Stripe\Util\RequestOptions::parse($opts);
  104. $instance = new static($id, $opts);
  105. $instance->refresh();
  106. return $instance;
  107. }
  108. /**
  109. * Updates a <code>ValueList</code> object by setting the values of the parameters
  110. * passed. Any parameters not provided will be left unchanged. Note that
  111. * <code>item_type</code> is immutable.
  112. *
  113. * @param string $id the ID of the resource to update
  114. * @param null|array $params
  115. * @param null|array|string $opts
  116. *
  117. * @throws \Stripe\Exception\ApiErrorException if the request fails
  118. *
  119. * @return \Stripe\Radar\ValueList the updated resource
  120. */
  121. public static function update($id, $params = null, $opts = null)
  122. {
  123. self::_validateParams($params);
  124. $url = static::resourceUrl($id);
  125. list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
  126. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  127. $obj->setLastResponse($response);
  128. return $obj;
  129. }
  130. }