ValueListItem.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Radar;
  4. /**
  5. * Value list items allow you to add specific values to a given Radar value list, which can then be used in rules.
  6. *
  7. * Related guide: <a href="https://stripe.com/docs/radar/lists#managing-list-items">Managing list items</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 int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  12. * @property string $created_by The name or email address of the user who added this item to the value list.
  13. * @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.
  14. * @property string $value The value of the item.
  15. * @property string $value_list The identifier of the value list this item belongs to.
  16. */
  17. class ValueListItem extends \Stripe\ApiResource
  18. {
  19. const OBJECT_NAME = 'radar.value_list_item';
  20. /**
  21. * Creates a new <code>ValueListItem</code> object, which is added to the specified
  22. * parent value list.
  23. *
  24. * @param null|array $params
  25. * @param null|array|string $options
  26. *
  27. * @throws \Stripe\Exception\ApiErrorException if the request fails
  28. *
  29. * @return \Stripe\Radar\ValueListItem the created resource
  30. */
  31. public static function create($params = null, $options = null)
  32. {
  33. self::_validateParams($params);
  34. $url = static::classUrl();
  35. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  36. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  37. $obj->setLastResponse($response);
  38. return $obj;
  39. }
  40. /**
  41. * Deletes a <code>ValueListItem</code> object, removing it from its parent value
  42. * list.
  43. *
  44. * @param null|array $params
  45. * @param null|array|string $opts
  46. *
  47. * @throws \Stripe\Exception\ApiErrorException if the request fails
  48. *
  49. * @return \Stripe\Radar\ValueListItem the deleted resource
  50. */
  51. public function delete($params = null, $opts = null)
  52. {
  53. self::_validateParams($params);
  54. $url = $this->instanceUrl();
  55. list($response, $opts) = $this->_request('delete', $url, $params, $opts);
  56. $this->refreshFrom($response, $opts);
  57. return $this;
  58. }
  59. /**
  60. * Returns a list of <code>ValueListItem</code> objects. The objects are sorted in
  61. * descending order by creation date, with the most recently created object
  62. * appearing first.
  63. *
  64. * @param null|array $params
  65. * @param null|array|string $opts
  66. *
  67. * @throws \Stripe\Exception\ApiErrorException if the request fails
  68. *
  69. * @return \Stripe\Collection<\Stripe\Radar\ValueListItem> of ApiResources
  70. */
  71. public static function all($params = null, $opts = null)
  72. {
  73. $url = static::classUrl();
  74. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  75. }
  76. /**
  77. * Retrieves a <code>ValueListItem</code> object.
  78. *
  79. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  80. * @param null|array|string $opts
  81. *
  82. * @throws \Stripe\Exception\ApiErrorException if the request fails
  83. *
  84. * @return \Stripe\Radar\ValueListItem
  85. */
  86. public static function retrieve($id, $opts = null)
  87. {
  88. $opts = \Stripe\Util\RequestOptions::parse($opts);
  89. $instance = new static($id, $opts);
  90. $instance->refresh();
  91. return $instance;
  92. }
  93. }