File.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe;
  4. /**
  5. * This object represents files hosted on Stripe's servers. You can upload
  6. * files with the <a href="https://stripe.com/docs/api#create_file">create file</a> request
  7. * (for example, when uploading dispute evidence). Stripe also
  8. * creates files independently (for example, the results of a <a href="#scheduled_queries">Sigma scheduled
  9. * query</a>).
  10. *
  11. * Related guide: <a href="https://stripe.com/docs/file-upload">File upload guide</a>
  12. *
  13. * @property string $id Unique identifier for the object.
  14. * @property string $object String representing the object's type. Objects of the same type share the same value.
  15. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  16. * @property null|int $expires_at The file expires and isn't available at this time in epoch seconds.
  17. * @property null|string $filename The suitable name for saving the file to a filesystem.
  18. * @property null|\Stripe\Collection<\Stripe\FileLink> $links A list of <a href="https://stripe.com/docs/api#file_links">file links</a> that point at this file.
  19. * @property string $purpose The <a href="https://stripe.com/docs/file-upload#uploading-a-file">purpose</a> of the uploaded file.
  20. * @property int $size The size of the file object in bytes.
  21. * @property null|string $title A suitable title for the document.
  22. * @property null|string $type The returned file type (for example, <code>csv</code>, <code>pdf</code>, <code>jpg</code>, or <code>png</code>).
  23. * @property null|string $url Use your live secret API key to download the file from this URL.
  24. */
  25. class File extends ApiResource
  26. {
  27. const OBJECT_NAME = 'file';
  28. const PURPOSE_ACCOUNT_REQUIREMENT = 'account_requirement';
  29. const PURPOSE_ADDITIONAL_VERIFICATION = 'additional_verification';
  30. const PURPOSE_BUSINESS_ICON = 'business_icon';
  31. const PURPOSE_BUSINESS_LOGO = 'business_logo';
  32. const PURPOSE_CUSTOMER_SIGNATURE = 'customer_signature';
  33. const PURPOSE_DISPUTE_EVIDENCE = 'dispute_evidence';
  34. const PURPOSE_DOCUMENT_PROVIDER_IDENTITY_DOCUMENT = 'document_provider_identity_document';
  35. const PURPOSE_FINANCE_REPORT_RUN = 'finance_report_run';
  36. const PURPOSE_IDENTITY_DOCUMENT = 'identity_document';
  37. const PURPOSE_IDENTITY_DOCUMENT_DOWNLOADABLE = 'identity_document_downloadable';
  38. const PURPOSE_PCI_DOCUMENT = 'pci_document';
  39. const PURPOSE_SELFIE = 'selfie';
  40. const PURPOSE_SIGMA_SCHEDULED_QUERY = 'sigma_scheduled_query';
  41. const PURPOSE_TAX_DOCUMENT_USER_UPLOAD = 'tax_document_user_upload';
  42. const PURPOSE_TERMINAL_READER_SPLASHSCREEN = 'terminal_reader_splashscreen';
  43. /**
  44. * Returns a list of the files that your account has access to. Stripe sorts and
  45. * returns the files by their creation dates, placing the most recently created
  46. * files at the top.
  47. *
  48. * @param null|array $params
  49. * @param null|array|string $opts
  50. *
  51. * @throws \Stripe\Exception\ApiErrorException if the request fails
  52. *
  53. * @return \Stripe\Collection<\Stripe\File> of ApiResources
  54. */
  55. public static function all($params = null, $opts = null)
  56. {
  57. $url = static::classUrl();
  58. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  59. }
  60. /**
  61. * Retrieves the details of an existing file object. After you supply a unique file
  62. * ID, Stripe returns the corresponding file object. Learn how to <a
  63. * href="/docs/file-upload#download-file-contents">access file contents</a>.
  64. *
  65. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  66. * @param null|array|string $opts
  67. *
  68. * @throws \Stripe\Exception\ApiErrorException if the request fails
  69. *
  70. * @return \Stripe\File
  71. */
  72. public static function retrieve($id, $opts = null)
  73. {
  74. $opts = \Stripe\Util\RequestOptions::parse($opts);
  75. $instance = new static($id, $opts);
  76. $instance->refresh();
  77. return $instance;
  78. }
  79. // This resource can have two different object names. In latter API
  80. // versions, only `file` is used, but since stripe-php may be used with
  81. // any API version, we need to support deserializing the older
  82. // `file_upload` object into the same class.
  83. const OBJECT_NAME_ALT = 'file_upload';
  84. use ApiOperations\Create {
  85. create as protected _create;
  86. }
  87. /**
  88. * @param null|array $params
  89. * @param null|array|string $opts
  90. *
  91. * @throws \Stripe\Exception\ApiErrorException if the request fails
  92. *
  93. * @return \Stripe\File the created file
  94. */
  95. public static function create($params = null, $opts = null)
  96. {
  97. $opts = \Stripe\Util\RequestOptions::parse($opts);
  98. if (null === $opts->apiBase) {
  99. $opts->apiBase = Stripe::$apiUploadBase;
  100. }
  101. // Manually flatten params, otherwise curl's multipart encoder will
  102. // choke on nested arrays.
  103. $flatParams = \array_column(\Stripe\Util\Util::flattenParams($params), 1, 0);
  104. return static::_create($flatParams, $opts);
  105. }
  106. }