-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbasic-usage-expr.ts
More file actions
38 lines (31 loc) · 1.1 KB
/
Copy pathbasic-usage-expr.ts
File metadata and controls
38 lines (31 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { mul, add } from "@scrawn/core";
import { biller } from "./scrawn/biller.ts";
import { config } from "dotenv";
config({ path: ".env.local" });
async function main() {
await biller.basicUsageEventConsumer({
userId: "c0971bcb-b901-4c3e-a191-c9a97871c39f",
debit: biller.expr(mul(biller.tag("PREMIUM_CALL"), 3)),
});
await biller.basicUsageEventConsumer({
userId: "c0971bcb-b901-4c3e-a191-c9a97871c39f",
debit: biller.expr(mul(biller.tag("EXTRA_FEE"), 3)),
});
await biller.basicUsageEventConsumer({
userId: "c0971bcb-b901-4c3e-a191-c9a97871c39f",
debit: biller.expr(
add(biller.expr("COMPLEX_FEE"), mul(biller.tag("PREMIUM_CALL"), 5))
),
});
// biller.expr() also accepts raw amounts and tags
await biller.basicUsageEventConsumer({
userId: "c0971bcb-b901-4c3e-a191-c9a97871c39f",
debit: biller.expr(250),
});
await biller.basicUsageEventConsumer({
userId: "c0971bcb-b901-4c3e-a191-c9a97871c39f",
debit: biller.expr(biller.tag("EXTRA_FEE")),
});
console.log("Basic usage expression events consumed successfully");
}
main().catch(console.error);