| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# File generated from our OpenAPI spec |
| 3 |
from stripe._createable_api_resource import CreateableAPIResource |
| 4 |
from stripe._list_object import ListObject |
| 5 |
from stripe._listable_api_resource import ListableAPIResource |
| 6 |
from stripe._stripe_object import StripeObject |
| 7 |
from typing import ClassVar, List, Optional, cast |
| 8 |
from typing_extensions import Literal, Unpack, TYPE_CHECKING |
| 9 |
|
| 10 |
if TYPE_CHECKING: |
| 11 |
from stripe._file import File |
| 12 |
from stripe.params.reporting._report_run_create_params import ( |
| 13 |
ReportRunCreateParams, |
| 14 |
) |
| 15 |
from stripe.params.reporting._report_run_list_params import ( |
| 16 |
ReportRunListParams, |
| 17 |
) |
| 18 |
from stripe.params.reporting._report_run_retrieve_params import ( |
| 19 |
ReportRunRetrieveParams, |
| 20 |
) |
| 21 |
|
| 22 |
|
| 23 |
class ReportRun( |
| 24 |
CreateableAPIResource["ReportRun"], |
| 25 |
ListableAPIResource["ReportRun"], |
| 26 |
): |
| 27 |
""" |
| 28 |
The Report Run object represents an instance of a report type generated with |
| 29 |
specific run parameters. Once the object is created, Stripe begins processing the report. |
| 30 |
When the report has finished running, it will give you a reference to a file |
| 31 |
where you can retrieve your results. For an overview, see |
| 32 |
[API Access to Reports](https://docs.stripe.com/reporting/statements/api). |
| 33 |
|
| 34 |
Note that certain report types can only be run based on your live-mode data (not test-mode |
| 35 |
data), and will error when queried without a [live-mode API key](https://docs.stripe.com/keys#test-live-modes). |
| 36 |
""" |
| 37 |
|
| 38 |
OBJECT_NAME: ClassVar[Literal["reporting.report_run"]] = ( |
| 39 |
"reporting.report_run" |
| 40 |
) |
| 41 |
|
| 42 |
class Parameters(StripeObject): |
| 43 |
columns: Optional[List[str]] |
| 44 |
""" |
| 45 |
The set of output columns requested for inclusion in the report run. |
| 46 |
""" |
| 47 |
connected_account: Optional[str] |
| 48 |
""" |
| 49 |
Connected account ID by which to filter the report run. |
| 50 |
""" |
| 51 |
currency: Optional[str] |
| 52 |
""" |
| 53 |
Currency of objects to be included in the report run. |
| 54 |
""" |
| 55 |
interval_end: Optional[int] |
| 56 |
""" |
| 57 |
Ending timestamp of data to be included in the report run. Can be any UTC timestamp between 1 second after the user specified `interval_start` and 1 second before this report's last `data_available_end` value. |
| 58 |
""" |
| 59 |
interval_start: Optional[int] |
| 60 |
""" |
| 61 |
Starting timestamp of data to be included in the report run. Can be any UTC timestamp between 1 second after this report's `data_available_start` and 1 second before the user specified `interval_end` value. |
| 62 |
""" |
| 63 |
payout: Optional[str] |
| 64 |
""" |
| 65 |
Payout ID by which to filter the report run. |
| 66 |
""" |
| 67 |
reporting_category: Optional[str] |
| 68 |
""" |
| 69 |
Category of balance transactions to be included in the report run. |
| 70 |
""" |
| 71 |
timezone: Optional[str] |
| 72 |
""" |
| 73 |
Defaults to `Etc/UTC`. The output timezone for all timestamps in the report. A list of possible time zone values is maintained at the [IANA Time Zone Database](http://www.iana.org/time-zones). Has no effect on `interval_start` or `interval_end`. |
| 74 |
""" |
| 75 |
|
| 76 |
created: int |
| 77 |
""" |
| 78 |
Time at which the object was created. Measured in seconds since the Unix epoch. |
| 79 |
""" |
| 80 |
error: Optional[str] |
| 81 |
""" |
| 82 |
If something should go wrong during the run, a message about the failure (populated when |
| 83 |
`status=failed`). |
| 84 |
""" |
| 85 |
id: str |
| 86 |
""" |
| 87 |
Unique identifier for the object. |
| 88 |
""" |
| 89 |
livemode: bool |
| 90 |
""" |
| 91 |
`true` if the report is run on live mode data and `false` if it is run on test mode data. |
| 92 |
""" |
| 93 |
object: Literal["reporting.report_run"] |
| 94 |
""" |
| 95 |
String representing the object's type. Objects of the same type share the same value. |
| 96 |
""" |
| 97 |
parameters: Parameters |
| 98 |
report_type: str |
| 99 |
""" |
| 100 |
The ID of the [report type](https://docs.stripe.com/reports/report-types) to run, such as `"balance.summary.1"`. |
| 101 |
""" |
| 102 |
result: Optional["File"] |
| 103 |
""" |
| 104 |
The file object representing the result of the report run (populated when |
| 105 |
`status=succeeded`). |
| 106 |
""" |
| 107 |
status: str |
| 108 |
""" |
| 109 |
Status of this report run. This will be `pending` when the run is initially created. |
| 110 |
When the run finishes, this will be set to `succeeded` and the `result` field will be populated. |
| 111 |
Rarely, we may encounter an error, at which point this will be set to `failed` and the `error` field will be populated. |
| 112 |
""" |
| 113 |
succeeded_at: Optional[int] |
| 114 |
""" |
| 115 |
Timestamp at which this run successfully finished (populated when |
| 116 |
`status=succeeded`). Measured in seconds since the Unix epoch. |
| 117 |
""" |
| 118 |
|
| 119 |
@classmethod |
| 120 |
def create(cls, **params: Unpack["ReportRunCreateParams"]) -> "ReportRun": |
| 121 |
""" |
| 122 |
Creates a new object and begin running the report. (Certain report types require a [live-mode API key](https://stripe.com/docs/keys#test-live-modes).) |
| 123 |
""" |
| 124 |
return cast( |
| 125 |
"ReportRun", |
| 126 |
cls._static_request( |
| 127 |
"post", |
| 128 |
cls.class_url(), |
| 129 |
params=params, |
| 130 |
), |
| 131 |
) |
| 132 |
|
| 133 |
@classmethod |
| 134 |
async def create_async( |
| 135 |
cls, **params: Unpack["ReportRunCreateParams"] |
| 136 |
) -> "ReportRun": |
| 137 |
""" |
| 138 |
Creates a new object and begin running the report. (Certain report types require a [live-mode API key](https://stripe.com/docs/keys#test-live-modes).) |
| 139 |
""" |
| 140 |
return cast( |
| 141 |
"ReportRun", |
| 142 |
await cls._static_request_async( |
| 143 |
"post", |
| 144 |
cls.class_url(), |
| 145 |
params=params, |
| 146 |
), |
| 147 |
) |
| 148 |
|
| 149 |
@classmethod |
| 150 |
def list( |
| 151 |
cls, **params: Unpack["ReportRunListParams"] |
| 152 |
) -> ListObject["ReportRun"]: |
| 153 |
""" |
| 154 |
Returns a list of Report Runs, with the most recent appearing first. |
| 155 |
""" |
| 156 |
result = cls._static_request( |
| 157 |
"get", |
| 158 |
cls.class_url(), |
| 159 |
params=params, |
| 160 |
) |
| 161 |
if not isinstance(result, ListObject): |
| 162 |
raise TypeError( |
| 163 |
"Expected list object from API, got %s" |
| 164 |
% (type(result).__name__) |
| 165 |
) |
| 166 |
|
| 167 |
return result |
| 168 |
|
| 169 |
@classmethod |
| 170 |
async def list_async( |
| 171 |
cls, **params: Unpack["ReportRunListParams"] |
| 172 |
) -> ListObject["ReportRun"]: |
| 173 |
""" |
| 174 |
Returns a list of Report Runs, with the most recent appearing first. |
| 175 |
""" |
| 176 |
result = await cls._static_request_async( |
| 177 |
"get", |
| 178 |
cls.class_url(), |
| 179 |
params=params, |
| 180 |
) |
| 181 |
if not isinstance(result, ListObject): |
| 182 |
raise TypeError( |
| 183 |
"Expected list object from API, got %s" |
| 184 |
% (type(result).__name__) |
| 185 |
) |
| 186 |
|
| 187 |
return result |
| 188 |
|
| 189 |
@classmethod |
| 190 |
def retrieve( |
| 191 |
cls, id: str, **params: Unpack["ReportRunRetrieveParams"] |
| 192 |
) -> "ReportRun": |
| 193 |
""" |
| 194 |
Retrieves the details of an existing Report Run. |
| 195 |
""" |
| 196 |
instance = cls(id, **params) |
| 197 |
instance.refresh() |
| 198 |
return instance |
| 199 |
|
| 200 |
@classmethod |
| 201 |
async def retrieve_async( |
| 202 |
cls, id: str, **params: Unpack["ReportRunRetrieveParams"] |
| 203 |
) -> "ReportRun": |
| 204 |
""" |
| 205 |
Retrieves the details of an existing Report Run. |
| 206 |
""" |
| 207 |
instance = cls(id, **params) |
| 208 |
await instance.refresh_async() |
| 209 |
return instance |
| 210 |
|
| 211 |
_inner_class_types = {"parameters": Parameters} |