PromotionCodeService.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Service;
  4. /**
  5. * @phpstan-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
  6. * @psalm-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
  7. */
  8. class PromotionCodeService extends \Stripe\Service\AbstractService
  9. {
  10. /**
  11. * Returns a list of your promotion codes.
  12. *
  13. * @param null|array $params
  14. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  15. *
  16. * @throws \Stripe\Exception\ApiErrorException if the request fails
  17. *
  18. * @return \Stripe\Collection<\Stripe\PromotionCode>
  19. */
  20. public function all($params = null, $opts = null)
  21. {
  22. return $this->requestCollection('get', '/v1/promotion_codes', $params, $opts);
  23. }
  24. /**
  25. * A promotion code points to a coupon. You can optionally restrict the code to a
  26. * specific customer, redemption limit, and expiration date.
  27. *
  28. * @param null|array $params
  29. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  30. *
  31. * @throws \Stripe\Exception\ApiErrorException if the request fails
  32. *
  33. * @return \Stripe\PromotionCode
  34. */
  35. public function create($params = null, $opts = null)
  36. {
  37. return $this->request('post', '/v1/promotion_codes', $params, $opts);
  38. }
  39. /**
  40. * Retrieves the promotion code with the given ID. In order to retrieve a promotion
  41. * code by the customer-facing <code>code</code> use <a
  42. * href="/docs/api/promotion_codes/list">list</a> with the desired
  43. * <code>code</code>.
  44. *
  45. * @param string $id
  46. * @param null|array $params
  47. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  48. *
  49. * @throws \Stripe\Exception\ApiErrorException if the request fails
  50. *
  51. * @return \Stripe\PromotionCode
  52. */
  53. public function retrieve($id, $params = null, $opts = null)
  54. {
  55. return $this->request('get', $this->buildPath('/v1/promotion_codes/%s', $id), $params, $opts);
  56. }
  57. /**
  58. * Updates the specified promotion code by setting the values of the parameters
  59. * passed. Most fields are, by design, not editable.
  60. *
  61. * @param string $id
  62. * @param null|array $params
  63. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  64. *
  65. * @throws \Stripe\Exception\ApiErrorException if the request fails
  66. *
  67. * @return \Stripe\PromotionCode
  68. */
  69. public function update($id, $params = null, $opts = null)
  70. {
  71. return $this->request('post', $this->buildPath('/v1/promotion_codes/%s', $id), $params, $opts);
  72. }
  73. }