add email events
This commit is contained in:
@@ -38,22 +38,22 @@ class CustomPricing(BaseModel):
|
||||
|
||||
|
||||
@router.post('/<id>/custompricing', compress=True)
|
||||
def post_custom_pricing(id: str, payload: CustomPricing):
|
||||
def post_custom_pricing(id: str, custom_princing: CustomPricing):
|
||||
now_ = now()
|
||||
|
||||
with course_layer.transact_writer() as transact:
|
||||
transact.put(
|
||||
item={
|
||||
'id': f'CUSTOM_PRICING#ORG#{id}',
|
||||
'sk': f'COURSE#{payload.course_id}',
|
||||
'unit_price': payload.unit_price,
|
||||
'sk': f'COURSE#{custom_princing.course_id}',
|
||||
'unit_price': custom_princing.unit_price,
|
||||
'created_at': now_,
|
||||
},
|
||||
cond_expr='attribute_not_exists(sk)',
|
||||
exc_cls=CoursConflictError,
|
||||
)
|
||||
transact.condition(
|
||||
key=KeyPair(str(payload.course_id), '0'),
|
||||
key=KeyPair(str(custom_princing.course_id), '0'),
|
||||
cond_expr='attribute_exists(sk)',
|
||||
exc_cls=CourseNotFoundError,
|
||||
)
|
||||
@@ -61,18 +61,18 @@ def post_custom_pricing(id: str, payload: CustomPricing):
|
||||
return JSONResponse(status_code=HTTPStatus.CREATED)
|
||||
|
||||
|
||||
class Delete(BaseModel):
|
||||
class DeleteCustomPricing(BaseModel):
|
||||
course_id: UUID4
|
||||
|
||||
|
||||
@router.delete('/<id>/custompricing', compress=True)
|
||||
def delete_custom_pricing(id: str, payload: Delete):
|
||||
if course_layer.delete_item(
|
||||
KeyPair(
|
||||
f'CUSTOM_PRICING#ORG#{id}',
|
||||
f'COURSE#{payload.course_id}',
|
||||
)
|
||||
):
|
||||
def delete_custom_pricing(id: str, custom_princing: DeleteCustomPricing):
|
||||
pair = KeyPair(
|
||||
f'CUSTOM_PRICING#ORG#{id}',
|
||||
f'COURSE#{custom_princing.course_id}',
|
||||
)
|
||||
|
||||
if course_layer.delete_item(pair):
|
||||
return JSONResponse(status_code=HTTPStatus.OK)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user