ActiveEntitlement.php
7 months ago
ActiveEntitlementSummary.php
7 months ago
Feature.php
7 months ago
Feature.php
93 lines
| 1 | <?php |
| 2 | |
| 3 | // File generated from our OpenAPI spec |
| 4 | namespace AmeliaVendor\Stripe\Entitlements; |
| 5 | |
| 6 | /** |
| 7 | * A feature represents a monetizable ability or functionality in your system. |
| 8 | * Features can be assigned to products, and when those products are purchased, Stripe will create an entitlement to the feature for the purchasing customer. |
| 9 | * |
| 10 | * @property string $id Unique identifier for the object. |
| 11 | * @property string $object String representing the object's type. Objects of the same type share the same value. |
| 12 | * @property bool $active Inactive features cannot be attached to new products and will not be returned from the features list endpoint. |
| 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 $lookup_key A unique key you provide as your own system identifier. This may be up to 80 characters. |
| 15 | * @property \AmeliaVendor\Stripe\StripeObject $metadata Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format. |
| 16 | * @property string $name The feature's name, for your own purpose, not meant to be displayable to the customer. |
| 17 | */ |
| 18 | class Feature extends \AmeliaVendor\Stripe\ApiResource |
| 19 | { |
| 20 | const OBJECT_NAME = 'entitlements.feature'; |
| 21 | use \AmeliaVendor\Stripe\ApiOperations\Update; |
| 22 | /** |
| 23 | * Creates a feature. |
| 24 | * |
| 25 | * @param null|array{expand?: string[], lookup_key: string, metadata?: array<string, string>, name: string} $params |
| 26 | * @param null|array|string $options |
| 27 | * |
| 28 | * @return Feature the created resource |
| 29 | * |
| 30 | * @throws \AmeliaVendor\Stripe\Exception\ApiErrorException if the request fails |
| 31 | */ |
| 32 | public static function create($params = null, $options = null) |
| 33 | { |
| 34 | self::_validateParams($params); |
| 35 | $url = static::classUrl(); |
| 36 | list($response, $opts) = static::_staticRequest('post', $url, $params, $options); |
| 37 | $obj = \AmeliaVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 38 | $obj->setLastResponse($response); |
| 39 | return $obj; |
| 40 | } |
| 41 | /** |
| 42 | * Retrieve a list of features. |
| 43 | * |
| 44 | * @param null|array{archived?: bool, ending_before?: string, expand?: string[], limit?: int, lookup_key?: string, starting_after?: string} $params |
| 45 | * @param null|array|string $opts |
| 46 | * |
| 47 | * @return \AmeliaVendor\Stripe\Collection<Feature> of ApiResources |
| 48 | * |
| 49 | * @throws \AmeliaVendor\Stripe\Exception\ApiErrorException if the request fails |
| 50 | */ |
| 51 | public static function all($params = null, $opts = null) |
| 52 | { |
| 53 | $url = static::classUrl(); |
| 54 | return static::_requestPage($url, \AmeliaVendor\Stripe\Collection::class, $params, $opts); |
| 55 | } |
| 56 | /** |
| 57 | * Retrieves a feature. |
| 58 | * |
| 59 | * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key |
| 60 | * @param null|array|string $opts |
| 61 | * |
| 62 | * @return Feature |
| 63 | * |
| 64 | * @throws \AmeliaVendor\Stripe\Exception\ApiErrorException if the request fails |
| 65 | */ |
| 66 | public static function retrieve($id, $opts = null) |
| 67 | { |
| 68 | $opts = \AmeliaVendor\Stripe\Util\RequestOptions::parse($opts); |
| 69 | $instance = new static($id, $opts); |
| 70 | $instance->refresh(); |
| 71 | return $instance; |
| 72 | } |
| 73 | /** |
| 74 | * Update a feature’s metadata or permanently deactivate it. |
| 75 | * |
| 76 | * @param string $id the ID of the resource to update |
| 77 | * @param null|array{active?: bool, expand?: string[], metadata?: null|array<string, string>, name?: string} $params |
| 78 | * @param null|array|string $opts |
| 79 | * |
| 80 | * @return Feature the updated resource |
| 81 | * |
| 82 | * @throws \AmeliaVendor\Stripe\Exception\ApiErrorException if the request fails |
| 83 | */ |
| 84 | public static function update($id, $params = null, $opts = null) |
| 85 | { |
| 86 | self::_validateParams($params); |
| 87 | $url = static::resourceUrl($id); |
| 88 | list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); |
| 89 | $obj = \AmeliaVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 90 | $obj->setLastResponse($response); |
| 91 | return $obj; |
| 92 | } |
| 93 | } |