| 1 |
# -*- coding: utf-8 -*- |
| 2 |
# File generated from our OpenAPI spec |
| 3 |
from importlib import import_module |
| 4 |
from typing import Union |
| 5 |
from typing_extensions import TYPE_CHECKING |
| 6 |
from stripe.v2.core._event import UnknownEventNotification |
| 7 |
from stripe._stripe_object import StripeObject |
| 8 |
|
| 9 |
if TYPE_CHECKING: |
| 10 |
from stripe.events._v1_billing_meter_error_report_triggered_event import ( |
| 11 |
V1BillingMeterErrorReportTriggeredEventNotification, |
| 12 |
) |
| 13 |
from stripe.events._v1_billing_meter_no_meter_found_event import ( |
| 14 |
V1BillingMeterNoMeterFoundEventNotification, |
| 15 |
) |
| 16 |
from stripe.events._v2_core_account_closed_event import ( |
| 17 |
V2CoreAccountClosedEventNotification, |
| 18 |
) |
| 19 |
from stripe.events._v2_core_account_created_event import ( |
| 20 |
V2CoreAccountCreatedEventNotification, |
| 21 |
) |
| 22 |
from stripe.events._v2_core_account_including_configuration_customer_capability_status_updated_event import ( |
| 23 |
V2CoreAccountIncludingConfigurationCustomerCapabilityStatusUpdatedEventNotification, |
| 24 |
) |
| 25 |
from stripe.events._v2_core_account_including_configuration_customer_updated_event import ( |
| 26 |
V2CoreAccountIncludingConfigurationCustomerUpdatedEventNotification, |
| 27 |
) |
| 28 |
from stripe.events._v2_core_account_including_configuration_merchant_capability_status_updated_event import ( |
| 29 |
V2CoreAccountIncludingConfigurationMerchantCapabilityStatusUpdatedEventNotification, |
| 30 |
) |
| 31 |
from stripe.events._v2_core_account_including_configuration_merchant_updated_event import ( |
| 32 |
V2CoreAccountIncludingConfigurationMerchantUpdatedEventNotification, |
| 33 |
) |
| 34 |
from stripe.events._v2_core_account_including_configuration_recipient_capability_status_updated_event import ( |
| 35 |
V2CoreAccountIncludingConfigurationRecipientCapabilityStatusUpdatedEventNotification, |
| 36 |
) |
| 37 |
from stripe.events._v2_core_account_including_configuration_recipient_updated_event import ( |
| 38 |
V2CoreAccountIncludingConfigurationRecipientUpdatedEventNotification, |
| 39 |
) |
| 40 |
from stripe.events._v2_core_account_including_defaults_updated_event import ( |
| 41 |
V2CoreAccountIncludingDefaultsUpdatedEventNotification, |
| 42 |
) |
| 43 |
from stripe.events._v2_core_account_including_future_requirements_updated_event import ( |
| 44 |
V2CoreAccountIncludingFutureRequirementsUpdatedEventNotification, |
| 45 |
) |
| 46 |
from stripe.events._v2_core_account_including_identity_updated_event import ( |
| 47 |
V2CoreAccountIncludingIdentityUpdatedEventNotification, |
| 48 |
) |
| 49 |
from stripe.events._v2_core_account_including_requirements_updated_event import ( |
| 50 |
V2CoreAccountIncludingRequirementsUpdatedEventNotification, |
| 51 |
) |
| 52 |
from stripe.events._v2_core_account_link_returned_event import ( |
| 53 |
V2CoreAccountLinkReturnedEventNotification, |
| 54 |
) |
| 55 |
from stripe.events._v2_core_account_person_created_event import ( |
| 56 |
V2CoreAccountPersonCreatedEventNotification, |
| 57 |
) |
| 58 |
from stripe.events._v2_core_account_person_deleted_event import ( |
| 59 |
V2CoreAccountPersonDeletedEventNotification, |
| 60 |
) |
| 61 |
from stripe.events._v2_core_account_person_updated_event import ( |
| 62 |
V2CoreAccountPersonUpdatedEventNotification, |
| 63 |
) |
| 64 |
from stripe.events._v2_core_account_updated_event import ( |
| 65 |
V2CoreAccountUpdatedEventNotification, |
| 66 |
) |
| 67 |
from stripe.events._v2_core_event_destination_ping_event import ( |
| 68 |
V2CoreEventDestinationPingEventNotification, |
| 69 |
) |
| 70 |
|
| 71 |
|
| 72 |
_V2_EVENT_CLASS_LOOKUP = { |
| 73 |
"v1.billing.meter.error_report_triggered": ( |
| 74 |
"stripe.events._v1_billing_meter_error_report_triggered_event", |
| 75 |
"V1BillingMeterErrorReportTriggeredEvent", |
| 76 |
), |
| 77 |
"v1.billing.meter.no_meter_found": ( |
| 78 |
"stripe.events._v1_billing_meter_no_meter_found_event", |
| 79 |
"V1BillingMeterNoMeterFoundEvent", |
| 80 |
), |
| 81 |
"v2.core.account.closed": ( |
| 82 |
"stripe.events._v2_core_account_closed_event", |
| 83 |
"V2CoreAccountClosedEvent", |
| 84 |
), |
| 85 |
"v2.core.account.created": ( |
| 86 |
"stripe.events._v2_core_account_created_event", |
| 87 |
"V2CoreAccountCreatedEvent", |
| 88 |
), |
| 89 |
"v2.core.account[configuration.customer].capability_status_updated": ( |
| 90 |
"stripe.events._v2_core_account_including_configuration_customer_capability_status_updated_event", |
| 91 |
"V2CoreAccountIncludingConfigurationCustomerCapabilityStatusUpdatedEvent", |
| 92 |
), |
| 93 |
"v2.core.account[configuration.customer].updated": ( |
| 94 |
"stripe.events._v2_core_account_including_configuration_customer_updated_event", |
| 95 |
"V2CoreAccountIncludingConfigurationCustomerUpdatedEvent", |
| 96 |
), |
| 97 |
"v2.core.account[configuration.merchant].capability_status_updated": ( |
| 98 |
"stripe.events._v2_core_account_including_configuration_merchant_capability_status_updated_event", |
| 99 |
"V2CoreAccountIncludingConfigurationMerchantCapabilityStatusUpdatedEvent", |
| 100 |
), |
| 101 |
"v2.core.account[configuration.merchant].updated": ( |
| 102 |
"stripe.events._v2_core_account_including_configuration_merchant_updated_event", |
| 103 |
"V2CoreAccountIncludingConfigurationMerchantUpdatedEvent", |
| 104 |
), |
| 105 |
"v2.core.account[configuration.recipient].capability_status_updated": ( |
| 106 |
"stripe.events._v2_core_account_including_configuration_recipient_capability_status_updated_event", |
| 107 |
"V2CoreAccountIncludingConfigurationRecipientCapabilityStatusUpdatedEvent", |
| 108 |
), |
| 109 |
"v2.core.account[configuration.recipient].updated": ( |
| 110 |
"stripe.events._v2_core_account_including_configuration_recipient_updated_event", |
| 111 |
"V2CoreAccountIncludingConfigurationRecipientUpdatedEvent", |
| 112 |
), |
| 113 |
"v2.core.account[defaults].updated": ( |
| 114 |
"stripe.events._v2_core_account_including_defaults_updated_event", |
| 115 |
"V2CoreAccountIncludingDefaultsUpdatedEvent", |
| 116 |
), |
| 117 |
"v2.core.account[future_requirements].updated": ( |
| 118 |
"stripe.events._v2_core_account_including_future_requirements_updated_event", |
| 119 |
"V2CoreAccountIncludingFutureRequirementsUpdatedEvent", |
| 120 |
), |
| 121 |
"v2.core.account[identity].updated": ( |
| 122 |
"stripe.events._v2_core_account_including_identity_updated_event", |
| 123 |
"V2CoreAccountIncludingIdentityUpdatedEvent", |
| 124 |
), |
| 125 |
"v2.core.account[requirements].updated": ( |
| 126 |
"stripe.events._v2_core_account_including_requirements_updated_event", |
| 127 |
"V2CoreAccountIncludingRequirementsUpdatedEvent", |
| 128 |
), |
| 129 |
"v2.core.account_link.returned": ( |
| 130 |
"stripe.events._v2_core_account_link_returned_event", |
| 131 |
"V2CoreAccountLinkReturnedEvent", |
| 132 |
), |
| 133 |
"v2.core.account_person.created": ( |
| 134 |
"stripe.events._v2_core_account_person_created_event", |
| 135 |
"V2CoreAccountPersonCreatedEvent", |
| 136 |
), |
| 137 |
"v2.core.account_person.deleted": ( |
| 138 |
"stripe.events._v2_core_account_person_deleted_event", |
| 139 |
"V2CoreAccountPersonDeletedEvent", |
| 140 |
), |
| 141 |
"v2.core.account_person.updated": ( |
| 142 |
"stripe.events._v2_core_account_person_updated_event", |
| 143 |
"V2CoreAccountPersonUpdatedEvent", |
| 144 |
), |
| 145 |
"v2.core.account.updated": ( |
| 146 |
"stripe.events._v2_core_account_updated_event", |
| 147 |
"V2CoreAccountUpdatedEvent", |
| 148 |
), |
| 149 |
"v2.core.event_destination.ping": ( |
| 150 |
"stripe.events._v2_core_event_destination_ping_event", |
| 151 |
"V2CoreEventDestinationPingEvent", |
| 152 |
), |
| 153 |
} |
| 154 |
|
| 155 |
|
| 156 |
def get_v2_event_class(type_: str): |
| 157 |
if type_ not in _V2_EVENT_CLASS_LOOKUP: |
| 158 |
return StripeObject |
| 159 |
|
| 160 |
import_path, class_name = _V2_EVENT_CLASS_LOOKUP[type_] |
| 161 |
return getattr( |
| 162 |
import_module(import_path), |
| 163 |
class_name, |
| 164 |
) |
| 165 |
|
| 166 |
|
| 167 |
_V2_EVENT_NOTIFICATION_CLASS_LOOKUP = { |
| 168 |
"v1.billing.meter.error_report_triggered": ( |
| 169 |
"stripe.events._v1_billing_meter_error_report_triggered_event", |
| 170 |
"V1BillingMeterErrorReportTriggeredEventNotification", |
| 171 |
), |
| 172 |
"v1.billing.meter.no_meter_found": ( |
| 173 |
"stripe.events._v1_billing_meter_no_meter_found_event", |
| 174 |
"V1BillingMeterNoMeterFoundEventNotification", |
| 175 |
), |
| 176 |
"v2.core.account.closed": ( |
| 177 |
"stripe.events._v2_core_account_closed_event", |
| 178 |
"V2CoreAccountClosedEventNotification", |
| 179 |
), |
| 180 |
"v2.core.account.created": ( |
| 181 |
"stripe.events._v2_core_account_created_event", |
| 182 |
"V2CoreAccountCreatedEventNotification", |
| 183 |
), |
| 184 |
"v2.core.account[configuration.customer].capability_status_updated": ( |
| 185 |
"stripe.events._v2_core_account_including_configuration_customer_capability_status_updated_event", |
| 186 |
"V2CoreAccountIncludingConfigurationCustomerCapabilityStatusUpdatedEventNotification", |
| 187 |
), |
| 188 |
"v2.core.account[configuration.customer].updated": ( |
| 189 |
"stripe.events._v2_core_account_including_configuration_customer_updated_event", |
| 190 |
"V2CoreAccountIncludingConfigurationCustomerUpdatedEventNotification", |
| 191 |
), |
| 192 |
"v2.core.account[configuration.merchant].capability_status_updated": ( |
| 193 |
"stripe.events._v2_core_account_including_configuration_merchant_capability_status_updated_event", |
| 194 |
"V2CoreAccountIncludingConfigurationMerchantCapabilityStatusUpdatedEventNotification", |
| 195 |
), |
| 196 |
"v2.core.account[configuration.merchant].updated": ( |
| 197 |
"stripe.events._v2_core_account_including_configuration_merchant_updated_event", |
| 198 |
"V2CoreAccountIncludingConfigurationMerchantUpdatedEventNotification", |
| 199 |
), |
| 200 |
"v2.core.account[configuration.recipient].capability_status_updated": ( |
| 201 |
"stripe.events._v2_core_account_including_configuration_recipient_capability_status_updated_event", |
| 202 |
"V2CoreAccountIncludingConfigurationRecipientCapabilityStatusUpdatedEventNotification", |
| 203 |
), |
| 204 |
"v2.core.account[configuration.recipient].updated": ( |
| 205 |
"stripe.events._v2_core_account_including_configuration_recipient_updated_event", |
| 206 |
"V2CoreAccountIncludingConfigurationRecipientUpdatedEventNotification", |
| 207 |
), |
| 208 |
"v2.core.account[defaults].updated": ( |
| 209 |
"stripe.events._v2_core_account_including_defaults_updated_event", |
| 210 |
"V2CoreAccountIncludingDefaultsUpdatedEventNotification", |
| 211 |
), |
| 212 |
"v2.core.account[future_requirements].updated": ( |
| 213 |
"stripe.events._v2_core_account_including_future_requirements_updated_event", |
| 214 |
"V2CoreAccountIncludingFutureRequirementsUpdatedEventNotification", |
| 215 |
), |
| 216 |
"v2.core.account[identity].updated": ( |
| 217 |
"stripe.events._v2_core_account_including_identity_updated_event", |
| 218 |
"V2CoreAccountIncludingIdentityUpdatedEventNotification", |
| 219 |
), |
| 220 |
"v2.core.account[requirements].updated": ( |
| 221 |
"stripe.events._v2_core_account_including_requirements_updated_event", |
| 222 |
"V2CoreAccountIncludingRequirementsUpdatedEventNotification", |
| 223 |
), |
| 224 |
"v2.core.account_link.returned": ( |
| 225 |
"stripe.events._v2_core_account_link_returned_event", |
| 226 |
"V2CoreAccountLinkReturnedEventNotification", |
| 227 |
), |
| 228 |
"v2.core.account_person.created": ( |
| 229 |
"stripe.events._v2_core_account_person_created_event", |
| 230 |
"V2CoreAccountPersonCreatedEventNotification", |
| 231 |
), |
| 232 |
"v2.core.account_person.deleted": ( |
| 233 |
"stripe.events._v2_core_account_person_deleted_event", |
| 234 |
"V2CoreAccountPersonDeletedEventNotification", |
| 235 |
), |
| 236 |
"v2.core.account_person.updated": ( |
| 237 |
"stripe.events._v2_core_account_person_updated_event", |
| 238 |
"V2CoreAccountPersonUpdatedEventNotification", |
| 239 |
), |
| 240 |
"v2.core.account.updated": ( |
| 241 |
"stripe.events._v2_core_account_updated_event", |
| 242 |
"V2CoreAccountUpdatedEventNotification", |
| 243 |
), |
| 244 |
"v2.core.event_destination.ping": ( |
| 245 |
"stripe.events._v2_core_event_destination_ping_event", |
| 246 |
"V2CoreEventDestinationPingEventNotification", |
| 247 |
), |
| 248 |
} |
| 249 |
|
| 250 |
|
| 251 |
def get_v2_event_notification_class(type_: str): |
| 252 |
if type_ not in _V2_EVENT_NOTIFICATION_CLASS_LOOKUP: |
| 253 |
return UnknownEventNotification |
| 254 |
|
| 255 |
import_path, class_name = _V2_EVENT_NOTIFICATION_CLASS_LOOKUP[type_] |
| 256 |
return getattr( |
| 257 |
import_module(import_path), |
| 258 |
class_name, |
| 259 |
) |
| 260 |
|
| 261 |
|
| 262 |
ALL_EVENT_NOTIFICATIONS = Union[ |
| 263 |
"V1BillingMeterErrorReportTriggeredEventNotification", |
| 264 |
"V1BillingMeterNoMeterFoundEventNotification", |
| 265 |
"V2CoreAccountClosedEventNotification", |
| 266 |
"V2CoreAccountCreatedEventNotification", |
| 267 |
"V2CoreAccountIncludingConfigurationCustomerCapabilityStatusUpdatedEventNotification", |
| 268 |
"V2CoreAccountIncludingConfigurationCustomerUpdatedEventNotification", |
| 269 |
"V2CoreAccountIncludingConfigurationMerchantCapabilityStatusUpdatedEventNotification", |
| 270 |
"V2CoreAccountIncludingConfigurationMerchantUpdatedEventNotification", |
| 271 |
"V2CoreAccountIncludingConfigurationRecipientCapabilityStatusUpdatedEventNotification", |
| 272 |
"V2CoreAccountIncludingConfigurationRecipientUpdatedEventNotification", |
| 273 |
"V2CoreAccountIncludingDefaultsUpdatedEventNotification", |
| 274 |
"V2CoreAccountIncludingFutureRequirementsUpdatedEventNotification", |
| 275 |
"V2CoreAccountIncludingIdentityUpdatedEventNotification", |
| 276 |
"V2CoreAccountIncludingRequirementsUpdatedEventNotification", |
| 277 |
"V2CoreAccountLinkReturnedEventNotification", |
| 278 |
"V2CoreAccountPersonCreatedEventNotification", |
| 279 |
"V2CoreAccountPersonDeletedEventNotification", |
| 280 |
"V2CoreAccountPersonUpdatedEventNotification", |
| 281 |
"V2CoreAccountUpdatedEventNotification", |
| 282 |
"V2CoreEventDestinationPingEventNotification", |
| 283 |
] |