/// <summary>
 /// Update the admin action, weather the request is approved or rejected and
 /// the approved plans
 /// </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='adminRequestApprovalId'>
 /// The admin request approval ID to get create or update
 /// </param>
 /// <param name='payload'>
 /// </param>
 public static AdminRequestApprovalsResource UpdateAdminRequestApproval(this IPrivateStoreOperations operations, string privateStoreId, string adminRequestApprovalId, AdminRequestApprovalsResource payload = default(AdminRequestApprovalsResource))
 {
     return(operations.UpdateAdminRequestApprovalAsync(privateStoreId, adminRequestApprovalId, payload).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Update the admin action, weather the request is approved or rejected and
 /// the approved plans
 /// </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='adminRequestApprovalId'>
 /// The admin request approval ID to get create or update
 /// </param>
 /// <param name='payload'>
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <AdminRequestApprovalsResource> UpdateAdminRequestApprovalAsync(this IPrivateStoreOperations operations, string privateStoreId, string adminRequestApprovalId, AdminRequestApprovalsResource payload = default(AdminRequestApprovalsResource), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.UpdateAdminRequestApprovalWithHttpMessagesAsync(privateStoreId, adminRequestApprovalId, payload, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Example #3
0
        public void ApproveByAdminNotificationTest()
        {
            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;
                        }
                    }
                    var notificationState = client.PrivateStore.QueryNotificationsState(PrivateStoreId);
                    Assert.Contains(notificationState.ApprovalRequests, x => x.OfferId == requestApprovalId);

                    // Approve request by admin
                    AdminRequestApprovalsResource adminRequestApprovalsResource = new AdminRequestApprovalsResource
                    {
                        PublisherId   = publisherId,
                        AdminAction   = "Approved",
                        ApprovedPlans = new List <string>()
                        {
                            planId
                        },
                        Comment       = "I'm ok with that",
                        CollectionIds = new List <string>()
                        {
                            collectionId
                        }
                    };
                    client.PrivateStore.UpdateAdminRequestApproval(PrivateStoreId, requestApprovalId, adminRequestApprovalsResource);

                    var collectionOffers = client.PrivateStoreCollectionOffer.List(PrivateStoreId, collectionId);
                    Assert.Contains(collectionOffers, x => x.UniqueOfferId == requestApprovalId);

                    notificationState = client.PrivateStore.QueryNotificationsState(PrivateStoreId);
                    Assert.DoesNotContain(notificationState.ApprovalRequests, x => x.OfferId == requestApprovalId);

                    CleanUp(client);
                }
            }
        }