/// <summary>
        /// Gets the profile with the specified profile name.
        /// </summary>
        /// <param name="profileName">The name of the profile to load.</param>
        /// <returns>The profile or null if the profile name was not found.</returns>
        private Profile LoadProfile(string profileName)
        {
            ProfilesRequest profileRequest = new ProfilesRequest()
            {
                Language        = "EN",
                SecurityContext = this.securityContext,
                Type            = ProfileType.Static      // Only static profiles can be used for the subscriberimport.
            };

            try {
                ProfilesResponse profileResponse = this.serviceAgent.GetProfiles(profileRequest);

                if (profileResponse != null)
                {
                    // Search the profile with the given name.
                    return(profileResponse.Profiles.FirstOrDefault(p => p.Name.Equals(profileName)));
                }

                return(null);
            }
            catch (Exception ex) {
                // A error occured
                Console.WriteLine(ex.ToString());
                throw;
            }
        }
        public async Task <IHttpActionResult> UpdateProfilesAsync(ProfilesRequest request)
        {
            var response = new ProfilesResponse();

            await _profileService.UpdateProfilesAsync(request.ProfilesViewModel);

            response.StatusCode = (int)HttpStatusCode.OK;

            return(Ok(response));
        }
Пример #3
0
        public async Task <ProfilesResponse> GetProfilesResponseAsync(ProfilesRequest profilesRequest)
        {
            var request = new RestRequest(ApiRoutes.Profiles, Method.GET);

            request.AddHeaders(GetCommonHeaders(profilesRequest.Ticket, profilesRequest.UbiAppId, profilesRequest.SessionId));
            request.AddParameter("nameOnPlatform", string.Join(",", profilesRequest.Names), ParameterType.QueryString);
            request.AddParameter("platformType", profilesRequest.Platform);

            return(await ExecuteRequestAsync <ProfilesResponse>(request));
        }
        public async Task <IHttpActionResult> InsertProfilesAsync(ProfilesRequest request)
        {
            var response = new ProfilesResponse();

            var accountId = Identity.ToAccountID();
            await _profileService.InsertProfilesAsync(request.ProfilesViewModel);

            response.StatusCode = (int)HttpStatusCode.OK;

            return(Ok(response));
        }
        public async Task <ProfileResponse> GetProfilesBatchAsync(ulong[] xuids, ProfileSetting[] settings = null)
        {
            var request = new HttpRequestMessage(HttpMethod.Post, "users/batch/profile/settings");

            ProfileSetting[] profileSettings = settings != null ? settings : new ProfileSetting[]
            {
                ProfileSetting.AppDisplayName, ProfileSetting.Gamerscore,
                ProfileSetting.Gamertag, ProfileSetting.PublicGamerpic,
                ProfileSetting.XboxOneRep, ProfileSetting.RealName
            };
            ProfilesRequest body = new ProfilesRequest(xuids, profileSettings);

            request.Headers.Add(Headers);
            request.Content = new JsonContent(body, JsonNamingStrategy.CamelCase);

            var response = await HttpClient.SendAsync(request);

            return(await response.Content.ReadAsJsonAsync <ProfileResponse>());
        }
Пример #6
0
        public ProfileResponse GetProfilesBatch(ulong[] xuids, ProfileSetting[] settings = null)
        {
            RestRequestEx request = new RestRequestEx("users/batch/profile/settings",
                                                      Method.POST);

            ProfileSetting[] profileSettings = settings != null ? settings : new ProfileSetting[]
            {
                ProfileSetting.AppDisplayName, ProfileSetting.Gamerscore,
                ProfileSetting.Gamertag, ProfileSetting.PublicGamerpic,
                ProfileSetting.XboxOneRep, ProfileSetting.RealName
            };
            ProfilesRequest body = new ProfilesRequest(xuids, profileSettings);

            request.AddHeaders(Headers);
            request.AddJsonBody(body, JsonNamingStrategy.CamelCase);

            IRestResponse <ProfileResponse> response = HttpClient.Execute <ProfileResponse>(request);

            return(response.Data);
        }
Пример #7
0
        public async Task <IEnumerable <Player> > GetPlayersAsync(IEnumerable <string> usernames, EPlatform platform)
        {
            if (usernames == null)
            {
                throw new ArgumentNullException(nameof(usernames));
            }
            if (!Enum.IsDefined(typeof(EPlatform), platform))
            {
                throw new InvalidEnumArgumentException(nameof(platform), (int)platform, typeof(EPlatform));
            }

            var playersRequest = new ProfilesRequest
            {
                UbiAppId  = _settings.UbiAppId,
                Ticket    = _ticket,
                SessionId = _sessionId,
                Platform  = platform,
                Names     = usernames
            };

            var profilesResponse = await _apiManager.GetProfilesResponseAsync(playersRequest);

            return(profilesResponse.Profiles.Select(ApiMapper.GetMappedPlayer));
        }
 public async Task <ProfilesResponse> GetProfilesAsync(ProfilesRequest request)
 {
     // get the auto created profile based on hash and save the live key
     return(await PostAsync <ProfilesResponse>(ProfileListCommand, request));
 }