public IEnumerator BulkFriendRequest(string @namespace, string ownUserId, BulkFriendsRequest userIds, string accessToken, ResultCallback callback) { Assert.IsNotNull(@namespace, nameof(@namespace) + " cannot be null"); Assert.IsNotNull(ownUserId, nameof(ownUserId) + " cannot be null"); Assert.IsNotNull(userIds, nameof(userIds) + " cannot be null"); Assert.IsNotNull(accessToken, nameof(accessToken) + " cannot be null"); var request = HttpRequestBuilder .CreatePost(this.baseUrl + "/friends/namespaces/{namespace}/users/{userId}/add/bulk") .WithPathParam("namespace", @namespace) .WithPathParam("userId", ownUserId) .WithBearerAuth(accessToken) .WithContentType(MediaType.ApplicationJson) .Accepts(MediaType.ApplicationJson) .WithBody(userIds.ToUtf8Json()) .GetResult(); IHttpResponse response = null; yield return(this.httpWorker.SendRequest(request, rsp => response = rsp)); var result = response.TryParse(); callback.Try(result); }
/// <summary> /// Send request friend request in bulk. /// </summary> /// <param name="userIds">Targeted user ID.</param> /// <param name="callback">Returns a Result via callback when completed.</param> public void BulkRequestFriend(string[] userIds, ResultCallback callback) { Report.GetFunctionLog(this.GetType().Name); if (!this.session.IsValid()) { callback.TryError(ErrorCode.IsNotLoggedIn); return; } BulkFriendsRequest otherUserIds = new BulkFriendsRequest { friendIds = userIds }; this.coroutineRunner.Run( this.api.BulkFriendRequest( this.@namespace, this.session.UserId, otherUserIds, this.session.AuthorizationToken, callback)); }