public async ValueTask <BungieResponse <PartnerOfferSkuHistoryResponse[]> > GetPartnerOfferSkuHistory(
        AuthorizationTokenData authorizationToken,
        int partnerApplicationId,
        long targetBnetMembershipId,
        CancellationToken cancellationToken = default)
    {
        if (!_configuration.HasSufficientRights(ApplicationScopes.PartnerOfferGrant))
        {
            throw new InsufficientScopeException(ApplicationScopes.PartnerOfferGrant);
        }

        var url = StringBuilderPool
                  .GetBuilder(cancellationToken)
                  .Append("/Tokens/Partner/History/")
                  .AddUrlParam(partnerApplicationId.ToString())
                  .AddUrlParam(targetBnetMembershipId.ToString())
                  .Build();

        return(await _dotNetBungieApiHttpClient
               .GetFromBungieNetPlatform <PartnerOfferSkuHistoryResponse[]>(
                   url,
                   cancellationToken,
                   authorizationToken.AccessToken)
               .ConfigureAwait(false));
    }
Exemple #2
0
    public async ValueTask <BungieResponse <ApiUsage> > GetApplicationApiUsage(
        AuthorizationTokenData authorizationToken,
        int applicationId,
        DateTime?start = null,
        DateTime?end   = null,
        CancellationToken cancellationToken = default)
    {
        if (!_configuration.HasSufficientRights(ApplicationScopes.ReadUserData))
        {
            throw new InsufficientScopeException(ApplicationScopes.ReadUserData);
        }
        if (start.HasValue && end.HasValue && (end.Value - start.Value).TotalHours > 48)
        {
            throw new Exception("Can't request more than 48 hours.");
        }
        end ??= DateTime.Now;
        start ??= end.Value.AddHours(-24);
        var url = StringBuilderPool
                  .GetBuilder(cancellationToken)
                  .Append("/App/ApiUsage/")
                  .AddQueryParam("start",
                                 start.Value.ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture))
                  .AddQueryParam("end",
                                 end.Value.ToString("yyyy-MM-ddTHH:mm:ss", CultureInfo.InvariantCulture))
                  .Build();

        return(await _dotNetBungieApiHttpClient
               .GetFromBungieNetPlatform <ApiUsage>(url, cancellationToken, authorizationToken.AccessToken)
               .ConfigureAwait(false));
    }
    public async ValueTask <BungieResponse <int> > GetActivePrivateClanFireteamCount(
        AuthorizationTokenData authorizationToken,
        long groupId,
        CancellationToken cancellationToken = default)
    {
        if (!_configuration.HasSufficientRights(ApplicationScopes.ReadGroups))
        {
            throw new InsufficientScopeException(ApplicationScopes.ReadGroups);
        }

        var url = StringBuilderPool
                  .GetBuilder(cancellationToken)
                  .Append("/Fireteam/Clan/")
                  .AddUrlParam(groupId.ToString())
                  .Append("ActiveCount/")
                  .Build();

        return(await _dotNetBungieApiHttpClient
               .GetFromBungieNetPlatform <int>(url, cancellationToken, authorizationToken.AccessToken)
               .ConfigureAwait(false));
    }
Exemple #4
0
    public async ValueTask <BungieResponse <int> > TransferItem(
        DestinyItemTransferRequest request,
        AuthorizationTokenData authorizationToken,
        CancellationToken cancellationToken = default)
    {
        if (!_configuration.HasSufficientRights(ApplicationScopes.MoveEquipDestinyItems))
        {
            throw new InsufficientScopeException(ApplicationScopes.MoveEquipDestinyItems);
        }
        var stream = new MemoryStream();
        await _serializer.SerializeAsync(stream, request);

        return(await _dotNetBungieApiHttpClient
               .PostToBungieNetPlatform <int>("/Destiny2/Actions/Items/TransferItem/", cancellationToken, stream,
                                              authorizationToken.AccessToken)
               .ConfigureAwait(false));
    }
    public async ValueTask <BungieResponse <UserMembershipData> > GetMembershipDataForCurrentUser(
        AuthorizationTokenData authorizationToken,
        CancellationToken cancellationToken = default)
    {
        if (!_configuration.HasSufficientRights(ApplicationScopes.ReadBasicUserProfile))
        {
            throw new InsufficientScopeException(ApplicationScopes.ReadBasicUserProfile);
        }

        return(await _dotNetBungieApiHttpClient
               .GetFromBungieNetPlatform <UserMembershipData>(
                   "/User/GetMembershipsForCurrentUser/",
                   cancellationToken,
                   authorizationToken.AccessToken)
               .ConfigureAwait(false));
    }
Exemple #6
0
 public async ValueTask <BungieResponse <BungieFriendListResponse> > GetFriendList(
     AuthorizationTokenData authorizationToken,
     CancellationToken cancellationToken = default)
 {
     if (!_configuration.HasSufficientRights(ApplicationScopes.ReadUserData))
     {
         throw new InsufficientScopeException(ApplicationScopes.ReadUserData);
     }
     return(await _dotNetBungieApiHttpClient
            .GetFromBungieNetPlatform <BungieFriendListResponse>(
                "/Social/Friends/",
                cancellationToken,
                authorizationToken.AccessToken)
            .ConfigureAwait(false));
 }
Exemple #7
0
    public async ValueTask <BungieResponse <bool> > GetUserClanInviteSetting(
        AuthorizationTokenData authorizationToken,
        BungieMembershipType mType,
        CancellationToken cancellationToken = default)
    {
        if (!_configuration.HasSufficientRights(ApplicationScopes.ReadUserData))
        {
            throw new InsufficientScopeException(ApplicationScopes.ReadUserData);
        }

        var url = StringBuilderPool
                  .GetBuilder(cancellationToken)
                  .Append("/GroupV2/GetUserClanInviteSetting/")
                  .AddUrlParam(((int)mType).ToString())
                  .Build();

        return(await _dotNetBungieApiHttpClient
               .GetFromBungieNetPlatform <bool>(url, cancellationToken, authorizationToken.AccessToken)
               .ConfigureAwait(false));
    }