Working on data importing. Mainly for IDAA membership.
This commit is contained in:
@@ -11,7 +11,7 @@ from app.routers.api_crud import delete_obj_template, get_obj_template, get_obj_
|
||||
|
||||
# from app.methods.membership_person_methods import load_membership_person_obj
|
||||
from app.methods.order_methods import get_order_rec_list, load_order_obj
|
||||
from app.methods.person_methods import create_update_person_obj, get_person_rec_list, load_person_obj, update_person_obj
|
||||
from app.methods.person_methods import create_update_person_obj, get_person_rec_list, get_person_rec_w_external_id, load_person_obj, update_person_obj
|
||||
|
||||
from app.models.person_models import Person_Base
|
||||
from app.models.response_models import Resp_Body_Base, mk_resp
|
||||
@@ -179,6 +179,57 @@ async def get_person_obj_li(
|
||||
return result
|
||||
|
||||
|
||||
# ### BEGIN ### API Person ### person_obj_external_id() ###
|
||||
# NOTE: This endpoint is a little different. It will likely be used to help log in the person/user coming from an external service (Cvent).
|
||||
# Updated 2021-08-19
|
||||
@router.get('/person/external_id', response_model=Resp_Body_Base)
|
||||
async def person_obj_external_id(
|
||||
account_id: str = Query(..., min_length=1, max_length=22),
|
||||
external_id: str = Query(..., min_length=1, max_length=75),
|
||||
limit: int = 500,
|
||||
enabled: str = 'enabled',
|
||||
inc_address: bool = False,
|
||||
inc_contact: bool = False,
|
||||
# inc_person: bool = False,
|
||||
inc_user: bool = False,
|
||||
inc_user_role_list: bool = False,
|
||||
x_account_id: str = Header(...),
|
||||
by_alias: Optional[bool] = True,
|
||||
exclude_unset: Optional[bool] = True,
|
||||
response: Response = Response,
|
||||
):
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
# if account_id := redis_lookup_id_random(record_id_random=account_id, table_name='account'): pass
|
||||
# else: return mk_resp(data=None, status_code=404, response=response)
|
||||
account_id = 99 # WARNING!!!! Get rid of 99!
|
||||
|
||||
if person_data := get_person_rec_w_external_id(account_id=account_id, external_id=external_id): pass
|
||||
else: return mk_resp(data=None, status_code=404, response=response)
|
||||
person_id = person_data.get('person_id')
|
||||
|
||||
if person_dict := load_person_obj(
|
||||
person_id = person_id,
|
||||
limit = limit,
|
||||
model_as_dict = True, # NOTE: returning model as a dict
|
||||
enabled = enabled,
|
||||
inc_address = inc_address,
|
||||
inc_contact = inc_contact,
|
||||
inc_user = inc_user,
|
||||
inc_user_role_list = inc_user_role_list,
|
||||
):
|
||||
if isinstance(person_dict, dict):
|
||||
response_data = person_dict
|
||||
else:
|
||||
response_data = person_dict
|
||||
else:
|
||||
return mk_resp(data=False, status_code=400, response=response) # Bad Request
|
||||
|
||||
return mk_resp(data=response_data)
|
||||
# ### END ### API Person ### person_obj_external_id() ###
|
||||
|
||||
|
||||
# ### BEGIN ### API Person ### get_person_obj() ###
|
||||
# Working well as of 2021-06-25. Using as a template for other routes.
|
||||
@router.get('/person/{person_id}', response_model=Resp_Body_Base)
|
||||
@@ -216,7 +267,7 @@ async def get_person_obj(
|
||||
exclude_unset: Optional[bool] = True,
|
||||
response: Response = Response,
|
||||
):
|
||||
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
|
||||
log.debug(locals())
|
||||
|
||||
if person_id := redis_lookup_id_random(record_id_random=person_id, table_name='person'): pass
|
||||
|
||||
Reference in New Issue
Block a user