/// <summary> /// Adds members to a group or role. /// </summary> public static void AddMembers(AddMembersRequest request, Action <EmptyResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null) { var context = (request == null ? null : request.AuthenticationContext) ?? PlayFabSettings.staticPlayer; PlayFabHttp.MakeApiCall("/Group/AddMembers", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context); }
/// <summary> /// Adds members to a group or role. /// </summary> public static async Task <PlayFabResult <EmptyResponse> > AddMembersAsync(AddMembersRequest request, object customData = null, Dictionary <string, string> extraHeaders = null) { if ((request?.AuthenticationContext?.EntityToken ?? PlayFabSettings.staticPlayer.EntityToken) == null) { throw new PlayFabException(PlayFabExceptionCode.EntityTokenNotSet, "Must call GetEntityToken before calling this method"); } var httpResult = await PlayFabHttp.DoPost("/Group/AddMembers", request, "X-EntityToken", PlayFabSettings.staticPlayer.EntityToken, extraHeaders); if (httpResult is PlayFabError) { var error = (PlayFabError)httpResult; PlayFabSettings.GlobalErrorHandler?.Invoke(error); return(new PlayFabResult <EmptyResponse> { Error = error, CustomData = customData }); } var resultRawJson = (string)httpResult; var resultData = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer).DeserializeObject <PlayFabJsonSuccess <EmptyResponse> >(resultRawJson); var result = resultData.data; return(new PlayFabResult <EmptyResponse> { Result = result, CustomData = customData }); }
/// <summary> /// Adds members to a group or role. /// </summary> public void AddMembers(AddMembersRequest request, Action <EmptyResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null) { var context = (request == null ? null : request.AuthenticationContext) ?? authenticationContext; var callSettings = apiSettings ?? PlayFabSettings.staticSettings; if (!context.IsEntityLoggedIn()) { throw new PlayFabException(PlayFabExceptionCode.NotLoggedIn, "Must be logged in to call this method"); } PlayFabHttp.MakeApiCall("/Group/AddMembers", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders, context, callSettings, this); }
public async Task <JsonResult> AddMembers([FromBody] AddMembersRequest req) { var group = await groupRepo.GetById(req.Title); if (group == null) { return(Json(new BaseResponse(false, "Group does not exist"))); } group.membersList.Concat(req.Members); await groupRepo.Save(); return(Json(new BaseResponse(true))); }
/// <summary> /// Adds members to a group or role. /// </summary> /// <param name="Group">The identifier of the group (Required)</param> /// <param name="Members">List of entities to add to the group. Only entities of type title_player_account and character may be added to groups. (Required)</param> /// <param name="RoleId">Optional: The ID of the existing role to add the entities to. If this is not specified, the default member role for the group will be used. Role IDs must be between 1 and 64 characters long. (Optional)</param> public static Task <EmptyResponse> AddMembers(EntityKey Group, List <EntityKey> Members, string RoleId = default, PlayFabAuthenticationContext customAuthContext = null, object customData = null, Dictionary <string, string> extraHeaders = null) { AddMembersRequest request = new AddMembersRequest() { Group = Group, Members = Members, RoleId = RoleId, }; var context = GetContext(customAuthContext); return(PlayFabHttp.MakeApiCallAsync <EmptyResponse>("/Group/AddMembers", request, AuthType.EntityToken, customData, extraHeaders, context)); }
public async Task <JsonResult> RemoveMembers([FromBody] AddMembersRequest req) { var group = await groupRepo.GetById(req.Title); if (group == null) { return(Json(new BaseResponse(false, "Group does not exist"))); } var ids = req.Members.Select(m => m.Id); group.membersList = new HashSet <GroupMember>( group.membersList.Where(m => !ids.Contains(m.Id))); await groupRepo.Save(); return(Json(new BaseResponse(true))); }
/// <summary> /// Adds members to a group or role. /// </summary> public static void AddMembers(AddMembersRequest request, Action <EmptyResponse> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null) { PlayFabHttp.MakeApiCall("/Group/AddMembers", request, AuthType.EntityToken, resultCallback, errorCallback, customData, extraHeaders); }