Class Index | File Index

Classes


Class KiiThing

Represents a Thing object
Defined in: KiiSDK.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Field Summary
Field Attributes Field Name and Description
 
of this thing.
Method Summary
Method Attributes Method Name and Description
 
bucketWithName(bucketName)
Instantiate bucket belongs to this thing.
 
deleteThing(callbacks)
Delete registered thing in Kii Cloud.
 
disable(callbacks)
Disable the thing.
 
enable(callbacks)
Enable the thing.
 
Creates a reference to a encrypted bucket for this thing

The bucket will be created/accessed within this thing's scope
<static>  
KiiThing.executeQuery(KiiThingQuery, Object)
Perform a query to get the owned things.
 
Get access token of this thing.
 
Get created time of this thing.
 
Get disabled status of this thing.
 
Get online status modified date of the thing.
 
Get thing ID.
 
Get vendor thing ID.
 
Get online status of the thing.
 
isOwner(owner, callbacks)
Check if user/ group is owner of the thing.
 
listTopics(callbacks, paginationKey)
Gets a list of topics in this thing scope
<static>  
KiiThing.loadWithThingID(thingID, callbacks)
Load thing with thing id given by Kii Cloud.
<static>  
KiiThing.loadWithVendorThingID(vendorThingID, callbacks)
Load thing with given vendor thing id.
 
Instantiate push subscription for this thing.
 
refresh(callbacks)
Retrieve the latest thing information from KiiCloud.
<static>  
KiiThing.register(fields, callbacks)
Register thing in KiiCloud.
 
registerOwner(owner, callbacks)
Register user/group as owner of this thing.
 
registerOwnerWithPassword(owner, password, callbacks)
Register user/group as owner of this thing.
<static>  
KiiThing.registerOwnerWithThingID(thingID, owner, callbacks)
Register user/group as owner of specified thing.
<static>  
KiiThing.registerOwnerWithThingIDAndPassword(thingID, owner, password, callbacks)
Register user/group as owner of specified thing.
<static>  
KiiThing.registerOwnerWithVendorThingID(vendorThingID, owner, callbacks)
Register user/group as owner of specified thing.
<static>  
KiiThing.registerOwnerWithVendorThingIDAndPassword(vendorThingID, owner, password, callbacks)
Register user/group as owner of specified thing.
 
topicWithName(topicName)
Instantiate topic belongs to this thing.
 
unregisterOwner(owner, callbacks)
Remove ownership of thing from specified user/group.
 
update(callbacks)
Update registered thing information in Kii Cloud
This API is authorized by owner of thing.
 
updatePassword(newPassword, callbacks)
Updates thing password.
Class Detail
KiiThing()
Field Detail
{Object} fields
of this thing. For details refer to KiiThing.register
Method Detail
{KiiBucket} bucketWithName(bucketName)
Instantiate bucket belongs to this thing.
Parameters:
{String} bucketName
name of the bucket.
Returns:
{KiiBucket} bucket instance.

{Promise} deleteThing(callbacks)
Delete registered thing in Kii Cloud.
This API is authorized by owner of thing.
Need user login who owns this thing before execute this API.
To let users to own thing, please call KiiThing#registerOwner
Note: if you obtain thing instance from KiiAppAdminContext, API is authorized by app admin.
It will delete bucket, topic which belongs to this thing, entity belongs to the bucket/topic and all ownership information of thing. This operation can not be reverted. Please carefully use this.
  // example to use callbacks directly
  // assume thing is already registered.
  thing.deleteThing({
      success: function(thing) {
          // Delete succeeded.
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  // assume thing is already registered.
  thing.deleteThing().then(
      function(thing) {
          // Delete succeeded.
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
argument is updated thing.
{Function} callbacks.failure
callback called when operation failed.
argument is Error object.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(thing). thing is a KiiThing instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiThing instance which this method was called on.
    • error.message

{Promise} disable(callbacks)
Disable the thing.
This API is authorized by owner of thing.
Need user login who owns this thing before execute this API.
To let users to own Thing, please call KiiThing#registerOwner
Note: if you obtain thing instance from KiiAppAdminContext, API is authorized by app admin.
After succeeded, access token published for thing is disabled. In a result, only the app administrator and owners of thing can access the thing. Used when user lost the thing and avoid using by unknown users. It doesn't throw error when the thing is already disabled.
  // example to use callbacks directly
  // assume thing is already registered.
  thing.disable({
      success: function(thing) {
          // Disable succeeded.
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  // assume thing is already registered.
  thing.disable().then(
      function(thing) {
          // Disable succeeded.
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
argument is disabled thing
{Function} callbacks.failure
callback called when operation failed.
argument is Error object
Returns:
{Promise} return promise object.
  • fulfill callback function: function(thing). thing is a KiiThing instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiThing instance which this method was called on.
    • error.message

{Promise} enable(callbacks)
Enable the thing.
This API is authorized by owner of thing.
Need user login who owns this thing before execute this API.
To let users to own Thing, please call KiiThing#registerOwner
Note: if you obtain thing instance from KiiAppAdminContext, API is authorized by app admin.
After succeeded, If thing is registered with "persistentToken" option, token should be recovered (Access token which is used before disabling can be available). Otherwise, it does not recovered. It doesn't throw error when the thing is already enabled.
  // example to use callbacks directly
  // assume thing is already registered.
  thing.enable({
      success: function(thing) {
          // Enable succeeded.
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  // assume thing is already registered.
  thing.enable().then(
      function(thing) {
          // Disable succeeded.
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
argument is enabled thing
{Function} callbacks.failure
callback called when operation failed.
argument is Error object
Returns:
{Promise} return promise object.
  • fulfill callback function: function(thing). thing is a KiiThing instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiThing instance which this method was called on.
    • error.message

{KiiEncryptedBucket} encryptedBucketWithName(bucketName)
Creates a reference to a encrypted bucket for this thing

The bucket will be created/accessed within this thing's scope
  var thing = . . .; // a KiiThing
  var bucket = thing.encryptedBucketWithName("myBucket");
Parameters:
{String} bucketName
The name of the bucket the user should create/access
Returns:
{KiiEncryptedBucket} A working KiiEncryptedBucket object

<static> {Promise} KiiThing.executeQuery(KiiThingQuery, Object)
Perform a query to get the owned things.

The query will be executed against the server, returning a result set.
Parameters:
KiiThingQuery
thingQuery thingQuery.
Object
callbacks An object with callback methods defined
{Function} callbacks.success
The callback method to call on a successful query request
{Function} callbacks.failure
The callback method to call on a failed query request
Returns:
{Promise} return promise object.
  • fulfill callback function: function(result). result is KiiThingQueryResult instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiThing instance.
    • error.message

{String} getAccessToken()
Get access token of this thing.
Returns:
{String} access token of this thing.

{Date} getCreated()
Get created time of this thing.
Returns:
{Date} created time of this thing.

{Boolean} getDisabled()
Get disabled status of this thing.
Returns:
{Boolean} true if thing is disabled, false otherwise.

{Date} getOnlineStatusModifiedAt()
Get online status modified date of the thing.
Returns:
{Date} online status modified time of this thing. The date will be null initially until the thing is connected for the first time.

{String} getThingID()
Get thing ID.
Returns:
{String} thing id

{String} getVendorThingID()
Get vendor thing ID.
Returns:
{String} vendor thing id

{Boolean} isOnline()
Get online status of the thing.
Returns:
{Boolean} true if the thing is online, false otherwise. The return value will be null initially until the thing is connected for the first time.

{Promise} isOwner(owner, callbacks)
Check if user/ group is owner of the thing.
This API is authorized by owner of thing.
Need user login before execute this API.
To let users to own Thing, please call KiiThing#registerOwner
Note: if you obtain thing instance from KiiAppAdminContext, API is authorized by app admin.
  // example to use callbacks directly
  // assume thing/user is already registered.
  var user = KiiUser.userWithURI("kiicloud://users/xxxyyyy");
  thing.isOwner(user, {
      success: function(thing, user, isOwner) {
          if (isOwner) {
              // user is owner of the thing.
          } else {
              // user is not owner of the thing.
          }
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  // assume thing/user is already registered.
  var user = KiiUser.userWithURI("kiicloud://users/xxxyyyy");
  thing.isOwner(user).then(
      function(params) {
          var thing = params[0];
          var user = params[1];
          var isOwner = params[2];
          if (isOwner) {
              // user is owner of the thing.
          } else {
              // user is not owner of the thing.
          }
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{KiiUser or KiiGroup} owner
whether the instance is owner of thing or not.
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
1st argument: thing object.
2nd argument: user/group object.
3rd argument: result whether the user/group owns this thing.
{Function} callbacks.failure
callback called when operation failed.
argument is Error object.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(params). params is an Array instance.
    • params[0] is the KiiThing instance which this method was called on.
    • params[1] is a KiiUser/KiiGroup instance.
    • params[2] is Boolean value, true is the user/group is owner of the thing, otherwise false.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiThing instance which this method was called on.
    • error.message

{Promise} listTopics(callbacks, paginationKey)
Gets a list of topics in this thing scope
  // example to use callbacks directly
  var thing = . . .; // a KiiThing
  thing.listTopics({
      success: function(topicList, nextPaginationKey) {
          // do something with the result
          for(var i=0; i<topicList.length; i++){
              var topic = topicList[i];
          }
          if (nextPaginationKey != null) {
              thing.listTopics({
                  success: function(topicList, nextPaginationKey) {...},
                  failure: function(anErrorString) {...}
              }, nextPaginationKey);
          }
      },
      failure: function(anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use promise
  var thing = . . .; // a KiiThing
  thing.listTopics().then(
      function(params) {
          var topicList = params[0];
          var nextPaginationKey = params[1];
          // do something with the result
          for(var i=0; i<topicList.length; i++){
              var topic = topicList[i];
          }
          if (nextPaginationKey != null) {
              thing.listTopics(null, nextPaginationKey).then(
                  function(params) {...},
                  function(error) {...}
              );
          }
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{Object} callbacks Optional
An object with callback methods defined
{Method} callbacks.success
The callback method to call on a successful list request
{Method} callbacks.failure
The callback method to call on a failed list request
{String} paginationKey Optional
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} 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 KiiThing instance which this method was called on.
    • error.message

<static> {Promise} KiiThing.loadWithThingID(thingID, callbacks)
Load thing with thing id given by Kii Cloud.
This API is authorized by owner of thing.
Need user login who owns this thing before execute this API.
To let users to own Thing, please call KiiThing#registerOwner
Note: if you obtain thing instance from KiiAppAdminContext, API is authorized by app admin.
thing id can be obtained by thingID
  // example to use callbacks directly
  KiiThing.loadWithThingID("thing-xxxx-yyyy",{
      success: function(thing) {
          // Load succeeded.
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  KiiThing.loadWithVendorThingID("thing-xxxx-yyyy").then(
      function(thing) {
          // Load succeeded.
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{String} thingID
registered thing id.
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
argument is loaded thing.
{Function} callbacks.failure
callback called when operation failed.
argument is Error object.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(thing). thing is a KiiThing instance.
  • reject callback function: function(error). error is an Error instance.
    • error.message

<static> {Promise} KiiThing.loadWithVendorThingID(vendorThingID, callbacks)
Load thing with given vendor thing id.
This API is authorized by owner of thing.
Need user login who owns this thing before execute this API.
To let users to own Thing, please call KiiThing#registerOwner
Note: if you obtain thing instance from KiiAppAdminContext, API is authorized by app admin.
  // example to use callbacks directly
  KiiThing.loadWithVendorThingID("thing-xxxx-yyyy",{
      success: function(thing) {
          // Load succeeded.
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  KiiThing.loadWithVendorThingID("thing-xxxx-yyyy").then(
      function(thing) {
          // Load succeeded.
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{String} vendorThingID
registered vendor thing id.
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
{Function} callbacks.failure
callback called when operation failed.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(thing). thing is a KiiThing instance.
  • reject callback function: function(error). error is an Error instance.
    • error.message

{KiiPushSubscription} pushSubscription()
Instantiate push subscription for this thing.
Returns:
{KiiPushSubscription} push subscription object.

{Promise} refresh(callbacks)
Retrieve the latest thing information from KiiCloud.
This API is authorized by owner of thing.
Need user login who owns this thing before execute this API.
To let users to own thing, please call KiiThing#registerOwner
Note: if you obtain thing instance from KiiAppAdminContext, API is authorized by app admin.
  // example to use callbacks directly
  // assume thing is already registered.
  thing.refresh({
      success: function(thing) {
          // Refresh succeeded.
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  // assume thing is already registered.
  thing.refresh().then(
      function(thing) {
          // Refresh succeeded.
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
argument is refreshed thing.
{Function} callbacks.failure
callback called when operation failed.
argument is Error object.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(thing). thing is KiiThing instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiThing instance which this method was called on.
    • error.message

<static> {Promise} KiiThing.register(fields, callbacks)
Register thing in KiiCloud.
This API doesnt require users login Anonymous user can register thing.
Propertis started with '_' in the fields is reserved by Kii Cloud.
Those properties are indexed in Kii Cloud storage.
Properties not started with '_' is custom properties defined by developer.
Custom properties are not indexed in KiiCloud storage.
Following properties are readonly and ignored on creation/#update of thing.
'_thingID', '_created', '_accessToken'
Following properties are readonly after creation and will be ignored on #update of thing.
'_vendorThingID', '_password'
As Property prefixed with '_' is reserved by Kii Cloud, properties other than ones described in the parameter secion and '_layoutPosition' are ignored on creation/#update of thing.
Those ignored properties won't be removed from fields object passed as argument. However it won't be reflected to fields object property of created/updated Thing.
  // example to use callbacks directly
  KiiThing.register(
      {
          _vendorThingID: "thing-XXXX-YYYY-ZZZZZ",
          _password: "thing-password",
          _thingType: "thermometer",
          yourCustomObj: // Arbitrary key can be used.
          { // Object, Array, Number, String can be used. Should be compatible with JSON.
              yourCustomKey1: "value",
              yourCustomKey2: 100
          }
      },
      {
          success: function(thing) {
              // Register Thing succeeded.
          },
          failure: function(error) {
              // Handle error.
          }
      }
  );
  
  // example to use Promise
  KiiThing.register(
      {
          _vendorThingID: "thing-XXXX-YYYY-ZZZZZ",
          _password: "thing-password",
          _thingType: "thermometer",
          yourCustomObj: // Arbitrary key can be used.
          { // Object, Array, Number, String can be used. Should be compatible with JSON.
              yourCustomKey1: "value",
              yourCustomKey2: 100
          }
      }
  ).then(
      function(thing) {
          // Register Thing succeeded.
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{Object} fields
of the thing to be registered.
{String} fields._vendorThingID
thing identifier given by thing vendor.
{String} fields._password
thing password given by thing vendor.
{String} fields._thingType Optional
thing type given by thing vendor.
{String} fields._vendor Optional
vendor identifier given by thing vendor.
{String} fields._firmwareVersion Optional
firmware version given by thing vendor.
{String} fields._lot Optional
lot identifier given by thing vendor.
{String} fields._productName Optional
product name given by thing vendor.
{String} fields._stringField1 Optional
arbitrary string field.
{String} fields._stringField2 Optional
arbitrary string field.
{String} fields._stringField3 Optional
arbitrary string field.
{String} fields._stringField4 Optional
arbitrary string field.
{String} fields._stringField5 Optional
arbitrary string field.
{Number} fields._numberField1 Optional
arbitrary number field.
{Number} fields._numberField2 Optional
arbitrary number field.
{Number} fields._numberField3 Optional
arbitrary number field.
{Number} fields._numberField4 Optional
arbitrary number field.
{Number} fields._numberField5 Optional
arbitrary number field.
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
argument is registered thing.
{Function} callbacks.failure
callback called when operation failed.
argument is Error object.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(thing). thing is a KiiThing instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiThing instance.
    • error.message

{Promise} registerOwner(owner, callbacks)
Register user/group as owner of this thing.
Need user login before execute this API.
Note: if you obtain thing instance from KiiAppAdminContext, API is authorized by app admin.
  // example to use callbacks directly
  // assume thing/group is already registered.
  var group = KiiGroup.groupWithURI("kiicloud://groups/xxxyyyy");
  thing.registerOwner(group, {
      success: function(thing, group) {
          // Register owner succeeded.
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  // assume thing/group is already registered.
  var group = KiiGroup.groupWithURI("kiicloud://groups/xxxyyyy");
  thing.registerOwner(group).then(
      function(params) {
          // Register owner succeeded.
          var thing = params[0];
          var group = params[1];
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{KiiUser or KiiGroup} owner
to be registered as owner.
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
1st argument: thing object.
2nd argument: user/group object registered as owner.
{Function} callbacks.failure
callback called when operation failed.
argument is Error object.
Deprecated:
Use KiiThing.registerOwnerWithPassword instead.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(params). params is an Array instance.
    • params[0] is the KiiThing instance which this method was called on.
    • params[1] is a KiiUser/KiiGroup instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiThing instance which this method was called on.
    • error.message

{Promise} registerOwnerWithPassword(owner, password, callbacks)
Register user/group as owner of this thing.
Need user login before execute this API.
Note: if you obtain thing instance from KiiAppAdminContext, API is authorized by app admin.
  // example to use callbacks directly
  // assume thing/group is already registered.
  var group = KiiGroup.groupWithURI("kiicloud://groups/xxxyyyy");
  thing.registerOwnerWithPassword(group, "Thing password", {
      success: function(thing, group) {
          // Register owner succeeded.
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  // assume thing/group is already registered.
  var group = KiiGroup.groupWithURI("kiicloud://groups/xxxyyyy");
  thing.registerOwnerWithPassword(group, "Thing password").then(
      function(params) {
          // Register owner succeeded.
          var thing = params[0];
          var group = params[1];
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{KiiUser or KiiGroup} owner
to be registered as owner.
{String} password Optional
the thing password
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
1st argument: thing object.
2nd argument: user/group object registered as owner.
{Function} callbacks.failure
callback called when operation failed.
argument is Error object.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(params). params is an Array instance.
    • params[0] is the KiiThing instance which this method was called on.
    • params[1] is a KiiUser/KiiGroup instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiThing instance which this method was called on.
    • error.message

<static> {Promise} KiiThing.registerOwnerWithThingID(thingID, owner, callbacks)
Register user/group as owner of specified thing.
Need user login before execute this API.
Note: if you obtain thing instance from KiiAppAdminContext, API is authorized by app admin.
  // example to use callbacks directly
  // assume thing/group is already registered.
  var group = KiiGroup.groupWithURI("kiicloud://groups/xxxyyyy");
  KiiThing.registerOwnerWithThingID("th.xxxx-yyyy-zzzz", group, {
      success: function(group) {
          // Register owner succeeded.
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  // assume thing/group is already registered.
  var group = KiiGroup.groupWithURI("kiicloud://groups/xxxyyyy");
  KiiThing.registerOwnerWithThingID("th.xxxx-yyyy-zzzz", group).then(
      function(params) {
          // Register owner succeeded.
          var group = params[0];
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{String} thingID
The ID of thing
{KiiUser or KiiGroup} owner
instance of KiiUser/KiiGroup to be registered as owner.
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
1st argument: user/group object registered as owner.
{Function} callbacks.failure
callback called when operation failed.
argument is Error object.
Deprecated:
Use KiiThing.registerOwnerWithThingIDAndPassword instead.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(params). params is an Array instance.
    • params[0] is a KiiUser/KiiGroup instance.
  • reject callback function: function(error). error is an Error instance.
    • error.message

<static> {Promise} KiiThing.registerOwnerWithThingIDAndPassword(thingID, owner, password, callbacks)
Register user/group as owner of specified thing.
Need user login before execute this API.
Note: if you obtain thing instance from KiiAppAdminContext, API is authorized by app admin.
  // example to use callbacks directly
  // assume thing/group is already registered.
  var group = KiiGroup.groupWithURI("kiicloud://groups/xxxyyyy");
  KiiThing.registerOwnerWithThingIDAndPassword("th.xxxx-yyyy-zzzz", group, "Thing password", {
      success: function(owner) {
          // Register owner succeeded.
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  // assume thing/group is already registered.
  var group = KiiGroup.groupWithURI("kiicloud://groups/xxxyyyy");
  KiiThing.registerOwnerWithThingIDAndPassword("th.xxxx-yyyy-zzzz", group, "Thing password").then(
      function(owner) {
          // Register owner succeeded.
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{String} thingID
The ID of thing
{KiiUser or KiiGroup} owner
instance of KiiUser/KiiGroup to be registered as owner.
{String} password Optional
the thing password
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
1st argument: user/group object registered as owner.
{Function} callbacks.failure
callback called when operation failed.
argument is Error object.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(owner).
    • owner is a KiiUser/KiiGroup instance.
  • reject callback function: function(error). error is an Error instance.
    • error.message

<static> {Promise} KiiThing.registerOwnerWithVendorThingID(vendorThingID, owner, callbacks)
Register user/group as owner of specified thing.
Need user login before execute this API.
Note: if you obtain thing instance from KiiAppAdminContext, API is authorized by app admin.
  // example to use callbacks directly
  // assume thing/group is already registered.
  var group = KiiGroup.groupWithURI("kiicloud://groups/xxxyyyy");
  KiiThing.registerOwnerWithVendorThingID("xxxx-yyyy-zzzz", group, {
      success: function(group) {
          // Register owner succeeded.
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  // assume thing/group is already registered.
  var group = KiiGroup.groupWithURI("kiicloud://groups/xxxyyyy");
  KiiThing.registerOwnerWithVendorThingID("xxxx-yyyy-zzzz", group).then(
      function(group) {
          // Register owner succeeded.
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{String} vendorThingID
The vendor thing ID of thing
{KiiUser or KiiGroup} owner
instance of KiiUser/KiiGroup to be registered as owner.
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
1st argument: user/group object registered as owner.
{Function} callbacks.failure
callback called when operation failed.
argument is Error object.
Deprecated:
Use KiiThing.registerOwnerWithVendorThingIDAndPassword instead.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(params). params is an Array instance.
    • params[0] is a KiiUser/KiiGroup instance.
  • reject callback function: function(error). error is an Error instance.
    • error.message

<static> {Promise} KiiThing.registerOwnerWithVendorThingIDAndPassword(vendorThingID, owner, password, callbacks)
Register user/group as owner of specified thing.
Need user login before execute this API.
Note: if you obtain thing instance from KiiAppAdminContext, API is authorized by app admin.
  // example to use callbacks directly
  // assume thing/group is already registered.
  var group = KiiGroup.groupWithURI("kiicloud://groups/xxxyyyy");
  KiiThing.registerOwnerWithVendorThingIDAndPassword("xxxx-yyyy-zzzz", group, "Thing password", {
      success: function(owner) {
          // Register owner succeeded.
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  // assume thing/group is already registered.
  var group = KiiGroup.groupWithURI("kiicloud://groups/xxxyyyy");
  KiiThing.registerOwnerWithVendorThingIDAndPassword("xxxx-yyyy-zzzz", group, "Thing password").then(
      function(owner) {
          // Register owner succeeded.
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{String} vendorThingID
The vendor thing ID of thing
{KiiUser or KiiGroup} owner
instance of KiiUser/KiiGroup to be registered as owner.
{String} password Optional
the thing password
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
1st argument: user/group object registered as owner.
{Function} callbacks.failure
callback called when operation failed.
argument is Error object.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(owner).
    • owner is a KiiUser/KiiGroup instance.
  • reject callback function: function(error). error is an Error instance.
    • error.message

{KiiTopic} topicWithName(topicName)
Instantiate topic belongs to this thing.
Parameters:
{String} topicName
name of the topic. Must be a not empty string.
Returns:
{KiiTopic} topic instance.

{Promise} unregisterOwner(owner, callbacks)
Remove ownership of thing from specified user/group.
This API is authorized by owner of thing.
Need user login who owns this thing before execute this API.
Note: if you obtain thing instance from KiiAppAdminContext, API is authorized by app admin.
  // example to use callbacks directly
  // assume thing/group is already registered.
  var group = KiiGroup.groupWithURI("kiicloud://groups/xxxyyyy");
  thing.unregisterOwner(group, {
      success: function(thing, group) {
          // Unregister owner succeeded.
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  // assume thing/group is already registered.
  var group = KiiGroup.groupWithURI("kiicloud://groups/xxxyyyy");
  thing.unregisterOwner(group).then(
      function(params) {
          // Unregister owner succeeded.
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{KiiUser or KiiGroup} owner
to be unregistered.
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
1st argument: thing object
2nd argument: unregistered owner
{Function} callbacks.failure
callback called when operation failed.
argument is Error object
Returns:
{Promise} return promise object.
  • fulfill callback function: function(params). params is an Array instance.
    • params[0] is the KiiThing instance which this method was called on.
    • params[1] is a KiiUser/KiiGroup instance which had ownership of the thing removed.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiThing instance which this method was called on.
    • error.message

{Promise} update(callbacks)
Update registered thing information in Kii Cloud
This API is authorized by owner of thing.
Need user login who owns this thing before execute this API.
To let users to own thing, please call KiiThing#registerOwner
Note: if you obtain thing instance from KiiAppAdminContext, API is authorized by app admin.
  // example to use callbacks directly
  // assume thing is already registered.
  thing.fields._stringField1 = "new string value";
  thing.fields.customObject = {
      "customField1" : "abcd",
      "customField2" : 123
  };
  thing.update({
      success: function(thing) {
          // Update succeeded.
      },
      failure: function(error) {
          // Handle error.
      }
  });
  
  // example to use Promise
  // assume thing is already registered.
  thing.fields._stringField1 = "new string value";
  thing.fields.customObject = {
      "customField1" : "abcd",
      "customField2" : 123
  };
  thing.update().then(
      function(thing) {
          // Update succeeded.
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
argument is updated thing.
{Function} callbacks.failure
callback called when operation failed.
argument is Error object.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(thing). thing is a KiiThing instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiThing instance which this method was called on.
    • error.message
See:
KiiThing.register

{Promise} updatePassword(newPassword, callbacks)
Updates thing password. This method can be used only by app admin.
  // example to use callbacks directly
  // assume thing is already registered and you had an adminContext.
  adminContext.thingWithID(thing.getThingID()).updatePassword("new password", {
    success: function(thing) {
      // Update succeeded.
    },
    failure: function(error) {
      // Handle error.
    }
  });
  // example to use Promise
  // assume thing is already registered and you had an adminContext.
  adminContext.thingWithID(thing.getThingID()).updatePassword("new password").then(
      function(thing) {
          // Update succeeded.
      },
      function(error) {
          // Handle error.
      }
  );
Parameters:
{String} newPassword
new password
{Object} callbacks Optional
object holds callback functions.
{Function} callbacks.success
callback called when operation succeeded.
argument is this thing.
{Function} callbacks.failure
callback called when operation failed.
argument is Error object.
Returns:
{Promise} return promise object.
  • fulfill callback function: function(thing). thing is a KiiThing instance.
  • reject callback function: function(error). error is an Error instance.
    • error.target is the KiiThing instance which this method was called on.
    • error.message

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Sep 15 2021 05:31:33 GMT-0000 (UTC)