Ejemplo n.º 1
0
        public async Task <FullfilmentRequestResult> ActivateSubscriptionAsync(Guid subscriptionId, ActivatedSubscription subscriptionDetails, Guid requestId, Guid correlationId, string bearerToken, CancellationToken cancellationToken)
        {
            var requestUrl = FluentUriBuilder
                             .Start(this.baseUri)
                             .AddPath("subscriptions")
                             .AddPath(subscriptionId.ToString())
                             .AddPath("activate")
                             .AddQuery(DefaultApiVersionParameterName, this.apiVersion)
                             .Uri;

            requestId     = requestId == default ? Guid.NewGuid() : requestId;
            correlationId = correlationId == default ? Guid.NewGuid() : correlationId;

            var response = await this.SendRequestAndReturnResult(
                HttpMethod.Post,
                requestUrl,
                requestId,
                correlationId,
                bearerToken,
                null,
                JsonConvert.SerializeObject(subscriptionDetails),
                cancellationToken);

            return(await FullfilmentRequestResult.ParseAsync <FullfilmentRequestResult>(response));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="marketplaceToken">
        /// Token query parameter in the URL when the user is redirected to the SaaS ISV’s website from Azure.
        /// Note: The URL decodes the token value from the browser before using it.
        /// This token is valid only for 1 hour
        /// </param>
        /// <param name="requestId"></param>
        /// <param name="correlationId"></param>
        /// <param name="bearerToken"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task <ResolvedSubscription> ResolveSubscriptionAsync(string marketplaceToken, Guid requestId, Guid correlationId, string bearerToken, CancellationToken cancellationToken)
        {
            var requestUrl = FluentUriBuilder
                             .Start(this.baseUri)
                             .AddPath("subscriptions")
                             .AddPath("resolve")
                             .AddQuery(DefaultApiVersionParameterName, this.apiVersion)
                             .Uri;

            requestId     = requestId == default ? Guid.NewGuid() : requestId;
            correlationId = correlationId == default ? Guid.NewGuid() : correlationId;

            var response = await this.SendRequestAndReturnResult(HttpMethod.Post,
                                                                 requestUrl,
                                                                 requestId,
                                                                 correlationId,
                                                                 bearerToken,
                                                                 r =>
            {
                r.Headers.Add("x-ms-marketplace-token", marketplaceToken);
            },
                                                                 "",
                                                                 cancellationToken);

            return(await FullfilmentRequestResult.ParseAsync <ResolvedSubscription>(response));
        }
Ejemplo n.º 3
0
        public async Task <UpdateOrDeleteSubscriptionRequestResult> UpdateSubscriptionAsync(Guid subscriptionId, ActivatedSubscription update, Guid requestId, Guid correlationId, string bearerToken, CancellationToken cancellationToken)
        {
            var requestUrl = FluentUriBuilder
                             .Start(this.baseUri)
                             .AddPath("subscriptions")
                             .AddPath(subscriptionId.ToString())
                             .AddQuery(DefaultApiVersionParameterName, this.apiVersion)
                             .Uri;

            requestId     = requestId == default ? Guid.NewGuid() : requestId;
            correlationId = correlationId == default ? Guid.NewGuid() : correlationId;
            var updateContent = JsonConvert.SerializeObject(update);

            if (!string.IsNullOrEmpty(update.PlanId) && !string.IsNullOrEmpty(update.Quantity))
            {
                throw new ApplicationException("Plan Id and quantity cannot be patched at the same time.");
            }

            var response = await this.SendRequestAndReturnResult(
                new HttpMethod("PATCH"),
                requestUrl,
                requestId,
                correlationId,
                bearerToken,
                null,
                updateContent,
                cancellationToken);

            return(await FullfilmentRequestResult.ParseAsync <UpdateOrDeleteSubscriptionRequestResult>(response));
        }
Ejemplo n.º 4
0
        public async Task <IEnumerable <Subscription> > GetSubscriptionsAsync(
            Guid requestId,
            Guid correlationId,
            string bearerToken, CancellationToken cancellationToken)
        {
            var requestUrl = FluentUriBuilder
                             .Start(this.baseUri)
                             .AddPath("subscriptions")
                             .AddQuery(DefaultApiVersionParameterName, this.apiVersion)
                             .Uri;

            requestId     = requestId == default ? Guid.NewGuid() : requestId;
            correlationId = correlationId == default ? Guid.NewGuid() : correlationId;

            var response = await this.SendRequestAndReturnResult(HttpMethod.Get,
                                                                 requestUrl,
                                                                 requestId,
                                                                 correlationId,
                                                                 bearerToken,
                                                                 null,
                                                                 "",
                                                                 cancellationToken);

            return(await FullfilmentRequestResult.ParseMultipleAsync <Subscription>(response));
        }
Ejemplo n.º 5
0
        public async Task <UpdateOrDeleteSubscriptionRequestResult> DeleteSubscriptionAsync(Guid subscriptionId, Guid requestId, Guid correlationId, string bearerToken, CancellationToken cancellationToken)
        {
            var requestUrl = FluentUriBuilder
                             .Start(this.baseUri)
                             .AddPath("subscriptions")
                             .AddPath(subscriptionId.ToString())
                             .AddQuery(DefaultApiVersionParameterName, this.apiVersion)
                             .Uri;

            requestId     = requestId == default ? Guid.NewGuid() : requestId;
            correlationId = correlationId == default ? Guid.NewGuid() : correlationId;

            var response = await this.SendRequestAndReturnResult(
                HttpMethod.Delete,
                requestUrl,
                requestId,
                correlationId,
                bearerToken,
                null,
                "",
                cancellationToken);

            return(await FullfilmentRequestResult.ParseAsync <UpdateOrDeleteSubscriptionRequestResult>(response));
        }