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