Adding promotion eligibility samples.
This commit is contained in:
Kyle Swartz 2021-12-06 14:58:20 -05:00
Родитель 7e0645b3c1
Коммит f5e9b68934
4 изменённых файлов: 95 добавлений и 11 удалений

Просмотреть файл

@ -28,7 +28,8 @@ namespace Microsoft.Store.PartnerCenter.Samples
using Offers;
using Orders;
using Products;
using Profile;
using Profile;
using PromotionEligibilities;
using RateCards;
using RatedUsage;
using ServiceIncidents;
@ -80,7 +81,8 @@ namespace Microsoft.Store.PartnerCenter.Samples
Program.GetCartWithAddonItemsScenarios(context),
Program.GetEntitlementScenarios(context),
Program.GetComplianceScenarios(context),
Program.GetSelfServePoliciesScenarios(context)
Program.GetSelfServePoliciesScenarios(context),
Program.PostPromotionEligibilitiesScenarios(context)
};
// run the main scenario
@ -648,5 +650,20 @@ namespace Microsoft.Store.PartnerCenter.Samples
return new AggregatePartnerScenario("Cart With Addon Items Scenarios", cartScenarios, context);
}
/// <summary>
/// Gets the post promotion eligibilities scenarios.
/// </summary>
/// <param name="context">A scenario context</param>
/// <returns>The post promotion eligibilities scenarios.</returns>
private static IPartnerScenario PostPromotionEligibilitiesScenarios(IScenarioContext context)
{
var postPromotionEligibilitiesScenarios = new IPartnerScenario[]
{
new PostPromotionEligibilities(context)
};
return new AggregatePartnerScenario("Post Promotion Eligibilities Scenarios", postPromotionEligibilitiesScenarios, context);
}
}
}

Просмотреть файл

@ -0,0 +1,66 @@
// -----------------------------------------------------------------------
// <copyright file="PostPromotionEligibilities.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------
namespace Microsoft.Store.PartnerCenter.Samples.PromotionEligibilities
{
using System;
using System.Collections.Generic;
using Microsoft.Store.PartnerCenter.Models.PromotionEligibilities;
using Microsoft.Store.PartnerCenter.Models.PromotionEligibilities.Enums;
/// <summary>
/// A scenario that posts promotion eligibilities for a customer.
/// </summary>
public class PostPromotionEligibilities : BasePartnerScenario
{
/// <summary>
/// Initializes a new instance of the <see cref="CheckoutCart"/> class.
/// </summary>
/// <param name="context">The scenario context.</param>
public PostPromotionEligibilities(IScenarioContext context) : base("Post promotion eligibilities", 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 to check eligibility for");
string catalogItemId = this.ObtainCatalogItemId("Enter the catalog Item Id");
int quantity = int.Parse(this.ObtainQuantity("Enter the Quantity"));
string termDuration = this.ObtainRenewalTermDuration("Enter the term duration");
string billingCycle = this.ObtainBillingCycle("Enter the billing cycle");
var billingCycleType = (BillingCycleType)Enum.Parse(typeof(BillingCycleType), billingCycle, true);
var promotionId = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the promotionId", "The promotionId can't be empty");
var promotionEligibilityRequest = new PromotionEligibilitiesRequest()
{
Items = new List<PromotionEligibilitiesRequestItem>()
{
new PromotionEligibilitiesRequestItem()
{
Id = 0,
CatalogItemId = catalogItemId,
Quantity = quantity,
BillingCycle = billingCycleType,
TermDuration = termDuration,
PromotionId = promotionId
}
}
};
this.Context.ConsoleHelper.StartProgress("Posting promotion eligibilities");
var promotionEligibilities = partnerOperations.Customers.ById(customerId).PromotionEligibilities.Post(promotionEligibilityRequest);
this.Context.ConsoleHelper.StopProgress();
this.Context.ConsoleHelper.WriteObject(promotionEligibilities, "Posted promotion eligibilities");
}
}
}

Просмотреть файл

@ -45,21 +45,21 @@
<Reference Include="Microsoft.Identity.Client, Version=4.31.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Identity.Client.4.31.0\lib\net461\Microsoft.Identity.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Store.PartnerCenter, Version=2.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Store.PartnerCenter.2.0.1\lib\netstandard2.0\Microsoft.Store.PartnerCenter.dll</HintPath>
<Reference Include="Microsoft.Store.PartnerCenter, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Store.PartnerCenter.3.0.0\lib\netstandard2.0\Microsoft.Store.PartnerCenter.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Store.PartnerCenter.Extensions, Version=2.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Store.PartnerCenter.2.0.1\lib\netstandard2.0\Microsoft.Store.PartnerCenter.Extensions.dll</HintPath>
<Reference Include="Microsoft.Store.PartnerCenter.Extensions, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Store.PartnerCenter.3.0.0\lib\netstandard2.0\Microsoft.Store.PartnerCenter.Extensions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Store.PartnerCenter.Models, Version=2.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Store.PartnerCenter.2.0.1\lib\netstandard2.0\Microsoft.Store.PartnerCenter.Models.dll</HintPath>
<Reference Include="Microsoft.Store.PartnerCenter.Models, Version=3.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Store.PartnerCenter.3.0.0\lib\netstandard2.0\Microsoft.Store.PartnerCenter.Models.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.ComponentModel.Annotations.4.7.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
<HintPath>..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.configuration" />
@ -230,6 +230,7 @@
<Compile Include="Profile\UpdateLegalBusinessProfile.cs" />
<Compile Include="Profile\UpdateOrganizationProfile.cs" />
<Compile Include="Profile\UpdateSupportProfile.cs" />
<Compile Include="PromotionEligibilities\PostPromotionEligibilities.cs" />
<Compile Include="RateCards\GetAzureRateCard.cs" />
<Compile Include="RateCards\GetAzureSharedRateCard.cs" />
<Compile Include="RatedUsage\GetCustomerSubscriptionsUsage.cs" />

Просмотреть файл

@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Identity.Client" version="4.31.0" targetFramework="net461" />
<package id="Microsoft.Store.PartnerCenter" version="2.0.1" targetFramework="net461" />
<package id="Microsoft.Store.PartnerCenter" version="3.0.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net461" />
<package id="System.ComponentModel.Annotations" version="4.7.0" targetFramework="net461" />
<package id="System.ComponentModel.Annotations" version="5.0.0" targetFramework="net461" />
<package id="System.Data.DataSetExtensions" version="4.5.0" targetFramework="net461" />
<package id="System.Net.Http" version="4.3.4" targetFramework="net461" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.1" targetFramework="net461" />