Work on Stripe log
This commit is contained in:
64
app/models/e_stripe_models.py
Normal file
64
app/models/e_stripe_models.py
Normal file
@@ -0,0 +1,64 @@
|
||||
import datetime, pytz
|
||||
|
||||
from typing import Dict, List, Optional, Set, Union
|
||||
from pydantic import BaseModel, EmailStr, Field, Json, PrivateAttr, ValidationError, validator
|
||||
|
||||
from app.db_sql import redis_lookup_id_random
|
||||
from app.lib_general import log, logging
|
||||
|
||||
from app.models.common_field_schema import base_fields, default_num_bytes
|
||||
|
||||
|
||||
# ### BEGIN ### API Stripe Models ### Stripe_Log_Base() ###
|
||||
class Stripe_Log_Base(BaseModel):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
# id_random: Optional[str] = Field(
|
||||
# **base_fields['stripe_log_id_random'],
|
||||
# alias = 'stripe_log_id_random',
|
||||
# )
|
||||
id: Optional[int] = Field(
|
||||
alias = 'stripe_log_id'
|
||||
)
|
||||
|
||||
account_id_random: Optional[str]
|
||||
account_id: Optional[int]
|
||||
|
||||
name: Optional[str]
|
||||
|
||||
meta_data: Optional[Json]
|
||||
|
||||
notes: Optional[str]
|
||||
created_on: Optional[datetime.datetime] = None
|
||||
updated_on: Optional[datetime.datetime] = None
|
||||
|
||||
# Including other related objects
|
||||
|
||||
_processed_at: datetime.datetime = PrivateAttr(default_factory=datetime.datetime.now)
|
||||
|
||||
@validator('account_id', always=True)
|
||||
def account_id_lookup(cls, v, values, **kwargs):
|
||||
if isinstance(v, int) and v > 0: return v
|
||||
elif id_random := values.get('account_id_random'):
|
||||
return redis_lookup_id_random(record_id_random=id_random, table_name='account')
|
||||
return None
|
||||
# ### END ### API Stripe Models ### Stripe_Log_Base() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Stripe Models ### Stripe_Log_Base_In() ###
|
||||
class Stripe_Log_Base_In(Stripe_Log_Base):
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
meta_data: Optional[str]
|
||||
# ### END ### API Stripe Models ### Stripe_Log_Base_In() ###
|
||||
|
||||
|
||||
# # ### BEGIN ### API Stripe Models ### Stripe_Log_Base_Out() ###
|
||||
# class Stripe_Log_Base_Out(Stripe_Log_Base):
|
||||
# log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
# log.debug(locals())
|
||||
|
||||
# meta_data: Optional[Json]
|
||||
# # ### END ### API Stripe Models ### Stripe_Log_Base_Out() ###
|
||||
Reference in New Issue
Block a user