DocumentUpload.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace Braintree;
  3. use InvalidArgumentException;
  4. /**
  5. * Upload documents to Braintree in exchange for a DocumentUpload object.
  6. *
  7. * An example of creating a document upload with all available fields:
  8. * $result = Braintree\DocumentUpload::create([
  9. * "kind" => Braintree\DocumentUpload::EVIDENCE_DOCUMENT,
  10. * "file" => $pngFile
  11. * ]);
  12. *
  13. * For more information on DocumentUploads, see https://developers.braintreepayments.com/reference/request/document_upload/create
  14. *
  15. * @property-read string $contentType
  16. * @property-read \DateTime $expiresAt
  17. * @property-read string $id
  18. * @property-read string $kind
  19. * @property-read string $name
  20. * @property-read int $size
  21. */
  22. class DocumentUpload extends Base
  23. {
  24. /* DocumentUpload Kind */
  25. const EVIDENCE_DOCUMENT = "evidence_document";
  26. protected function _initialize($documentUploadAttribs)
  27. {
  28. $this->_attributes = $documentUploadAttribs;
  29. }
  30. /**
  31. * Creates a DocumentUpload object
  32. * @param kind The kind of document
  33. * @param file The open file to upload
  34. * @throws InvalidArgumentException if the params are not expected
  35. */
  36. public static function create($params)
  37. {
  38. return Configuration::gateway()->documentUpload()->create($params);
  39. }
  40. public static function factory($attributes)
  41. {
  42. $instance = new self();
  43. $instance->_initialize($attributes);
  44. return $instance;
  45. }
  46. }
  47. class_alias('Braintree\DocumentUpload', 'Braintree_DocumentUpload');