FileLink.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe;
  4. /**
  5. * To share the contents of a <code>File</code> object with non-Stripe users, you can
  6. * create a <code>FileLink</code>. <code>FileLink</code>s contain a URL that you can use to
  7. * retrieve the contents of the file without authentication.
  8. *
  9. * @property string $id Unique identifier for the object.
  10. * @property string $object String representing the object's type. Objects of the same type share the same value.
  11. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  12. * @property bool $expired Returns if the link is already expired.
  13. * @property null|int $expires_at Time that the link expires.
  14. * @property string|\Stripe\File $file The file object this link points to.
  15. * @property bool $livemode Has the value <code>true</code> if the object exists in live mode or the value <code>false</code> if the object exists in test mode.
  16. * @property \Stripe\StripeObject $metadata Set of <a href="https://stripe.com/docs/api/metadata">key-value pairs</a> that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
  17. * @property null|string $url The publicly accessible URL to download the file.
  18. */
  19. class FileLink extends ApiResource
  20. {
  21. const OBJECT_NAME = 'file_link';
  22. use ApiOperations\Update;
  23. /**
  24. * Creates a new file link object.
  25. *
  26. * @param null|array $params
  27. * @param null|array|string $options
  28. *
  29. * @throws \Stripe\Exception\ApiErrorException if the request fails
  30. *
  31. * @return \Stripe\FileLink the created resource
  32. */
  33. public static function create($params = null, $options = null)
  34. {
  35. self::_validateParams($params);
  36. $url = static::classUrl();
  37. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  38. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  39. $obj->setLastResponse($response);
  40. return $obj;
  41. }
  42. /**
  43. * Returns a list of file links.
  44. *
  45. * @param null|array $params
  46. * @param null|array|string $opts
  47. *
  48. * @throws \Stripe\Exception\ApiErrorException if the request fails
  49. *
  50. * @return \Stripe\Collection<\Stripe\FileLink> of ApiResources
  51. */
  52. public static function all($params = null, $opts = null)
  53. {
  54. $url = static::classUrl();
  55. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  56. }
  57. /**
  58. * Retrieves the file link with the given ID.
  59. *
  60. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  61. * @param null|array|string $opts
  62. *
  63. * @throws \Stripe\Exception\ApiErrorException if the request fails
  64. *
  65. * @return \Stripe\FileLink
  66. */
  67. public static function retrieve($id, $opts = null)
  68. {
  69. $opts = \Stripe\Util\RequestOptions::parse($opts);
  70. $instance = new static($id, $opts);
  71. $instance->refresh();
  72. return $instance;
  73. }
  74. /**
  75. * Updates an existing file link object. Expired links can no longer be updated.
  76. *
  77. * @param string $id the ID of the resource to update
  78. * @param null|array $params
  79. * @param null|array|string $opts
  80. *
  81. * @throws \Stripe\Exception\ApiErrorException if the request fails
  82. *
  83. * @return \Stripe\FileLink the updated resource
  84. */
  85. public static function update($id, $params = null, $opts = null)
  86. {
  87. self::_validateParams($params);
  88. $url = static::resourceUrl($id);
  89. list($response, $opts) = static::_staticRequest('post', $url, $params, $opts);
  90. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  91. $obj->setLastResponse($response);
  92. return $obj;
  93. }
  94. }