TestClock.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\TestHelpers;
  4. /**
  5. * A test clock enables deterministic control over objects in testmode. With a test
  6. * clock, you can create objects at a frozen time in the past or future, and
  7. * advance to a specific future time to observe webhooks and state changes. After
  8. * the clock advances, you can either validate the current state of your scenario
  9. * (and test your assumptions), change the current state of your scenario (and test
  10. * more complex scenarios), or keep advancing forward in time.
  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 int $deletes_after Time at which this clock is scheduled to auto delete.
  16. * @property int $frozen_time Time at which all objects belonging to this clock are frozen.
  17. * @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.
  18. * @property null|string $name The custom name supplied at creation.
  19. * @property string $status The status of the Test Clock.
  20. */
  21. class TestClock extends \Stripe\ApiResource
  22. {
  23. const OBJECT_NAME = 'test_helpers.test_clock';
  24. use \Stripe\ApiOperations\All;
  25. use \Stripe\ApiOperations\Create;
  26. use \Stripe\ApiOperations\Delete;
  27. use \Stripe\ApiOperations\Retrieve;
  28. const STATUS_ADVANCING = 'advancing';
  29. const STATUS_INTERNAL_FAILURE = 'internal_failure';
  30. const STATUS_READY = 'ready';
  31. /**
  32. * @param null|array $params
  33. * @param null|array|string $opts
  34. *
  35. * @throws \Stripe\Exception\ApiErrorException if the request fails
  36. *
  37. * @return \Stripe\TestHelpers\TestClock the advanced test clock
  38. */
  39. public function advance($params = null, $opts = null)
  40. {
  41. $url = $this->instanceUrl() . '/advance';
  42. list($response, $opts) = $this->_request('post', $url, $params, $opts);
  43. $this->refreshFrom($response, $opts);
  44. return $this;
  45. }
  46. }