/// <summary> /// Withdraw a user request approval on specific plan /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='privateStoreId'> /// The store ID - must use the tenant ID /// </param> /// <param name='requestApprovalId'> /// The request approval ID to get create or update /// </param> /// <param name='payload'> /// </param> public static void WithdrawPlan(this IPrivateStoreOperations operations, string privateStoreId, string requestApprovalId, WithdrawProperties payload = default(WithdrawProperties)) { operations.WithdrawPlanAsync(privateStoreId, requestApprovalId, payload).GetAwaiter().GetResult(); }
/// <summary> /// Withdraw a user request approval on specific plan /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='privateStoreId'> /// The store ID - must use the tenant ID /// </param> /// <param name='requestApprovalId'> /// The request approval ID to get create or update /// </param> /// <param name='payload'> /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task WithdrawPlanAsync(this IPrivateStoreOperations operations, string privateStoreId, string requestApprovalId, WithdrawProperties payload = default(WithdrawProperties), CancellationToken cancellationToken = default(CancellationToken)) { (await operations.WithdrawPlanWithHttpMessagesAsync(privateStoreId, requestApprovalId, payload, null, cancellationToken).ConfigureAwait(false)).Dispose(); }
public void CreateAndWithdrawApprovalRequestTest() { using (var context = MockContext.Start(this.GetType())) { using (var client = context.GetServiceClient <MarketplaceRPServiceClient>()) { SetUp(client); //create approval request PlanDetails planDetails = new PlanDetails { PlanId = planId, Justification = "because ...", SubscriptionId = testSubscription, SubscriptionName = TestSubscriptionName }; RequestApprovalResource requestApprovalResource = new RequestApprovalResource { PublisherId = "data3-limited-1019419", PlansDetails = new List <PlanDetails>() { planDetails } }; try { var approvalRequest = client.PrivateStore.CreateApprovalRequest(PrivateStoreId, requestApprovalId, requestApprovalResource); } catch (Exception ex) { if (!ex.Message.Contains("BadRequest")) { throw; } } // Assert notification arrived var notificationState = client.PrivateStore.QueryNotificationsState(PrivateStoreId); Assert.Contains(notificationState.ApprovalRequests, x => x.OfferId == requestApprovalId); var adminRequestApproval = client.PrivateStore.GetAdminRequestApproval(publisherId, PrivateStoreId, requestApprovalId); Assert.Equal("Pending", adminRequestApproval.AdminAction); RequestDetails requestDetails = new RequestDetails { PublisherId = publisherId, PlanIds = new List <string> { planId, managedAzurePlanId, managedAzureOptimiser }, SubscriptionId = testSubscription }; QueryRequestApprovalProperties queryRequestApprovalProperties = new QueryRequestApprovalProperties { Properties = requestDetails }; var requestApproval = client.PrivateStore.QueryRequestApprovalMethod(PrivateStoreId, requestApprovalId, queryRequestApprovalProperties); Assert.Equal("Pending", requestApproval.PlansDetails[planId].Status); // Withdraw request WithdrawProperties withdrawProperties = new WithdrawProperties { PublisherId = publisherId, PlanId = planId }; client.PrivateStore.WithdrawPlan(PrivateStoreId, requestApprovalId, withdrawProperties); notificationState = client.PrivateStore.QueryNotificationsState(PrivateStoreId); Assert.DoesNotContain(notificationState.ApprovalRequests, x => x.OfferId == requestApprovalId); CleanUp(client); } } }