From 0e0cc0c53887d2c1f81765d35d568ad3146849bd Mon Sep 17 00:00:00 2001 From: Yonezawa-T2 Date: Tue, 5 Jan 2016 17:05:43 +0900 Subject: [PATCH] Updates kii-cloud-sdk v2.3.0 -> v2.4.0 --- kii-cloud-sdk/kii-cloud-sdk-tests.ts | 11 ++ kii-cloud-sdk/kii-cloud-sdk.d.ts | 207 +++++++++++++++++++++++++-- 2 files changed, 206 insertions(+), 12 deletions(-) diff --git a/kii-cloud-sdk/kii-cloud-sdk-tests.ts b/kii-cloud-sdk/kii-cloud-sdk-tests.ts index f926425383..ed5bb29666 100644 --- a/kii-cloud-sdk/kii-cloud-sdk-tests.ts +++ b/kii-cloud-sdk/kii-cloud-sdk-tests.ts @@ -46,4 +46,15 @@ function main() { object.set("foo", 1); object.save(); + + KiiGroup.registerGroupWithID("Group ID", "Group Name", [user], { + success: function(theSavedGroup: KiiGroup) { + theSavedGroup.saveWithOwner("user ID"); + }, + failure: function(theGroup: KiiGroup, + anErrorString: String, + addMembersArray: KiiUser[], + removeMembersArray: KiiUser[]) { + } + }); } diff --git a/kii-cloud-sdk/kii-cloud-sdk.d.ts b/kii-cloud-sdk/kii-cloud-sdk.d.ts index 57c8f50b1f..6f14d47bb9 100644 --- a/kii-cloud-sdk/kii-cloud-sdk.d.ts +++ b/kii-cloud-sdk/kii-cloud-sdk.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Kii Cloud SDK v2.3.0 +// Type definitions for Kii Cloud SDK v2.4.0 // Project: http://en.kii.com/ // Definitions by: Kii Consortium // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -83,6 +83,11 @@ declare module KiiCloud { */ _lot?: string; + /** + * product name given by thing vendor. + */ + _productName?: string; + /** * arbitrary string field. */ @@ -1028,6 +1033,65 @@ declare module KiiCloud { */ groupWithID(group: string): KiiGroup; + /** + * Register new group own by specified user on Kii Cloud with specified ID. + * This method can be used only by app admin. + * + *

If the group that has specified id already exists, registration will be failed. + * + * @param groupID ID of the KiiGroup + * @param groupName Name of the KiiGroup + * @param user id of owner + * @param members An array of KiiUser objects to add to the group + * @param callbacks + * + * @return return promise object. + * + * + * @example + * // example to use callbacks directly + * Kii.authenticateAsAppAdmin("client-id", "client-secret", { + * success: function(adminContext) { + * var members = []; + * members.push(KiiUser.userWithID("Member User Id")); + * adminContext.registerGroupWithOwnerAndID("Group ID", "Group Name", "Owner User ID", members, { + * success: function(theSavedGroup) { + * // do something with the saved group + * }, + * failure: function(theGroup, anErrorString, addMembersArray, removeMembersArray) { + * // do something with the error response + * } + * }); + * }, + * failure: function(errorString, errorCode) { + * // auth failed. + * } + * }); + * // example to use Promise + * Kii.authenticateAsAppAdmin("client-id", "client-secret").then( + * function(adminContext) { + * var members = []; + * members.push(KiiUser.userWithID("Member User Id")); + * return adminContext.registerGroupWithOwnerAndID("Group ID", "Group Name", "Owner User ID", members); + * } + * ).then( + * function(group) { + * // do something with the saved group + * } + * ); + */ + registerGroupWithOwnerAndID(groupID: string, groupName: string, user: string, members: KiiUser[], callbacks?: { success(adminContext: KiiAppAdminContext): any; failure(theGroup: KiiGroup, anErrorString: string, addMembersArray: KiiUser[], removeMembersArray: KiiUser[]): any; }): Promise; + /** * Creates a reference to a group operated by app admin using group's URI. *

@@ -1362,7 +1426,7 @@ declare module KiiCloud { * Register user/group as owner of specified thing by app admin. * * @param thingID The ID of thing - * @param owner to be registered as owner. + * @param owner instnce of KiiUser/KiiGroup to be registered as owner. * @param callbacks object holds callback functions. * * @return return promise object. @@ -1415,7 +1479,7 @@ declare module KiiCloud { * Register user/group as owner of specified thing by app admin. * * @param vendorThingID The vendor thing ID of thing - * @param owner to be registered as owner. + * @param owner instance of KiiUser/KiiGroupd to be registered as owner. * @param callbacks object holds callback functions. * * @return return promise object. @@ -2205,6 +2269,58 @@ declare module KiiCloud { */ objectURI(): string; + /** + * Register new group own by current user on Kii Cloud with specified ID. + * + *

If the group that has specified id already exists, registration will be failed. + * + * @param groupID ID of the KiiGroup + * @param groupName Name of the KiiGroup + * @param members An array of KiiUser objects to add to the group + * @param callbacks An object with callback methods defined + * + * @return 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.
    • + *
    + *
  • + *
+ * + * @example + * // example to use callbacks directly + * var members = []; + * members.push(KiiUser.userWithID("Member User Id")); + * KiiGroup.registerGroupWithID("Group ID", "Group Name", members, { + * success: function(theSavedGroup) { + * // do something with the saved group + * }, + * failure: function(theGroup, anErrorString, addMembersArray, removeMembersArray) { + * // do something with the error response + * } + * }); + * + * // example to use Promise + * var members = []; + * members.push(KiiUser.userWithID("Member User Id")); + * KiiGroup.registerGroupWithID("Group ID", "Group Name", members).then( + * function(theSavedGroup) { + * // do something with the saved group + * }, + * function(error) { + * var theGroup = error.target; + * var anErrorString = error.message; + * var addMembersArray = error.addMembersArray; + * // do something with the error response + * }); + */ + static registerGroupWithID(groupID: string, groupName: string, members: KiiUser[], callbacks?: { success(theSavedGroup: KiiGroup): any; failure(theGroup: KiiGroup, anErrorString: string, addMembersArray: KiiUser[], removeMembersArray: KiiUser[]): any; }): Promise; + /** * Creates a reference to a bucket for this group * @@ -2420,6 +2536,65 @@ declare module KiiCloud { */ save(callbacks?: { success(theSavedGroup: KiiGroup): any; failure(theGroup: KiiGroup, anErrorString: string, addMembersArray: KiiUser[], removeMembersArray: KiiUser[]): any; }): Promise; + /** + * 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 {@link #changeGroupName}. + * + * @param user id of owner + * @param callbacks An object with callback methods defined + * + * @return 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.
    • + *
    + *
  • + *
+ * + * @example + * // example to use callbacks directly + * var group = . . .; // a KiiGroup + * group.saveWithOwner("UserID of owner", { + * success: function(theSavedGroup) { + * // do something with the saved group + * }, + * + * failure: function(theGroup, anErrorString, addMembersArray, removeMembersArray) { + * // do something with the error response + * } + * }); + * + * // example to use Promise + * var group = . . .; // a KiiGroup + * group.saveWithOwner("UserID of owner", { + * success: function(theSavedGroup) { + * // do something with the saved group + * }, + * + * failure: function(theGroup, anErrorString, addMembersArray, removeMembersArray) { + * // do something with the error response + * } + * }).then( + * function(theSavedGroup) { + * // do something with the saved group + * }, + * function(error) { + * var theGroup = error.target; + * var anErrorString = error.message; + * var addMembersArray = error.addMembersArray; + * var removeMembersArray = error.removeMembersArray; + * // do something with the error response + * }); + */ + saveWithOwner(user: string, callbacks?: { success(theSavedGroup: KiiGroup): any; failure(theGroup: KiiGroup, anErrorString: string, addMembersArray: KiiUser[], removeMembersArray: KiiUser[]): any; }): Promise; + /** * Updates the local group's data with the group data on the server * @@ -2735,14 +2910,14 @@ declare module KiiCloud { /** * Get the application-defined type name of the object * - * @return + * @return type of this object. null or undefined if none exists */ getObjectType(): string; /** * Get the body content-type. * It will be updated after the success of {@link KiiObject#uploadBody} and {@link KiiObject#downloadBody} - * returns null when this object doesn't have body content-type information. + * returns null or undefined when this object doesn't have body content-type information. * * @return content-type of object body */ @@ -2751,15 +2926,18 @@ declare module KiiCloud { /** * Sets a key/value pair to a KiiObject * - *

If the key already exists, its value will be written over. If the object is of invalid type, it will return false and a KiiError will be thrown (quietly). Accepted types are any JSON-encodable objects. + *

If the key already exists, its value will be written over. *
NOTE: Before involving floating point value, please consider using integer instead. For example, use percentage, permil, ppm, etc.
* The reason is: *
  • Will dramatically improve the performance of bucket query.
  • *
  • Bucket query does not support the mixed result of integer and floating point. * ex.) If you use same key for integer and floating point and inquire object with the integer value, objects which has floating point value with the key would not be evaluated in the query. (and vice versa)
  • * - * @param key The key to set. The key must not be a system key (created, metadata, modified, type, uuid) or begin with an underscore (_) - * @param value The value to be set. Object must be of a JSON-encodable type (Ex: dictionary, array, string, number, etc) + * @param key The key to set. + * if null, empty string or string prefixed with '_' is specified, silently ignored and have no effect. + * We don't check if actual type is String or not. If non-string type is specified, it will be encoded as key by JSON.stringify() + * @param value The value to be set. Object must be JSON-encodable type (dictionary, array, string, number, boolean) + * We don't check actual type of the value. It will be encoded as value by JSON.stringify() * * @example * var obj = . . .; // a KiiObject @@ -2772,7 +2950,7 @@ declare module KiiCloud { * * @param key The key to retrieve * - * @return The object associated with the key. null if none exists + * @return The object associated with the key. null or undefined if none exists * * @example * var obj = . . .; // a KiiObject @@ -4665,6 +4843,11 @@ declare module KiiCloud { * '_thingID', '_created', '_accessToken'
    * Following properties are readonly after creation and will be ignored on {@link #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/{@link #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. * * @param fields of the thing to be registered. * @param callbacks object holds callback functions. @@ -5007,7 +5190,7 @@ declare module KiiCloud { * API is authorized by app admin.
    * * @param thingID The ID of thing - * @param owner to be registered as owner. + * @param owner instance of KiiUser/KiiGroup to be registered as owner. * @param callbacks object holds callback functions. * * @return return promise object. @@ -5059,7 +5242,7 @@ declare module KiiCloud { * API is authorized by app admin.
    * * @param vendorThingID The vendor thing ID of thing - * @param owner to be registered as owner. + * @param owner instance of KiiUser/KiiGroup to be registered as owner. * @param callbacks object holds callback functions. * * @return return promise object. @@ -5850,7 +6033,7 @@ declare module KiiCloud { * * @param key The key to retrieve * - * @return The object associated with the key. null if none exists + * @return The object associated with the key. null or undefined if none exists * * @example * var user = . . .; // a KiiUser