Options
All
  • Public
  • Public/Protected
  • All
Menu

Class KiiGroup

Represents a KiiGroup object

Hierarchy

  • KiiGroup

Implements

Index

Methods

  • Adds a user to the given group

    This method will NOT access the server immediately. You must call save to add the user on the server. This allows multiple users to be added/removed before calling save.

    example
    let user = . . .; // a KiiUser
    let group = . . .; // a KiiGroup
    group.addUser(user);
    group.save();

    Parameters

    • member: KiiUser

      The user to be added to the group

    Returns void

  • bucketWithName(bucketName: string): KiiBucket
  • Creates a reference to a bucket for this group

    The bucket will be created/accessed within this group's scope

    example
    let group = . . .; // a KiiGroup
    let bucket = group.bucketWithName("myBucket");

    Parameters

    • bucketName: string

      The name of the bucket the user should create/access

    Returns KiiBucket

    A working KiiBucket object

  • changeGroupName(newName: string): Promise<KiiGroup>
  • Updates the group name on the server

    example
    let group = . . .; // a KiiGroup
    group.changeGroupName("myNewName").then(theRenamedGroup => {
    // do something with the group
    }).catch(error => {
    // do something with the error response
    });

    Parameters

    • newName: string

      A String of the desired group name

    Returns Promise<KiiGroup>

    return promise object.

    • fulfill callback function: function(theRenamedGroup). theRenamedGroup is KiiGroup instance.
    • reject callback function: function(error). error is an Error instance.
      • error.target is the KiiGroup instance which this method was called on.
      • error.message

  • Delete the group from the server

    example
    let group = . . .; // a KiiGroup
    group.delete().then(theDeletedGroup => {
    // do something
    }).catch(error => {
    // do something with the error response
    });

    Returns Promise<KiiGroup>

    return promise object.

    • fulfill callback function: function(theDeletedGroup). theDeletedGroup is KiiGroup instance.
    • reject callback function: function(error). error is an Error instance.
      • error.target is the KiiGroup instance which this method was called on.
      • error.message

  • Creates a reference to a encrypted bucket for this group

    The bucket will be created/accessed within this group's scope

    example
    let group = . . .; // a KiiGroup
    let bucket = group.encryptedBucketWithName("myBucket");

    Parameters

    • bucketName: string

      The name of the bucket the user should create/access

    Returns KiiEncryptedBucket

    A working KiiEncryptedBucket object

  • getCachedOwner(): undefined | null | KiiUser
  • Returns the owner of this group if this group holds the information of owner.

    Group will holds the information of owner when "saving group on cloud" or "retrieving group info/owner from cloud". The cache will not be shared among the different instances of KiiGroup.

    • This API will not access to server. To update the group owner information on cloud, please call KiiGroup.refresh or KiiGroup.getOwner.
    • This API does not return all the properties of the owner. To get all owner properties, KiiUser.refresh is necessary.

    Returns undefined | null | KiiUser

    KiiUser who owns this group, undefined if this group doesn't hold the information of owner yet. KiiGroup.getOwner

  • getID(): string
  • Get the ID of the current KiiGroup instance.

    Returns string

  • getMemberList(): Promise<KiiUser[]>
  • Gets a list of all current members of a group

    example
    let group = . . .; // a KiiGroup
    group.getMemberList().then(memberList => {
    // do something with the result
    for (let i = 0; i < memberList.length; i++) {
    let u = memberList[i]; // a KiiUser within the group
    }
    }).catch(error => {
    // do something with the error response
    });

    Returns Promise<KiiUser[]>

    return promise object.

    • fulfill callback function: function(theMemberList). theMemberList is array of memeber KiiUser instances.
    • reject callback function: function(error). error is an Error instance.
      • error.target is the KiiGroup instance which this method was called on.
      • error.message

  • getName(): string
  • getOwner(): Promise<undefined | null | KiiUser>
  • Gets the owner of the associated group

    This API does not return all the properties of the owner. To get all owner properties, KiiUser.refresh is necessary.

    example
    let group = . . .; // a KiiGroup
    group.getOwner().then(theOwner => {
    // do something
    }).catch(error => {
    // do something with the error response
    });

    Returns Promise<undefined | null | KiiUser>

    return promise object.

    • fulfill callback function: function(theOwner). theOwner is an group owner KiiUser instance.
    • reject callback function: function(error). error is an Error instance.
      • error.target is the KiiGroup instance which this method was called on.
      • error.message

  • getUUID(): string
  • listTopics(paginationKey: string): Promise<[KiiTopic[], null | string]>
  • Gets a list of topics in this group scope

    example
    let group = . . .; // a KiiGroup
    group.listTopics().then(params => {
    let topicList = params[0];
    let nextPaginationKey = params[1];
    // do something with the result
    for (let i = 0; i < topicList.length; i++) {
    let topic = topicList[i];
    }
    if (nextPaginationKey != null) {
    group.listTopics(null, nextPaginationKey)
    .then(params => {...})
    .catch(error => {...});
    }
    }).catch(error => {
    // do something with the error response
    });

    Parameters

    • paginationKey: string

      You can specify the pagination key with the nextPaginationKey passed by callbacks.success. If empty string or no string object is provided, this API regards no paginationKey specified.

    Returns Promise<[KiiTopic[], null | string]>

    return promise object.

    • fulfill callback function: function(params). params is Array instance.
      • params[0] is array of KiiTopic instances.
      • params[1] is string of nextPaginationKey.
    • reject callback function: function(error). error is an Error instance.
      • error.target is the KiiGroup instance which this method was called on.
      • error.message

  • objectURI(): null | string
  • Get a specifically formatted string referencing the group

    The group must exist in the cloud (have a valid UUID).

    example
    let group = . . .; // a KiiGroup
    let uri = group.objectURI();

    Returns null | string

    A URI string based on the current group. null if a URI couldn't be generated.

  • Updates the local group's data with the group data on the server

    The group must exist on the server. Local data will be overwritten.

    example
    let group = . . .; // a KiiGroup
    group.refresh().then(theRefreshedGroup => {
    // do something with the refreshed group
    }).catch(error => {
    // do something with the error response
    });

    Returns Promise<KiiGroup>

    return promise object.

    • fulfill callback function: function(theRefreshedGroup). theRefreshedGroup is KiiGroup instance.
    • reject callback function: function(error). error is an Error instance.
      • error.target is the KiiGroup instance which this method was called on.
      • error.message

  • Removes a user from the given group

    This method will NOT access the server immediately. You must call save to remove the user on the server. This allows multiple users to be added/removed before calling save.

    example
    let user = . . .; // a KiiUser
    let group = . . .; // a KiiGroup
    group.removeUser(user);
    group.save();

    Parameters

    • member: KiiUser

      The user to be added to the group

    Returns KiiGroup

  • Saves the latest group values to the server

    If the group does not yet exist, it will be created. If the group already exists, the members that have changed will be updated accordingly. If the group already exists and there is no updates of members, it will allways succeed but does not execute update. To change the name of group, use KiiGroup.changeGroupName.

    example
    let group = . . .; // a KiiGroup
    group.save().then(theSavedGroup => {
    // do something with the saved group
    }).catch(error => {
    let theGroup = error.target;
    let anErrorString = error.message;
    let addMembersArray = error.addMembersArray;
    let removeMembersArray = error.removeMembersArray;
    // do something with the error response
    });

    Returns Promise<KiiGroup>

    return promise object.

    • fulfill callback function: function(theSavedGroup). theSavedGroup is KiiGroup instance.
    • reject callback function: function(error). error is an Error instance.
      • error.target is the KiiGroup instance which this method was called on.
      • error.message
      • error.addMembersArray is array of KiiUser to be added as memebers of this group.
      • error.removeMembersArray is array of KiiUser to be removed from the memebers list of this group.

  • saveWithOwner(owner: string): Promise<KiiGroup>
  • Saves the latest group values to the server with specified owner. This method can be used only by the group owner or app admin.

    If the group does not yet exist, it will be created. If the group already exists, the members and owner that have changed will be updated accordingly. If the group already exists and there is no updates of members and owner, it will allways succeed but does not execute update. To change the name of group, use KiiGroup.changeGroupName.

    example
    let group = . . .; // a KiiGroup
    group.saveWithOwner("UserID of owner").then(theSavedGroup => {
    // do something with the saved group
    }).catch(error => {
    let theGroup = error.target;
    let anErrorString = error.message;
    let addMembersArray = error.addMembersArray;
    let removeMembersArray = error.removeMembersArray;
    // do something with the error response
    });

    Parameters

    • owner: string

      id of owner

    Returns Promise<KiiGroup>

    return promise object.

    • fulfill callback function: function(theSavedGroup). theSavedGroup is KiiGroup instance.
    • reject callback function: function(error). error is an Error instance.
      • error.target is the KiiGroup instance which this method was called on.
      • error.message
      • error.addMembersArray is array of KiiUser to be added as memebers of this group.
      • error.removeMembersArray is array of KiiUser to be removed from the memebers list of this group.

  • topicWithName(topicName: string): KiiTopic
  • Instantiate topic belongs to this group.

    Parameters

    • topicName: string

      name of the topic. Must be a not empty string.

    Returns KiiTopic

    topic instance.

  • Instantiate KiiGroup that refers to existing group which has specified ID. You have to specify the ID of existing KiiGroup. Unlike KiiObject, you can not assign ID in the client side.
    NOTE: This API does not access to the server. After instantiation, call KiiGroup.refresh to fetch the properties.

    example
    let group = KiiGroup.groupWithID("__GROUP_ID__");
    

    Parameters

    Returns KiiGroup

    instance of KiiGroup.

  • Creates a reference to a group with the given name

    Note: Returned instance from this API can not operate existing KiiGroup.
    If you want to operate existing KiiGroup, please use KiiGroup.groupWithURI.

    example
    let group = KiiGroup.groupWithName("myGroup");
    

    Parameters

    Returns KiiGroup

    A new KiiGroup reference

  • Creates a reference to a group with the given name and a list of default members

    Note: Returned instance from this API can not operate existing KiiGroup.
    If you want to operate existing KiiGroup, please use KiiGroup.groupWithURI.

    example
    let group = KiiGroup.groupWithName("myGroup", members);
    

    Parameters

    Returns KiiGroup

    A new KiiGroup reference

  • Generate a new KiiGroup based on a given URI

    Note: Returned instance from this API can operate existing KiiGroup.
    If you want to create a new KiiGroup, please use KiiGroup.groupWithName.

    example
    let group = KiiGroup.groupWithURI("kiicloud://myuri");
    

    Parameters

    Returns KiiGroup

    A new KiiGroup with its parameters filled in from the URI

  • Register new group owned by current user on Kii Cloud with specified ID.

    If the group that has specified id already exists, registration will be failed.

    example
    let members = [];
    members.push(KiiUser.userWithID("Member User Id"));
    KiiGroup.registerGroupWithID("Group ID", "Group Name", members).then(theSavedGroup => {
    // do something with the saved group
    }).catch(error => {
    let theGroup = error.target;
    let anErrorString = error.message;
    let addMembersArray = error.addMembersArray;
    // do something with the error response
    });

    Parameters

    • groupID: string

      ID of the KiiGroup

    • groupName: string

      Name of the KiiGroup

    • members: KiiUser[]

      An array of KiiUser objects to add to the group

    • app: KiiApplication = KiiApplication.globalApp

      KiiApplication instance. When omitted, KiiApplication.globalApp is used.

    Returns Promise<KiiGroup>

    return promise object.

    • fulfill callback function: function(theSavedGroup). theSavedGroup is KiiGroup instance.
    • reject callback function: function(error). error is an Error instance.
      • error.target is the KiiGroup instance which this method was called on.
      • error.message
      • error.addMembersArray is array of KiiUser to be added as memebers of this group.
      • error.removeMembersArray is array of KiiUser to be removed from the memebers list of this group.

Generated using TypeDoc