SkuService.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Service;
  4. class SkuService extends \Stripe\Service\AbstractService
  5. {
  6. /**
  7. * Returns a list of your SKUs. The SKUs are returned sorted by creation date, with
  8. * the most recently created SKUs appearing first.
  9. *
  10. * @param null|array $params
  11. * @param null|array|\Stripe\Util\RequestOptions $opts
  12. *
  13. * @throws \Stripe\Exception\ApiErrorException if the request fails
  14. *
  15. * @return \Stripe\Collection
  16. */
  17. public function all($params = null, $opts = null)
  18. {
  19. return $this->requestCollection('get', '/v1/skus', $params, $opts);
  20. }
  21. /**
  22. * Creates a new SKU associated with a product.
  23. *
  24. * @param null|array $params
  25. * @param null|array|\Stripe\Util\RequestOptions $opts
  26. *
  27. * @throws \Stripe\Exception\ApiErrorException if the request fails
  28. *
  29. * @return \Stripe\SKU
  30. */
  31. public function create($params = null, $opts = null)
  32. {
  33. return $this->request('post', '/v1/skus', $params, $opts);
  34. }
  35. /**
  36. * Delete a SKU. Deleting a SKU is only possible until it has been used in an
  37. * order.
  38. *
  39. * @param string $id
  40. * @param null|array $params
  41. * @param null|array|\Stripe\Util\RequestOptions $opts
  42. *
  43. * @throws \Stripe\Exception\ApiErrorException if the request fails
  44. *
  45. * @return \Stripe\SKU
  46. */
  47. public function delete($id, $params = null, $opts = null)
  48. {
  49. return $this->request('delete', $this->buildPath('/v1/skus/%s', $id), $params, $opts);
  50. }
  51. /**
  52. * Retrieves the details of an existing SKU. Supply the unique SKU identifier from
  53. * either a SKU creation request or from the product, and Stripe will return the
  54. * corresponding SKU information.
  55. *
  56. * @param string $id
  57. * @param null|array $params
  58. * @param null|array|\Stripe\Util\RequestOptions $opts
  59. *
  60. * @throws \Stripe\Exception\ApiErrorException if the request fails
  61. *
  62. * @return \Stripe\SKU
  63. */
  64. public function retrieve($id, $params = null, $opts = null)
  65. {
  66. return $this->request('get', $this->buildPath('/v1/skus/%s', $id), $params, $opts);
  67. }
  68. /**
  69. * Updates the specific SKU by setting the values of the parameters passed. Any
  70. * parameters not provided will be left unchanged.
  71. *
  72. * Note that a SKU’s <code>attributes</code> are not editable. Instead, you would
  73. * need to deactivate the existing SKU and create a new one with the new attribute
  74. * values.
  75. *
  76. * @param string $id
  77. * @param null|array $params
  78. * @param null|array|\Stripe\Util\RequestOptions $opts
  79. *
  80. * @throws \Stripe\Exception\ApiErrorException if the request fails
  81. *
  82. * @return \Stripe\SKU
  83. */
  84. public function update($id, $params = null, $opts = null)
  85. {
  86. return $this->request('post', $this->buildPath('/v1/skus/%s', $id), $params, $opts);
  87. }
  88. }