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