FileService.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Service;
  4. class FileService extends \Stripe\Service\AbstractService
  5. {
  6. /**
  7. * Returns a list of the files that your account has access to. The files are
  8. * returned sorted by creation date, with the most recently created files appearing
  9. * first.
  10. *
  11. * @param null|array $params
  12. * @param null|array|\Stripe\Util\RequestOptions $opts
  13. *
  14. * @throws \Stripe\Exception\ApiErrorException if the request fails
  15. *
  16. * @return \Stripe\Collection
  17. */
  18. public function all($params = null, $opts = null)
  19. {
  20. return $this->requestCollection('get', '/v1/files', $params, $opts);
  21. }
  22. /**
  23. * Retrieves the details of an existing file object. Supply the unique file ID from
  24. * a file, and Stripe will return the corresponding file object. To access file
  25. * contents, see the <a href="/docs/file-upload#download-file-contents">File Upload
  26. * Guide</a>.
  27. *
  28. * @param string $id
  29. * @param null|array $params
  30. * @param null|array|\Stripe\Util\RequestOptions $opts
  31. *
  32. * @throws \Stripe\Exception\ApiErrorException if the request fails
  33. *
  34. * @return \Stripe\File
  35. */
  36. public function retrieve($id, $params = null, $opts = null)
  37. {
  38. return $this->request('get', $this->buildPath('/v1/files/%s', $id), $params, $opts);
  39. }
  40. /**
  41. * Create a file.
  42. *
  43. * @param null|array $params
  44. * @param null|array|\Stripe\Util\RequestOptions $opts
  45. *
  46. * @return \Stripe\File
  47. */
  48. public function create($params = null, $opts = null)
  49. {
  50. $opts = \Stripe\Util\RequestOptions::parse($opts);
  51. if (!isset($opts->apiBase)) {
  52. $opts->apiBase = $this->getClient()->getFilesBase();
  53. }
  54. // Manually flatten params, otherwise curl's multipart encoder will
  55. // choke on nested null|arrays.
  56. $flatParams = \array_column(\Stripe\Util\Util::flattenParams($params), 1, 0);
  57. return $this->request('post', '/v1/files', $flatParams, $opts);
  58. }
  59. }