Class Index | File Index

Classes


Class KiiThingContext

represents a KiiThingContext object
Defined in: KiiSDK.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
 
Creates a reference to a bucket in App scope operated by thing.
 
Creates a reference to a encrypted bucket in App scope operated by thing.
 
Gets authenticated KiiThing instance.
 
listTopics(callbacks, paginationKey)
Gets a list of topics in app scope
 
objectWithURI(String)
Creates a reference to an object operated by thing using object`s URI.
 
Instantiate push installation for this thing.
 
topicWithName(topicName)
Creates a reference to a topic in App scope operated by thing.
Class Detail
KiiThingContext()
Method Detail
{KiiBucket} bucketWithName(String)
Creates a reference to a bucket in App scope operated by thing.
      Kii.authenticateAsThing("vendorThingID", "password", {
          success: function(thingAuthContext) {
              var bucket = thingAuthContext.bucketWithName("myAppBucket");
          },
          failure: function(errorString, errorCode) {
              // auth failed.
          }
      });
Parameters:
String
bucketName The name of the bucket the app should create/access
Returns:
{KiiBucket} A working KiiBucket object

{KiiBucket} encryptedBucketWithName(String)
Creates a reference to a encrypted bucket in App scope operated by thing.

The bucket will be created/accessed within this app's scope
      Kii.authenticateAsThing("vendorThingID", "password", {
          success: function(thingAuthContext) {
              var bucket = thingAuthContext.encryptedBucketWithName("myAppBucket");
          },
          failure: function(errorString, errorCode) {
              // auth failed.
          }
      });
Parameters:
String
bucketName The name of the bucket the app should create/access
Returns:
{KiiBucket} A working KiiBucket object

{KiiThing} getAuthenticatedThing()
Gets authenticated KiiThing instance.
Returned thing instance only have thingID, vendorThingID and accessToken. (vendorThingID is not included when you used Kii.authenticateAsThingWithToken() to obtain KiiThingContext.)
Please execute KiiThing#refresh() to obtain other properties.
Returns:
{KiiThing} return authenticated KiiThing instance.

{Promise} listTopics(callbacks, paginationKey)
Gets a list of topics in app scope
  // example to use callbacks directly
  // Assume you already have thingAuthContext instance.
  thingAuthContext.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) {
              thingAuthContext.listTopics({
                  success: function(topicList, nextPaginationKey) {...},
                  failure: function(anErrorString) {...}
              }, nextPaginationKey);
          }
      },
      failure: function(anErrorString) {
          // do something with the error response
      }
  });
  
  // example to use Promise
  // Assume you already have thingAuthContext instance.
  thingAuthContext.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) {
              thingAuthContext.listTopics(null, nextPaginationKey).then(
                  function(params) {...},
                  function(error) {...}
              );
          }
      },
      function(error) {
          // do something with the error response
      }
  );
Parameters:
{Object} callbacks
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
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 a KiiAppAdminContext instance which this method was called on.
    • error.message

{KiiObject} objectWithURI(String)
Creates a reference to an object operated by thing using object`s URI.
Parameters:
String
object URI.
Throws:
{InvalidURIException}
If the URI is null, empty or does not have correct format.
Returns:
{KiiObject} A working KiiObject instance

{KiiPushInstallation} pushInstallation()
Instantiate push installation for this thing.
Returns:
{KiiPushInstallation} push installation object.

{KiiTopic} topicWithName(topicName)
Creates a reference to a topic in App scope operated by thing.

The Topic will be created/accessed within this app's scope
Parameters:
{String} topicName
name of the topic. Must be a not empty string.
Returns:
{KiiTopic} topic instance.

Documentation generated by JsDoc Toolkit 2.4.0 on Mon May 21 2018 05:13:33 GMT-0000 (UTC)