From 3efde03cf1a9ae6da453cbdf8d52e213dabdfd0c Mon Sep 17 00:00:00 2001 From: Tyler Baumgartner Date: Fri, 19 Nov 2021 15:36:32 -0800 Subject: [PATCH 1/2] upgrade Microsoft.Store.PartnerCenter to 3.0.0 --- sdk/SdkSamples/SdkSamples.csproj | 14 +++++++------- sdk/SdkSamples/packages.config | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sdk/SdkSamples/SdkSamples.csproj b/sdk/SdkSamples/SdkSamples.csproj index 7040703..630bc48 100644 --- a/sdk/SdkSamples/SdkSamples.csproj +++ b/sdk/SdkSamples/SdkSamples.csproj @@ -45,21 +45,21 @@ ..\packages\Microsoft.Identity.Client.4.31.0\lib\net461\Microsoft.Identity.Client.dll - - ..\packages\Microsoft.Store.PartnerCenter.2.0.1\lib\netstandard2.0\Microsoft.Store.PartnerCenter.dll + + ..\packages\Microsoft.Store.PartnerCenter.3.0.0\lib\netstandard2.0\Microsoft.Store.PartnerCenter.dll - - ..\packages\Microsoft.Store.PartnerCenter.2.0.1\lib\netstandard2.0\Microsoft.Store.PartnerCenter.Extensions.dll + + ..\packages\Microsoft.Store.PartnerCenter.3.0.0\lib\netstandard2.0\Microsoft.Store.PartnerCenter.Extensions.dll - - ..\packages\Microsoft.Store.PartnerCenter.2.0.1\lib\netstandard2.0\Microsoft.Store.PartnerCenter.Models.dll + + ..\packages\Microsoft.Store.PartnerCenter.3.0.0\lib\netstandard2.0\Microsoft.Store.PartnerCenter.Models.dll ..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll - ..\packages\System.ComponentModel.Annotations.4.7.0\lib\net461\System.ComponentModel.Annotations.dll + ..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll diff --git a/sdk/SdkSamples/packages.config b/sdk/SdkSamples/packages.config index a3a2bd3..265ea90 100644 --- a/sdk/SdkSamples/packages.config +++ b/sdk/SdkSamples/packages.config @@ -1,9 +1,9 @@  - + - + From 3f928c061a5e6bf155ddcd7b28b8393c44379c2c Mon Sep 17 00:00:00 2001 From: Tyler Baumgartner Date: Fri, 19 Nov 2021 15:41:32 -0800 Subject: [PATCH 2/2] add product promotions --- sdk/SdkSamples/App.config | 2 + sdk/SdkSamples/BasePartnerScenario.cs | 14 +++++++ .../Configuration/ScenarioSettingsSection.cs | 11 +++++ .../Products/GetProductPromotion.cs | 40 +++++++++++++++++++ .../Products/GetProductPromotions.cs | 40 +++++++++++++++++++ sdk/SdkSamples/Program.cs | 4 +- sdk/SdkSamples/SdkSamples.csproj | 2 + 7 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 sdk/SdkSamples/Products/GetProductPromotion.cs create mode 100644 sdk/SdkSamples/Products/GetProductPromotions.cs diff --git a/sdk/SdkSamples/App.config b/sdk/SdkSamples/App.config index 211cfec..ebdf4c0 100644 --- a/sdk/SdkSamples/App.config +++ b/sdk/SdkSamples/App.config @@ -92,6 +92,8 @@ + + diff --git a/sdk/SdkSamples/BasePartnerScenario.cs b/sdk/SdkSamples/BasePartnerScenario.cs index c589c2d..396257b 100644 --- a/sdk/SdkSamples/BasePartnerScenario.cs +++ b/sdk/SdkSamples/BasePartnerScenario.cs @@ -284,6 +284,20 @@ namespace Microsoft.Store.PartnerCenter.Samples "The Product ID can't be empty"); } + /// + /// Obtains a product promotion ID to work with from the configuration if set there or prompts the user to enter it. + /// + /// An optional custom prompt message. + /// The product promotion ID. + protected string ObtainProductPromotionId(string promptMessage = default(string)) + { + return this.ObtainValue( + this.Context.Configuration.Scenario.DefaultProductPromotionId, + "Product Promotion Id", + string.IsNullOrWhiteSpace(promptMessage) ? "Enter the product promotion ID" : promptMessage, + "The Product Promotion ID can't be empty"); + } + /// /// Obtains a SKU ID to work with from the configuration if set there or prompts the user to enter it. /// diff --git a/sdk/SdkSamples/Configuration/ScenarioSettingsSection.cs b/sdk/SdkSamples/Configuration/ScenarioSettingsSection.cs index 4974fdb..4d24b35 100644 --- a/sdk/SdkSamples/Configuration/ScenarioSettingsSection.cs +++ b/sdk/SdkSamples/Configuration/ScenarioSettingsSection.cs @@ -249,6 +249,17 @@ namespace Microsoft.Store.PartnerCenter.Samples.Configuration } } + /// + /// Gets the configured product promotion ID. + /// + public string DefaultProductPromotionId + { + get + { + return this.ConfigurationSection["DefaultProductPromotionId"]; + } + } + /// /// Gets the configured SKU ID. /// diff --git a/sdk/SdkSamples/Products/GetProductPromotion.cs b/sdk/SdkSamples/Products/GetProductPromotion.cs new file mode 100644 index 0000000..7361c1b --- /dev/null +++ b/sdk/SdkSamples/Products/GetProductPromotion.cs @@ -0,0 +1,40 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// ----------------------------------------------------------------------- + +namespace Microsoft.Store.PartnerCenter.Samples.Products +{ + using System.Globalization; + + /// + /// A scenario that retrieves product promotion details supported in a country. + /// + public class GetProductPromotion : BasePartnerScenario + { + /// + /// Initializes a new instance of the class. + /// + /// The scenario context. + public GetProductPromotion(IScenarioContext context) : base("Get product promotion", context) + { + } + + /// + /// Executes the scenario. + /// + protected override void RunScenario() + { + var partnerOperations = this.Context.UserPartnerOperations; + var productPromotionId = this.ObtainProductId("Enter the ID of the product promotion"); + string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the 2 digit country code of the product", "The country code can't be empty"); + + this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting details for product promotion {0} in country {1}", productPromotionId, countryCode)); + var productPromotion = partnerOperations.ProductPromotions.ByCountry(countryCode).ById(productPromotionId).Get(); + this.Context.ConsoleHelper.StopProgress(); + + this.Context.ConsoleHelper.WriteObject(productPromotion, string.Format(CultureInfo.InvariantCulture, "Product promotion details of {0}", productPromotionId)); + } + } +} \ No newline at end of file diff --git a/sdk/SdkSamples/Products/GetProductPromotions.cs b/sdk/SdkSamples/Products/GetProductPromotions.cs new file mode 100644 index 0000000..c12888f --- /dev/null +++ b/sdk/SdkSamples/Products/GetProductPromotions.cs @@ -0,0 +1,40 @@ +// ----------------------------------------------------------------------- +// +// Copyright (c) Microsoft Corporation. All rights reserved. +// +// ----------------------------------------------------------------------- + +namespace Microsoft.Store.PartnerCenter.Samples.Products +{ + using System.Globalization; + + /// + /// A scenario that retrieves all the product promotions supported in a country and in a segment. + /// + public class GetProductPromotions : BasePartnerScenario + { + /// + /// Initializes a new instance of the class. + /// + /// The scenario context. + public GetProductPromotions(IScenarioContext context) : base("Get product promotions", context) + { + } + + /// + /// Executes the scenario. + /// + protected override void RunScenario() + { + var partnerOperations = this.Context.UserPartnerOperations; + string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the 2 digit country code to get its supported products", "The country code can't be empty"); + string segment = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the segment to get its supported product promotions", "The segment can't be empty"); + + this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting product promotions in segment {0} in country {1}", segment, countryCode)); + var productPromotions = partnerOperations.ProductPromotions.ByCountry(countryCode).BySegment(segment).Get(); + this.Context.ConsoleHelper.StopProgress(); + + this.Context.ConsoleHelper.WriteObject(productPromotions, string.Format(CultureInfo.InvariantCulture, "Product promotions in segment {0}", segment)); + } + } +} \ No newline at end of file diff --git a/sdk/SdkSamples/Program.cs b/sdk/SdkSamples/Program.cs index bf076dd..4c6dd6f 100644 --- a/sdk/SdkSamples/Program.cs +++ b/sdk/SdkSamples/Program.cs @@ -280,7 +280,9 @@ namespace Microsoft.Store.PartnerCenter.Samples private static IPartnerScenario GetProductScenarios(IScenarioContext context) { var productScenarios = new IPartnerScenario[] - { + { + new GetProductPromotions(context), + new GetProductPromotion(context), new GetProducts(context), new GetProductsByTargetSegment(context), new GetProduct(context), diff --git a/sdk/SdkSamples/SdkSamples.csproj b/sdk/SdkSamples/SdkSamples.csproj index 630bc48..168e58f 100644 --- a/sdk/SdkSamples/SdkSamples.csproj +++ b/sdk/SdkSamples/SdkSamples.csproj @@ -215,6 +215,8 @@ + +