tiki_sdk_dart 3.0.0 tiki_sdk_dart: ^3.0.0 copied to clipboard
Create and enforce immutable data licensing records client-side. The core-implementation of TIKI's client-side infrastructure.
/*
* Copyright (c) TIKI Inc.
* MIT license. See LICENSE file in root directory.
*/
import 'dart:io';
import 'package:example/in_mem.dart';
import 'package:tiki_sdk_dart/tiki_sdk.dart';
import 'package:uuid/uuid.dart';
void main(List<String> arguments) async {
TikiSdk tikiSdk = await InMemBuilders.tikiSdk();
String ptr = const Uuid().v4();
TitleRecord title =
await tikiSdk.title.create(ptr, tags: [TitleTag.emailAddress()]);
print("Created a Title Record with id ${title.id} for PTR: $ptr");
LicenseRecord first = await tikiSdk.license.create(
title,
[
LicenseUse([LicenseUsecase.attribution()])
],
'terms');
print("Created a License Record with id ${first.id} for PTR: $ptr");
tikiSdk.guard(ptr, [LicenseUsecase.attribution()],
onPass: () => print(
"There is a valid License Record for attribution use for Title Record with PTR $ptr"));
tikiSdk.guard(ptr, [LicenseUsecase.support()],
onFail: (cause) => print(
"There is no valid License Record for support use for Title Record with PTR $ptr. Cause: $cause"));
exit(0);
}