/// <summary> /// Replaces a member's public profile. /// </summary> /// <param name="profile">the profile to set</param> /// <returns>the profile that was set</returns> public Task <Profile> SetProfile(Profile profile) { var request = new SetProfileRequest { Profile = profile }; return(gateway(authenticationContext()).SetProfileAsync(request) .ToTask(response => response.Profile)); }
public async Task SetProfile(CancellationToken cancellationToken = default) { var profile = SelectedProfile?.ProfileName; if (string.IsNullOrWhiteSpace(profile)) { return; } var model = SetProfileRequest.Create(profile); var json = JsonSerializer.Serialize(model); await _server.SendAsync(SelectedClient, json, cancellationToken) .ConfigureAwait(false); }
public async Task GetSetProfile() { var p = await remoteGateway.GetProfile(); Assert.IsTrue(p == new GetProfileResponse()); var n = new SetProfileRequest { Name = "name", Tagline = "tagline", Bio = "bio", AvatarHash = "avatarresource" }; await remoteGateway.SetProfile(n); p = await remoteGateway.GetProfile(); Assert.IsTrue((p.Name, p.Tagline, p.Bio) == (n.Name, n.Tagline, n.Bio)); }
public async Task Set(SetProfileRequest r, PublicIdentity client) { await users.Authenticate(client, User.Auth.Self); if (r.Name.Length > 18) { throw new APIException($"Name used {r.Name.Length}/18 characters."); } if (r.Tagline.Length > 30) { throw new APIException($"Tagline used {r.Tagline.Length}/30 characters."); } if (r.Bio.Length > 400) { throw new APIException($"Bio used {r.Bio.Length}/400 characters."); } await conn.InsertOrReplaceAsync(Profile.FromSetRequest(r, users.Self)); }
public override Task SetProfile(SetProfileRequest request, PublicIdentity?client) => Call(() => profiles.Set(request, client.GuardNull()));
public void DataRecievedHandler(ServerPipe serverPipe, PipeEventArgs arguments) { var commandJsonString = arguments.String; BaseCommand baseCommand = JsonConvert.DeserializeObject <BaseCommand>(commandJsonString); if (baseCommand == null) { return; } switch (baseCommand.Command) { case ZC_Command.CONFIRM_CONNECT_HOST: { ConfirmConnectedHost response = JsonConvert.DeserializeObject <ConfirmConnectedHost>(commandJsonString); if (response != null && response.IsSuccess) { Profile selectedObject = profile; List <string> ByPassListPattern = selectedObject.ByPassProxySites.Select(p => { return($"*{p}*"); }).ToList(); SetProfileRequest request = new SetProfileRequest() { Command = ZC_Command.SET_PROFILE_REQUEST, Profile = new BrowserProfile() { Id = selectedObject.Id, Email = selectedObject.Email, CPU = selectedObject.CPU, Battery = selectedObject.Battery, EnableAudioApi = selectedObject.EnableAudioApi, EnablePlugins = selectedObject.EnablePlugins, EnableMediaPlugins = selectedObject.EnableMediaPlugins, Fonts = selectedObject.Fonts, RandomTimersEnabled = selectedObject.RandomTimersEnabled, UserAgent = selectedObject.UserAgent, Screen = selectedObject.Screen, HistoryLength = selectedObject.HistoryLength, WebGL = selectedObject.WebGL, FakeClientRects = true, Canvas = selectedObject.Canvas, EnableNetwork = selectedObject.EnableNetwork, Language = selectedObject.Language, GeoIpEnabled = selectedObject.GeoIpEnabled, ProxyEnabled = selectedObject.ProxyEnabled, Proxies = selectedObject.Proxies.Where(p => p.Enabled).ToList(), ByPassProxySites = ByPassListPattern, } }; serverPipe.WriteString(JsonConvert.SerializeObject(request)); } break; } case ZC_Command.NOTIFICATION: { Notification response = JsonConvert.DeserializeObject <Notification>(commandJsonString); if (response != null && response.IsSuccess) { Notification request = new Notification() { Type = NotificationType.INFOR, IsSuccess = true, Message = "Hello from zchanger application" }; serverPipe.WriteString(JsonConvert.SerializeObject(request)); } break; } case ZC_Command.DISCONNECT: { DissposeHostConnection(serverPipe.Id); break; } } }
/// <summary> /// Sets the profile. /// </summary> public abstract Task SetProfile(SetProfileRequest request, PublicIdentity?client = null);
public IHttpActionResult SetProfileAction([FromUri] GetProfilesByProductRequest uriObj, [FromBody] SetProfileRequest bodyObj) { try { // Verify at least object arrives with data if (bodyObj == null) { throw new NotEnoughAttributesException("No se ha recibido ningún parámetro"); } // Verify required parameters if (String.IsNullOrEmpty(bodyObj.Name) || String.IsNullOrEmpty(bodyObj.Description) || String.IsNullOrEmpty(bodyObj.TagName)) { throw new NotEnoughAttributesException("No se han recibido todos los parámetros requeridos"); } // Business layer ActionResponse action = core.SetProfileAction( uriObj.idProduct, bodyObj ); if (action.code == (int)CodeStatusEnum.OK) { return(ResponseOk(action.data)); } else { return(ResponseError(action.code, action.message)); } } catch (NotValidDataException e) { logger.Error(e.Message); return(ResponseError((int)CodeStatusEnum.BAD_REQUEST, e.Message)); } catch (NotEnoughAttributesException e) { logger.Error(e.Message); return(ResponseError((int)CodeStatusEnum.BAD_REQUEST, e.Message)); } catch (Exception ex) { logger.Fatal(ex.Message); return(ResponseError((int)CodeStatusEnum.INTERNAL_ERROR, "Error desconocido en el sistema: " + ex.Message)); } }