Secret.php
107 lines
| 1 | <?php |
| 2 | |
| 3 | // File generated from our OpenAPI spec |
| 4 | |
| 5 | namespace AmeliaVendor\Stripe\Apps; |
| 6 | |
| 7 | /** |
| 8 | * Secret Store is an API that allows Stripe Apps developers to securely persist secrets for use by UI Extensions and app backends. |
| 9 | * |
| 10 | * The primary resource in Secret Store is a <code>secret</code>. Other apps can't view secrets created by an app. Additionally, secrets are scoped to provide further permission control. |
| 11 | * |
| 12 | * All Dashboard users and the app backend share <code>account</code> scoped secrets. Use the <code>account</code> scope for secrets that don't change per-user, like a third-party API key. |
| 13 | * |
| 14 | * A <code>user</code> scoped secret is accessible by the app backend and one specific Dashboard user. Use the <code>user</code> scope for per-user secrets like per-user OAuth tokens, where different users might have different permissions. |
| 15 | * |
| 16 | * Related guide: <a href="https://stripe.com/docs/stripe-apps/store-auth-data-custom-objects">Store data between page reloads</a> |
| 17 | * |
| 18 | * @property string $id Unique identifier for the object. |
| 19 | * @property string $object String representing the object's type. Objects of the same type share the same value. |
| 20 | * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch. |
| 21 | * @property null|bool $deleted If true, indicates that this secret has been deleted |
| 22 | * @property null|int $expires_at The Unix timestamp for the expiry time of the secret, after which the secret deletes. |
| 23 | * @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. |
| 24 | * @property string $name A name for the secret that's unique within the scope. |
| 25 | * @property null|string $payload The plaintext secret value to be stored. |
| 26 | * @property (object{type: string, user?: string}&\AmeliaVendor\Stripe\StripeObject) $scope |
| 27 | */ |
| 28 | class Secret extends \AmeliaVendor\Stripe\ApiResource |
| 29 | { |
| 30 | const OBJECT_NAME = 'apps.secret'; |
| 31 | |
| 32 | /** |
| 33 | * Create or replace a secret in the secret store. |
| 34 | * |
| 35 | * @param null|array{expand?: string[], expires_at?: int, name: string, payload: string, scope: array{type: string, user?: string}} $params |
| 36 | * @param null|array|string $options |
| 37 | * |
| 38 | * @return Secret the created resource |
| 39 | * |
| 40 | * @throws \AmeliaVendor\Stripe\Exception\ApiErrorException if the request fails |
| 41 | */ |
| 42 | public static function create($params = null, $options = null) |
| 43 | { |
| 44 | self::_validateParams($params); |
| 45 | $url = static::classUrl(); |
| 46 | |
| 47 | list($response, $opts) = static::_staticRequest('post', $url, $params, $options); |
| 48 | $obj = \AmeliaVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 49 | $obj->setLastResponse($response); |
| 50 | |
| 51 | return $obj; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * List all secrets stored on the given scope. |
| 56 | * |
| 57 | * @param null|array{ending_before?: string, expand?: string[], limit?: int, scope: array{type: string, user?: string}, starting_after?: string} $params |
| 58 | * @param null|array|string $opts |
| 59 | * |
| 60 | * @return \AmeliaVendor\Stripe\Collection<Secret> of ApiResources |
| 61 | * |
| 62 | * @throws \AmeliaVendor\Stripe\Exception\ApiErrorException if the request fails |
| 63 | */ |
| 64 | public static function all($params = null, $opts = null) |
| 65 | { |
| 66 | $url = static::classUrl(); |
| 67 | |
| 68 | return static::_requestPage($url, \AmeliaVendor\Stripe\Collection::class, $params, $opts); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * @param null|array $params |
| 73 | * @param null|array|string $opts |
| 74 | * |
| 75 | * @return Secret the deleted secret |
| 76 | * |
| 77 | * @throws \AmeliaVendor\Stripe\Exception\ApiErrorException if the request fails |
| 78 | */ |
| 79 | public static function deleteWhere($params = null, $opts = null) |
| 80 | { |
| 81 | $url = static::classUrl() . '/delete'; |
| 82 | list($response, $opts) = static::_staticRequest('post', $url, $params, $opts); |
| 83 | $obj = \AmeliaVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 84 | $obj->setLastResponse($response); |
| 85 | |
| 86 | return $obj; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * @param null|array $params |
| 91 | * @param null|array|string $opts |
| 92 | * |
| 93 | * @return Secret the finded secret |
| 94 | * |
| 95 | * @throws \AmeliaVendor\Stripe\Exception\ApiErrorException if the request fails |
| 96 | */ |
| 97 | public static function find($params = null, $opts = null) |
| 98 | { |
| 99 | $url = static::classUrl() . '/find'; |
| 100 | list($response, $opts) = static::_staticRequest('get', $url, $params, $opts); |
| 101 | $obj = \AmeliaVendor\Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 102 | $obj->setLastResponse($response); |
| 103 | |
| 104 | return $obj; |
| 105 | } |
| 106 | } |
| 107 |