QuoteService.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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 QuoteService extends \Stripe\Service\AbstractService
  9. {
  10. /**
  11. * Accepts the specified quote.
  12. *
  13. * @param string $id
  14. * @param null|array $params
  15. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  16. *
  17. * @throws \Stripe\Exception\ApiErrorException if the request fails
  18. *
  19. * @return \Stripe\Quote
  20. */
  21. public function accept($id, $params = null, $opts = null)
  22. {
  23. return $this->request('post', $this->buildPath('/v1/quotes/%s/accept', $id), $params, $opts);
  24. }
  25. /**
  26. * Returns a list of your quotes.
  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\Collection<\Stripe\Quote>
  34. */
  35. public function all($params = null, $opts = null)
  36. {
  37. return $this->requestCollection('get', '/v1/quotes', $params, $opts);
  38. }
  39. /**
  40. * When retrieving a quote, there is an includable <a
  41. * href="https://stripe.com/docs/api/quotes/object#quote_object-computed-upfront-line_items"><strong>computed.upfront.line_items</strong></a>
  42. * property containing the first handful of those items. There is also a URL where
  43. * you can retrieve the full (paginated) list of upfront line items.
  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\Collection<\Stripe\LineItem>
  52. */
  53. public function allComputedUpfrontLineItems($id, $params = null, $opts = null)
  54. {
  55. return $this->requestCollection('get', $this->buildPath('/v1/quotes/%s/computed_upfront_line_items', $id), $params, $opts);
  56. }
  57. /**
  58. * When retrieving a quote, there is an includable <strong>line_items</strong>
  59. * property containing the first handful of those items. There is also a URL where
  60. * you can retrieve the full (paginated) list of line items.
  61. *
  62. * @param string $id
  63. * @param null|array $params
  64. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  65. *
  66. * @throws \Stripe\Exception\ApiErrorException if the request fails
  67. *
  68. * @return \Stripe\Collection<\Stripe\LineItem>
  69. */
  70. public function allLineItems($id, $params = null, $opts = null)
  71. {
  72. return $this->requestCollection('get', $this->buildPath('/v1/quotes/%s/line_items', $id), $params, $opts);
  73. }
  74. /**
  75. * Cancels the quote.
  76. *
  77. * @param string $id
  78. * @param null|array $params
  79. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  80. *
  81. * @throws \Stripe\Exception\ApiErrorException if the request fails
  82. *
  83. * @return \Stripe\Quote
  84. */
  85. public function cancel($id, $params = null, $opts = null)
  86. {
  87. return $this->request('post', $this->buildPath('/v1/quotes/%s/cancel', $id), $params, $opts);
  88. }
  89. /**
  90. * A quote models prices and services for a customer. Default options for
  91. * <code>header</code>, <code>description</code>, <code>footer</code>, and
  92. * <code>expires_at</code> can be set in the dashboard via the <a
  93. * href="https://dashboard.stripe.com/settings/billing/quote">quote template</a>.
  94. *
  95. * @param null|array $params
  96. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  97. *
  98. * @throws \Stripe\Exception\ApiErrorException if the request fails
  99. *
  100. * @return \Stripe\Quote
  101. */
  102. public function create($params = null, $opts = null)
  103. {
  104. return $this->request('post', '/v1/quotes', $params, $opts);
  105. }
  106. /**
  107. * Finalizes the quote.
  108. *
  109. * @param string $id
  110. * @param null|array $params
  111. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  112. *
  113. * @throws \Stripe\Exception\ApiErrorException if the request fails
  114. *
  115. * @return \Stripe\Quote
  116. */
  117. public function finalizeQuote($id, $params = null, $opts = null)
  118. {
  119. return $this->request('post', $this->buildPath('/v1/quotes/%s/finalize', $id), $params, $opts);
  120. }
  121. /**
  122. * Download the PDF for a finalized quote. Explanation for special handling can be
  123. * found <a href="https://docs.corp.stripe.com/quotes/overview#quote_pdf">here</a>.
  124. *
  125. * @param string $id
  126. * @param callable $readBodyChunkCallable
  127. * @param null|array $params
  128. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  129. *
  130. * @throws \Stripe\Exception\ApiErrorException if the request fails
  131. *
  132. * @return mixed
  133. */
  134. public function pdf($id, $readBodyChunkCallable, $params = null, $opts = null)
  135. {
  136. $opts = \Stripe\Util\RequestOptions::parse($opts);
  137. if (!isset($opts->apiBase)) {
  138. $opts->apiBase = $this->getClient()->getFilesBase();
  139. }
  140. return $this->requestStream('get', $this->buildPath('/v1/quotes/%s/pdf', $id), $readBodyChunkCallable, $params, $opts);
  141. }
  142. /**
  143. * Retrieves the quote with the given ID.
  144. *
  145. * @param string $id
  146. * @param null|array $params
  147. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  148. *
  149. * @throws \Stripe\Exception\ApiErrorException if the request fails
  150. *
  151. * @return \Stripe\Quote
  152. */
  153. public function retrieve($id, $params = null, $opts = null)
  154. {
  155. return $this->request('get', $this->buildPath('/v1/quotes/%s', $id), $params, $opts);
  156. }
  157. /**
  158. * A quote models prices and services for a customer.
  159. *
  160. * @param string $id
  161. * @param null|array $params
  162. * @param null|RequestOptionsArray|\Stripe\Util\RequestOptions $opts
  163. *
  164. * @throws \Stripe\Exception\ApiErrorException if the request fails
  165. *
  166. * @return \Stripe\Quote
  167. */
  168. public function update($id, $params = null, $opts = null)
  169. {
  170. return $this->request('post', $this->buildPath('/v1/quotes/%s', $id), $params, $opts);
  171. }
  172. }