Adding new samples (#22)
* Adding Cancel Subscription, Toggle Autorenew, and Get activation Link samples.
This commit is contained in:
Родитель
8a435af2d0
Коммит
f947cbfc03
|
@ -0,0 +1,52 @@
|
|||
// -----------------------------------------------------------------------
|
||||
// <copyright file="GetLineItemActivationLink.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Store.PartnerCenter.Samples.Orders
|
||||
{
|
||||
/// <summary>
|
||||
/// A scenario that retrieves a customer orders.
|
||||
/// </summary>
|
||||
public class GetLineItemActivationLink : BasePartnerScenario
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GetLineItemActivationLink"/> class.
|
||||
/// </summary>
|
||||
/// <param name="context">The scenario context.</param>
|
||||
public GetLineItemActivationLink(IScenarioContext context) : base("Get customer order activation link", context)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the scenario.
|
||||
/// </summary>
|
||||
protected override void RunScenario()
|
||||
{
|
||||
var partnerOperations = this.Context.UserPartnerOperations;
|
||||
|
||||
string customerId = this.ObtainCustomerId("Enter the ID of the customer whom to retrieve their orders");
|
||||
|
||||
this.Context.ConsoleHelper.StartProgress("Retrieving customer orders");
|
||||
var customerOrders = partnerOperations.Customers.ById(customerId).Orders.Get();
|
||||
this.Context.ConsoleHelper.StopProgress();
|
||||
this.Context.ConsoleHelper.WriteObject(customerOrders, "Customer orders");
|
||||
|
||||
string orderId = this.ObtainOrderID();
|
||||
this.Context.ConsoleHelper.StartProgress("Retrieving customer order");
|
||||
var customerOrder = partnerOperations.Customers.ById(customerId).Orders.ById(orderId).Get();
|
||||
this.Context.ConsoleHelper.StopProgress();
|
||||
this.Context.ConsoleHelper.WriteObject(customerOrder, "Customer order");
|
||||
|
||||
Console.Write("Enter order line item number: ");
|
||||
string orderLineItemNumber = Console.ReadLine();
|
||||
this.Context.ConsoleHelper.StartProgress("Obtaining order line item activation link");
|
||||
var activationLink = partnerOperations.Customers.ById(customerId).Orders.ById(orderId).OrderLineItems.ById(orderLineItemNumber).ActivationLink.Get();
|
||||
this.Context.ConsoleHelper.StopProgress();
|
||||
this.Context.ConsoleHelper.WriteObject(activationLink, "activationLinks");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -328,7 +328,8 @@ namespace Microsoft.Store.PartnerCenter.Samples
|
|||
new CreateAzureReservationOrder(context),
|
||||
new GetOrdersByBillingCycleType(context),
|
||||
new GetOrderProvisioningStatus(context),
|
||||
new UpdateOrder(context)
|
||||
new UpdateOrder(context),
|
||||
new GetLineItemActivationLink(context)
|
||||
};
|
||||
|
||||
return new AggregatePartnerScenario("Order samples", orderScenarios, context);
|
||||
|
@ -353,6 +354,8 @@ namespace Microsoft.Store.PartnerCenter.Samples
|
|||
new UpgradeSubscription(context),
|
||||
new AddSubscriptionAddOn(context),
|
||||
new ConvertTrialSubscription(context),
|
||||
new CancelSaaSSubscription(context),
|
||||
new ToggleSubscriptionAutoRenew(context)
|
||||
};
|
||||
|
||||
return new AggregatePartnerScenario("Subscription samples", subscriptionScenarios, context);
|
||||
|
|
|
@ -179,6 +179,7 @@
|
|||
<Compile Include="Offers\GetOffers.cs" />
|
||||
<Compile Include="Offers\GetPagedOffers.cs" />
|
||||
<Compile Include="Orders\CreateAzureReservationOrder.cs" />
|
||||
<Compile Include="Orders\GetLineItemActivationLink.cs" />
|
||||
<Compile Include="Orders\GetOrderDetails.cs" />
|
||||
<Compile Include="Orders\GetOrderProvisioningStatus.cs" />
|
||||
<Compile Include="Orders\GetOrders.cs" />
|
||||
|
@ -223,6 +224,7 @@
|
|||
<Compile Include="ServiceRequests\GetPartnerServiceRequestDetails.cs" />
|
||||
<Compile Include="ServiceRequests\GetServiceRequestSupportTopics.cs" />
|
||||
<Compile Include="ServiceRequests\UpdatePartnerServiceRequest.cs" />
|
||||
<Compile Include="Subscriptions\CancelSaaSSubscription.cs" />
|
||||
<Compile Include="Subscriptions\ConvertTrialSubscription.cs" />
|
||||
<Compile Include="Subscriptions\GetSubscription.cs" />
|
||||
<Compile Include="Subscriptions\GetSubscriptionProvisioningStatus.cs" />
|
||||
|
@ -231,6 +233,7 @@
|
|||
<Compile Include="RatedUsage\GetSubscriptionUsageRecords.cs" />
|
||||
<Compile Include="RatedUsage\GetSubscriptionUsageSummary.cs" />
|
||||
<Compile Include="Subscriptions\GetSubscriptionSupportContact.cs" />
|
||||
<Compile Include="Subscriptions\ToggleSubscriptionAutoRenew.cs" />
|
||||
<Compile Include="Subscriptions\UpdateSubscriptionSupportContact.cs" />
|
||||
<Compile Include="Subscriptions\UpgradeSubscription.cs" />
|
||||
<Compile Include="Subscriptions\UpdateSubscription.cs" />
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
// -----------------------------------------------------------------------
|
||||
// <copyright file="CancelSaaSSubscription.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Store.PartnerCenter.Samples.Subscriptions
|
||||
{
|
||||
/// <summary>
|
||||
/// A scenario that updates an existing customer subscription.
|
||||
/// </summary>
|
||||
public class CancelSaaSSubscription : BasePartnerScenario
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CancelSaaSSubscription"/> class.
|
||||
/// </summary>
|
||||
/// <param name="context">The scenario context.</param>
|
||||
public CancelSaaSSubscription(IScenarioContext context) : base("Cancel existing customer SaaS subscription", context)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the scenario.
|
||||
/// </summary>
|
||||
protected override void RunScenario()
|
||||
{
|
||||
var partnerOperations = this.Context.UserPartnerOperations;
|
||||
var customerId = this.ObtainCustomerId();
|
||||
var subscriptionId = this.ObtainSubscriptionId(customerId, "Enter the ID of the subscription to cancel");
|
||||
|
||||
this.Context.ConsoleHelper.StartProgress("Retrieving customer subscription");
|
||||
var existingSubscription = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionId).Get();
|
||||
this.Context.ConsoleHelper.StopProgress();
|
||||
this.Context.ConsoleHelper.WriteObject(existingSubscription, "Existing subscription");
|
||||
|
||||
this.Context.ConsoleHelper.StartProgress("Cancelling subscription");
|
||||
existingSubscription.Status = Models.Subscriptions.SubscriptionStatus.Deleted;
|
||||
var updatedSubscription = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionId).Patch(existingSubscription);
|
||||
this.Context.ConsoleHelper.StopProgress();
|
||||
|
||||
this.Context.ConsoleHelper.WriteObject(updatedSubscription, "Cancelled subscription");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.Store.PartnerCenter.Samples.Subscriptions
|
||||
{
|
||||
class ToggleSubscriptionAutoRenew : BasePartnerScenario
|
||||
|
||||
{
|
||||
public ToggleSubscriptionAutoRenew(IScenarioContext context) : base("Toggle Subcription Autorenew", context)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the scenario.
|
||||
/// </summary>
|
||||
protected override void RunScenario()
|
||||
{
|
||||
var partnerOperations = this.Context.UserPartnerOperations;
|
||||
|
||||
string customerId = this.ObtainCustomerId("Enter the ID of the customer whom to retrieve their subscription");
|
||||
string subscriptionId = this.ObtainSubscriptionId(customerId);
|
||||
|
||||
this.Context.ConsoleHelper.StartProgress("Retrieving customer subscription");
|
||||
|
||||
this.Context.ConsoleHelper.StartProgress("Retrieving customer subscription");
|
||||
var existingSubscription = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionId).Get();
|
||||
this.Context.ConsoleHelper.StopProgress();
|
||||
this.Context.ConsoleHelper.WriteObject(existingSubscription, "Existing subscription");
|
||||
|
||||
this.Context.ConsoleHelper.StartProgress("Toggling subscription autorenew");
|
||||
existingSubscription.AutoRenewEnabled = !existingSubscription.AutoRenewEnabled;
|
||||
var updatedSubscription = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionId).Patch(existingSubscription);
|
||||
this.Context.ConsoleHelper.StopProgress();
|
||||
this.Context.ConsoleHelper.WriteObject(updatedSubscription, "Subscription after update");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче