public void Test_UserScopeWithPaginationSync() { LogIn("test-user-00001"); AddMockResponse(200, new string[] { "Topic1", "Topic2" }, "ab=12/12+"); AddMockResponse(200, new string[] { "Topic3" }, null); string userID = "test_user"; KiiListResult <KiiTopic> topics = KiiUser.UserWithID(userID).ListTopics(); Assert.IsTrue(topics.HasNext); Assert.AreEqual("ab=12/12+", topics.PaginationKey); Assert.AreEqual(2, topics.Result.Count); Assert.AreEqual("Topic1", topics.Result[0].Name); Assert.AreEqual("kiicloud://" + Utils.Path("users", userID, "topics", "Topic1"), topics.Result[0].Uri.ToString()); Assert.AreEqual("Topic2", topics.Result[1].Name); Assert.AreEqual("kiicloud://" + Utils.Path("users", userID, "topics", "Topic2"), topics.Result[1].Uri.ToString()); Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod [0]); Assert.AreEqual(Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "users", userID, "topics"), client.RequestUrl [0]); Assert.AreEqual("Bearer " + KiiUser.AccessToken, client.RequestHeader [0]["Authorization"]); topics = KiiUser.UserWithID(userID).ListTopics(topics.PaginationKey); Assert.IsFalse(topics.HasNext); Assert.IsNull(topics.PaginationKey); Assert.AreEqual(1, topics.Result.Count); Assert.AreEqual("Topic3", topics.Result[0].Name); Assert.AreEqual("kiicloud://" + Utils.Path("users", userID, "topics", "Topic3"), topics.Result[0].Uri.ToString()); Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod [1]); Assert.AreEqual(Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "users", userID, "topics") + "?paginationKey=" + Uri.EscapeUriString("ab=12/12+"), client.RequestUrl [1]); Assert.AreEqual("Bearer " + KiiUser.AccessToken, client.RequestHeader [1]["Authorization"]); }
public void Test_UserScopeWithEmptyResultASync() { LogIn("test-user-00001"); AddMockResponse(200, new string[] {}, null); string userID = "test_user"; CountDownLatch cd = new CountDownLatch(1); KiiListResult <KiiTopic> topics = null; Exception exception = null; KiiUser.UserWithID(userID).ListTopics((KiiListResult <KiiTopic> t, Exception e) => { topics = t; exception = e; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 3))) { Assert.Fail("Callback not fired."); } Assert.IsNull(exception); Assert.IsFalse(topics.HasNext); Assert.IsNull(topics.PaginationKey); Assert.AreEqual(0, topics.Result.Count); Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod [0]); Assert.AreEqual(Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "users", userID, "topics"), client.RequestUrl [0]); Assert.AreEqual("Bearer " + KiiUser.AccessToken, client.RequestHeader [0]["Authorization"]); }
public void TestAllCultures() { KiiUser user = KiiUser.BuilderWithEmail(CurrentTimeMillis() + "@kii.com").Build(); user.Register("password"); foreach (CultureInfo cultureInfo in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) { user.Locale = new LocaleContainer(cultureInfo); user.Update(); KiiUser actual = KiiUser.UserWithID(user.ID); actual.Refresh(); Assert.AreEqual(cultureInfo, actual.Locale.CultureInfo, cultureInfo.ToString()); } foreach (CultureInfo cultureInfo in CultureInfo.GetCultures(CultureTypes.NeutralCultures)) { if (cultureInfo.IsNeutralCulture) { user.Locale = new LocaleContainer(cultureInfo); user.Update(); KiiUser actual = KiiUser.UserWithID(user.ID); actual.Refresh(); String expected = cultureInfo.Name.ToLower(); if (expected == "zh-chs") { expected = "zh-cn"; } else if (expected == "zh-cht") { expected = "zh-hk"; } Assert.AreEqual(expected, actual.Locale.LocaleString, cultureInfo.Name); } } }
public void Test_UserScopeFalseASync() { LogIn("test-user-00001"); client.AddResponse(new NotFoundException("", null, "", NotFoundException.Reason.TOPIC_NOT_FOUND)); string userID = "test_user"; string topicName = "test_topic"; KiiTopic topic = KiiUser.UserWithID(userID).Topic(topicName); CountDownLatch cd = new CountDownLatch(1); bool? existence = null; Exception exception = null; topic.Exists((bool?b, Exception e) => { existence = b; exception = e; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 3))) { Assert.Fail("Callback not fired."); } Assert.IsFalse(existence.Value); Assert.IsNull(exception); Assert.AreEqual(KiiHttpMethod.HEAD, client.RequestMethod [0]); Assert.AreEqual(Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "users", userID, "topics", topicName), client.RequestUrl [0]); }
public void Test_GetStatusWhenDisabledIsFalse() { // refresh response string response = @" { ""userID"" : ""dummyID"", ""internalUserID"" : 87442786592227328, ""loginName"" : ""kii_user01"", ""_disabled"" : ""false"" } "; client.AddResponse(200, response); KiiUser user = KiiUser.UserWithID("dummyID"); user.Refresh(); Assert.AreEqual("kii_user01", user.Username); Assert.IsFalse(user.Disabled); // verify request. string url = Utils.Path(ConstantValues.DEFAULT_BASE_URL, "apps", "appId", "users", "dummyID"); Assert.AreEqual(url, client.RequestUrl [0]); Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod [0]); MockHttpHeaderList headerList = client.RequestHeader [0]; Assert.AreEqual("appId", headerList ["X-Kii-AppID"]); Assert.AreEqual("appKey", headerList ["X-Kii-AppKey"]); Assert.IsTrue(headerList ["X-Kii-SDK"].StartsWith("sn=cs;sv=")); }
public void Test_UserScope404ASync() { LogIn("test-user-00001"); client.AddResponse(new NotFoundException("", null, "", NotFoundException.Reason.ACL_NOT_FOUND)); string userID = "test_user"; string topicName = "test_topic"; KiiTopic topic = KiiUser.UserWithID(userID).Topic(topicName); CountDownLatch cd = new CountDownLatch(1); IList <KiiACLEntry <KiiTopic, TopicAction> > entries = null; Exception exception = null; topic.ListAclEntries((IList <KiiACLEntry <KiiTopic, TopicAction> > result, Exception e) => { entries = result; exception = e; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 3))) { Assert.Fail("Callback not fired."); } Assert.IsNull(entries); Assert.IsInstanceOfType(typeof(NotFoundException), exception); Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod [0]); Assert.AreEqual(Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "users", userID, "topics", topicName, "acl"), client.RequestUrl [0]); }
public void TestUserWithID_1_3_existsInCloud_refresh() { // mock refresh response MockHttpClientFactory factory = new MockHttpClientFactory(); Kii.HttpClientFactory = factory; MockHttpClient client = factory.Client; client.AddResponse(201, "{" + "\"userID\" : \"dummyID\"," + "\"loginName\" : \"dummyName\"" + "}"); // create user with id KiiUser userWithId = KiiUser.UserWithID("dummyID"); Assert.IsNull(userWithId.Username); // refresh userWithId.Refresh(); Assert.AreEqual("dummyName", userWithId.Username); // verify request. string url = Utils.Path(ConstantValues.DEFAULT_BASE_URL, "apps", "appId", "users", "dummyID"); Assert.AreEqual(url, client.RequestUrl[0]); Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod[0]); MockHttpHeaderList headerList = client.RequestHeader[0]; Assert.AreEqual("appId", headerList["X-Kii-AppID"]); Assert.AreEqual("appKey", headerList["X-Kii-AppKey"]); Assert.IsTrue(headerList["X-Kii-SDK"].StartsWith("sn=cs;sv=")); }
public void Test_Reserved_Field() { string[] KiiUserReservedFields = new string[] { "loginName", "emailAddress", "phoneNumber", "displayName", "country", "locale", "userID", "password", "internalUserID", "phoneNumberVerified", "emailAddressVerified", "_hasPassword", "_disabled" }; KiiUser user = KiiUser.UserWithID("user-id-0001"); foreach (string reservedField in KiiUserReservedFields) { try { user [reservedField] = "value"; Assert.Fail("ArgumentException must be thrown"); } catch (ArgumentException expected) { } } }
public void Test_UserScopeSync() { LogIn("test-user-00001"); client.AddResponse(200, RESPONSE_BODY); string userID = "test_user"; string topicName = "test_topic"; KiiTopic topic = KiiUser.UserWithID(userID).Topic(topicName); IList <KiiACLEntry <KiiTopic, TopicAction> > entries = topic.ListAclEntries(); Assert.AreEqual(6, entries.Count); Assert.AreEqual(TopicAction.SEND_MESSAGE_TO_TOPIC, entries [0].Action); Assert.AreEqual("UUUU-5555-6666-7777-8888", ((KiiUser)entries [0].Subject).ID); Assert.AreEqual(TopicAction.SEND_MESSAGE_TO_TOPIC, entries [1].Action); Assert.AreEqual("GGGG-5555-6666-7777-8888", ((KiiGroup)entries[1].Subject).ID); Assert.AreEqual(TopicAction.SUBSCRIBE_TO_TOPIC, entries [2].Action); Assert.AreEqual(KiiAnonymousUser.Get(), entries [2].Subject); Assert.AreEqual(TopicAction.SUBSCRIBE_TO_TOPIC, entries [3].Action); Assert.AreEqual(KiiAnyAuthenticatedUser.Get(), entries [3].Subject); Assert.AreEqual(TopicAction.SUBSCRIBE_TO_TOPIC, entries [4].Action); Assert.AreEqual("UUUU-1111-2222-3333-4444", ((KiiUser)entries [4].Subject).ID); Assert.AreEqual(TopicAction.SUBSCRIBE_TO_TOPIC, entries [5].Action); Assert.AreEqual("GGGG-1111-2222-3333-4444", ((KiiGroup)entries[5].Subject).ID); Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod [0]); Assert.AreEqual(Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "users", userID, "topics", topicName, "acl"), client.RequestUrl [0]); }
public void Test_1_3_GroupWithID_ExistsInCloud_Refresh_AddMembers() { // mock refresh response MockHttpClientFactory factory = new MockHttpClientFactory(); Kii.HttpClientFactory = factory; MockHttpClient client = (MockHttpClient)factory.Client; client.AddResponse(200, "{" + "\"groupID\" : \"dummyId\"," + "\"name\" : \"MyGroup\"," + "\"owner\" : \"user1234\"" + "}"); // mock response for adding user client.AddResponse(201, "{}"); // create group string groupId = "dummyId"; KiiGroup group = KiiGroup.GroupWithID(groupId); Assert.IsNull(group.Name); // refresh group.Refresh(); Assert.AreEqual("MyGroup", group.Name); // add member string memberID = TextUtils.generateUUID(); KiiUser member = KiiUser.UserWithID(memberID); group.AddUser(member); HashSet <KiiUser> addUsers = (HashSet <KiiUser>)SDKTestHack.GetField(group, "addUsers"); HashSet <KiiUser> removeUsers = (HashSet <KiiUser>)SDKTestHack.GetField(group, "removeUsers"); Assert.AreEqual(1, addUsers.Count); Assert.AreEqual(0, removeUsers.Count); // Save group group.Save(); // Verify add member request string requestUrl = Utils.Path(ConstantValues.DEFAULT_BASE_URL, "apps", "appId", "groups", "dummyId", "members", memberID); Assert.AreEqual(requestUrl, client.RequestUrl[1]); Assert.AreEqual("PUT", client.RequestMethod[1].ToString()); Assert.AreEqual(AppConst.APP_ID, client.RequestHeader[1]["X-Kii-AppID"]); Assert.AreEqual(AppConst.APP_KEY, client.RequestHeader[1]["X-Kii-AppKey"]); Assert.AreEqual("Bearer token1234", client.RequestHeader[1]["Authorization"]); Assert.AreEqual(null, client.RequestBody[1]); // Verify local userList get empty. Assert.AreEqual(groupId, group.ID); addUsers = (HashSet <KiiUser>)SDKTestHack.GetField(group, "addUsers"); removeUsers = (HashSet <KiiUser>)SDKTestHack.GetField(group, "removeUsers"); Assert.AreEqual(0, addUsers.Count); Assert.AreEqual(0, removeUsers.Count); }
public void SetUp() { Kii.Initialize(AppConst.APP_ID, AppConst.APP_KEY, AppConst.APP_SITE); KiiUser user = KiiUser.UserWithID("user1234"); SDKTestHack.SetField(Kii.Instance, "mLoginUser", user); KiiCloudEngine.UpdateAccessToken("token1234"); }
public void Test_UserScopeWithPaginationASync() { LogIn("test-user-00001"); AddMockResponse(200, new string[] { "Topic1", "Topic2" }, "ab=12/12+"); AddMockResponse(200, new string[] { "Topic3" }, null); string userID = "test_user"; CountDownLatch cd = new CountDownLatch(1); KiiListResult <KiiTopic> topics = null; Exception exception = null; KiiUser.UserWithID(userID).ListTopics((KiiListResult <KiiTopic> t, Exception e) => { topics = t; exception = e; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 3))) { Assert.Fail("Callback not fired."); } Assert.IsNull(exception); Assert.IsTrue(topics.HasNext); Assert.AreEqual("ab=12/12+", topics.PaginationKey); Assert.AreEqual(2, topics.Result.Count); Assert.AreEqual("Topic1", topics.Result[0].Name); Assert.AreEqual("kiicloud://" + Utils.Path("users", userID, "topics", "Topic1"), topics.Result[0].Uri.ToString()); Assert.AreEqual("Topic2", topics.Result[1].Name); Assert.AreEqual("kiicloud://" + Utils.Path("users", userID, "topics", "Topic2"), topics.Result[1].Uri.ToString()); Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod [0]); Assert.AreEqual(Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "users", userID, "topics"), client.RequestUrl [0]); Assert.AreEqual("Bearer " + KiiUser.AccessToken, client.RequestHeader [0]["Authorization"]); String paginationKey = topics.PaginationKey; cd = new CountDownLatch(1); topics = null; exception = null; KiiUser.UserWithID(userID).ListTopics(paginationKey, (KiiListResult <KiiTopic> t, Exception e) => { topics = t; exception = e; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 3))) { Assert.Fail("Callback not fired."); } Assert.IsFalse(topics.HasNext); Assert.IsNull(topics.PaginationKey); Assert.AreEqual(1, topics.Result.Count); Assert.AreEqual("Topic3", topics.Result[0].Name); Assert.AreEqual("kiicloud://" + Utils.Path("users", userID, "topics", "Topic3"), topics.Result[0].Uri.ToString()); Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod [1]); Assert.AreEqual(Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "users", userID, "topics") + "?paginationKey=" + Uri.EscapeUriString("ab=12/12+"), client.RequestUrl [1]); Assert.AreEqual("Bearer " + KiiUser.AccessToken, client.RequestHeader [1]["Authorization"]); }
public void Test_UserScope404Sync() { LogIn("test-user-00001"); client.AddResponse(new NotFoundException("", null, "", NotFoundException.Reason.ACL_NOT_FOUND)); string userID = "test_user"; string topicName = "test_topic"; KiiTopic topic = KiiUser.UserWithID(userID).Topic(topicName); topic.ListAclEntries(); }
public void Test_UserScopeTrueSync() { LogIn("test-user-00001"); client.AddResponse(204, null); string userID = "test_user"; string topicName = "test_topic"; KiiTopic topic = KiiUser.UserWithID(userID).Topic(topicName); Assert.IsTrue(topic.Exists()); Assert.AreEqual(KiiHttpMethod.HEAD, client.RequestMethod [0]); Assert.AreEqual(Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "users", userID, "topics", topicName), client.RequestUrl [0]); }
public void Test_UserScopeFalseSync() { LogIn("test-user-00001"); client.AddResponse(new NotFoundException("", null, "", NotFoundException.Reason.TOPIC_NOT_FOUND)); string userID = "test_user"; string topicName = "test_topic"; KiiTopic topic = KiiUser.UserWithID(userID).Topic(topicName); Assert.IsFalse(topic.Exists()); Assert.AreEqual(KiiHttpMethod.HEAD, client.RequestMethod [0]); Assert.AreEqual(Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "users", userID, "topics", topicName), client.RequestUrl [0]); }
private KiiSubject GetSubjetFromUserID(string userID) { if (string.Compare(userID, "ANONYMOUS_USER", true) == 0) { return(KiiAnonymousUser.Get()); } else if (string.Compare(userID, "ANY_AUTHENTICATED_USER", true) == 0) { return(KiiAnyAuthenticatedUser.Get()); } else { return(KiiUser.UserWithID(userID)); } }
public void Test_UserScopeWithEmptyResultSync() { LogIn("test-user-00001"); AddMockResponse(200, new string[] {}, null); string userID = "test_user"; KiiListResult <KiiTopic> topics = KiiUser.UserWithID(userID).ListTopics(); Assert.IsFalse(topics.HasNext); Assert.IsNull(topics.PaginationKey); Assert.AreEqual(0, topics.Result.Count); Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod [0]); Assert.AreEqual(Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "users", userID, "topics"), client.RequestUrl [0]); Assert.AreEqual("Bearer " + KiiUser.AccessToken, client.RequestHeader [0]["Authorization"]); }
public void Test_0003_initialize_2times_same() { Kii.Initialize("ee573743", "5eb7b8bc1b4e4c98e659431c69cef8d4", Kii.Site.US); Assert.AreEqual("ee573743", Kii.AppId); Assert.AreEqual("5eb7b8bc1b4e4c98e659431c69cef8d4", Kii.AppKey); Assert.AreEqual("https://api.kii.com/api", Kii.BaseUrl); KiiUser user = KiiUser.UserWithID("dummyID"); _KiiInternalUtils.SetCurrentUser(user); KiiCloudEngine.UpdateAccessToken("accesstoken"); // same id and key Kii.Initialize("ee573743", "5eb7b8bc1b4e4c98e659431c69cef8d4", Kii.Site.US); Assert.AreEqual("ee573743", Kii.AppId); Assert.AreEqual("5eb7b8bc1b4e4c98e659431c69cef8d4", Kii.AppKey); Assert.AreEqual("https://api.kii.com/api", Kii.BaseUrl); Assert.AreEqual(user, KiiUser.CurrentUser); Assert.AreEqual("accesstoken", KiiCloudEngine.AccessToken); }
public void Test_UserScopeASync() { LogIn("test-user-00001"); client.AddResponse(200, RESPONSE_BODY); string userID = "test_user"; string topicName = "test_topic"; KiiTopic topic = KiiUser.UserWithID(userID).Topic(topicName); CountDownLatch cd = new CountDownLatch(1); IList <KiiACLEntry <KiiTopic, TopicAction> > entries = null; Exception exception = null; topic.ListAclEntries((IList <KiiACLEntry <KiiTopic, TopicAction> > result, Exception e) => { entries = result; exception = e; cd.Signal(); }); if (!cd.Wait(new TimeSpan(0, 0, 0, 3))) { Assert.Fail("Callback not fired."); } Assert.IsNull(exception); Assert.AreEqual(6, entries.Count); Assert.AreEqual(TopicAction.SEND_MESSAGE_TO_TOPIC, entries [0].Action); Assert.AreEqual("UUUU-5555-6666-7777-8888", ((KiiUser)entries [0].Subject).ID); Assert.AreEqual(TopicAction.SEND_MESSAGE_TO_TOPIC, entries [1].Action); Assert.AreEqual("GGGG-5555-6666-7777-8888", ((KiiGroup)entries[1].Subject).ID); Assert.AreEqual(TopicAction.SUBSCRIBE_TO_TOPIC, entries [2].Action); Assert.AreEqual(KiiAnonymousUser.Get(), entries [2].Subject); Assert.AreEqual(TopicAction.SUBSCRIBE_TO_TOPIC, entries [3].Action); Assert.AreEqual(KiiAnyAuthenticatedUser.Get(), entries [3].Subject); Assert.AreEqual(TopicAction.SUBSCRIBE_TO_TOPIC, entries [4].Action); Assert.AreEqual("UUUU-1111-2222-3333-4444", ((KiiUser)entries [4].Subject).ID); Assert.AreEqual(TopicAction.SUBSCRIBE_TO_TOPIC, entries [5].Action); Assert.AreEqual("GGGG-1111-2222-3333-4444", ((KiiGroup)entries[5].Subject).ID); Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod [0]); Assert.AreEqual(Utils.Path(Kii.BaseUrl, "apps", Kii.AppId, "users", userID, "topics", topicName, "acl"), client.RequestUrl [0]); }
private IEnumerator TestStep() { string username = StringUtils.RandomAlphabetic(20); string password = StringUtils.RandomAlphabetic(20); KiiUser user = KiiUser.BuilderWithName(username).Build(); var task = RegisterUser(user, password, (KiiUser u, Exception e) => { if (e != null) { throw new TestFailException(); } Debug.Log("Register user."); }); yield return(StartCoroutine(task)); string userId = StringUtils.RandomAlphabetic(20); KiiUser userWithId = KiiUser.UserWithID(userId); Exception exp = null; bool endFlag = false; userWithId.Refresh((KiiUser usr, Exception e) => { exp = e; endFlag = true; }); while (!endFlag) { yield return(new WaitForSeconds(1)); } if (exp == null) { throw new TestFailException(); } if (404 != ((CloudException)exp).Status) { throw new TestFailException(); } resultFlag = true; }
public void TestUserWithID_1_8_NotExistsInCloud_refresh() { // mock refresh response. MockHttpClientFactory factory = new MockHttpClientFactory(); Kii.HttpClientFactory = factory; MockHttpClient client = factory.Client; client.AddResponse(new CloudException(404, "USER_NOT_FOUND")); // create user with id. KiiUser userWithId = KiiUser.UserWithID("dummyID"); Assert.IsNull(userWithId.Username); // refresh CloudException exp = null; try { userWithId.Refresh(); Assert.Fail("Exception not thrown"); } catch (CloudException e) { exp = e; } Assert.IsNotNull(exp); Assert.AreEqual(404, exp.Status); // verify request. string url = Utils.Path(ConstantValues.DEFAULT_BASE_URL, "apps", "appId", "users", "dummyID"); Assert.AreEqual(url, client.RequestUrl[0]); Assert.AreEqual(KiiHttpMethod.GET, client.RequestMethod[0]); MockHttpHeaderList headerList = client.RequestHeader[0]; Assert.AreEqual("appId", headerList["X-Kii-AppID"]); Assert.AreEqual("appKey", headerList["X-Kii-AppKey"]); Assert.IsTrue(headerList["X-Kii-SDK"].StartsWith("sn=cs;sv=")); }
public void Test_GetInitialStatus() { KiiUser user = KiiUser.UserWithID("dummyID"); Assert.IsFalse(user.Disabled); }
public void Test_2_1_UserWithNullID() { KiiUser.UserWithID(null); }
public void Test_2_2_UserWithEmptyID() { KiiUser.UserWithID(""); }
private void ExecListMembers(KiiHttpClientFactory factory, KiiUserListCallback callback) { Utils.CheckInitialize(true); string groupId = ID; if (Utils.IsEmpty(groupId)) { if (callback != null) { callback(null, new InvalidOperationException(ErrorInfo.KIIGROUP_NO_ID)); } return; } string getUrl = Utils.Path(MembersUrl); KiiHttpClient client = factory.Create(getUrl, Kii.AppId, Kii.AppKey, KiiHttpMethod.GET); KiiCloudEngine.SetAuthBearer(client); client.Accept = "application/vnd.kii.MembersRetrievalResponse+json"; // send request client.SendRequest((ApiResponse response, Exception e) => { if (e != null) { if (callback != null) { callback(null, e); } return; } // parse response List <KiiUser> members = new List <KiiUser>(); try { JsonObject respObj = new JsonObject(response.Body); JsonArray array = respObj.GetJsonArray("members"); if (array == null || array.Length() == 0) { if (callback != null) { callback(members, null); } return; } for (int i = 0; i < array.Length(); i++) { JsonObject obj = array.GetJsonObject(i); string id = obj.GetString("userID"); if (Utils.IsEmpty(id)) { callback(null, new IllegalKiiBaseObjectFormatException(response.Body)); return; } KiiUser user = KiiUser.UserWithID(id); members.Add(user); } } catch (JsonException) { if (callback != null) { callback(null, new IllegalKiiBaseObjectFormatException(response.Body)); } return; } if (callback != null) { callback(members, null); } }); }