All.php
6 years ago
Create.php
6 years ago
Delete.php
6 years ago
NestedResource.php
6 years ago
Request.php
6 years ago
Retrieve.php
6 years ago
Update.php
6 years ago
Create.php
29 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Stripe\ApiOperations; |
| 4 | |
| 5 | /** |
| 6 | * Trait for creatable resources. Adds a `create()` static method to the class. |
| 7 | * |
| 8 | * This trait should only be applied to classes that derive from StripeObject. |
| 9 | */ |
| 10 | trait Create |
| 11 | { |
| 12 | /** |
| 13 | * @param array|null $params |
| 14 | * @param array|string|null $options |
| 15 | * |
| 16 | * @return static The created resource. |
| 17 | */ |
| 18 | public static function create($params = null, $options = null) |
| 19 | { |
| 20 | self::_validateParams($params); |
| 21 | $url = static::classUrl(); |
| 22 | |
| 23 | list($response, $opts) = static::_staticRequest('post', $url, $params, $options); |
| 24 | $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts); |
| 25 | $obj->setLastResponse($response); |
| 26 | return $obj; |
| 27 | } |
| 28 | } |
| 29 |