fix
This commit is contained in:
40
http-api/app/rules/org.py
Normal file
40
http-api/app/rules/org.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from layercake.dateutils import now
|
||||
from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair, TransactItems
|
||||
|
||||
|
||||
def update_policies(
|
||||
id: str,
|
||||
/,
|
||||
payment_policy: dict = {},
|
||||
billing_policy: dict = {},
|
||||
*,
|
||||
persistence_layer: DynamoDBPersistenceLayer,
|
||||
):
|
||||
now_ = now()
|
||||
transact = TransactItems(persistence_layer.table_name)
|
||||
|
||||
if payment_policy:
|
||||
transact.put(
|
||||
item={
|
||||
'id': id,
|
||||
'sk': 'payment_policy',
|
||||
'create_date': now_,
|
||||
}
|
||||
| payment_policy
|
||||
)
|
||||
else:
|
||||
transact.delete(key=KeyPair(id, 'payment_policy'))
|
||||
|
||||
if billing_policy:
|
||||
transact.put(
|
||||
item={
|
||||
'id': id,
|
||||
'sk': 'billing_policy',
|
||||
'create_date': now_,
|
||||
}
|
||||
| billing_policy
|
||||
)
|
||||
else:
|
||||
transact.delete(key=KeyPair(id, 'billing_policy'))
|
||||
|
||||
return persistence_layer.transact_write_items(transact)
|
||||
Reference in New Issue
Block a user