コード例 #1
0
 /// <inheritdoc cref="FortniteService.MarkItemSeen"/>
 public async Task <McpResponse> MarkItemSeen(Profile profile, MarkItemSeen payload, int revision = -1)
 => await FortniteService.MarkItemSeen(this, profile, payload, revision);
コード例 #2
0
        /// <summary>
        /// Executes the MarkItemSeen command which marks an item within the profile as seen for the account bound to the provided <see cref="OAuthSession"/>.
        /// </summary>
        /// <param name="oAuthSession">The <see cref="OAuthSession"/> to use for authentication.</param>
        /// <param name="profile">The profile to retrieve the profile data of.</param>
        /// <param name="revision">The operation revision. This parameter is optional.</param>
        /// <param name="payload">The payload for the request.</param>
        /// <returns>The <see cref="McpResponse"/> of the executed command.</returns>
        internal static async Task <McpResponse> MarkItemSeen(OAuthSession oAuthSession, Profile profile, MarkItemSeen payload, int revision = -1)
        {
            var profileId = profile.GetAttribute <ValueAttribute>().Value;

            // We're using a using statement so that the initialised client is disposed of when the code block is exited.
            using var client = new WebClient
                  {
                      Headers =
                      {
                          // This is so Epic Games' API knows what kind of data we're providing.
                          [HttpRequestHeader.ContentType] = "application/json",
                          // Set the Authorization header to the access token from the provided OAuthSession.
                          [HttpRequestHeader.Authorization] = $"bearer {oAuthSession.AccessToken}"
                      }
                  };

            // Use our request helper to make a POST request, and return the response data deserialized into the appropriate type.
            return(await client.PostDataAsync <McpResponse>(Endpoints.Fortnite.Mcp.MarkItemSeen(oAuthSession.AccountId, profileId, revision),
                                                            JsonConvert.SerializeObject(payload)).ConfigureAwait(false));
        }