Debian Codegraph @

stripe/billing/_meter_event.py

raw
1 # -*- coding: utf-8 -*-
2 # File generated from our OpenAPI spec
3 from stripe._createable_api_resource import CreateableAPIResource
4 from typing import ClassVar, Dict, cast
5 from typing_extensions import Literal, Unpack, TYPE_CHECKING
6
7 if TYPE_CHECKING:
8 from stripe.params.billing._meter_event_create_params import (
9 MeterEventCreateParams,
10 )
11
12
13 class MeterEvent(CreateableAPIResource["MeterEvent"]):
14 """
15 Meter events represent actions that customers take in your system. You can use meter events to bill a customer based on their usage. Meter events are associated with billing meters, which define both the contents of the event's payload and how to aggregate those events.
16 """
17
18 OBJECT_NAME: ClassVar[Literal["billing.meter_event"]] = (
19 "billing.meter_event"
20 )
21 created: int
22 """
23 Time at which the object was created. Measured in seconds since the Unix epoch.
24 """
25 event_name: str
26 """
27 The name of the meter event. Corresponds with the `event_name` field on a meter.
28 """
29 identifier: str
30 """
31 A unique identifier for the event.
32 """
33 livemode: bool
34 """
35 Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
36 """
37 object: Literal["billing.meter_event"]
38 """
39 String representing the object's type. Objects of the same type share the same value.
40 """
41 payload: Dict[str, str]
42 """
43 The payload of the event. This contains the fields corresponding to a meter's `customer_mapping.event_payload_key` (default is `stripe_customer_id`) and `value_settings.event_payload_key` (default is `value`). Read more about the [payload](https://docs.stripe.com/billing/subscriptions/usage-based/meters/configure#meter-configuration-attributes).
44 """
45 timestamp: int
46 """
47 The timestamp passed in when creating the event. Measured in seconds since the Unix epoch.
48 """
49
50 @classmethod
51 def create(
52 cls, **params: Unpack["MeterEventCreateParams"]
53 ) -> "MeterEvent":
54 """
55 Creates a billing meter event.
56 """
57 return cast(
58 "MeterEvent",
59 cls._static_request(
60 "post",
61 cls.class_url(),
62 params=params,
63 ),
64 )
65
66 @classmethod
67 async def create_async(
68 cls, **params: Unpack["MeterEventCreateParams"]
69 ) -> "MeterEvent":
70 """
71 Creates a billing meter event.
72 """
73 return cast(
74 "MeterEvent",
75 await cls._static_request_async(
76 "post",
77 cls.class_url(),
78 params=params,
79 ),
80 )