File.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe;
  4. /**
  5. * This is an object representing a file hosted on Stripe's servers. The file may
  6. * have been uploaded by yourself using the <a
  7. * href="https://stripe.com/docs/api#create_file">create file</a> request (for
  8. * example, when uploading dispute evidence) or it may have been created by Stripe
  9. * (for example, the results of a <a href="#scheduled_queries">Sigma scheduled
  10. * query</a>).
  11. *
  12. * Related guide: <a href="https://stripe.com/docs/file-upload">File Upload
  13. * Guide</a>.
  14. *
  15. * @property string $id Unique identifier for the object.
  16. * @property string $object String representing the object's type. Objects of the same type share the same value.
  17. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  18. * @property null|int $expires_at The time at which the file expires and is no longer available in epoch seconds.
  19. * @property null|string $filename A filename for the file, suitable for saving to a filesystem.
  20. * @property null|\Stripe\Collection $links A list of <a href="https://stripe.com/docs/api#file_links">file links</a> that point at this file.
  21. * @property string $purpose The <a href="https://stripe.com/docs/file-upload#uploading-a-file">purpose</a> of the uploaded file.
  22. * @property int $size The size in bytes of the file object.
  23. * @property null|string $title A user friendly title for the document.
  24. * @property null|string $type The type of the file returned (e.g., <code>csv</code>, <code>pdf</code>, <code>jpg</code>, or <code>png</code>).
  25. * @property null|string $url The URL from which the file can be downloaded using your live secret API key.
  26. */
  27. class File extends ApiResource
  28. {
  29. const OBJECT_NAME = 'file';
  30. use ApiOperations\All;
  31. use ApiOperations\Retrieve;
  32. const PURPOSE_ADDITIONAL_VERIFICATION = 'additional_verification';
  33. const PURPOSE_BUSINESS_ICON = 'business_icon';
  34. const PURPOSE_BUSINESS_LOGO = 'business_logo';
  35. const PURPOSE_CUSTOMER_SIGNATURE = 'customer_signature';
  36. const PURPOSE_DISPUTE_EVIDENCE = 'dispute_evidence';
  37. const PURPOSE_IDENTITY_DOCUMENT = 'identity_document';
  38. const PURPOSE_PCI_DOCUMENT = 'pci_document';
  39. const PURPOSE_TAX_DOCUMENT_USER_UPLOAD = 'tax_document_user_upload';
  40. // This resource can have two different object names. In latter API
  41. // versions, only `file` is used, but since stripe-php may be used with
  42. // any API version, we need to support deserializing the older
  43. // `file_upload` object into the same class.
  44. const OBJECT_NAME_ALT = 'file_upload';
  45. use ApiOperations\Create {
  46. create as protected _create;
  47. }
  48. public static function classUrl()
  49. {
  50. return '/v1/files';
  51. }
  52. /**
  53. * @param null|array $params
  54. * @param null|array|string $opts
  55. *
  56. * @throws \Stripe\Exception\ApiErrorException if the request fails
  57. *
  58. * @return \Stripe\File the created file
  59. */
  60. public static function create($params = null, $opts = null)
  61. {
  62. $opts = \Stripe\Util\RequestOptions::parse($opts);
  63. if (null === $opts->apiBase) {
  64. $opts->apiBase = Stripe::$apiUploadBase;
  65. }
  66. // Manually flatten params, otherwise curl's multipart encoder will
  67. // choke on nested arrays.
  68. $flatParams = \array_column(\Stripe\Util\Util::flattenParams($params), 1, 0);
  69. return static::_create($flatParams, $opts);
  70. }
  71. }