Create a reward entry for an entity, credit or debit
DEBITs are atomically validated against the entity's current balance and rejected with INSUFFICIENT_BALANCE if they would drive it negative. Concurrent writes on the same (customer, entity) pair are serialized via a postgres advisory lock held for the duration of the transaction.
Usage:
service.create({ phone, ... });
service.create({ entityId, ... });
ProtectedgetAccount ID for an identity, which is really their phone number
Current balance for the entity
Optionalcategory?: stringOptionalcreatedAt?: DbTimestampCriteriaOptionalidempotencyKey?: stringOptionalorderBy?: DbOrderByCriterion<Optionalpage?: numberDefaults to 1
OptionalpageSize?: numberDefaults to 100
OptionaltransactionType?: "CREDIT" | "DEBIT"OptionalupdatedAt?: DbTimestampCriteriaentity reward entries
invalidPhone, notSupported and whatever EntityService throws
Manage rewards for entities
Internally, this is using a ledger so each reward causes a double-entry.