PromotionCodeService.php 2.4 KB

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