ReportRun.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?php
  2. // File generated from our OpenAPI spec
  3. namespace Stripe\Reporting;
  4. /**
  5. * The Report Run object represents an instance of a report type generated with
  6. * specific run parameters. Once the object is created, Stripe begins processing the report.
  7. * When the report has finished running, it will give you a reference to a file
  8. * where you can retrieve your results. For an overview, see
  9. * <a href="https://stripe.com/docs/reporting/statements/api">API Access to Reports</a>.
  10. *
  11. * Note that certain report types can only be run based on your live-mode data (not test-mode
  12. * data), and will error when queried without a <a href="https://stripe.com/docs/keys#test-live-modes">live-mode API key</a>.
  13. *
  14. * @property string $id Unique identifier for the object.
  15. * @property string $object String representing the object's type. Objects of the same type share the same value.
  16. * @property int $created Time at which the object was created. Measured in seconds since the Unix epoch.
  17. * @property null|string $error If something should go wrong during the run, a message about the failure (populated when <code>status=failed</code>).
  18. * @property bool $livemode <code>true</code> if the report is run on live mode data and <code>false</code> if it is run on test mode data.
  19. * @property \Stripe\StripeObject $parameters
  20. * @property string $report_type The ID of the <a href="https://stripe.com/docs/reports/report-types">report type</a> to run, such as <code>&quot;balance.summary.1&quot;</code>.
  21. * @property null|\Stripe\File $result The file object representing the result of the report run (populated when <code>status=succeeded</code>).
  22. * @property string $status Status of this report run. This will be <code>pending</code> when the run is initially created. When the run finishes, this will be set to <code>succeeded</code> and the <code>result</code> field will be populated. Rarely, we may encounter an error, at which point this will be set to <code>failed</code> and the <code>error</code> field will be populated.
  23. * @property null|int $succeeded_at Timestamp at which this run successfully finished (populated when <code>status=succeeded</code>). Measured in seconds since the Unix epoch.
  24. */
  25. class ReportRun extends \Stripe\ApiResource
  26. {
  27. const OBJECT_NAME = 'reporting.report_run';
  28. /**
  29. * Creates a new object and begin running the report. (Certain report types require
  30. * a <a href="https://stripe.com/docs/keys#test-live-modes">live-mode API key</a>.).
  31. *
  32. * @param null|array $params
  33. * @param null|array|string $options
  34. *
  35. * @throws \Stripe\Exception\ApiErrorException if the request fails
  36. *
  37. * @return \Stripe\Reporting\ReportRun the created resource
  38. */
  39. public static function create($params = null, $options = null)
  40. {
  41. self::_validateParams($params);
  42. $url = static::classUrl();
  43. list($response, $opts) = static::_staticRequest('post', $url, $params, $options);
  44. $obj = \Stripe\Util\Util::convertToStripeObject($response->json, $opts);
  45. $obj->setLastResponse($response);
  46. return $obj;
  47. }
  48. /**
  49. * Returns a list of Report Runs, with the most recent appearing first.
  50. *
  51. * @param null|array $params
  52. * @param null|array|string $opts
  53. *
  54. * @throws \Stripe\Exception\ApiErrorException if the request fails
  55. *
  56. * @return \Stripe\Collection<\Stripe\Reporting\ReportRun> of ApiResources
  57. */
  58. public static function all($params = null, $opts = null)
  59. {
  60. $url = static::classUrl();
  61. return static::_requestPage($url, \Stripe\Collection::class, $params, $opts);
  62. }
  63. /**
  64. * Retrieves the details of an existing Report Run.
  65. *
  66. * @param array|string $id the ID of the API resource to retrieve, or an options array containing an `id` key
  67. * @param null|array|string $opts
  68. *
  69. * @throws \Stripe\Exception\ApiErrorException if the request fails
  70. *
  71. * @return \Stripe\Reporting\ReportRun
  72. */
  73. public static function retrieve($id, $opts = null)
  74. {
  75. $opts = \Stripe\Util\RequestOptions::parse($opts);
  76. $instance = new static($id, $opts);
  77. $instance->refresh();
  78. return $instance;
  79. }
  80. }