MeterService.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Service\Billing;
  4. /**
  5. * @phpstan-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
  6. * @psalm-import-type RequestOptionsArray from \Stripe\Util\RequestOptions
  7. */
  8. class MeterService extends \Stripe\Service\AbstractService
  9. {
  10. /**
  11. * Retrieve a list of billing meters.
  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\Billing\Meter>
  19. */
  20. public function all($params = null, $opts = null)
  21. {
  22. return $this->requestCollection('get', '/v1/billing/meters', $params, $opts);
  23. }
  24. /**
  25. * Retrieve a list of billing meter event summaries.
  26. *
  27. * @param string $parentId
  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\Collection<\Stripe\Billing\MeterEventSummary>
  34. */
  35. public function allEventSummaries($parentId, $params = null, $opts = null)
  36. {
  37. return $this->requestCollection('get', $this->buildPath('/v1/billing/meters/%s/event_summaries', $parentId), $params, $opts);
  38. }
  39. /**
  40. * Creates a billing meter.
  41. *
  42. * @param null|array $params
  43. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  44. *
  45. * @throws \Stripe\Exception\ApiErrorException if the request fails
  46. *
  47. * @return \Stripe\Billing\Meter
  48. */
  49. public function create($params = null, $opts = null)
  50. {
  51. return $this->request('post', '/v1/billing/meters', $params, $opts);
  52. }
  53. /**
  54. * Deactivates a billing meter.
  55. *
  56. * @param string $id
  57. * @param null|array $params
  58. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  59. *
  60. * @throws \Stripe\Exception\ApiErrorException if the request fails
  61. *
  62. * @return \Stripe\Billing\Meter
  63. */
  64. public function deactivate($id, $params = null, $opts = null)
  65. {
  66. return $this->request('post', $this->buildPath('/v1/billing/meters/%s/deactivate', $id), $params, $opts);
  67. }
  68. /**
  69. * Reactivates a billing meter.
  70. *
  71. * @param string $id
  72. * @param null|array $params
  73. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  74. *
  75. * @throws \Stripe\Exception\ApiErrorException if the request fails
  76. *
  77. * @return \Stripe\Billing\Meter
  78. */
  79. public function reactivate($id, $params = null, $opts = null)
  80. {
  81. return $this->request('post', $this->buildPath('/v1/billing/meters/%s/reactivate', $id), $params, $opts);
  82. }
  83. /**
  84. * Retrieves a billing meter given an ID.
  85. *
  86. * @param string $id
  87. * @param null|array $params
  88. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  89. *
  90. * @throws \Stripe\Exception\ApiErrorException if the request fails
  91. *
  92. * @return \Stripe\Billing\Meter
  93. */
  94. public function retrieve($id, $params = null, $opts = null)
  95. {
  96. return $this->request('get', $this->buildPath('/v1/billing/meters/%s', $id), $params, $opts);
  97. }
  98. /**
  99. * Updates a billing meter.
  100. *
  101. * @param string $id
  102. * @param null|array $params
  103. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  104. *
  105. * @throws \Stripe\Exception\ApiErrorException if the request fails
  106. *
  107. * @return \Stripe\Billing\Meter
  108. */
  109. public function update($id, $params = null, $opts = null)
  110. {
  111. return $this->request('post', $this->buildPath('/v1/billing/meters/%s', $id), $params, $opts);
  112. }
  113. }