update address
This commit is contained in:
@@ -5,36 +5,38 @@ from layercake.dynamodb import DynamoDBPersistenceLayer, KeyPair
|
||||
def update_policies(
|
||||
id: str,
|
||||
/,
|
||||
payment_policy: dict = {},
|
||||
billing_policy: dict = {},
|
||||
payment_policy: dict | None = None,
|
||||
billing_policy: dict | None = None,
|
||||
*,
|
||||
persistence_layer: DynamoDBPersistenceLayer,
|
||||
):
|
||||
now_ = now()
|
||||
payment_sk = 'metadata#payment_policy'
|
||||
billing_sk = 'metadata#billing_policy'
|
||||
|
||||
with persistence_layer.transact_writer() as transact:
|
||||
if payment_policy:
|
||||
transact.put(
|
||||
item={
|
||||
'id': id,
|
||||
'sk': 'metadata#payment_policy',
|
||||
'create_date': now_,
|
||||
'sk': payment_sk,
|
||||
'created_at': now_,
|
||||
}
|
||||
| payment_policy
|
||||
)
|
||||
else:
|
||||
transact.delete(key=KeyPair(id, 'metadata#payment_policy'))
|
||||
transact.delete(key=KeyPair(id, payment_sk))
|
||||
|
||||
if billing_policy:
|
||||
transact.put(
|
||||
item={
|
||||
'id': id,
|
||||
'sk': 'metadata#billing_policy',
|
||||
'create_date': now_,
|
||||
'sk': billing_sk,
|
||||
'created_at': now_,
|
||||
}
|
||||
| billing_policy
|
||||
)
|
||||
else:
|
||||
transact.delete(key=KeyPair(id, 'metadata#billing_policy'))
|
||||
transact.delete(key=KeyPair(id, billing_sk))
|
||||
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user