PlayPortalBucketClient

This class is responsible for handling playPORTAL buckets.
public sealed class PlayPortalBucketClient

The PlayPortalBucketClient class allows you to create and update buckets to store your app's data. Buckets can be created for a single user for private data, or for multiple users, allowing them to access shared data. Buckets are essentially JSON objects with key-value pairs and can be updated by creating and writing to a new key, or overwriting an existing one.

You will need to enable the "Lightning Database" scope for your app in the developer dashboard before using the data API.

Properties

public static readonly PlayPortalBucketClient Instance;

Singleton instance of PlayPortalBucketClient. You will access all the available PlayPortalBucketClient methods through this instance.

Methods

GetBucket

public void GetBucket(string bucketId, Action<Exception, PlayPortalBucket<TData>> completion, string key = null)

Request a bucket by its id.

Parameter

Type

Description

bucketId

string

The id of the bucket being requested.

completion

Action<Exception, PlayPortalBucket<TData>>

The delegate invoked when the request finishes. Called with an Exception argument for a failed request; otherwise, called with an instance of PlayPortalBucket with TData representing the structure of the bucket.

CreateBucket

public void CreateBucket<TData>(string bucketId, List<string> users, Action<Exception, PlayPortalBucket<TData>> completion, TData data = default, bool isPublic = false)

Create a bucket, specifying the users that have access to it, and optionally with initial data.

Parameter

Type

Description

bucketId

string

A unique ID to name this bucket, generated by your app. To read the bucket you must keep track of this ID.

users

List<string>

A list of the other users that will be able to read and update this bucket.

completion

Action<Exception, PlayPortalBucket<TData>>

The delegate invoked when the request finishes. Called with an Exception argument for a failed request; otherwise, called with an instance of PlayPortalBucket where TData represents the structure of the bucket.

data

TData

Optional argument. The data to initialize the bucket with.

isPublic

bool

Optional argument; defaults to false. Indicates if the bucket is accessible by all users within your app.

UpdateBucketData

public void UpdateBucket<TData>(string bucketId, string key, TData value, Action<Exception, TData> completion)

Update an existing bucket's data. If no key is provided, the entire bucket will be updated. If the key does not exist in the bucket, it will be created in the bucket as a key-value pair. A user must be in the users list of the bucket to perform this operation.

Parameter

Type

Description

bucketId

string

The id of the bucket being updated.

key

string

Location in the bucket's data to update, in dot object notation.

value

TData

Value to insert into the bucket at the location specified by the key parameter. Can be any valid JSON data.

completion

Action<Exception, PlayPortalBucket<TData>>

The delegate invoked when the request finishes. Called with an Exception argument for a failed request; otherwise, called with an instance of PlayPortalBucket where TData is the newly updated data.

DeleteBucket

public void DeleteBucket(string bucketId, Action<Exception> completion)

Deletes a data bucket. A user must be in the users list of the bucket to perform this operation.

Parameter

Type

Description

bucketId

string

Id of the bucket being deleted.

completion

Action<Exception>

The delegate invoked when the request finishes. Called with an Exception argument for a failed request.