PromotionCodeService.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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
  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.
  37. *
  38. * @param string $id
  39. * @param null|array $params
  40. * @param null|array|\Stripe\Util\RequestOptions $opts
  41. *
  42. * @throws \Stripe\Exception\ApiErrorException if the request fails
  43. *
  44. * @return \Stripe\PromotionCode
  45. */
  46. public function retrieve($id, $params = null, $opts = null)
  47. {
  48. return $this->request('get', $this->buildPath('/v1/promotion_codes/%s', $id), $params, $opts);
  49. }
  50. /**
  51. * Updates the specified promotion code by setting the values of the parameters
  52. * passed. Most fields are, by design, not editable.
  53. *
  54. * @param string $id
  55. * @param null|array $params
  56. * @param null|array|\Stripe\Util\RequestOptions $opts
  57. *
  58. * @throws \Stripe\Exception\ApiErrorException if the request fails
  59. *
  60. * @return \Stripe\PromotionCode
  61. */
  62. public function update($id, $params = null, $opts = null)
  63. {
  64. return $this->request('post', $this->buildPath('/v1/promotion_codes/%s', $id), $params, $opts);
  65. }
  66. }