ProductService.php 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Service;
  4. class ProductService extends \Stripe\Service\AbstractService
  5. {
  6. /**
  7. * Returns a list of your products. The products are returned sorted by creation
  8. * date, with the most recently created products 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/products', $params, $opts);
  20. }
  21. /**
  22. * Creates a new product object.
  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\Product
  30. */
  31. public function create($params = null, $opts = null)
  32. {
  33. return $this->request('post', '/v1/products', $params, $opts);
  34. }
  35. /**
  36. * Delete a product. Deleting a product is only possible if it has no prices
  37. * associated with it. Additionally, deleting a product with <code>type=good</code>
  38. * is only possible if it has no SKUs associated with it.
  39. *
  40. * @param string $id
  41. * @param null|array $params
  42. * @param null|array|\Stripe\Util\RequestOptions $opts
  43. *
  44. * @throws \Stripe\Exception\ApiErrorException if the request fails
  45. *
  46. * @return \Stripe\Product
  47. */
  48. public function delete($id, $params = null, $opts = null)
  49. {
  50. return $this->request('delete', $this->buildPath('/v1/products/%s', $id), $params, $opts);
  51. }
  52. /**
  53. * Retrieves the details of an existing product. Supply the unique product ID from
  54. * either a product creation request or the product list, and Stripe will return
  55. * the corresponding product information.
  56. *
  57. * @param string $id
  58. * @param null|array $params
  59. * @param null|array|\Stripe\Util\RequestOptions $opts
  60. *
  61. * @throws \Stripe\Exception\ApiErrorException if the request fails
  62. *
  63. * @return \Stripe\Product
  64. */
  65. public function retrieve($id, $params = null, $opts = null)
  66. {
  67. return $this->request('get', $this->buildPath('/v1/products/%s', $id), $params, $opts);
  68. }
  69. /**
  70. * Updates the specific product by setting the values of the parameters passed. Any
  71. * parameters not provided will be left unchanged.
  72. *
  73. * @param string $id
  74. * @param null|array $params
  75. * @param null|array|\Stripe\Util\RequestOptions $opts
  76. *
  77. * @throws \Stripe\Exception\ApiErrorException if the request fails
  78. *
  79. * @return \Stripe\Product
  80. */
  81. public function update($id, $params = null, $opts = null)
  82. {
  83. return $this->request('post', $this->buildPath('/v1/products/%s', $id), $params, $opts);
  84. }
  85. }