public async Task <DataProfileResult[]> GetProfileSearch(ProfileSearchRequestBody requestBody) { var request = new ProfileSearchRequest { Body = requestBody }; var client = await Connect(); var response = (await client.ProfileSearchAsync(request))?.Body; if (!string.IsNullOrEmpty(response?.error_msg)) { throw new Exception(response.error_msg); } var responseResult = response?.ProfileSearchResult; if (responseResult?.Length > 0) { ((IClientChannel)client).Close(); } return(responseResult); }
public async Task <CharacterOverview> GetCharacterOverview(long id, ProfileSearchRequest data) { return(await WebApiConfig._DestinyApi.GetCharacterBreakdown(data.MembershipId, data.MembershipType, id)); }
public async Task <Dictionary <long, CharacterOverview> > GetCharactersOverview(ProfileSearchRequest data) { return(await WebApiConfig._DestinyApi.GetCharacterBreakdowns(data.MembershipId, data.MembershipType)); }
public async Task <SearchDestinyPlayerResponse> SearchDestinyPlayer(ProfileSearchRequest data) { return(await WebApiConfig._DestinyApi.SearchDestinyPlayer(data.DisplayName, data.MembershipType)); }
/// <summary> /// Checks whether the profile search request is valid. /// </summary> /// <param name="ProfileSearchRequest">Profile search request part of the client's request message.</param> /// <param name="MessageBuilder">Client's network message builder.</param> /// <param name="RequestMessage">Full request message from client.</param> /// <param name="ErrorResponse">If the function fails, this is filled with error response message that is ready to be sent to the client.</param> /// <returns>true if the profile search request is valid, false otherwise.</returns> public static bool ValidateProfileSearchRequest(ProfileSearchRequest ProfileSearchRequest, PsMessageBuilder MessageBuilder, PsProtocolMessage RequestMessage, out PsProtocolMessage ErrorResponse) { log.Trace("()"); bool res = false; ErrorResponse = null; string details = null; if (ProfileSearchRequest == null) { ProfileSearchRequest = new ProfileSearchRequest(); } bool includeImages = ProfileSearchRequest.IncludeThumbnailImages; int responseResultLimit = includeImages ? PsMessageProcessor.ProfileSearchMaxResponseRecordsWithImage : PsMessageProcessor.ProfileSearchMaxResponseRecordsWithoutImage; int totalResultLimit = includeImages ? PsMessageProcessor.ProfileSearchMaxTotalRecordsWithImage : PsMessageProcessor.ProfileSearchMaxTotalRecordsWithoutImage; bool maxResponseRecordCountValid = (1 <= ProfileSearchRequest.MaxResponseRecordCount) && (ProfileSearchRequest.MaxResponseRecordCount <= responseResultLimit); if (!maxResponseRecordCountValid) { log.Debug("Invalid maxResponseRecordCount value '{0}'.", ProfileSearchRequest.MaxResponseRecordCount); details = "maxResponseRecordCount"; } if (details == null) { bool maxTotalRecordCountValid = (1 <= ProfileSearchRequest.MaxTotalRecordCount) && (ProfileSearchRequest.MaxTotalRecordCount <= totalResultLimit) && (ProfileSearchRequest.MaxResponseRecordCount <= ProfileSearchRequest.MaxTotalRecordCount); if (!maxTotalRecordCountValid) { log.Debug("Invalid maxTotalRecordCount value '{0}'.", ProfileSearchRequest.MaxTotalRecordCount); details = "maxTotalRecordCount"; } } if ((details == null) && (ProfileSearchRequest.Type != null)) { bool typeValid = Encoding.UTF8.GetByteCount(ProfileSearchRequest.Type) <= PsMessageBuilder.MaxProfileSearchTypeLengthBytes; if (!typeValid) { log.Debug("Invalid type value length '{0}'.", ProfileSearchRequest.Type.Length); details = "type"; } } if ((details == null) && (ProfileSearchRequest.Name != null)) { bool nameValid = Encoding.UTF8.GetByteCount(ProfileSearchRequest.Name) <= PsMessageBuilder.MaxProfileSearchNameLengthBytes; if (!nameValid) { log.Debug("Invalid name value length '{0}'.", ProfileSearchRequest.Name.Length); details = "name"; } } if ((details == null) && (ProfileSearchRequest.Latitude != GpsLocation.NoLocationLocationType)) { GpsLocation locLat = new GpsLocation(ProfileSearchRequest.Latitude, 0); GpsLocation locLong = new GpsLocation(0, ProfileSearchRequest.Longitude); if (!locLat.IsValid()) { log.Debug("Latitude '{0}' is not a valid GPS latitude value.", ProfileSearchRequest.Latitude); details = "latitude"; } else if (!locLong.IsValid()) { log.Debug("Longitude '{0}' is not a valid GPS longitude value.", ProfileSearchRequest.Longitude); details = "longitude"; } } if ((details == null) && (ProfileSearchRequest.Latitude != GpsLocation.NoLocationLocationType)) { bool radiusValid = ProfileSearchRequest.Radius > 0; if (!radiusValid) { log.Debug("Invalid radius value '{0}'.", ProfileSearchRequest.Radius); details = "radius"; } } if ((details == null) && (ProfileSearchRequest.ExtraData != null)) { bool validLength = (Encoding.UTF8.GetByteCount(ProfileSearchRequest.ExtraData) <= PsMessageBuilder.MaxProfileSearchExtraDataLengthBytes); bool extraDataValid = RegexTypeValidator.ValidateRegex(ProfileSearchRequest.ExtraData); if (!validLength || !extraDataValid) { log.Debug("Invalid extraData regular expression filter."); details = "extraData"; } } if (details == null) { res = true; } else { ErrorResponse = MessageBuilder.CreateErrorInvalidValueResponse(RequestMessage, details); } log.Trace("(-):{0}", res); return(res); }