EphemeralKey.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe;
  4. /**
  5. * @property string $id Unique identifier for the object.
  6. * @property string $object String representing the object's type. Objects of the same type share the same value.
  7. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  8. * @property int $expires Time at which the key will expire. Measured in seconds since the Unix epoch.
  9. * @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.
  10. * @property null|string $secret The key's secret. You can use this value to make authorized requests to the Stripe API.
  11. */
  12. class EphemeralKey extends ApiResource
  13. {
  14. const OBJECT_NAME = 'ephemeral_key';
  15. /**
  16. * Invalidates a short-lived API key for a given resource.
  17. *
  18. * @param null|array $params
  19. * @param null|array|string $opts
  20. *
  21. * @throws \Stripe\Exception\ApiErrorException if the request fails
  22. *
  23. * @return \Stripe\EphemeralKey the deleted resource
  24. */
  25. public function delete($params = null, $opts = null)
  26. {
  27. self::_validateParams($params);
  28. $url = $this->instanceUrl();
  29. list($response, $opts) = $this->_request('delete', $url, $params, $opts);
  30. $this->refreshFrom($response, $opts);
  31. return $this;
  32. }
  33. use ApiOperations\Create {
  34. create as protected _create;
  35. }
  36. /**
  37. * @param null|array $params
  38. * @param null|array|string $opts
  39. *
  40. * @throws \Stripe\Exception\InvalidArgumentException if stripe_version is missing
  41. * @throws \Stripe\Exception\ApiErrorException if the request fails
  42. *
  43. * @return \Stripe\EphemeralKey the created key
  44. */
  45. public static function create($params = null, $opts = null)
  46. {
  47. if (!$opts || !isset($opts['stripe_version'])) {
  48. throw new Exception\InvalidArgumentException('stripe_version must be specified to create an ephemeral key');
  49. }
  50. return self::_create($params, $opts);
  51. }
  52. }