QuoteService.php 5.7 KB

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