Blyx Nest Blyx language
Registry / Framework
framework · v0.1.2

Subscription Grace

Control renewal, grace-period expiration and reactivation by comparing absolute billing deadlines.

Source repository · Package JSON

Use Subscription Grace

use vendor::subscription_grace::subscription_grace;

Run the example

nest demo subscription_grace@0.1.2
blyxc native-run subscription_grace-demo/main.blyx
Example source and expected output
use std::cli;
use std::text;
use vendor::subscription_grace::subscription_grace;

fn main() {
    let arguments = cli_args();
    if args_len(arguments) > 0 {
        if args_len(arguments) % 2 != 0 {
            stderr_line("Expected event and value pairs");
            process_exit(2);
        }
        let mut live = subscription_grace_start();
        let mut i = 0;
        while i < args_len(arguments) {
            let input = args_at(arguments, i + 1);
            if !text_is_number(input) {
                stderr_line("Expected a whole numeric event value");
                process_exit(2);
            }
            live = subscription_grace_step(live, args_at(arguments, i), text_number(input));
            let command = subscription_grace_command(live);
            println!(command);
            if command == "reject" { process_exit(1); }
            i += 2;
        }
        return;
    }
    let mut state = subscription_grace_start();
    state = subscription_grace_step(state, "start", 30.0);
    println!(subscription_grace_command(state));
    state = subscription_grace_step(state, "unpaid", 30.0);
    println!(subscription_grace_command(state));
    state = subscription_grace_step(state, "extend", 37.0);
    println!(subscription_grace_command(state));
    state = subscription_grace_step(state, "clock", 35.0);
    println!(subscription_grace_command(state));
    state = subscription_grace_step(state, "clock", 37.0);
    println!(subscription_grace_command(state));
    state = subscription_grace_step(state, "renew", 65.0);
    println!(subscription_grace_command(state));
}

Expected output

open_term
begin_grace
set_grace_end
reject
pause_service
restore_service

Published versions

VersionPackageSource commitSHA-256
0.1.2Download ZIP · Browse filesb12c54af7779f93b445e045289c0a6ba737f73031d49bc43ca975f6287bcdbe9877333dc9b
0.1.1Download ZIP · Browse filesfe72b1401190430d36797d14399df1b57eed28a535d59727abbf9cb2d0c4b87c002287b45c
0.1.0Download ZIP · Browse files6349f237847962476f54c3605b5b877b91bf76cd47cd447c9225dfab72b94fa546e7f7f2e5