Merge pull request #5 from Microsoft/dev
Updating samples for partner center SDK 1.10.0 update
This commit is contained in:
Коммит
c107748538
|
@ -66,7 +66,7 @@ namespace Microsoft.Store.PartnerCenter.Samples.Agreements
|
|||
if (!customerAgreements.Items.Any())
|
||||
{
|
||||
this.Context.ConsoleHelper.WriteObject(noAgreements, "Agreement", 1);
|
||||
File.AppendAllText(csvFilePath, $"{customer?.CompanyProfile?.TenantId ?? customer?.Id}, {customer?.CompanyProfile?.Domain ?? "Domain not available."},,,,,{Environment.NewLine}");
|
||||
File.AppendAllText(csvFilePath, $"{customer?.CompanyProfile?.TenantId ?? customer?.Id} ,{customer?.CompanyProfile?.Domain ?? "Domain not available."},,,,,{Environment.NewLine}");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
// -----------------------------------------------------------------------
|
||||
// <copyright file="CreateCartAddonWithExistingSubscription.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Store.PartnerCenter.Samples.Carts
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Models.Carts;
|
||||
|
||||
/// <summary>
|
||||
/// A scenario that creates a new cart with add on items for existing subscription for customer.
|
||||
/// </summary>
|
||||
public class CreateCartAddonWithExistingSubscription : BasePartnerScenario
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CreateCartAddonWithExistingSubscription"/> class.
|
||||
/// </summary>
|
||||
/// <param name="context">The scenario context.</param>
|
||||
public CreateCartAddonWithExistingSubscription(IScenarioContext context) : base("Create a cart with addon items for existing subscription", 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 making the purchase");
|
||||
string existingSubscriptionId = this.ObtainSubscriptionId(customerId, "Enter existing subscription Id");
|
||||
string addonCatalogItemId = this.ObtainCatalogItemId("Enter the addon Item Id");
|
||||
var cart = new Cart()
|
||||
{
|
||||
LineItems = new List<CartLineItem>()
|
||||
{
|
||||
new CartLineItem()
|
||||
{
|
||||
Id = 0,
|
||||
CatalogItemId = addonCatalogItemId,
|
||||
ProvisioningContext = new Dictionary<string, string>
|
||||
{
|
||||
{
|
||||
"ParentSubscriptionId",
|
||||
existingSubscriptionId
|
||||
}
|
||||
},
|
||||
Quantity = 1,
|
||||
BillingCycle = Models.Products.BillingCycleType.Monthly
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.Context.ConsoleHelper.WriteObject(cart, "Cart to be created");
|
||||
this.Context.ConsoleHelper.StartProgress("Creating cart");
|
||||
|
||||
var createdCart = partnerOperations.Customers.ById(customerId).Carts.Create(cart);
|
||||
|
||||
this.Context.ConsoleHelper.StopProgress();
|
||||
this.Context.ConsoleHelper.WriteObject(createdCart, "Created cart");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
// -----------------------------------------------------------------------
|
||||
// <copyright file="CreateCartWithAddons.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Store.PartnerCenter.Samples.Carts
|
||||
{
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Models.Carts;
|
||||
|
||||
/// <summary>
|
||||
/// A scenario that creates a new cart with add on items for a customer.
|
||||
/// </summary>
|
||||
public class CreateCartWithAddons : BasePartnerScenario
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="CreateCartWithAddons"/> class.
|
||||
/// </summary>
|
||||
/// <param name="context">The scenario context.</param>
|
||||
public CreateCartWithAddons(IScenarioContext context) : base("Create a Cart with addon items", 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 making the purchase");
|
||||
string catalogItemId = this.ObtainCatalogItemId("Enter the catalog Item Id");
|
||||
string addonCatalogItemId = this.ObtainCatalogItemId("Enter the addon Item Id");
|
||||
var cart = new Cart()
|
||||
{
|
||||
LineItems = new List<CartLineItem>()
|
||||
{
|
||||
new CartLineItem()
|
||||
{
|
||||
Id = 0,
|
||||
CatalogItemId = catalogItemId,
|
||||
FriendlyName = "Myofferpurchase",
|
||||
Quantity = 3,
|
||||
BillingCycle = Models.Products.BillingCycleType.Monthly,
|
||||
AddonItems = new List<CartLineItem>
|
||||
{
|
||||
new CartLineItem
|
||||
{
|
||||
Id = 1,
|
||||
CatalogItemId = addonCatalogItemId,
|
||||
BillingCycle = Models.Products.BillingCycleType.Monthly,
|
||||
Quantity = 2,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.Context.ConsoleHelper.WriteObject(cart, "Cart to be created");
|
||||
this.Context.ConsoleHelper.StartProgress("Creating cart");
|
||||
|
||||
var createdCart = partnerOperations.Customers.ById(customerId).Carts.Create(cart);
|
||||
|
||||
this.Context.ConsoleHelper.StopProgress();
|
||||
this.Context.ConsoleHelper.WriteObject(createdCart, "Created cart");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
// -----------------------------------------------------------------------
|
||||
// <copyright file="UpdateCustomerQualificationWithGCC.cs" company="Microsoft">
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// </copyright>
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
namespace Microsoft.Store.PartnerCenter.Samples.Customers
|
||||
{
|
||||
using Microsoft.Store.PartnerCenter.Models.Customers;
|
||||
using Microsoft.Store.PartnerCenter.Models.ValidationCodes;
|
||||
using System.Collections.Generic;
|
||||
|
||||
/// <summary>
|
||||
/// Updates a single customer qualification to GCC.
|
||||
/// </summary>
|
||||
public class UpdateCustomerQualificationWithGCC : BasePartnerScenario
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdateCustomerQualificationWithGCC"/> class.
|
||||
/// </summary>
|
||||
/// <param name="context">The scenario context.</param>
|
||||
public UpdateCustomerQualificationWithGCC(IScenarioContext context) : base("Update customer qualification with GCC", context)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the update customer qualification scenario.
|
||||
/// </summary>
|
||||
protected override void RunScenario()
|
||||
{
|
||||
string customerIdToRetrieve = this.ObtainCustomerId($"Enter the ID of the customer to update qualification to {CustomerQualification.GovernmentCommunityCloud}");
|
||||
|
||||
var partnerOperations = this.Context.UserPartnerOperations;
|
||||
|
||||
this.Context.ConsoleHelper.StartProgress("Retrieving validation codes");
|
||||
var validations = partnerOperations.Validations.GetValidationCodes();
|
||||
this.Context.ConsoleHelper.StopProgress();
|
||||
|
||||
this.Context.ConsoleHelper.Success("Success!");
|
||||
|
||||
this.Context.ConsoleHelper.WriteObject(validations, "Validations");
|
||||
|
||||
string validationCodeToRetrieve = this.ObtainQuantity("Enter validation code to use by ValidationId");
|
||||
|
||||
ValidationCode code = null;
|
||||
|
||||
foreach(ValidationCode c in validations)
|
||||
{
|
||||
if(c.ValidationId == validationCodeToRetrieve)
|
||||
{
|
||||
code = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(code == null)
|
||||
{
|
||||
this.Context.ConsoleHelper.Error("Code not found");
|
||||
}
|
||||
|
||||
this.Context.ConsoleHelper.StartProgress("Updating customer qualification");
|
||||
|
||||
|
||||
var customerQualification =
|
||||
partnerOperations.Customers.ById(customerIdToRetrieve)
|
||||
.Qualification.Update(CustomerQualification.GovernmentCommunityCloud, code);
|
||||
|
||||
this.Context.ConsoleHelper.StopProgress();
|
||||
this.Context.ConsoleHelper.WriteObject(customerQualification, "Customer Qualification");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -47,17 +47,18 @@
|
|||
<Reference Include="Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms, Version=2.29.0.1078, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.29.0\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Store.PartnerCenter, Version=1.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Store.PartnerCenter.1.9.0\lib\Net45\Microsoft.Store.PartnerCenter.dll</HintPath>
|
||||
<Reference Include="Microsoft.Store.PartnerCenter, Version=1.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Store.PartnerCenter.1.10.0\lib\Net45\Microsoft.Store.PartnerCenter.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Store.PartnerCenter.Extensions, Version=1.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Store.PartnerCenter.1.9.0\lib\Net45\Microsoft.Store.PartnerCenter.Extensions.dll</HintPath>
|
||||
<Reference Include="Microsoft.Store.PartnerCenter.Extensions, Version=1.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Store.PartnerCenter.1.10.0\lib\Net45\Microsoft.Store.PartnerCenter.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Store.PartnerCenter.Models, Version=1.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Store.PartnerCenter.1.9.0\lib\Net45\Microsoft.Store.PartnerCenter.Models.dll</HintPath>
|
||||
<Reference Include="Microsoft.Store.PartnerCenter.Models, Version=1.10.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Store.PartnerCenter.1.10.0\lib\Net45\Microsoft.Store.PartnerCenter.Models.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.configuration" />
|
||||
|
@ -83,6 +84,8 @@
|
|||
<Compile Include="Auditing\SearchAuditRecordsByResourceType.cs" />
|
||||
<Compile Include="Carts\CheckoutCart.cs" />
|
||||
<Compile Include="Carts\CreateCart.cs" />
|
||||
<Compile Include="Carts\CreateCartAddonWithExistingSubscription.cs" />
|
||||
<Compile Include="Carts\CreateCartWithAddons.cs" />
|
||||
<Compile Include="Carts\UpdateCart.cs" />
|
||||
<Compile Include="Configuration\ApplicationAuthenticationSection.cs" />
|
||||
<Compile Include="Configuration\ScenarioSettingsSection.cs" />
|
||||
|
@ -122,6 +125,7 @@
|
|||
<Compile Include="Customers\GetCustomerDetails.cs" />
|
||||
<Compile Include="Customers\CheckDomainAvailability.cs" />
|
||||
<Compile Include="Customers\CreateCustomer.cs" />
|
||||
<Compile Include="Customers\UpdateCustomerQualificationWithGCC.cs" />
|
||||
<Compile Include="Customers\ValidateCustomerAddress.cs" />
|
||||
<Compile Include="CustomerUser\CreateCustomerUser.cs" />
|
||||
<Compile Include="CustomerUser\CustomerUserAssignedGroup1AndGroup2Licenses.cs" />
|
||||
|
|
|
@ -75,6 +75,7 @@ namespace Microsoft.Store.PartnerCenter.Samples
|
|||
Program.GetAddressValidationsScenarios(context),
|
||||
Program.GetDevicesScenarios(context),
|
||||
Program.GetCartScenarios(context),
|
||||
Program.GetCartWithAddonItemsScenarios(context),
|
||||
Program.GetEntitlementScenarios(context)
|
||||
};
|
||||
|
||||
|
@ -126,14 +127,14 @@ namespace Microsoft.Store.PartnerCenter.Samples
|
|||
{
|
||||
new CreateConfigurationPolicy(context),
|
||||
new GetAllConfigurationPolicies(context),
|
||||
new UpdateConfigurationPolicy(context),
|
||||
new UpdateConfigurationPolicy(context),
|
||||
new DeleteConfigurationPolicy(context),
|
||||
new CreateDeviceBatch(context),
|
||||
new GetDevicesBatches(context),
|
||||
new CreateDevices(context),
|
||||
new GetDevices(context),
|
||||
new UpdateDevicesPolicy(context),
|
||||
new DeleteDevice(context),
|
||||
new DeleteDevice(context),
|
||||
new GetBatchUploadStatus(context)
|
||||
};
|
||||
|
||||
|
@ -233,6 +234,7 @@ namespace Microsoft.Store.PartnerCenter.Samples
|
|||
new GetCustomerDetails(context),
|
||||
new GetCustomerQualification(context),
|
||||
new UpdateCustomerQualification(context),
|
||||
new UpdateCustomerQualificationWithGCC(context),
|
||||
new DeleteCustomerFromTipAccount(context),
|
||||
new GetCustomerManagedServices(context),
|
||||
new GetCustomerRelationshipRequest(context),
|
||||
|
@ -584,5 +586,22 @@ namespace Microsoft.Store.PartnerCenter.Samples
|
|||
|
||||
return new AggregatePartnerScenario("Cart Scenarios", cartScenarios, context);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the cart with add on items scenarios of create and checkout
|
||||
/// </summary>
|
||||
/// <param name="context">A scenario context</param>
|
||||
/// <returns>The cart with add on items scenarios.</returns>
|
||||
private static IPartnerScenario GetCartWithAddonItemsScenarios(IScenarioContext context)
|
||||
{
|
||||
var cartScenarios = new IPartnerScenario[]
|
||||
{
|
||||
new CreateCartWithAddons(context),
|
||||
new CheckoutCart(context),
|
||||
new CreateCartAddonWithExistingSubscription(context)
|
||||
};
|
||||
|
||||
return new AggregatePartnerScenario("Cart With Addon Items Scenarios", cartScenarios, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.29.0" targetFramework="net451" />
|
||||
<package id="Microsoft.Store.PartnerCenter" version="1.9.0" targetFramework="net451" />
|
||||
<package id="Microsoft.Store.PartnerCenter" version="1.10.0" targetFramework="net451" />
|
||||
<package id="Newtonsoft.Json" version="11.0.2" targetFramework="net451" />
|
||||
<package id="Visual-StyleCop.MSBuild" version="4.7.59.0" targetFramework="net45" />
|
||||
</packages>
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key="NuGet official package source" value="https://nuget.org/api/v2/" />
|
||||
<add key="NuGet official package source" value="https://nuget.org/api/v2/" />
|
||||
<add key="dependencyVersion" value="Highest" />
|
||||
</packageSources>
|
||||
</configuration>
|
Загрузка…
Ссылка в новой задаче