Type: "Bucket"

Introduction

The bucket type represents a bucket. The bucket may be an active bucket stored on a wallet. It may be a bucket used during rating, or a bucket that can be added to a wallet.

API Methods

.id

Returns the unique bucket ID that can be used to reference the bucket inside a wallet. This method has no parameters.

    ...
    local id = context.active_lifecycle_target().as_bucket().id()
    ...

The bucket’s ID may not be defined, although if the bucket is part of an active wallet it will be. A bucket’s ID may not be defined if the bucket has been created from a template and is not yet added to a wallet.

.expiry

Returns the expiry date/time of the bucket, as a floating point number representing the seconds since the unix epoch, with milliseconds represented as the fractional part.

This method returns nil if the bucket does not have an expiry.

.value

Returns the value of the bucket. This will always be a whole number with a range of a signed 64-bit.

Even if this bucket’s behaviour is manipulated by annotations (such as the infinite balance annotation) this value mehtod will return a value.

.unit

Returns the unit type the bucket is in. This will be equivalent to one of the unit types exposed by the engine.

This method will never return nil.

.as_table

Returns the bucket as a table of data that represents the encoded JSON format of the bucket if it were to be returned from the OCS by the OCS APIs

This is the cannonical form of the bucket for interoperability.