├── .gitattributes ├── .gitignore ├── LICENSE ├── Partner Center SDK Samples.sln ├── README.md ├── Source └── Partner Center SDK Samples │ ├── AggregatePartnerScenario.cs │ ├── Agreements │ ├── CreateCustomerAgreement.cs │ ├── GetAgreementDetails.cs │ ├── GetAllCustomersAgreements.cs │ ├── GetCustomerAgreements.cs │ └── ImportCustomersAgreement.cs │ ├── Analytics │ ├── GetCustomerLicensesDeploymentAnalytics.cs │ ├── GetCustomerLicensesUsageAnalytics.cs │ ├── GetPartnerLicensesDeploymentAnalytics.cs │ └── GetPartnerLicensesUsageAnalytics.cs │ ├── App.config │ ├── Auditing │ ├── QueryAuditRecords.cs │ ├── SearchAuditRecords.cs │ ├── SearchAuditRecordsByCustomerId.cs │ └── SearchAuditRecordsByResourceType.cs │ ├── BasePartnerScenario.cs │ ├── Carts │ ├── CheckoutCart.cs │ ├── CreateCart.cs │ ├── CreateCartAddonWithExistingSubscription.cs │ ├── CreateCartWithAddons.cs │ └── UpdateCart.cs │ ├── Configuration │ ├── ApplicationAuthenticationSection.cs │ ├── ConfigurationManager.cs │ ├── PartnerServiceSettingsSection.cs │ ├── ScenarioSettingsSection.cs │ ├── Section.cs │ └── UserAuthenticationSection.cs │ ├── Context │ └── ScenarioContext.cs │ ├── CustomerDirectoryRoles │ ├── AddUserMemberToDirectoryRole.cs │ ├── GetCustomerDirectoryRoleUserMembers.cs │ ├── GetCustomerDirectoryRoles.cs │ └── RemoveCustomerUserMemberFromDirectoryRole.cs │ ├── CustomerProducts │ ├── GetCustomerAvailabilities.cs │ ├── GetCustomerAvailabilitiesByTargetSegment.cs │ ├── GetCustomerAvailability.cs │ ├── GetCustomerProduct.cs │ ├── GetCustomerProducts.cs │ ├── GetCustomerProductsByTargetSegment.cs │ ├── GetCustomerSku.cs │ ├── GetCustomerSkuDownloadOptions.cs │ ├── GetCustomerSkus.cs │ └── GetCustomerSkusByTargetSegment.cs │ ├── CustomerServiceCosts │ ├── GetCustomerServiceCostsLineItems.cs │ └── GetCustomerServiceCostsSummary.cs │ ├── CustomerSubscribedSkus │ └── GetCustomerSubscribedSkus.cs │ ├── CustomerUser │ ├── CreateCustomerUser.cs │ ├── CustomerUserAssignGroup1Licenses.cs │ ├── CustomerUserAssignGroup2Licenses.cs │ ├── CustomerUserAssignLicenses.cs │ ├── CustomerUserAssignedGroup1AndGroup2Licenses.cs │ ├── CustomerUserAssignedGroup1Licenses.cs │ ├── CustomerUserAssignedGroup2Licenses.cs │ ├── CustomerUserAssignedLicenses.cs │ ├── CustomerUserRestore.cs │ ├── DeleteCustomerUser.cs │ ├── GetCustomerInactiveUsers.cs │ ├── GetCustomerUserCollection.cs │ ├── GetCustomerUserDetails.cs │ ├── GetCustomerUserDirectoryRoles.cs │ ├── GetPagedCustomerUsers.cs │ ├── SortCustomerUsers.cs │ └── UpdateCustomerUser.cs │ ├── Customers │ ├── CheckDomainAvailability.cs │ ├── CreateCustomer.cs │ ├── DeleteCustomerFromTipAccount.cs │ ├── DeletePartnerCustomerRelationship.cs │ ├── FilterCustomers.cs │ ├── GetCustomerDetails.cs │ ├── GetCustomerManagedServices.cs │ ├── GetCustomerQualification.cs │ ├── GetCustomerRelationshipRequest.cs │ ├── GetPagedCustomers.cs │ ├── UpdateCustomerBillingProfile.cs │ ├── UpdateCustomerQualification.cs │ ├── UpdateCustomerQualificationWithGCC.cs │ └── ValidateCustomerAddress.cs │ ├── DevicesDeployment │ ├── CreateConfigurationPolicy.cs │ ├── CreateDeviceBatch.cs │ ├── CreateDevices.cs │ ├── DeleteConfigurationPolicy.cs │ ├── DeleteDevice.cs │ ├── GetAllConfigurationPolicies.cs │ ├── GetBatchUploadStatus.cs │ ├── GetDevices.cs │ ├── GetDevicesBatches.cs │ ├── UpdateConfigurationPolicy.cs │ └── UpdateDevicesPolicy.cs │ ├── Entitlements │ └── GetEntitlements.cs │ ├── Helpers │ └── ConsoleHelper.cs │ ├── IPartnerScenario.cs │ ├── IScenarioContext.cs │ ├── IndirectModel │ ├── CreateCustomerForIndirectReseller.cs │ ├── GetCustomersOfIndirectReseller.cs │ ├── GetIndirectResellers.cs │ ├── GetIndirectResellersOfCustomer.cs │ ├── GetSubscriptionsByMpnId.cs │ ├── PlaceOrderForCustomer.cs │ └── VerifyPartnerMpnId.cs │ ├── IndirectPartners │ ├── GetSubscriptionsByMpnId.cs │ └── VerifyPartnerMpnId.cs │ ├── Invoice │ ├── GetAccountBalance.cs │ ├── GetInvoice.cs │ ├── GetInvoiceLineItems.cs │ ├── GetInvoiceStatement.cs │ ├── GetInvoiceSummaries.cs │ └── GetPagedInvoices.cs │ ├── Offers │ ├── GetCustomerOfferCategories.cs │ ├── GetCustomerOffers.cs │ ├── GetOffer.cs │ ├── GetOfferCategories.cs │ ├── GetOffers.cs │ └── GetPagedOffers.cs │ ├── Orders │ ├── CreateAzureReservationOrder.cs │ ├── CreateOrder.cs │ ├── GetOrderDetails.cs │ ├── GetOrderProvisioningStatus.cs │ ├── GetOrders.cs │ ├── GetOrdersByBillingCycleType.cs │ └── UpdateOrder.cs │ ├── Partner Center SDK Samples.csproj │ ├── Products │ ├── CheckInventory.cs │ ├── GetAvailabilities.cs │ ├── GetAvailabilitiesByTargetSegment.cs │ ├── GetAvailability.cs │ ├── GetProduct.cs │ ├── GetProducts.cs │ ├── GetProductsByTargetSegment.cs │ ├── GetSku.cs │ ├── GetSkuDownloadOptions.cs │ ├── GetSkus.cs │ └── GetSkusByTargetSegment.cs │ ├── Profile │ ├── GetBillingProfile.cs │ ├── GetMPNProfile.cs │ ├── GetOrganizationProfile.cs │ ├── GetSupportProfile.cs │ ├── GetlegalBusinessProfile.cs │ ├── UpdateBillingProfile.cs │ ├── UpdateLegalBusinessProfile.cs │ ├── UpdateOrganizationProfile.cs │ └── UpdateSupportProfile.cs │ ├── Program.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── RateCards │ ├── GetAzureRateCard.cs │ └── GetAzureSharedRateCard.cs │ ├── RatedUsage │ ├── GetCustomerSubscriptionsUsage.cs │ ├── GetCustomerUsageSummary.cs │ ├── GetSubscriptionResourceUsage.cs │ ├── GetSubscriptionUsageRecords.cs │ └── GetSubscriptionUsageSummary.cs │ ├── ScenarioExecution │ ├── AggregateScenarioExecutionStrategy.cs │ ├── IScenarioExecutionStrategy.cs │ └── PromptExecutionStrategy.cs │ ├── ServiceIncidents │ └── GetServiceIncidents.cs │ ├── ServiceRequests │ ├── CreatePartnerServiceRequest.cs │ ├── GetCustomerServiceRequests.cs │ ├── GetPagedPartnerServiceRequests.cs │ ├── GetPartnerServiceRequestDetails.cs │ ├── GetServiceRequestSupportTopics.cs │ └── UpdatePartnerServiceRequest.cs │ ├── Settings.StyleCop │ ├── StyleCop.Cache │ ├── Subscriptions │ ├── AddSubscriptionAddOn.cs │ ├── ConvertTrialSubscription.cs │ ├── GetSubscription.cs │ ├── GetSubscriptionProvisioningStatus.cs │ ├── GetSubscriptionSupportContact.cs │ ├── GetSubscriptions.cs │ ├── GetSubscriptionsByOrder.cs │ ├── UpdateSubscription.cs │ ├── UpdateSubscriptionSupportContact.cs │ └── UpgradeSubscription.cs │ ├── Utilization │ └── GetAzureSubscriptionUtilization.cs │ ├── Validations │ ├── AddressValidation.cs │ └── ValidateAddress.cs │ └── packages.config └── nuget.config /.gitattributes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PartnerCenterSamples/Partner-Center-SDK-Samples/06f5a693673185ba4567e9914219cb9289515965/.gitattributes -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 PartnerCenterSamples 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Partner Center SDK Samples.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Partner Center SDK Samples", "Source\Partner Center SDK Samples\Partner Center SDK Samples.csproj", "{AC93E5CC-549C-4F13-9675-A86860918C2B}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9445B986-021F-44FE-BA08-92C43301F8AF}" 9 | ProjectSection(SolutionItems) = preProject 10 | nuget.config = nuget.config 11 | EndProjectSection 12 | EndProject 13 | Global 14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 15 | Debug|Any CPU = Debug|Any CPU 16 | Release|Any CPU = Release|Any CPU 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {AC93E5CC-549C-4F13-9675-A86860918C2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 20 | {AC93E5CC-549C-4F13-9675-A86860918C2B}.Debug|Any CPU.Build.0 = Debug|Any CPU 21 | {AC93E5CC-549C-4F13-9675-A86860918C2B}.Release|Any CPU.ActiveCfg = Release|Any CPU 22 | {AC93E5CC-549C-4F13-9675-A86860918C2B}.Release|Any CPU.Build.0 = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(SolutionProperties) = preSolution 25 | HideSolutionNode = FALSE 26 | EndGlobalSection 27 | EndGlobal 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Partner-Center-SDK-Samples 2 | Contains sample code on how to use the partner center .NET SDK 3 | 4 | Please note that Partner Center .NET SDK samples will be moving to a new repository in Github, the new location is https://github.com/Microsoft/Partner-Center-DotNet-Samples 5 | (current repository location is https://github.com/PartnerCenterSamples/Partner-Center-SDK-Samples ). 6 | We will try to keep the two repositories in sync until we deprecate the current repository on December 1st 2018. 7 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/AggregatePartnerScenario.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples 8 | { 9 | using System; 10 | using System.Collections.Generic; 11 | using System.Globalization; 12 | using ScenarioExecution; 13 | 14 | /// 15 | /// A scenarios that is composed of one or more sub-scenarios. 16 | /// 17 | public class AggregatePartnerScenario : BasePartnerScenario 18 | { 19 | /// 20 | /// Initializes a new instance of the class. 21 | /// 22 | /// The scenario title. 23 | /// A list of child scenarios. 24 | /// The scenario context. 25 | public AggregatePartnerScenario( 26 | string title, 27 | IEnumerable childScenarios, 28 | IScenarioContext context) : base(title, context, new AggregateScenarioExecutionStrategy(), new List(childScenarios)) 29 | { 30 | } 31 | 32 | /// 33 | /// Runs the aggregate scenario. 34 | /// 35 | protected override void RunScenario() 36 | { 37 | // display the child scenarios 38 | for (int i = 0; i < this.Children.Count; ++i) 39 | { 40 | Console.WriteLine(string.Format(CultureInfo.InvariantCulture, "{0}: {1}", i + 1, this.Children[i].Title)); 41 | } 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Agreements/GetAgreementDetails.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Agreements 8 | { 9 | using Models; 10 | using Models.Agreements; 11 | 12 | /// 13 | /// Showcases getting the list of agreement details. 14 | /// 15 | public class GetAgreementDetails : BasePartnerScenario 16 | { 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The scenario context. 21 | public GetAgreementDetails(IScenarioContext context) : base("Get agreement details.", context) 22 | { 23 | } 24 | 25 | /// 26 | /// Executes the get agreement details scenario. 27 | /// 28 | protected override void RunScenario() 29 | { 30 | var partnerOperations = this.Context.UserPartnerOperations; 31 | this.Context.ConsoleHelper.StartProgress("Retrieving agreement details"); 32 | 33 | ResourceCollection agreementDetails = partnerOperations.AgreementDetails.Get(); 34 | 35 | this.Context.ConsoleHelper.StopProgress(); 36 | this.Context.ConsoleHelper.WriteObject(agreementDetails, "Agreement details:"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Agreements/GetCustomerAgreements.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | // ----------------------------------------------------------------------- 5 | 6 | namespace Microsoft.Store.PartnerCenter.Samples.Agreements 7 | { 8 | using System; 9 | using System.Linq; 10 | using Models; 11 | using Models.Agreements; 12 | 13 | /// 14 | /// Showcases the retrieval of customer agreements. 15 | /// 16 | public class GetCustomerAgreements : BasePartnerScenario 17 | { 18 | /// 19 | /// Initializes a new instance of the class. 20 | /// 21 | /// The scenario context. 22 | public GetCustomerAgreements(IScenarioContext context) : base("Get agreements for a customer.", context) 23 | { 24 | } 25 | 26 | /// 27 | /// Executes the get customer agreements scenario. 28 | /// 29 | protected override void RunScenario() 30 | { 31 | var partnerOperations = this.Context.UserPartnerOperations; 32 | string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the customer to get agreement for"); 33 | 34 | this.Context.ConsoleHelper.StartProgress("Retrieving agreements of the customer"); 35 | 36 | ResourceCollection customerAgreements = partnerOperations.Customers.ById(selectedCustomerId) 37 | .Agreements.Get(); 38 | 39 | this.Context.ConsoleHelper.StopProgress(); 40 | 41 | if (!customerAgreements.Items.Any()) 42 | { 43 | Console.WriteLine("No agreements found for the given customer."); 44 | } 45 | else 46 | { 47 | this.Context.ConsoleHelper.WriteObject(customerAgreements, "Customer agreements:"); 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Analytics/GetCustomerLicensesDeploymentAnalytics.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Analytics 8 | { 9 | /// 10 | /// Gets a single customer's licenses deployment analytics. 11 | /// 12 | public class GetCustomerLicensesDeploymentAnalytics : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetCustomerLicensesDeploymentAnalytics(IScenarioContext context) : base("Get customer licenses deployment analytics", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | string customerIdToRetrieve = this.ObtainCustomerId("Enter the ID of the customer to retrieve"); 28 | 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | this.Context.ConsoleHelper.StartProgress("Retrieving customer licenses deployment analytics"); 31 | 32 | var customerLicensesDeploymentAnalytics = partnerOperations.Customers.ById(customerIdToRetrieve).Analytics.Licenses.Deployment.Get(); 33 | 34 | this.Context.ConsoleHelper.StopProgress(); 35 | this.Context.ConsoleHelper.WriteObject(customerLicensesDeploymentAnalytics, "Customer licenses deployment analytics"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Analytics/GetCustomerLicensesUsageAnalytics.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Analytics 8 | { 9 | /// 10 | /// Gets a single customer's licenses usage analytics. 11 | /// 12 | public class GetCustomerLicensesUsageAnalytics : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetCustomerLicensesUsageAnalytics(IScenarioContext context) : base("Get customer licenses usage analytics", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | string customerIdToRetrieve = this.ObtainCustomerId("Enter the ID of the customer to retrieve"); 28 | 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | this.Context.ConsoleHelper.StartProgress("Retrieving customer licenses usage analytics"); 31 | 32 | var customerLicensesDeploymentAnalytics = partnerOperations.Customers.ById(customerIdToRetrieve).Analytics.Licenses.Usage.Get(); 33 | 34 | this.Context.ConsoleHelper.StopProgress(); 35 | this.Context.ConsoleHelper.WriteObject(customerLicensesDeploymentAnalytics, "Customer licenses usage analytics"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Analytics/GetPartnerLicensesDeploymentAnalytics.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Analytics 8 | { 9 | /// 10 | /// Gets partner's licenses deployment analytics. 11 | /// 12 | public class GetPartnerLicensesDeploymentAnalytics : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetPartnerLicensesDeploymentAnalytics(IScenarioContext context) : base("Get partner licenses deployment analytics", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | this.Context.ConsoleHelper.StartProgress("Retrieving partner licenses deployment analytics"); 29 | 30 | var partnerLicensesDeploymentAnalytics = partnerOperations.Analytics.Licenses.Deployment.Get(); 31 | 32 | this.Context.ConsoleHelper.StopProgress(); 33 | this.Context.ConsoleHelper.WriteObject(partnerLicensesDeploymentAnalytics, "Partner licenses deployment analytics"); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Analytics/GetPartnerLicensesUsageAnalytics.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Analytics 8 | { 9 | /// 10 | /// Gets partner's licenses usage analytics. 11 | /// 12 | public class GetPartnerLicensesUsageAnalytics : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetPartnerLicensesUsageAnalytics(IScenarioContext context) : base("Get partner licenses usage analytics", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | this.Context.ConsoleHelper.StartProgress("Retrieving partner licenses usage analytics"); 29 | 30 | var partnerLicensesUsageAnalytics = partnerOperations.Analytics.Licenses.Usage.Get(); 31 | 32 | this.Context.ConsoleHelper.StopProgress(); 33 | this.Context.ConsoleHelper.WriteObject(partnerLicensesUsageAnalytics, "Partner licenses usage analytics"); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Carts/CheckoutCart.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Carts 8 | { 9 | /// 10 | /// A scenario that checkout a cart for a customer. 11 | /// 12 | public class CheckoutCart : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public CheckoutCart(IScenarioContext context) : base("Checkout a Cart", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | string customerId = this.ObtainCustomerId("Enter the ID of the customer making the purchase"); 30 | string cartId = this.ObtainCartID("Enter the ID of cart to checkout"); 31 | 32 | var existingCart = partnerOperations.Customers.ById(customerId).Carts.ById(cartId).Get(); 33 | 34 | this.Context.ConsoleHelper.WriteObject(existingCart, "Cart to be checked out"); 35 | this.Context.ConsoleHelper.StartProgress("Checking out cart"); 36 | var checkoutResult = partnerOperations.Customers.ById(customerId).Carts.ById(cartId).Checkout(); 37 | this.Context.ConsoleHelper.StopProgress(); 38 | this.Context.ConsoleHelper.WriteObject(checkoutResult, "Final Cart: "); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Carts/UpdateCart.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Carts 8 | { 9 | using System.Linq; 10 | using Store.PartnerCenter.Models.Carts; 11 | 12 | /// 13 | /// A scenario that updates a new cart for a customer. 14 | /// 15 | public class UpdateCart : BasePartnerScenario 16 | { 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The scenario context. 21 | public UpdateCart(IScenarioContext context) : base("Update a Cart", context) 22 | { 23 | } 24 | 25 | /// 26 | /// Executes the scenario. 27 | /// 28 | protected override void RunScenario() 29 | { 30 | var partnerOperations = this.Context.UserPartnerOperations; 31 | 32 | string customerId = this.ObtainCustomerId("Enter the ID of the customer making the purchase"); 33 | string cartId = this.ObtainCartID("Enter the ID of cart for which changes are to be made"); 34 | int quantityChange = int.Parse(this.ObtainQuantity("Enter the amount the quantity has to be changed")); 35 | 36 | Cart existingCart = partnerOperations.Customers.ById(customerId).Carts.ById(cartId).Get(); 37 | 38 | this.Context.ConsoleHelper.WriteObject(existingCart, "Cart to be updated"); 39 | this.Context.ConsoleHelper.StartProgress("Updating cart"); 40 | 41 | existingCart.LineItems.ToArray()[0].Quantity += quantityChange; 42 | 43 | var updatedCart = partnerOperations.Customers.ById(customerId).Carts.ById(cartId).Put(existingCart); 44 | this.Context.ConsoleHelper.StopProgress(); 45 | this.Context.ConsoleHelper.WriteObject(updatedCart, "Updated cart"); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Configuration/ApplicationAuthenticationSection.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Configuration 8 | { 9 | /// 10 | /// Holds an application authentication section settings. 11 | /// 12 | public class ApplicationAuthenticationSection : Section 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The application authentication section name. 18 | public ApplicationAuthenticationSection(string sectionName) : base(sectionName) 19 | { 20 | } 21 | 22 | /// 23 | /// Gets the AAD application ID. 24 | /// 25 | public string ApplicationId 26 | { 27 | get 28 | { 29 | return this.ConfigurationSection["ApplicationId"]; 30 | } 31 | } 32 | 33 | /// 34 | /// Gets AAD application secret. 35 | /// 36 | public string ApplicationSecret 37 | { 38 | get 39 | { 40 | return this.ConfigurationSection["ApplicationSecret"]; 41 | } 42 | } 43 | 44 | /// 45 | /// Gets AAD Domain which hosts the application. 46 | /// 47 | public string Domain 48 | { 49 | get 50 | { 51 | return this.ConfigurationSection["Domain"]; 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Configuration/PartnerServiceSettingsSection.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Configuration 8 | { 9 | using System; 10 | 11 | /// 12 | /// Holds the partner service settings section. 13 | /// 14 | public class PartnerServiceSettingsSection : Section 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | public PartnerServiceSettingsSection() : base("PartnerServiceSettings") 20 | { 21 | } 22 | 23 | /// 24 | /// Gets the partner service API endpoint. 25 | /// 26 | public Uri PartnerServiceApiEndpoint 27 | { 28 | get 29 | { 30 | return new Uri(this.ConfigurationSection["PartnerServiceApiEndpoint"]); 31 | } 32 | } 33 | 34 | /// 35 | /// Gets the authentication authority (AAD) endpoint. 36 | /// 37 | public Uri AuthenticationAuthorityEndpoint 38 | { 39 | get 40 | { 41 | return new Uri(this.ConfigurationSection["AuthenticationAuthorityEndpoint"]); 42 | } 43 | } 44 | 45 | /// 46 | /// Gets the graph API end point. 47 | /// 48 | public Uri GraphEndpoint 49 | { 50 | get 51 | { 52 | return new Uri(this.ConfigurationSection["GraphEndpoint"]); 53 | } 54 | } 55 | 56 | /// 57 | /// Gets the AAD common domain. 58 | /// 59 | public string CommonDomain 60 | { 61 | get 62 | { 63 | return this.ConfigurationSection["CommonDomain"]; 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Configuration/Section.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Configuration 8 | { 9 | using System; 10 | using System.Collections.Specialized; 11 | using System.Configuration; 12 | using System.Globalization; 13 | 14 | /// 15 | /// Encapsulates a configuration section read from app.config. 16 | /// 17 | public abstract class Section 18 | { 19 | /// 20 | /// Initializes a new instance of the class. 21 | /// 22 | /// The configuration section name. 23 | protected Section(string sectionName) 24 | { 25 | if (string.IsNullOrWhiteSpace(sectionName)) 26 | { 27 | throw new ArgumentException("sectionName must be set"); 28 | } 29 | 30 | this.ConfigurationSection = System.Configuration.ConfigurationManager.GetSection(sectionName) as NameValueCollection; 31 | 32 | if (this.ConfigurationSection == null) 33 | { 34 | throw new ConfigurationErrorsException(string.Format(CultureInfo.InvariantCulture, "Could not read section: {0} from configuration", sectionName)); 35 | } 36 | } 37 | 38 | /// 39 | /// Gets the configuration section. 40 | /// 41 | protected NameValueCollection ConfigurationSection { get; private set; } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerDirectoryRoles/GetCustomerDirectoryRoleUserMembers.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerDirectoryRoles 8 | { 9 | /// 10 | /// Showcases get customer users by directory role service. 11 | /// 12 | public class GetCustomerDirectoryRoleUserMembers : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetCustomerDirectoryRoleUserMembers(IScenarioContext context) : base("Get customer user by directory role", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the get customer users by directory role service scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | // get customer Id to get directory role user members. 28 | string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the customer to get directory role user members"); 29 | 30 | // get directory role Id. 31 | string selectedDirectoryRoleId = this.ObtainDirectoryRoleId("Enter the ID of the directory role"); 32 | 33 | var partnerOperations = this.Context.UserPartnerOperations; 34 | 35 | this.Context.ConsoleHelper.StartProgress("Getting user members by directory roles"); 36 | 37 | // Get all user members having the selected directory role. 38 | var userMembers = partnerOperations.Customers.ById(selectedCustomerId).DirectoryRoles.ById(selectedDirectoryRoleId).UserMembers.Get(); 39 | this.Context.ConsoleHelper.StopProgress(); 40 | this.Context.ConsoleHelper.WriteObject(userMembers, "User Members who are having the selected directory role"); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerDirectoryRoles/GetCustomerDirectoryRoles.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerDirectoryRoles 8 | { 9 | /// 10 | /// Gets customer directory roles details. 11 | /// 12 | public class GetCustomerDirectoryRoles : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetCustomerDirectoryRoles(IScenarioContext context) : base("Get customer directory roles", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the get customer directory roles scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | // get customer Id. 28 | string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the customer to get directory roles"); 29 | 30 | var partnerOperations = this.Context.UserPartnerOperations; 31 | 32 | this.Context.ConsoleHelper.StartProgress("Getting customer directory roles"); 33 | 34 | // get directory roles of customer. 35 | var directoryRoles = partnerOperations.Customers.ById(selectedCustomerId).DirectoryRoles.Get(); 36 | this.Context.ConsoleHelper.StopProgress(); 37 | this.Context.ConsoleHelper.WriteObject(directoryRoles, "Customer Directory Role Details"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerProducts/GetCustomerAvailabilities.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerProducts 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves the availabilities of a product's SKU for a customer. 13 | /// 14 | public class GetCustomerAvailabilities : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetCustomerAvailabilities(IScenarioContext context) : base("Get availabilities for customer", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var customerId = this.ObtainCustomerId("Enter the ID of the corresponding customer"); 31 | var productId = this.ObtainProductId("Enter the ID of the corresponding product"); 32 | var skuId = this.ObtainSkuId("Enter the ID of the corresponding sku"); 33 | 34 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting availabilities for product {0} and sku {1} for customer {2}", productId, skuId, customerId)); 35 | var skuAvailabilities = partnerOperations.Customers.ById(customerId).Products.ById(productId).Skus.ById(skuId).Availabilities.Get(); 36 | this.Context.ConsoleHelper.StopProgress(); 37 | 38 | this.Context.ConsoleHelper.WriteObject(skuAvailabilities, "Availabilities for customer"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerProducts/GetCustomerAvailabilitiesByTargetSegment.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerProducts 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves the availabilities of a product's SKU for a customer that target a specific segment. 13 | /// 14 | public class GetCustomerAvailabilitiesByTargetSegment : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetCustomerAvailabilitiesByTargetSegment(IScenarioContext context) : base("Get availabilities for customer by segment", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var customerId = this.ObtainCustomerId("Enter the ID of the corresponding customer"); 31 | var productId = this.ObtainProductId("Enter the ID of the corresponding product"); 32 | var skuId = this.ObtainSkuId("Enter the ID of the corresponding sku"); 33 | string segment = this.Context.ConsoleHelper.ReadNonEmptyString("The segment to filter the availabilities on", "The segment can't be empty"); 34 | 35 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting sku availabilities for product {0} and sku {1} by segment {2} for customer {3}", productId, skuId, segment, customerId)); 36 | var skuAvailabilities = partnerOperations.Customers.ById(customerId).Products.ById(productId).Skus.ById(skuId).Availabilities.ByTargetSegment(segment).Get(); 37 | this.Context.ConsoleHelper.StopProgress(); 38 | 39 | this.Context.ConsoleHelper.WriteObject(skuAvailabilities, "Availabilities for customer by segment"); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerProducts/GetCustomerAvailability.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerProducts 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves the availability of a product's SKU for a customer. 13 | /// 14 | public class GetCustomerAvailability : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetCustomerAvailability(IScenarioContext context) : base("Get availability for customer", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var customerId = this.ObtainCustomerId("Enter the ID of the corresponding customer"); 31 | var productId = this.ObtainProductId("Enter the ID of the corresponding product"); 32 | var skuId = this.ObtainSkuId("Enter the ID of the corresponding sku"); 33 | var availabilityId = this.ObtainAvailabilityId("Enter the ID of the availability"); 34 | 35 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting availability {0} for product {1} and sku {2} for customer {3}", availabilityId, productId, skuId, customerId)); 36 | var skuAvailability = partnerOperations.Customers.ById(customerId).Products.ById(productId).Skus.ById(skuId).Availabilities.ById(availabilityId).Get(); 37 | this.Context.ConsoleHelper.StopProgress(); 38 | 39 | this.Context.ConsoleHelper.WriteObject(skuAvailability, "Availability for customer"); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerProducts/GetCustomerProduct.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerProducts 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves product details for a customer. 13 | /// 14 | public class GetCustomerProduct : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetCustomerProduct(IScenarioContext context) : base("Get product for customer", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var customerId = this.ObtainCustomerId("Enter the ID of the corresponding customer"); 31 | var productId = this.ObtainProductId("Enter the ID of the product"); 32 | 33 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting product {0} details for customer {1}", productId, customerId)); 34 | var product = partnerOperations.Customers.ById(customerId).Products.ById(productId).Get(); 35 | this.Context.ConsoleHelper.StopProgress(); 36 | 37 | this.Context.ConsoleHelper.WriteObject(product, "Product details for customer"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerProducts/GetCustomerProducts.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerProducts 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves all the products in a catalog view that apply to a costumer. 13 | /// 14 | public class GetCustomerProducts : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetCustomerProducts(IScenarioContext context) : base("Get products for customer", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var customerId = this.ObtainCustomerId("Enter the ID of the corresponding customer"); 31 | string targetView = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the target view to get its supported products", "The target view can't be empty"); 32 | 33 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting products in catalog view {0} for customer {1}", targetView, customerId)); 34 | var products = partnerOperations.Customers.ById(customerId).Products.ByTargetView(targetView).Get(); 35 | this.Context.ConsoleHelper.StopProgress(); 36 | 37 | this.Context.ConsoleHelper.WriteObject(products, "Products for customer"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerProducts/GetCustomerProductsByTargetSegment.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerProducts 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves all the products in a catalog view that apply to a customer and that target a specific segment. 13 | /// 14 | public class GetCustomerProductsByTargetSegment : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetCustomerProductsByTargetSegment(IScenarioContext context) : base("Get products for customer by segment", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var customerId = this.ObtainCustomerId("Enter the ID of the corresponding customer"); 31 | string targetView = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the target view to get its supported products", "The target view can't be empty"); 32 | string segment = this.Context.ConsoleHelper.ReadNonEmptyString("The segment to filter the products on", "The segment can't be empty"); 33 | 34 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting products in catalog view {0} by segment {1} for customer {2}", targetView, segment, customerId)); 35 | var products = partnerOperations.Customers.ById(customerId).Products.ByTargetView(targetView).ByTargetSegment(segment).Get(); 36 | this.Context.ConsoleHelper.StopProgress(); 37 | 38 | this.Context.ConsoleHelper.WriteObject(products, "Products for customer by segment"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerProducts/GetCustomerSku.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerProducts 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves details of a product's SKU for a customer. 13 | /// 14 | public class GetCustomerSku : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetCustomerSku(IScenarioContext context) : base("Get sku for customer", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var customerId = this.ObtainCustomerId("Enter the ID of the corresponding customer"); 31 | var productId = this.ObtainProductId("Enter the ID of the corresponding product"); 32 | var skuId = this.ObtainSkuId("Enter the ID of the sku"); 33 | 34 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting sku details for sku {0} from product {1} for customer {2}", skuId, productId, customerId)); 35 | var sku = partnerOperations.Customers.ById(customerId).Products.ById(productId).Skus.ById(skuId).Get(); 36 | this.Context.ConsoleHelper.StopProgress(); 37 | 38 | this.Context.ConsoleHelper.WriteObject(sku, "Sku details for customer"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerProducts/GetCustomerSkuDownloadOptions.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerProducts 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves the download options of a product's SKU for a customer. 13 | /// 14 | public class GetCustomerSkuDownloadOptions : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetCustomerSkuDownloadOptions(IScenarioContext context) : base("Get sku download options for customer", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var customerId = this.ObtainCustomerId("Enter the ID of the corresponding customer"); 31 | var productId = this.ObtainProductId("Enter the ID of the corresponding product"); 32 | var skuId = this.ObtainSkuId("Enter the ID of the corresponding sku"); 33 | 34 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting sku download options for sku {0} from product {1} for customer {2}", skuId, productId, customerId)); 35 | var sku = partnerOperations.Customers.ById(customerId).Products.ById(productId).Skus.ById(skuId).DownloadOptions.Get(); 36 | this.Context.ConsoleHelper.StopProgress(); 37 | 38 | this.Context.ConsoleHelper.WriteObject(sku, "Sku download options for customer"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerProducts/GetCustomerSkus.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerProducts 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves all the SKUs related to a product that apply to a customer. 13 | /// 14 | public class GetCustomerSkus : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetCustomerSkus(IScenarioContext context) : base("Get skus for customer", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var customerId = this.ObtainCustomerId("Enter the ID of the corresponding customer"); 31 | var productId = this.ObtainProductId("Enter the ID of the corresponding product"); 32 | 33 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting skus from product {0} for customer {1}", productId, customerId)); 34 | var skus = partnerOperations.Customers.ById(customerId).Products.ById(productId).Skus.Get(); 35 | this.Context.ConsoleHelper.StopProgress(); 36 | 37 | this.Context.ConsoleHelper.WriteObject(skus, "Skus for customer"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerProducts/GetCustomerSkusByTargetSegment.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerProducts 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves all the SKUs related to a product that apply to a customer and that target a specific segment. 13 | /// 14 | public class GetCustomerSkusByTargetSegment : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetCustomerSkusByTargetSegment(IScenarioContext context) : base("Get skus for customer by segment", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var customerId = this.ObtainCustomerId("Enter the ID of the corresponding customer"); 31 | var productId = this.ObtainProductId("Enter the ID of the corresponding product"); 32 | string segment = this.Context.ConsoleHelper.ReadNonEmptyString("The segment to filter the skus on", "The segment can't be empty"); 33 | 34 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting skus from product {0} by segment {1} for customer {2}", productId, segment, customerId)); 35 | var skus = partnerOperations.Customers.ById(customerId).Products.ById(productId).Skus.ByTargetSegment(segment).Get(); 36 | this.Context.ConsoleHelper.StopProgress(); 37 | 38 | this.Context.ConsoleHelper.WriteObject(skus, string.Format(CultureInfo.InvariantCulture, "Skus for customer {0} by segment {1}", productId, segment)); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerServiceCosts/GetCustomerServiceCostsLineItems.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerServiceCosts 8 | { 9 | using Models.ServiceCosts; 10 | 11 | /// 12 | /// Gets Customer Service Costs Line Items. 13 | /// 14 | public class GetCustomerServiceCostsLineItems : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetCustomerServiceCostsLineItems(IScenarioContext context) : base("Get customer service costs line items", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the get Customer Service Costs Line Items. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | // get a customer Id. 30 | string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the customer to get service costs line items"); 31 | 32 | var partnerOperations = this.Context.UserPartnerOperations; 33 | 34 | this.Context.ConsoleHelper.StartProgress("Getting customer service costs line items"); 35 | 36 | // get the customer's Service Costs Line Items. 37 | var customerServiceCostsLineItems = partnerOperations.Customers.ById(selectedCustomerId).ServiceCosts.ByBillingPeriod(ServiceCostsBillingPeriod.MostRecent).LineItems.Get(); 38 | this.Context.ConsoleHelper.StopProgress(); 39 | this.Context.ConsoleHelper.WriteObject(customerServiceCostsLineItems, "Customer Service Costs Line Items"); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerServiceCosts/GetCustomerServiceCostsSummary.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerServiceCosts 8 | { 9 | using Models.ServiceCosts; 10 | 11 | /// 12 | /// Gets Customer Service Costs Summary. 13 | /// 14 | public class GetCustomerServiceCostsSummary : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetCustomerServiceCostsSummary(IScenarioContext context) : base("Get customer service costs summary", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the get Customer Service Costs scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | // get a customer Id. 30 | string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the customer to get service costs summary"); 31 | 32 | var partnerOperations = this.Context.UserPartnerOperations; 33 | 34 | this.Context.ConsoleHelper.StartProgress("Getting customer service costs summary"); 35 | 36 | // get the customer's Service Costs Summary. 37 | var customerServiceCostsSummary = partnerOperations.Customers.ById(selectedCustomerId).ServiceCosts.ByBillingPeriod(ServiceCostsBillingPeriod.MostRecent).Summary.Get(); 38 | this.Context.ConsoleHelper.StopProgress(); 39 | this.Context.ConsoleHelper.WriteObject(customerServiceCostsSummary, "Customer Service Costs Summary"); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerSubscribedSkus/GetCustomerSubscribedSkus.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerSubscribedSkus 8 | { 9 | using System; 10 | 11 | /// 12 | /// Gets Customer Subscribed SKUs details. 13 | /// 14 | public class GetCustomerSubscribedSkus : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetCustomerSubscribedSkus(IScenarioContext context) : base("Get customer subscribed SKUs", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the get Customer Subscribed SKUs scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | // get customer Id. 30 | string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the customer to get subscribed skus"); 31 | 32 | var partnerOperations = this.Context.UserPartnerOperations; 33 | 34 | this.Context.ConsoleHelper.StartProgress("Getting customer subscribed SKUs"); 35 | 36 | // get Customer Subscribed SKUs information. 37 | var customerSubscribedSkus = partnerOperations.Customers.ById(selectedCustomerId).SubscribedSkus.Get(); 38 | this.Context.ConsoleHelper.StopProgress(); 39 | 40 | Console.Out.WriteLine("Customer Subscribed Skus Count: " + customerSubscribedSkus.TotalCount); 41 | this.Context.ConsoleHelper.WriteObject(customerSubscribedSkus, "Customer Subscribed Sku"); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerUser/CustomerUserAssignedLicenses.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerUser 8 | { 9 | /// 10 | /// Gets customer user assigned licenses. 11 | /// 12 | public class CustomerUserAssignedLicenses : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public CustomerUserAssignedLicenses(IScenarioContext context) : base("Get customer user assigned licenses", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the get customer user assigned licenses scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | // get customer user Id. 28 | string selectedCustomerUserId = this.ObtainCustomerUserId("Enter the ID of the customer user to get assigned licenses"); 29 | 30 | // get customer Id of the entered customer user. 31 | string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the customer"); 32 | 33 | var partnerOperations = this.Context.UserPartnerOperations; 34 | 35 | this.Context.ConsoleHelper.StartProgress("Getting customer user assigned licenses"); 36 | 37 | // get customer user assigned licenses information. 38 | var customerUserAssignedLicenses = partnerOperations.Customers.ById(selectedCustomerId).Users.ById(selectedCustomerUserId).Licenses.Get(); 39 | this.Context.ConsoleHelper.StopProgress(); 40 | this.Context.ConsoleHelper.WriteObject(customerUserAssignedLicenses, "Customer User Assigned Licenses"); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerUser/CustomerUserRestore.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerUser 8 | { 9 | using Models.Users; 10 | 11 | /// 12 | /// Showcases customer user restore API. 13 | /// 14 | public class CustomerUserRestore : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public CustomerUserRestore(IScenarioContext context) : base("Restore a deleted customer user", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the restore customer user scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | // get customer Id of the entered customer user. 30 | string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the corresponding customer to restore customer user details"); 31 | 32 | // get customer user Id. 33 | string selectedCustomerUserId = this.ObtainCustomerUserId("Enter the ID of the customer user to restore"); 34 | 35 | var partnerOperations = this.Context.UserPartnerOperations; 36 | 37 | var updatedCustomerUser = new CustomerUser() 38 | { 39 | State = UserState.Active 40 | }; 41 | 42 | this.Context.ConsoleHelper.StartProgress("Restoring the customer user"); 43 | 44 | // restore customer user information using older upn. 45 | var restoredCustomerUserInfo = partnerOperations.Customers.ById(selectedCustomerId).Users.ById(selectedCustomerUserId).Patch(updatedCustomerUser); 46 | this.Context.ConsoleHelper.StopProgress(); 47 | this.Context.ConsoleHelper.WriteObject(restoredCustomerUserInfo, "Restored customer user."); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerUser/DeleteCustomerUser.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerUser 8 | { 9 | /// 10 | /// Deletes a customer user. 11 | /// 12 | public class DeleteCustomerUser : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public DeleteCustomerUser(IScenarioContext context) : base("Delete customer user", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the delete customer user scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | // get customer user to delete. 28 | string customerUserIdToDelete = this.ObtainCustomerUserIdDelete("Enter the ID of the customer user to delete"); 29 | 30 | // get customer Id of the entered customer user. 31 | string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the corresponding customer whose customer user to delete"); 32 | 33 | var partnerOperations = this.Context.UserPartnerOperations; 34 | 35 | this.Context.ConsoleHelper.StartProgress("Deleting customer user"); 36 | 37 | // delete customer user 38 | partnerOperations.Customers.ById(selectedCustomerId).Users.ById(customerUserIdToDelete).Delete(); 39 | this.Context.ConsoleHelper.StopProgress(); 40 | this.Context.ConsoleHelper.Success("Customer User successfully deleted"); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerUser/GetCustomerUserCollection.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerUser 8 | { 9 | /// 10 | /// Gets customer user collection. 11 | /// 12 | public class GetCustomerUserCollection : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetCustomerUserCollection(IScenarioContext context) : base("Get a customer user collection", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the get customer user collection scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | // get customer Id. 28 | string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the customer to get customer user collection"); 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | 31 | this.Context.ConsoleHelper.StartProgress("Getting customer users collection"); 32 | 33 | // get customer users collection 34 | var customerUsers = partnerOperations.Customers.ById(selectedCustomerId).Users.Get(); 35 | 36 | this.Context.ConsoleHelper.StopProgress(); 37 | this.Context.ConsoleHelper.WriteObject(customerUsers, "Customer Users collection"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/CustomerUser/GetCustomerUserDetails.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.CustomerUser 8 | { 9 | /// 10 | /// Gets a single customer user details. 11 | /// 12 | public class GetCustomerUserDetails : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetCustomerUserDetails(IScenarioContext context) : base("Get a customer user details", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the get customer user details scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | // get customer user Id. 28 | string selectedCustomerUserId = this.ObtainCustomerUserId("Enter the ID of the customer user to get details"); 29 | 30 | // get customer Id of the entered customer user. 31 | string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the corresponding customer to get customer user details"); 32 | var partnerOperations = this.Context.UserPartnerOperations; 33 | 34 | this.Context.ConsoleHelper.StartProgress("Getting customer user detail"); 35 | 36 | // Get customer user detail 37 | var selectedCustomerUser = partnerOperations.Customers.ById(selectedCustomerId).Users.ById(selectedCustomerUserId).Get(); 38 | this.Context.ConsoleHelper.StopProgress(); 39 | this.Context.ConsoleHelper.WriteObject(selectedCustomerUser, "Customer User detail"); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Customers/CheckDomainAvailability.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Customers 8 | { 9 | /// 10 | /// A scenario that checks if a domain is still available for a customer or not. 11 | /// 12 | public class CheckDomainAvailability : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public CheckDomainAvailability(IScenarioContext context) : base("Check domain availability", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | string domainPrefix = this.Context.ConsoleHelper.ReadNonEmptyString("Enter a domain prefix to check its availability", "The entered domain is empty"); 29 | 30 | this.Context.ConsoleHelper.StartProgress("Checking"); 31 | bool isDomainAvailable = !partnerOperations.Domains.ByDomain(domainPrefix).Exists(); 32 | this.Context.ConsoleHelper.StopProgress(); 33 | 34 | if (isDomainAvailable) 35 | { 36 | this.Context.ConsoleHelper.Success("This domain prefix is available!"); 37 | } 38 | else 39 | { 40 | this.Context.ConsoleHelper.Warning("This domain prefix is unavailable."); 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Customers/DeleteCustomerFromTipAccount.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Customers 8 | { 9 | using System; 10 | 11 | /// 12 | /// Deletes a customer from a testing in production account. 13 | /// 14 | public class DeleteCustomerFromTipAccount : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public DeleteCustomerFromTipAccount(IScenarioContext context) : base("Delete customer from TIP account", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | string customerIdToDelete = this.Context.Configuration.Scenario.CustomerIdToDelete; 30 | 31 | if (string.IsNullOrWhiteSpace(customerIdToDelete)) 32 | { 33 | // prompt the user the enter the customer ID 34 | customerIdToDelete = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the ID of the customer to delete", "The customer ID can't be empty"); 35 | } 36 | else 37 | { 38 | Console.WriteLine("Found customer ID: {0} in configuration.", customerIdToDelete); 39 | } 40 | 41 | var partnerOperations = this.Context.AppPartnerOperations; 42 | 43 | this.Context.ConsoleHelper.StartProgress("Deleting customer"); 44 | partnerOperations.Customers.ById(customerIdToDelete).Delete(); 45 | 46 | this.Context.ConsoleHelper.StopProgress(); 47 | this.Context.ConsoleHelper.Success("Customer successfully deleted"); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Customers/FilterCustomers.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Customers 8 | { 9 | using Store.PartnerCenter.Models.Customers; 10 | using Store.PartnerCenter.Models.Query; 11 | 12 | /// 13 | /// Returns customers according to a provided filter. 14 | /// 15 | public class FilterCustomers : BasePartnerScenario 16 | { 17 | /// 18 | /// The search field. 19 | /// 20 | private readonly CustomerSearchField customerSearchField; 21 | 22 | /// 23 | /// Initializes a new instance of the class. 24 | /// 25 | /// The scenario title. 26 | /// The search field. 27 | /// The scenario context. 28 | public FilterCustomers(string title, CustomerSearchField customerSearchField, IScenarioContext context) : base(title, context) 29 | { 30 | this.customerSearchField = customerSearchField; 31 | } 32 | 33 | /// 34 | /// Executes the scenario. 35 | /// 36 | protected override void RunScenario() 37 | { 38 | var partnerOperations = this.Context.UserPartnerOperations; 39 | string searchPrefix = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the prefix to search for", "The entered prefix is empty"); 40 | 41 | this.Context.ConsoleHelper.StartProgress("Filtering"); 42 | 43 | var fieldFilter = new SimpleFieldFilter( 44 | this.customerSearchField.ToString(), 45 | FieldFilterOperation.StartsWith, 46 | searchPrefix); 47 | 48 | var myQuery = QueryFactory.Instance.BuildSimpleQuery(fieldFilter); 49 | 50 | var customers = partnerOperations.Customers.Query(myQuery); 51 | 52 | this.Context.ConsoleHelper.StopProgress(); 53 | this.Context.ConsoleHelper.WriteObject(customers, "Customer matches"); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Customers/GetCustomerDetails.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Customers 8 | { 9 | /// 10 | /// Gets a single customer details. 11 | /// 12 | public class GetCustomerDetails : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetCustomerDetails(IScenarioContext context) : base("Get a customer details", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the get customer details scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | string customerIdToRetrieve = this.ObtainCustomerId("Enter the ID of the customer to retrieve"); 28 | 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | this.Context.ConsoleHelper.StartProgress("Retrieving customer"); 31 | 32 | var customerDetails = partnerOperations.Customers.ById(customerIdToRetrieve).Get(); 33 | 34 | this.Context.ConsoleHelper.StopProgress(); 35 | this.Context.ConsoleHelper.WriteObject(customerDetails, "Customer details"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Customers/GetCustomerManagedServices.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Customers 8 | { 9 | /// 10 | /// Gets a customer list of managed services. 11 | /// 12 | public class GetCustomerManagedServices : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetCustomerManagedServices(IScenarioContext context) : base("Get customer managed services", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | string customerId = this.ObtainCustomerId(); 28 | 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | this.Context.ConsoleHelper.StartProgress("Getting the customer's managed services"); 31 | 32 | var managedServices = partnerOperations.Customers.ById(customerId).ManagedServices.Get(); 33 | 34 | this.Context.ConsoleHelper.StopProgress(); 35 | this.Context.ConsoleHelper.WriteObject(managedServices, "Customer managed services"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Customers/GetCustomerQualification.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Customers 8 | { 9 | /// 10 | /// Gets a single customer qualification. 11 | /// 12 | public class GetCustomerQualification : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetCustomerQualification(IScenarioContext context) : base("Get customer qualification", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the get customer qualification scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | string customerIdToRetrieve = this.ObtainCustomerId("Enter the ID of the customer to retrieve qualification for"); 28 | 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | this.Context.ConsoleHelper.StartProgress("Retrieving customer qualification"); 31 | 32 | var customerQualification = partnerOperations.Customers.ById(customerIdToRetrieve).Qualification.Get(); 33 | 34 | this.Context.ConsoleHelper.StopProgress(); 35 | this.Context.ConsoleHelper.WriteObject(customerQualification, "Customer Qualification"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Customers/GetCustomerRelationshipRequest.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Customers 8 | { 9 | /// 10 | /// Gets the request which establishes a relationship between the partner and their customers. 11 | /// 12 | public class GetCustomerRelationshipRequest : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetCustomerRelationshipRequest(IScenarioContext context) : base("Get customer relationship request", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | this.Context.ConsoleHelper.StartProgress("Retrieving customer relationship request"); 30 | var customerRelationshipRequest = partnerOperations.Customers.RelationshipRequest.Get(); 31 | 32 | this.Context.ConsoleHelper.StopProgress(); 33 | this.Context.ConsoleHelper.WriteObject(customerRelationshipRequest, "Customer relationship request"); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Customers/UpdateCustomerQualification.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Customers 8 | { 9 | using Microsoft.Store.PartnerCenter.Models.Customers; 10 | 11 | /// 12 | /// Updates a single customer qualification. 13 | /// 14 | public class UpdateCustomerQualification : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public UpdateCustomerQualification(IScenarioContext context) : base("Update customer qualification", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the update customer qualification scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | string customerIdToRetrieve = this.ObtainCustomerId($"Enter the ID of the customer to update qualification to {CustomerQualification.Education}"); 30 | 31 | var partnerOperations = this.Context.UserPartnerOperations; 32 | this.Context.ConsoleHelper.StartProgress("Updating customer qualification"); 33 | 34 | var customerQualification = 35 | partnerOperations.Customers.ById(customerIdToRetrieve) 36 | .Qualification.Update(CustomerQualification.Education); 37 | 38 | this.Context.ConsoleHelper.StopProgress(); 39 | this.Context.ConsoleHelper.WriteObject(customerQualification, "Customer Qualification"); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Customers/ValidateCustomerAddress.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Customers 8 | { 9 | /// 10 | /// A scenario that showcases country validation rules. 11 | /// 12 | public class ValidateCustomerAddress : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public ValidateCustomerAddress(IScenarioContext context) : base("Validate customer address.", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the 2 digit country code to get its validation rules", "The country code can't be empty"); 29 | 30 | this.Context.ConsoleHelper.StartProgress("Retrieving country validation rules"); 31 | var countryValidationRules = partnerOperations.CountryValidationRules.ByCountry(countryCode).Get(); 32 | this.Context.ConsoleHelper.StopProgress(); 33 | this.Context.ConsoleHelper.WriteObject(countryValidationRules, " Country validation rules"); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/DevicesDeployment/DeleteConfigurationPolicy.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.DevicesDeployment 8 | { 9 | /// 10 | /// Deletes a configuration policy. 11 | /// 12 | public class DeleteConfigurationPolicy : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public DeleteConfigurationPolicy(IScenarioContext context) : base("Delete a configuration policy", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the create device batch scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the customer to delete a configuration policy"); 28 | 29 | string selectedPolicyId = this.ObtainConfigurationPolicyId("Enter the ID of the configuration policy to delete"); 30 | 31 | var partnerOperations = this.Context.UserPartnerOperations; 32 | 33 | this.Context.ConsoleHelper.WriteObject(selectedPolicyId, "Configuration policy to be deleted"); 34 | this.Context.ConsoleHelper.StartProgress("Deleting Configuration policy"); 35 | 36 | partnerOperations.Customers.ById(selectedCustomerId).ConfigurationPolicies.ById(selectedPolicyId).Delete(); 37 | 38 | this.Context.ConsoleHelper.StopProgress(); 39 | this.Context.ConsoleHelper.Success("Delete Configuration policy request submitted successfully!"); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/DevicesDeployment/DeleteDevice.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.DevicesDeployment 8 | { 9 | /// 10 | /// Deletes a device. 11 | /// 12 | public class DeleteDevice : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public DeleteDevice(IScenarioContext context) : base("Deletes a device", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the delete device scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the customer to delete a device"); 28 | 29 | string selectedDeviceBatchId = this.ObtainDeviceBatchId("Enter the ID of the Device batch to retrieve the devices of"); 30 | 31 | string selectedDeviceId = this.ObtainDeviceId("Enter the ID of the device to delete"); 32 | 33 | var partnerOperations = this.Context.UserPartnerOperations; 34 | 35 | this.Context.ConsoleHelper.WriteObject(selectedDeviceId, "Device to be deleted"); 36 | this.Context.ConsoleHelper.StartProgress("Deleting device"); 37 | 38 | partnerOperations.Customers.ById(selectedCustomerId).DeviceBatches.ById(selectedDeviceBatchId).Devices.ById(selectedDeviceId).Delete(); 39 | 40 | this.Context.ConsoleHelper.StopProgress(); 41 | this.Context.ConsoleHelper.Success("Deleted the device successfully!"); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/DevicesDeployment/GetAllConfigurationPolicies.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.DevicesDeployment 8 | { 9 | /// 10 | /// Gets all configuration policies of a customer. 11 | /// 12 | public class GetAllConfigurationPolicies : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetAllConfigurationPolicies(IScenarioContext context) : base("Get all configuration policies", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes get all configuration policies scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | string selectedCustomerId = this.ObtainCustomerId("Enter the ID of the customer to get the configuration policies"); 28 | 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | 31 | this.Context.ConsoleHelper.StartProgress("Querying Configuration policies"); 32 | 33 | var configPolicies = partnerOperations.Customers.ById(selectedCustomerId).ConfigurationPolicies.Get(); 34 | 35 | this.Context.ConsoleHelper.StopProgress(); 36 | this.Context.ConsoleHelper.WriteObject(configPolicies, "Configuration Policies"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/DevicesDeployment/GetBatchUploadStatus.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.DevicesDeployment 8 | { 9 | /// 10 | /// Gets batch upload status. 11 | /// 12 | public class GetBatchUploadStatus : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetBatchUploadStatus(IScenarioContext context) : base("Get Batch Upload Status", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the create device batch scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | string selectedCustomerId = this.ObtainCustomerId("Enter the Customer Id to get the status for"); 28 | 29 | string selectedTrackingId = this.ObtainBatchUploadStatusTrackingId("Enter the batch upload status tracking Id to get the status of"); 30 | 31 | var partnerOperations = this.Context.UserPartnerOperations; 32 | 33 | this.Context.ConsoleHelper.StartProgress("Querying the status"); 34 | 35 | var status = partnerOperations.Customers.ById(selectedCustomerId).BatchUploadStatus.ById(selectedTrackingId).Get(); 36 | 37 | this.Context.ConsoleHelper.StopProgress(); 38 | this.Context.ConsoleHelper.WriteObject(status, "Tracking Status"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/DevicesDeployment/GetDevices.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.DevicesDeployment 8 | { 9 | /// 10 | /// Gets devices of a device batch. 11 | /// 12 | public class GetDevices : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetDevices(IScenarioContext context) : base("Get Devices", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the create device batch scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | string selectedCustomerId = this.ObtainCustomerId("Enter the Customer Id to get the devices for"); 28 | 29 | string selectedDeviceBatchId = this.ObtainDeviceBatchId("Enter the ID of the Device batch to retrieve the devices of"); 30 | 31 | var partnerOperations = this.Context.UserPartnerOperations; 32 | 33 | this.Context.ConsoleHelper.StartProgress("Querying for the devices"); 34 | 35 | var devices = partnerOperations.Customers.ById(selectedCustomerId).DeviceBatches.ById(selectedDeviceBatchId).Devices.Get(); 36 | 37 | this.Context.ConsoleHelper.StopProgress(); 38 | this.Context.ConsoleHelper.WriteObject(devices, "Devices"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/DevicesDeployment/GetDevicesBatches.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.DevicesDeployment 8 | { 9 | /// 10 | /// Gets devices batches. 11 | /// 12 | public class GetDevicesBatches : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetDevicesBatches(IScenarioContext context) : base("Get Devices Batches", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the create device batch scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | string selectedCustomerId = this.ObtainCustomerId("Enter the Customer Id to get the devices batches for"); 28 | 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | 31 | this.Context.ConsoleHelper.StartProgress("Querying for the devices batches"); 32 | 33 | var devicesBatches = partnerOperations.Customers.ById(selectedCustomerId).DeviceBatches.Get(); 34 | 35 | this.Context.ConsoleHelper.StopProgress(); 36 | this.Context.ConsoleHelper.WriteObject(devicesBatches, "Device Batches"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/IPartnerScenario.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples 8 | { 9 | using System.Collections.Generic; 10 | 11 | /// 12 | /// Represents a partner scenario that demos one or more related partner center APIs. 13 | /// 14 | public interface IPartnerScenario 15 | { 16 | /// 17 | /// Gets the scenario title. 18 | /// 19 | string Title { get; } 20 | 21 | /// 22 | /// Gets the children scenarios of the current scenario. 23 | /// 24 | IReadOnlyList Children { get; } 25 | 26 | /// 27 | /// Gets the scenario context. 28 | /// 29 | IScenarioContext Context { get; } 30 | 31 | /// 32 | /// Runs the scenario. 33 | /// 34 | void Run(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/IScenarioContext.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples 8 | { 9 | using Configuration; 10 | using Helpers; 11 | using Store.PartnerCenter; 12 | 13 | /// 14 | /// Holds context properties useful to the scenarios. 15 | /// 16 | public interface IScenarioContext 17 | { 18 | /// 19 | /// Gets a partner operations instance which is user based authenticated. 20 | /// 21 | IAggregatePartner UserPartnerOperations { get; } 22 | 23 | /// 24 | /// Gets a partner operations instance which is application based authenticated. 25 | /// 26 | IAggregatePartner AppPartnerOperations { get; } 27 | 28 | /// 29 | /// Gets a configuration instance. 30 | /// 31 | ConfigurationManager Configuration { get; } 32 | 33 | /// 34 | /// Gets a console helper instance. 35 | /// 36 | ConsoleHelper ConsoleHelper { get; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/IndirectModel/GetIndirectResellers.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.IndirectModel 8 | { 9 | using Models.Relationships; 10 | 11 | /// 12 | /// A scenario that retrieves the list of indirect resellers associated to the indirect CSP partner 13 | /// 14 | public class GetIndirectResellers : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetIndirectResellers(IScenarioContext context) : base("Get indirect resellers", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | this.Context.ConsoleHelper.StartProgress("Getting indirect resellers"); 31 | 32 | var indirectResellers = partnerOperations.Relationships.Get(PartnerRelationshipType.IsIndirectCloudSolutionProviderOf); 33 | 34 | this.Context.ConsoleHelper.StopProgress(); 35 | this.Context.ConsoleHelper.WriteObject(indirectResellers, "Indirect Resellers"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/IndirectModel/GetIndirectResellersOfCustomer.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.IndirectModel 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves the list of indirect resellers associated to the indirect CSP partner of a customer. 13 | /// 14 | public class GetIndirectResellersOfCustomer : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetIndirectResellersOfCustomer(IScenarioContext context) : base("Get indirect resellers of a customer", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var customerId = this.ObtainCustomerId("Enter the ID of the customer: "); 30 | 31 | var partnerOperations = this.Context.UserPartnerOperations; 32 | this.Context.ConsoleHelper.StartProgress("Getting indirect resellers of a customer"); 33 | 34 | var indirectResellers = partnerOperations.Customers[customerId].Relationships.Get(); 35 | 36 | this.Context.ConsoleHelper.StopProgress(); 37 | this.Context.ConsoleHelper.WriteObject( 38 | indirectResellers, 39 | string.Format(CultureInfo.InvariantCulture, "Indirect Resellers of customer: {0}", customerId)); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/IndirectModel/GetSubscriptionsByMpnId.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.IndirectModel 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that gets a customer's subscriptions which belong to a partner MPN ID. 13 | /// 14 | public class GetSubscriptionsByMpnId : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetSubscriptionsByMpnId(IScenarioContext context) : base("Get customer subscriptions by partner MPN ID", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | string customerId = this.ObtainCustomerId(); 30 | string partnerMpnId = this.ObtainMpnId(); 31 | 32 | var partnerOperations = this.Context.UserPartnerOperations; 33 | this.Context.ConsoleHelper.StartProgress("Getting subscriptions"); 34 | 35 | var customerSubscriptionsByMpnId = partnerOperations.Customers.ById(customerId).Subscriptions.ByPartner(partnerMpnId).Get(); 36 | 37 | this.Context.ConsoleHelper.StopProgress(); 38 | this.Context.ConsoleHelper.WriteObject( 39 | customerSubscriptionsByMpnId, 40 | string.Format(CultureInfo.InvariantCulture, "Customer subscriptions by MPN ID: {0}", partnerMpnId)); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/IndirectModel/VerifyPartnerMpnId.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.IndirectModel 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that verifies a partner MPN ID. 13 | /// 14 | public class VerifyPartnerMpnId : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public VerifyPartnerMpnId(IScenarioContext context) : base("Verify partner MPN ID", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | this.Context.ConsoleHelper.StartProgress("Getting the logged in partner's profile"); 31 | 32 | var currentPartnerProfile = partnerOperations.Profiles.MpnProfile.Get(); 33 | 34 | this.Context.ConsoleHelper.StopProgress(); 35 | this.Context.ConsoleHelper.WriteObject(currentPartnerProfile, "Logged in partner profile"); 36 | 37 | string partnerMpnId = this.ObtainMpnId("Enter the MPN ID to verify"); 38 | 39 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting the partner profile for MPN ID: {0}", partnerMpnId)); 40 | 41 | var partnerProfile = partnerOperations.Profiles.MpnProfile.Get(partnerMpnId); 42 | 43 | this.Context.ConsoleHelper.StopProgress(); 44 | this.Context.ConsoleHelper.WriteObject(partnerProfile, "Partner profile"); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/IndirectPartners/GetSubscriptionsByMpnId.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.IndirectPartners 8 | { 9 | using System; 10 | using System.Globalization; 11 | 12 | /// 13 | /// A scenario that gets a customer's subscriptions which belong to a partner MPN ID. 14 | /// 15 | public class GetSubscriptionsByMpnId : BasePartnerScenario 16 | { 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The scenario context. 21 | public GetSubscriptionsByMpnId(IScenarioContext context) : base("Get customer subscriptions by partner MPN ID", context) 22 | { 23 | } 24 | 25 | /// 26 | /// Executes the scenario. 27 | /// 28 | protected override void RunScenario() 29 | { 30 | string customerId = this.ObtainCustomerId(); 31 | string partnerMpnId = this.ObtainMpnId(); 32 | 33 | var partnerOperations = this.Context.UserPartnerOperations; 34 | this.Context.ConsoleHelper.StartProgress("Getting subscriptions"); 35 | 36 | var customerSubscriptionsByMpnId = partnerOperations.Customers.ById(customerId).Subscriptions.ByPartner(partnerMpnId).Get(); 37 | 38 | this.Context.ConsoleHelper.StopProgress(); 39 | this.Context.ConsoleHelper.WriteObject( 40 | customerSubscriptionsByMpnId, 41 | string.Format(CultureInfo.InvariantCulture, "Customer subscriptions by MPN ID: {0}", partnerMpnId)); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/IndirectPartners/VerifyPartnerMpnId.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.IndirectPartners 8 | { 9 | using System; 10 | using System.Globalization; 11 | 12 | /// 13 | /// A scenario that verifies a partner MPN ID. 14 | /// 15 | public class VerifyPartnerMpnId : BasePartnerScenario 16 | { 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The scenario context. 21 | public VerifyPartnerMpnId(IScenarioContext context) : base("Verify partner MPN ID", context) 22 | { 23 | } 24 | 25 | /// 26 | /// Executes the scenario. 27 | /// 28 | protected override void RunScenario() 29 | { 30 | var partnerOperations = this.Context.UserPartnerOperations; 31 | this.Context.ConsoleHelper.StartProgress("Getting the logged in partner's profile"); 32 | 33 | var currentPartnerProfile = partnerOperations.Profiles.MpnProfile.Get(); 34 | 35 | this.Context.ConsoleHelper.StopProgress(); 36 | this.Context.ConsoleHelper.WriteObject(currentPartnerProfile, "Logged in partner profile"); 37 | 38 | string partnerMpnId = this.ObtainMpnId("Enter the MPN ID to verify"); 39 | 40 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting the partner profile for MPN ID: {0}", partnerMpnId)); 41 | 42 | var partnerProfile = partnerOperations.Profiles.MpnProfile.Get(partnerMpnId); 43 | 44 | this.Context.ConsoleHelper.StopProgress(); 45 | this.Context.ConsoleHelper.WriteObject(partnerProfile, "Partner profile"); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Invoice/GetAccountBalance.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Invoice 8 | { 9 | /// 10 | /// Gets the account balance for a partner. 11 | /// 12 | public class GetAccountBalance : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetAccountBalance(IScenarioContext context) : base("Get account balance", context) 19 | { 20 | } 21 | 22 | /// 23 | /// executes the get account balance scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | this.Context.ConsoleHelper.StartProgress("Getting account balance"); 29 | 30 | // Getting the account balance 31 | var accountBalance = partnerOperations.Invoices.Summary.Get().BalanceAmount; 32 | 33 | this.Context.ConsoleHelper.StopProgress(); 34 | this.Context.ConsoleHelper.WriteObject(accountBalance, "Account Balance"); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Invoice/GetInvoice.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Invoice 8 | { 9 | using System; 10 | 11 | /// 12 | /// Gets a single partner invoice. 13 | /// 14 | public class GetInvoice : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetInvoice(IScenarioContext context) : base("Get partner's invoice details", context) 21 | { 22 | } 23 | 24 | /// 25 | /// executes the get invoice scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | string invoiceId = this.Context.Configuration.Scenario.DefaultInvoiceId; 31 | 32 | if (string.IsNullOrWhiteSpace(invoiceId)) 33 | { 34 | // prompt the user the enter the invoice ID 35 | invoiceId = this.Context.ConsoleHelper.ReadNonEmptyString("Please enter the invoice ID to retrieve ", "The invoice ID can't be empty"); 36 | } 37 | else 38 | { 39 | Console.WriteLine("Found Invoice ID: {0} in configuration.", invoiceId); 40 | } 41 | 42 | this.Context.ConsoleHelper.StartProgress("Retrieving invoice"); 43 | 44 | // Retrieving invoice 45 | var invoice = partnerOperations.Invoices.ById(invoiceId).Get(); 46 | 47 | this.Context.ConsoleHelper.StopProgress(); 48 | this.Context.ConsoleHelper.WriteObject(invoice, "Invoice details"); 49 | 50 | // Retrieving invoice line items 51 | if (invoice.InvoiceDetails != null) 52 | { 53 | foreach (var invoiceDetail in invoice.InvoiceDetails) 54 | { 55 | this.Context.ConsoleHelper.WriteObject(invoiceDetail, "Invoice Line Items"); 56 | } 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Invoice/GetInvoiceStatement.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Invoice 8 | { 9 | using System; 10 | 11 | /// 12 | /// Gets the invoice statement for an invoice id. 13 | /// 14 | public class GetInvoiceStatement : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetInvoiceStatement(IScenarioContext context) : base("Get Invoice Statement by Id", context) 21 | { 22 | } 23 | 24 | /// 25 | /// executes the get invoice statement scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | this.Context.ConsoleHelper.StartProgress("Getting Invoice Statement"); 31 | 32 | string invoiceId = this.Context.Configuration.Scenario.DefaultInvoiceId; 33 | if (string.IsNullOrWhiteSpace(invoiceId)) 34 | { 35 | // prompt the user the enter the invoice ID 36 | invoiceId = this.Context.ConsoleHelper.ReadNonEmptyString("Please enter the invoice ID to retrieve ", "The invoice ID can't be empty"); 37 | } 38 | else 39 | { 40 | Console.WriteLine("Found Invoice ID: {0} in configuration.", invoiceId); 41 | } 42 | 43 | // // Retrieving invoice statement for an invoice id 44 | var invoiceStatement = partnerOperations.Invoices.ById(invoiceId).Documents.Statement.Get(); 45 | 46 | this.Context.ConsoleHelper.StopProgress(); 47 | this.Context.ConsoleHelper.WriteObject(invoiceId, "Invoice Id"); 48 | this.Context.ConsoleHelper.WriteObject(invoiceStatement.Length, "Invoice Statement Size"); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Invoice/GetInvoiceSummaries.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Invoice 8 | { 9 | /// 10 | /// Gets a single partner invoice summaries. 11 | /// 12 | public class GetInvoiceSummaries : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetInvoiceSummaries(IScenarioContext context) : base("Get partner's invoice summaries", context) 19 | { 20 | } 21 | 22 | /// 23 | /// executes the get invoice summaries scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | this.Context.ConsoleHelper.StartProgress("Retrieving invoice summaries"); 29 | 30 | // Retrieving invoice summaries 31 | var invoiceSummaries = partnerOperations.Invoices.Summaries.Get(); 32 | 33 | this.Context.ConsoleHelper.StopProgress(); 34 | this.Context.ConsoleHelper.WriteObject(invoiceSummaries, "Invoice Summaries"); 35 | 36 | // Retrieving invoice summaries details 37 | if (invoiceSummaries.TotalCount > 0) 38 | { 39 | foreach (var summary in invoiceSummaries.Items) 40 | { 41 | foreach (var detail in summary.Details) 42 | { 43 | this.Context.ConsoleHelper.WriteObject(detail, "Invoice Summaries Details"); 44 | } 45 | } 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Offers/GetCustomerOfferCategories.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Offers 8 | { 9 | /// 10 | /// A scenario that retrieves all the offer categories available for a customer. 11 | /// 12 | public class GetCustomerOfferCategories : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetCustomerOfferCategories(IScenarioContext context) : base("Get customer offer categories", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | string customerIdToRetrieve = this.ObtainCustomerId("Enter the ID of the customer to retrieve offer categories for"); 28 | var partnerOperations = this.Context.UserPartnerOperations; 29 | 30 | this.Context.ConsoleHelper.StartProgress($"Getting offer catgories for customer { customerIdToRetrieve }"); 31 | var offerCategories = partnerOperations.Customers.ById(customerIdToRetrieve).OfferCategories.Get(); 32 | this.Context.ConsoleHelper.StopProgress(); 33 | 34 | this.Context.ConsoleHelper.WriteObject(offerCategories, $"Offer categories for customer { customerIdToRetrieve }"); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Offers/GetCustomerOffers.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Offers 8 | { 9 | /// 10 | /// A scenario that retrieves all the offers available for a customer. 11 | /// 12 | public class GetCustomerOffers : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetCustomerOffers(IScenarioContext context) : base("Get customer offers", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | string customerIdToRetrieve = this.ObtainCustomerId("Enter the ID of the customer to retrieve offers for"); 28 | var pageSize = this.Context.Configuration.Scenario.DefaultOfferPageSize; 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | 31 | this.Context.ConsoleHelper.StartProgress($"Getting first { pageSize } offers for customer { customerIdToRetrieve }"); 32 | var offers = partnerOperations.Customers.ById(customerIdToRetrieve).Offers.Get(0, pageSize); 33 | this.Context.ConsoleHelper.StopProgress(); 34 | 35 | this.Context.ConsoleHelper.WriteObject(offers, $"First { pageSize } offers for customer { customerIdToRetrieve }"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Offers/GetOffer.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Offers 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves offer details supported in a country. 13 | /// 14 | public class GetOffer : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetOffer(IScenarioContext context) : base("Get offer details", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var offerId = this.ObtainOfferId("Enter the ID of offer to retrieve"); 31 | string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the 2 digit country code to get its supported offers", "The country code can't be empty"); 32 | 33 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting offer details for {0}", countryCode)); 34 | 35 | var offer = partnerOperations.Offers.ByCountry(countryCode).ById(offerId).Get(); 36 | var offerAddOns = partnerOperations.Offers.ByCountry(countryCode).ById(offerId).AddOns.Get(); 37 | 38 | this.Context.ConsoleHelper.StopProgress(); 39 | 40 | this.Context.ConsoleHelper.WriteObject(offer, string.Format(CultureInfo.InvariantCulture, "Offer in {0}", countryCode)); 41 | this.Context.ConsoleHelper.WriteObject(offerAddOns, string.Format(CultureInfo.InvariantCulture, "Offer add-ons in {0}", countryCode)); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Offers/GetOfferCategories.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Offers 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that gets all offer categories. 13 | /// 14 | public class GetOfferCategories : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetOfferCategories(IScenarioContext context) : base("Get offer categories", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the 2 digit country code to get its supported offer categories", "The country code can't be empty"); 31 | 32 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting offer categories for {0}", countryCode)); 33 | var offerCategories = partnerOperations.OfferCategories.ByCountry(countryCode).Get(); 34 | this.Context.ConsoleHelper.StopProgress(); 35 | 36 | this.Context.ConsoleHelper.WriteObject(offerCategories, string.Format(CultureInfo.InvariantCulture, "Offer categories in {0}", countryCode)); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Offers/GetOffers.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Offers 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves all the offers supported in a country. 13 | /// 14 | public class GetOffers : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetOffers(IScenarioContext context) : base("Get offers", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var pageSize = this.Context.Configuration.Scenario.DefaultOfferPageSize; 31 | string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the 2 digit country code to get its supported offers", "The country code can't be empty"); 32 | 33 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting first {0} offers for {1}", pageSize, countryCode)); 34 | var offers = partnerOperations.Offers.ByCountry(countryCode).Get(0, pageSize); 35 | this.Context.ConsoleHelper.StopProgress(); 36 | 37 | this.Context.ConsoleHelper.WriteObject(offers, string.Format(CultureInfo.InvariantCulture, "Offers in {0}", countryCode)); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Orders/CreateOrder.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Orders 8 | { 9 | using System.Collections.Generic; 10 | using Store.PartnerCenter.Models.Orders; 11 | 12 | /// 13 | /// A scenario that creates a new order for a customer. 14 | /// 15 | public class CreateOrder : BasePartnerScenario 16 | { 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The scenario context. 21 | public CreateOrder(IScenarioContext context) : base("Create an order", context) 22 | { 23 | } 24 | 25 | /// 26 | /// Executes the scenario. 27 | /// 28 | protected override void RunScenario() 29 | { 30 | var partnerOperations = this.Context.UserPartnerOperations; 31 | 32 | string customerId = this.ObtainCustomerId("Enter the ID of the customer making the purchase"); 33 | string offerId = this.ObtainOfferId("Enter the ID of the offer to purchase"); 34 | 35 | var order = new Order() 36 | { 37 | ReferenceCustomerId = customerId, 38 | LineItems = new List() 39 | { 40 | new OrderLineItem() 41 | { 42 | OfferId = offerId, 43 | FriendlyName = "new offer purchase", 44 | Quantity = 5 45 | } 46 | } 47 | }; 48 | 49 | this.Context.ConsoleHelper.WriteObject(order, "Order to be placed"); 50 | this.Context.ConsoleHelper.StartProgress("Placing order"); 51 | 52 | var createdOrder = partnerOperations.Customers.ById(customerId).Orders.Create(order); 53 | 54 | this.Context.ConsoleHelper.StopProgress(); 55 | this.Context.ConsoleHelper.WriteObject(createdOrder, "Created order"); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Orders/GetOrderDetails.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Orders 8 | { 9 | /// 10 | /// A scenario that retrieves a customer order details. 11 | /// 12 | public class GetOrderDetails : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetOrderDetails(IScenarioContext context) : base("Get customer order details", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | string customerId = this.ObtainCustomerId("Enter the ID of the customer whom to retrieve their order details"); 30 | string orderId = this.ObtainOrderID("Enter the ID of order to retrieve"); 31 | 32 | this.Context.ConsoleHelper.StartProgress("Retrieving customer order details"); 33 | 34 | var customerOrderDetails = partnerOperations.Customers.ById(customerId).Orders.ById(orderId).Get(); 35 | 36 | this.Context.ConsoleHelper.StopProgress(); 37 | this.Context.ConsoleHelper.WriteObject(customerOrderDetails, "Customer order details"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Orders/GetOrderProvisioningStatus.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Orders 8 | { 9 | /// 10 | /// A scenario that retrieves a customer order details. 11 | /// 12 | public class GetOrderProvisioningStatus : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetOrderProvisioningStatus(IScenarioContext context) : base("Get customer order provisioning status", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | string customerId = this.ObtainCustomerId("Enter the ID of the customer whom to retrieve their order provisioning details"); 30 | string orderId = this.ObtainOrderID("Enter the ID of order to retrieve"); 31 | 32 | this.Context.ConsoleHelper.StartProgress("Retrieving customer order provisioning status"); 33 | var customerOrder = partnerOperations.Customers.ById(customerId).Orders.ById(orderId).Get(); 34 | var provisioningStatusList = partnerOperations.Customers.ById(customerId).Orders.ById(customerOrder.Id).ProvisioningStatus.Get(); 35 | 36 | this.Context.ConsoleHelper.StopProgress(); 37 | 38 | foreach (var provisioningStatus in provisioningStatusList.Items) 39 | { 40 | foreach (var orderItem in customerOrder.LineItems) 41 | { 42 | if (orderItem.LineItemNumber == provisioningStatus.LineItemNumber) 43 | { 44 | this.Context.ConsoleHelper.WriteObject(provisioningStatus.Status, "Customer order provisioning status"); 45 | } 46 | } 47 | } 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Orders/GetOrders.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Orders 8 | { 9 | /// 10 | /// A scenario that retrieves a customer orders. 11 | /// 12 | public class GetOrders : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetOrders(IScenarioContext context) : base("Get customer orders", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | string customerId = this.ObtainCustomerId("Enter the ID of the customer whom to retrieve their orders"); 30 | 31 | this.Context.ConsoleHelper.StartProgress("Retrieving customer orders"); 32 | 33 | var customerOrders = partnerOperations.Customers.ById(customerId).Orders.Get(); 34 | 35 | this.Context.ConsoleHelper.StopProgress(); 36 | this.Context.ConsoleHelper.WriteObject(customerOrders, "Customer orders"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Orders/GetOrdersByBillingCycleType.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Orders 8 | { 9 | using System; 10 | using Models.Offers; 11 | 12 | /// 13 | /// A scenario that retrieves all customer orders by billing cycle type. 14 | /// 15 | public class GetOrdersByBillingCycleType : BasePartnerScenario 16 | { 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The scenario context. 21 | public GetOrdersByBillingCycleType(IScenarioContext context) : base("Get All Orders by billing cycle type", context) 22 | { 23 | } 24 | 25 | /// 26 | /// Executes the scenario. 27 | /// 28 | protected override void RunScenario() 29 | { 30 | var partnerOperations = this.Context.UserPartnerOperations; 31 | 32 | string customerId = this.ObtainCustomerId("Enter the ID of the customer whom to retrieve their order by billing cycle type"); 33 | string billingCycle = this.ObtainBillingCycleType("Enter the billing cycle type"); 34 | 35 | var billingCyle = (BillingCycleType)Enum.Parse(typeof(BillingCycleType), billingCycle, true); 36 | 37 | this.Context.ConsoleHelper.StartProgress("Retrieving customer orders"); 38 | 39 | var customerOrders = partnerOperations.Customers.ById(customerId).Orders.ByBillingCycleType(billingCyle).Get(); 40 | 41 | this.Context.ConsoleHelper.StopProgress(); 42 | this.Context.ConsoleHelper.WriteObject(customerOrders, "Retrieved Customer orders"); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Orders/UpdateOrder.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Orders 8 | { 9 | using System.Linq; 10 | 11 | /// 12 | /// A scenario that updates a customer order. 13 | /// 14 | public class UpdateOrder : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public UpdateOrder(IScenarioContext context) : base("Update customer order", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | 31 | string customerId = this.ObtainCustomerId("Enter the ID of the customer whom to retrieve their orders"); 32 | string orderId = this.ObtainOrderID("Enter the ID of order to retrieve"); 33 | 34 | this.Context.ConsoleHelper.StartProgress("Retrieving customer order to be updated"); 35 | var customerOrder = partnerOperations.Customers.ById(customerId).Orders.ById(orderId).Get(); 36 | this.Context.ConsoleHelper.StopProgress(); 37 | 38 | // increase the quantity of first line item 39 | customerOrder.LineItems.ToArray()[0].Quantity++; 40 | 41 | this.Context.ConsoleHelper.StartProgress("Updating the customer order"); 42 | var updatedOrder = partnerOperations.Customers.ById(customerId).Orders.ById(customerOrder.Id).Patch(customerOrder); 43 | this.Context.ConsoleHelper.StopProgress(); 44 | this.Context.ConsoleHelper.WriteObject(updatedOrder, "Updated customer order"); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Products/GetAvailabilities.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Products 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves the availabilities of a product's SKU. 13 | /// 14 | public class GetAvailabilities : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetAvailabilities(IScenarioContext context) : base("Get availabilities", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var productId = this.ObtainProductId("Enter the ID of the corresponding product"); 31 | var skuId = this.ObtainSkuId("Enter the ID of the corresponding sku"); 32 | string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the 2 digit country code of the sku", "The country code can't be empty"); 33 | 34 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting availabilities for product {0} and sku {1} in country {2}", productId, skuId, countryCode)); 35 | var skuAvailabilities = partnerOperations.Products.ByCountry(countryCode).ById(productId).Skus.ById(skuId).Availabilities.Get(); 36 | this.Context.ConsoleHelper.StopProgress(); 37 | 38 | this.Context.ConsoleHelper.WriteObject(skuAvailabilities, string.Format(CultureInfo.InvariantCulture, "Availabilities for product {0}", productId)); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Products/GetAvailability.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Products 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves the availability of a product's SKU. 13 | /// 14 | public class GetAvailability : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetAvailability(IScenarioContext context) : base("Get availability", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var productId = this.ObtainProductId("Enter the ID of the corresponding product"); 31 | var skuId = this.ObtainSkuId("Enter the ID of the corresponding sku"); 32 | var availabilityId = this.ObtainAvailabilityId("Enter the ID of the availability"); 33 | string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the 2 digit country code of the availability", "The country code can't be empty"); 34 | 35 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting availability {0} for product {1} and sku {2} in country {3}", availabilityId, productId, skuId, countryCode)); 36 | var availability = partnerOperations.Products.ByCountry(countryCode).ById(productId).Skus.ById(skuId).Availabilities.ById(availabilityId).Get(); 37 | this.Context.ConsoleHelper.StopProgress(); 38 | 39 | this.Context.ConsoleHelper.WriteObject(availability, "Availability "); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Products/GetProduct.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Products 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves product details supported in a country. 13 | /// 14 | public class GetProduct : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetProduct(IScenarioContext context) : base("Get product", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var productId = this.ObtainProductId("Enter the ID of the product"); 31 | string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the 2 digit country code of the product", "The country code can't be empty"); 32 | 33 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting details for product {0} in country {1}", productId, countryCode)); 34 | var product = partnerOperations.Products.ByCountry(countryCode).ById(productId).Get(); 35 | this.Context.ConsoleHelper.StopProgress(); 36 | 37 | this.Context.ConsoleHelper.WriteObject(product, string.Format(CultureInfo.InvariantCulture, "Product details of {0}", productId)); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Products/GetProducts.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Products 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves all the products supported in a country and in a catalog view. 13 | /// 14 | public class GetProducts : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetProducts(IScenarioContext context) : base("Get products", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the 2 digit country code to get its supported products", "The country code can't be empty"); 31 | string targetView = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the target view to get its supported products", "The target view can't be empty"); 32 | 33 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting products in catalog view {0} in country {1}", targetView, countryCode)); 34 | var products = partnerOperations.Products.ByCountry(countryCode).ByTargetView(targetView).Get(); 35 | this.Context.ConsoleHelper.StopProgress(); 36 | 37 | this.Context.ConsoleHelper.WriteObject(products, string.Format(CultureInfo.InvariantCulture, "Products in catalog view {0}", targetView)); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Products/GetProductsByTargetSegment.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Products 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves all the products supported in a country, in a catalog view and in a segment. 13 | /// 14 | public class GetProductsByTargetSegment : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetProductsByTargetSegment(IScenarioContext context) : base("Get products by segment", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the 2 digit country code to get its supported products", "The country code can't be empty"); 31 | string targetView = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the target view to get its supported products", "The target view can't be empty"); 32 | string segment = this.Context.ConsoleHelper.ReadNonEmptyString("The segment to filter the products on", "The segment can't be empty"); 33 | 34 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting products in catalog view {0}, in country {1} and in segment {2}", targetView, countryCode, segment)); 35 | var products = partnerOperations.Products.ByCountry(countryCode).ByTargetView(targetView).ByTargetSegment(segment).Get(); 36 | this.Context.ConsoleHelper.StopProgress(); 37 | 38 | this.Context.ConsoleHelper.WriteObject(products, string.Format(CultureInfo.InvariantCulture, "Products in catalog view {0} by segment {1}", targetView, segment)); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Products/GetSku.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Products 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves details of a product's SKU. 13 | /// 14 | public class GetSku : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetSku(IScenarioContext context) : base("Get sku", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var productId = this.ObtainProductId("Enter the ID of the corresponding product"); 31 | var skuId = this.ObtainSkuId("Enter the ID of the sku"); 32 | string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the 2 digit country code of the sku", "The country code can't be empty"); 33 | 34 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting sku details for sku {0} and product {1} in country {2}", skuId, productId, countryCode)); 35 | var sku = partnerOperations.Products.ByCountry(countryCode).ById(productId).Skus.ById(skuId).Get(); 36 | this.Context.ConsoleHelper.StopProgress(); 37 | 38 | this.Context.ConsoleHelper.WriteObject(sku, string.Format(CultureInfo.InvariantCulture, "Sku details of {0}", skuId)); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Products/GetSkuDownloadOptions.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Products 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves the download options of a product's SKU. 13 | /// 14 | public class GetSkuDownloadOptions : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetSkuDownloadOptions(IScenarioContext context) : base("Get sku download options", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var productId = this.ObtainProductId("Enter the ID of the corresponding product"); 31 | var skuId = this.ObtainSkuId("Enter the ID of the corresponding sku"); 32 | string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the 2 digit country code of the sku", "The country code can't be empty"); 33 | 34 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting sku download options for product {0} and sku {1} in country {2}", productId, skuId, countryCode)); 35 | var sku = partnerOperations.Products.ByCountry(countryCode).ById(productId).Skus.ById(skuId).DownloadOptions.Get(); 36 | this.Context.ConsoleHelper.StopProgress(); 37 | 38 | this.Context.ConsoleHelper.WriteObject(sku, string.Format(CultureInfo.InvariantCulture, "Download options for sku {0}", skuId)); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Products/GetSkus.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Products 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves all the SKUs related to a product that are supported in a country. 13 | /// 14 | public class GetSkus : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetSkus(IScenarioContext context) : base("Get skus", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var productId = this.ObtainProductId("Enter the ID of the corresponding product"); 31 | string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the 2 digit country code to get its supported skus", "The country code can't be empty"); 32 | 33 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting skus for product {0} in country {1}", productId, countryCode)); 34 | var skus = partnerOperations.Products.ByCountry(countryCode).ById(productId).Skus.Get(); 35 | this.Context.ConsoleHelper.StopProgress(); 36 | 37 | this.Context.ConsoleHelper.WriteObject(skus, string.Format(CultureInfo.InvariantCulture, "Skus for product {0}", productId)); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Products/GetSkusByTargetSegment.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Products 8 | { 9 | using System.Globalization; 10 | 11 | /// 12 | /// A scenario that retrieves all the SKUs related to a product that are supported in a country and that target a specific segment. 13 | /// 14 | public class GetSkusByTargetSegment : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetSkusByTargetSegment(IScenarioContext context) : base("Get skus by segment", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | var productId = this.ObtainProductId("Enter the ID of the corresponding product"); 31 | string countryCode = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the 2 digit country code to get its supported skus", "The country code can't be empty"); 32 | string segment = this.Context.ConsoleHelper.ReadNonEmptyString("The segment to filter the skus on", "The segment can't be empty"); 33 | 34 | this.Context.ConsoleHelper.StartProgress(string.Format(CultureInfo.InvariantCulture, "Getting skus for product {0} in country {1} and in segment {2}", productId, countryCode, segment)); 35 | var skus = partnerOperations.Products.ByCountry(countryCode).ById(productId).Skus.ByTargetSegment(segment).Get(); 36 | this.Context.ConsoleHelper.StopProgress(); 37 | 38 | this.Context.ConsoleHelper.WriteObject(skus, string.Format(CultureInfo.InvariantCulture, "Skus for product {0} in segment {1}", productId, segment)); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Profile/GetBillingProfile.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Profile 8 | { 9 | /// 10 | /// A scenario that retrieves the partner's billing profile. 11 | /// 12 | public class GetBillingProfile : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetBillingProfile(IScenarioContext context) : base("Get partner's billing profile", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | this.Context.ConsoleHelper.StartProgress("Retrieving partner's billing profile"); 30 | 31 | var billingProfile = partnerOperations.Profiles.BillingProfile.Get(); 32 | 33 | this.Context.ConsoleHelper.StopProgress(); 34 | this.Context.ConsoleHelper.WriteObject(billingProfile, "Partner's billing profile"); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Profile/GetMPNProfile.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Profile 8 | { 9 | /// 10 | /// A scenario that retrieves the partner's MPN profile. 11 | /// 12 | public class GetMPNProfile : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetMPNProfile(IScenarioContext context) : base("Get partner MPN profile", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | this.Context.ConsoleHelper.StartProgress("Retrieving partner MPN profile"); 30 | 31 | var billingProfile = partnerOperations.Profiles.MpnProfile.Get(); 32 | 33 | this.Context.ConsoleHelper.StopProgress(); 34 | this.Context.ConsoleHelper.WriteObject(billingProfile, "Partner MPN profile"); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Profile/GetOrganizationProfile.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Profile 8 | { 9 | /// 10 | /// A scenario that retrieves the partner's organization profile. 11 | /// 12 | public class GetOrganizationProfile : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetOrganizationProfile(IScenarioContext context) : base("Get partner organization profile", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | this.Context.ConsoleHelper.StartProgress("Retrieving partner organization profile"); 30 | 31 | var billingProfile = partnerOperations.Profiles.OrganizationProfile.Get(); 32 | 33 | this.Context.ConsoleHelper.StopProgress(); 34 | this.Context.ConsoleHelper.WriteObject(billingProfile, "Partner organization profile"); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Profile/GetSupportProfile.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Profile 8 | { 9 | /// 10 | /// A scenario that retrieves the partner's support profile. 11 | /// 12 | public class GetSupportProfile : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetSupportProfile(IScenarioContext context) : base("Get partner support profile", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | this.Context.ConsoleHelper.StartProgress("Retrieving partner support profile"); 30 | 31 | var billingProfile = partnerOperations.Profiles.SupportProfile.Get(); 32 | 33 | this.Context.ConsoleHelper.StopProgress(); 34 | this.Context.ConsoleHelper.WriteObject(billingProfile, "partner support profile"); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Profile/GetlegalBusinessProfile.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Profile 8 | { 9 | /// 10 | /// A scenario that retrieves the partner's legal business profile. 11 | /// 12 | public class GetLegalBusinessProfile : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetLegalBusinessProfile(IScenarioContext context) : base("Get partner legal business profile", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | this.Context.ConsoleHelper.StartProgress("Retrieving partner legal business profile"); 30 | 31 | var billingProfile = partnerOperations.Profiles.LegalBusinessProfile.Get(); 32 | 33 | this.Context.ConsoleHelper.StopProgress(); 34 | this.Context.ConsoleHelper.WriteObject(billingProfile, "Partner legal business profile"); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Profile/UpdateBillingProfile.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Profile 8 | { 9 | using System; 10 | using System.Globalization; 11 | 12 | /// 13 | /// A scenario that updates the partner's billing profile. 14 | /// 15 | public class UpdateBillingProfile : BasePartnerScenario 16 | { 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The scenario context. 21 | public UpdateBillingProfile(IScenarioContext context) : base("Update partner billing profile", context) 22 | { 23 | } 24 | 25 | /// 26 | /// Executes the scenario. 27 | /// 28 | protected override void RunScenario() 29 | { 30 | var partnerOperations = this.Context.UserPartnerOperations; 31 | 32 | this.Context.ConsoleHelper.StartProgress("Retrieving partner billing profile"); 33 | 34 | var billingProfile = partnerOperations.Profiles.BillingProfile.Get(); 35 | 36 | this.Context.ConsoleHelper.StopProgress(); 37 | this.Context.ConsoleHelper.WriteObject(billingProfile); 38 | 39 | billingProfile.PurchaseOrderNumber = new Random().Next(9000, 10000).ToString(CultureInfo.InvariantCulture); 40 | 41 | this.Context.ConsoleHelper.StartProgress("Updating partner billing profile"); 42 | var updatedPartnerBillingProfile = partnerOperations.Profiles.BillingProfile.Update(billingProfile); 43 | 44 | this.Context.ConsoleHelper.StopProgress(); 45 | this.Context.ConsoleHelper.WriteObject(updatedPartnerBillingProfile, "Updated partner billing profile"); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Profile/UpdateLegalBusinessProfile.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Profile 8 | { 9 | using System; 10 | using System.Globalization; 11 | 12 | /// 13 | /// A scenario that updates the partner's legal business profile. 14 | /// 15 | public class UpdateLegalBusinessProfile : BasePartnerScenario 16 | { 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The scenario context. 21 | public UpdateLegalBusinessProfile(IScenarioContext context) : base("Update partner legal business profile", context) 22 | { 23 | } 24 | 25 | /// 26 | /// Executes the scenario. 27 | /// 28 | protected override void RunScenario() 29 | { 30 | var partnerOperations = this.Context.UserPartnerOperations; 31 | 32 | this.Context.ConsoleHelper.StartProgress("Displaying partner legal business profile"); 33 | 34 | var legalBusinessProfile = partnerOperations.Profiles.LegalBusinessProfile.Get(); 35 | 36 | this.Context.ConsoleHelper.StopProgress(); 37 | this.Context.ConsoleHelper.WriteObject(legalBusinessProfile); 38 | 39 | // Generating a random phone number to update in the legal busines profile 40 | legalBusinessProfile.CompanyApproverAddress.PhoneNumber = ((long)(new Random().NextDouble() * 9000000000) + 1000000000).ToString(CultureInfo.InvariantCulture); 41 | 42 | this.Context.ConsoleHelper.StartProgress("Updating partner legal business profile"); 43 | var updatedLegalBusinessProfile = partnerOperations.Profiles.LegalBusinessProfile.Update(legalBusinessProfile); 44 | 45 | this.Context.ConsoleHelper.StopProgress(); 46 | this.Context.ConsoleHelper.WriteObject(updatedLegalBusinessProfile, "Updated partner legal business profile"); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Profile/UpdateOrganizationProfile.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Profile 8 | { 9 | using System; 10 | using System.Globalization; 11 | 12 | /// 13 | /// A scenario that updates the partner's organization profile. 14 | /// 15 | public class UpdateOrganizationProfile : BasePartnerScenario 16 | { 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The scenario context. 21 | public UpdateOrganizationProfile(IScenarioContext context) : base("Update partner organization profile", context) 22 | { 23 | } 24 | 25 | /// 26 | /// Executes the scenario. 27 | /// 28 | protected override void RunScenario() 29 | { 30 | var partnerOperations = this.Context.UserPartnerOperations; 31 | 32 | this.Context.ConsoleHelper.StartProgress("Displaying partner organization profile"); 33 | 34 | var organizationProfile = partnerOperations.Profiles.OrganizationProfile.Get(); 35 | 36 | this.Context.ConsoleHelper.StopProgress(); 37 | this.Context.ConsoleHelper.WriteObject(organizationProfile); 38 | 39 | // Generating a random phone number to update in the organization profile 40 | organizationProfile.DefaultAddress.PhoneNumber = ((long)(new Random().NextDouble() * 9000000000) + 1000000000).ToString(CultureInfo.InvariantCulture); 41 | 42 | this.Context.ConsoleHelper.StartProgress("Updating partner organization profile"); 43 | var updatedPartnerOrganizationProfile = partnerOperations.Profiles.OrganizationProfile.Update(organizationProfile); 44 | 45 | this.Context.ConsoleHelper.StopProgress(); 46 | this.Context.ConsoleHelper.WriteObject(updatedPartnerOrganizationProfile, "Updated partner organization profile"); 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Profile/UpdateSupportProfile.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Profile 8 | { 9 | using System.Net.Mail; 10 | 11 | /// 12 | /// A scenario that updates the partner's support profile. 13 | /// 14 | public class UpdateSupportProfile : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public UpdateSupportProfile(IScenarioContext context) : base("Update partner support profile", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | 31 | this.Context.ConsoleHelper.StartProgress("Displaying partner support profile"); 32 | 33 | var supportProfile = partnerOperations.Profiles.SupportProfile.Get(); 34 | 35 | this.Context.ConsoleHelper.WriteObject(supportProfile); 36 | this.Context.ConsoleHelper.StopProgress(); 37 | 38 | var emailId = this.Context.ConsoleHelper.ReadNonEmptyString("Enter the email ID to be updated in support profile", "Email ID cannot be empty"); 39 | 40 | if (emailId != new MailAddress(emailId).Address) 41 | { 42 | this.Context.ConsoleHelper.Warning("Invalid email ID"); 43 | } 44 | else 45 | { 46 | supportProfile.Email = emailId; 47 | this.Context.ConsoleHelper.StartProgress("Updating partner support profile"); 48 | var updatedPartnerSupportProfile = partnerOperations.Profiles.SupportProfile.Update(supportProfile); 49 | 50 | this.Context.ConsoleHelper.StopProgress(); 51 | this.Context.ConsoleHelper.WriteObject(updatedPartnerSupportProfile, "Updated partner support profile"); 52 | } 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | using System.Reflection; 8 | using System.Runtime.InteropServices; 9 | 10 | // General Information about an assembly is controlled through the following 11 | // set of attributes. Change these attribute values to modify the information 12 | // associated with an assembly. 13 | [assembly: AssemblyTitle("Partner Center Samples")] 14 | [assembly: AssemblyDescription("")] 15 | [assembly: AssemblyConfiguration("")] 16 | [assembly: AssemblyCompany("")] 17 | [assembly: AssemblyProduct("Partner Center Samples")] 18 | [assembly: AssemblyCopyright("Copyright © 2016")] 19 | [assembly: AssemblyTrademark("")] 20 | [assembly: AssemblyCulture("")] 21 | 22 | // Setting ComVisible to false makes the types in this assembly not visible 23 | // to COM components. If you need to access a type in this assembly from 24 | // COM, set the ComVisible attribute to true on that type. 25 | [assembly: ComVisible(false)] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | [assembly: Guid("ac93e5cc-549c-4f13-9675-a86860918c2b")] 29 | 30 | // Version information for an assembly consists of the following four values: 31 | // 32 | // Major Version 33 | // Minor Version 34 | // Build Number 35 | // Revision 36 | // 37 | // You can specify all the values or you can default the Build and Revision Numbers 38 | // by using the '*' as shown below: 39 | // [assembly: AssemblyVersion("1.0.*")] 40 | [assembly: AssemblyVersion("1.0.0.0")] 41 | [assembly: AssemblyFileVersion("1.0.0.0")] 42 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/RateCards/GetAzureRateCard.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.RateCards 8 | { 9 | /// 10 | /// Gets the Azure rate card. 11 | /// 12 | public class GetAzureRateCard : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetAzureRateCard(IScenarioContext context) : base("Get Azure rate card", context) 19 | { 20 | } 21 | 22 | /// 23 | /// executes the get Azure rate card scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | this.Context.ConsoleHelper.StartProgress("Retrieving Azure rate card"); 30 | var azureRateCard = partnerOperations.RateCards.Azure.Get(); 31 | this.Context.ConsoleHelper.StopProgress(); 32 | 33 | this.Context.ConsoleHelper.WriteObject(azureRateCard, "Azure Rate Card"); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/RateCards/GetAzureSharedRateCard.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.RateCards 8 | { 9 | /// 10 | /// Gets the Azure shared rate card. 11 | /// 12 | public class GetAzureSharedRateCard : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetAzureSharedRateCard(IScenarioContext context) : base("Get Azure shared rate card", context) 19 | { 20 | } 21 | 22 | /// 23 | /// executes the get Azure shared rate card scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | this.Context.ConsoleHelper.StartProgress("Retrieving Azure shared rate card"); 30 | var azureSharedRateCard = partnerOperations.RateCards.Azure.GetShared(); 31 | this.Context.ConsoleHelper.StopProgress(); 32 | 33 | this.Context.ConsoleHelper.WriteObject(azureSharedRateCard, "Azure Shared Rate Card"); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/RatedUsage/GetCustomerSubscriptionsUsage.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.RatedUsage 8 | { 9 | /// 10 | /// A scenario that retrieves the usage records for all the subscriptions owned by a customer. 11 | /// 12 | public class GetCustomerSubscriptionsUsage : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetCustomerSubscriptionsUsage(IScenarioContext context) : base("Get customer subscriptions usage", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | string customerId = this.ObtainCustomerId("Enter the ID of the customer to retrieve his/her subscriptions usage"); 30 | this.Context.ConsoleHelper.StartProgress("Retrieving customer subscriptions usage"); 31 | 32 | var customerUsageRecords = partnerOperations.Customers.ById(customerId).Subscriptions.UsageRecords.Get(); 33 | 34 | this.Context.ConsoleHelper.StopProgress(); 35 | this.Context.ConsoleHelper.WriteObject(customerUsageRecords, "Customer subscriptions usage records"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/RatedUsage/GetCustomerUsageSummary.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.RatedUsage 8 | { 9 | /// 10 | /// A scenario that retrieves a single customer usage summary for usage based services. 11 | /// 12 | public class GetCustomerUsageSummary : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetCustomerUsageSummary(IScenarioContext context) : base("Get customer usage summary", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | string customerId = this.ObtainCustomerId("Enter the ID of the customer to retrieve his/her usage summary"); 30 | this.Context.ConsoleHelper.StartProgress("Retrieving customer usage summary"); 31 | 32 | var customerUsageSummary = partnerOperations.Customers.ById(customerId).UsageSummary.Get(); 33 | 34 | this.Context.ConsoleHelper.StopProgress(); 35 | this.Context.ConsoleHelper.WriteObject(customerUsageSummary, "Customer usage summary"); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/RatedUsage/GetSubscriptionResourceUsage.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.RatedUsage 8 | { 9 | /// 10 | /// A scenario that retrieves a single subscription's resource usage records. 11 | /// 12 | public class GetSubscriptionResourceUsage : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetSubscriptionResourceUsage(IScenarioContext context) : base("Get subscription resource usage", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | string customerId = this.ObtainCustomerId("Enter the ID of the customer who owns the subscription"); 30 | string subscriptionId = this.ObtainSubscriptionId(customerId, "Enter the subscription ID"); 31 | 32 | this.Context.ConsoleHelper.StartProgress("Retrieving customer orders"); 33 | 34 | var usageRecords = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionId).UsageRecords.Resources.Get(); 35 | 36 | this.Context.ConsoleHelper.StopProgress(); 37 | this.Context.ConsoleHelper.WriteObject(usageRecords, "Subscription resource usage records"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/RatedUsage/GetSubscriptionUsageRecords.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.RatedUsage 8 | { 9 | /// 10 | /// A scenario that retrieves a customer's subscriptions usage records. 11 | /// 12 | public class GetSubscriptionUsageRecords : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetSubscriptionUsageRecords(IScenarioContext context) : base("Get customer subscriptions usage records", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | string customerId = this.ObtainCustomerId("Enter the ID of the customer whom to retrieve their subscriptions usage records"); 30 | 31 | this.Context.ConsoleHelper.StartProgress("Retrieving customer subscriptions usage records"); 32 | 33 | var customerSubscription = partnerOperations.Customers.ById(customerId).Subscriptions.UsageRecords.Get(); 34 | 35 | this.Context.ConsoleHelper.StopProgress(); 36 | this.Context.ConsoleHelper.WriteObject(customerSubscription, "Customer subscriptions usage records"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/RatedUsage/GetSubscriptionUsageSummary.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.RatedUsage 8 | { 9 | /// 10 | /// A scenario that retrieves the customer's subscription usage summary. 11 | /// 12 | public class GetSubscriptionUsageSummary : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetSubscriptionUsageSummary(IScenarioContext context) : base("Get customer Subscription Usage Summary", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | string customerId = this.ObtainCustomerId("Enter the ID of the customer who owns the subscription to retrieve it's usage summary"); 30 | string subscriptionID = this.ObtainSubscriptionId(customerId, "Enter the ID of the subscription to retrieve it's usage summary"); 31 | 32 | this.Context.ConsoleHelper.StartProgress("Retrieving customer Subscription Usage Summary"); 33 | 34 | var customerSubscription = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionID).UsageSummary.Get(); 35 | 36 | this.Context.ConsoleHelper.StopProgress(); 37 | this.Context.ConsoleHelper.WriteObject(customerSubscription, "Customer Subscription Usage Summary"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/ScenarioExecution/IScenarioExecutionStrategy.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.ScenarioExecution 8 | { 9 | /// 10 | /// Defines the behavior to apply when a scenario is complete. 11 | /// 12 | public interface IScenarioExecutionStrategy 13 | { 14 | /// 15 | /// Determines whether the scenario is complete or it should be repeated. 16 | /// 17 | /// The scenario under consideration. 18 | /// True is the scenario is complete, False is it should be repeated. 19 | bool IsScenarioComplete(IPartnerScenario scenario); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/ScenarioExecution/PromptExecutionStrategy.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.ScenarioExecution 8 | { 9 | using System; 10 | using Helpers; 11 | 12 | /// 13 | /// An scenario execution strategy that prompts the user repeat or exit the current scenario. 14 | /// 15 | public class PromptExecutionStrategy : IScenarioExecutionStrategy 16 | { 17 | /// 18 | /// Determines whether the scenario is complete or it should be repeated. 19 | /// 20 | /// The scenario under consideration. 21 | /// True is the scenario is complete, False is it should be repeated. 22 | public bool IsScenarioComplete(IPartnerScenario scenario) 23 | { 24 | ConsoleHelper.Instance.Warning("Press Q return to the previous screen or R to repeat the current scenario:", false); 25 | 26 | ConsoleKeyInfo keyRead = Console.ReadKey(true); 27 | 28 | while (keyRead.Key != ConsoleKey.R && keyRead.Key != ConsoleKey.Q) 29 | { 30 | keyRead = Console.ReadKey(true); 31 | } 32 | 33 | return keyRead.Key == ConsoleKey.Q; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/ServiceIncidents/GetServiceIncidents.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.ServiceIncidents 8 | { 9 | using Store.PartnerCenter.Models.Query; 10 | using Store.PartnerCenter.Models.ServiceIncidents; 11 | 12 | /// 13 | /// Gets the list of service incidents for a partner 14 | /// 15 | public class GetServiceIncidents : BasePartnerScenario 16 | { 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The scenario context. 21 | public GetServiceIncidents(IScenarioContext context) : base("Get Service Incidents", context) 22 | { 23 | } 24 | 25 | /// 26 | /// executes the get service incidents scenario. 27 | /// 28 | protected override void RunScenario() 29 | { 30 | const string SearchTerm = "false"; 31 | var partnerOperations = this.Context.UserPartnerOperations; 32 | this.Context.ConsoleHelper.StartProgress("Retrieving Service incidents"); 33 | 34 | // Query service incidents based on their active status - resolved or not. resolved = false fetches all the active incidents for all subscribed services. 35 | var serviceIncidents = partnerOperations.ServiceIncidents.Query(QueryFactory.Instance.BuildIndexedQuery(1, 0, new SimpleFieldFilter(ServiceIncidentSearchField.Resolved.ToString(), FieldFilterOperation.Equals, SearchTerm))); 36 | this.Context.ConsoleHelper.StopProgress(); 37 | 38 | this.Context.ConsoleHelper.WriteObject(serviceIncidents, "Service Incidents"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/ServiceRequests/GetPartnerServiceRequestDetails.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.ServiceRequests 8 | { 9 | using System; 10 | using Store.PartnerCenter.Models.ServiceRequests; 11 | 12 | /// 13 | /// Gets a service request details for a partner. 14 | /// 15 | public class GetPartnerServiceRequestDetails : BasePartnerScenario 16 | { 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The scenario context. 21 | public GetPartnerServiceRequestDetails(IScenarioContext context) : base("Get service request details", context) 22 | { 23 | } 24 | 25 | /// 26 | /// executes the get service request details scenario. 27 | /// 28 | protected override void RunScenario() 29 | { 30 | var partnerOperations = this.Context.UserPartnerOperations; 31 | string serviceRequestIdToRetrieve = this.Context.Configuration.Scenario.DefaultServiceRequestId; 32 | 33 | if (string.IsNullOrWhiteSpace(serviceRequestIdToRetrieve)) 34 | { 35 | // prompt the user the enter the service request ID 36 | serviceRequestIdToRetrieve = this.Context.ConsoleHelper.ReadNonEmptyString("Please enter the ID of the service request to retrieve ", "The ID can't be empty"); 37 | } 38 | else 39 | { 40 | Console.WriteLine("Found service request ID: {0} in configuration.", serviceRequestIdToRetrieve); 41 | } 42 | 43 | this.Context.ConsoleHelper.StartProgress("Retrieving Service Request"); 44 | ServiceRequest serviceRequest = partnerOperations.ServiceRequests.ById(serviceRequestIdToRetrieve).Get(); 45 | 46 | this.Context.ConsoleHelper.StopProgress(); 47 | this.Context.ConsoleHelper.WriteObject(serviceRequest, "Service Request details"); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/ServiceRequests/GetServiceRequestSupportTopics.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.ServiceRequests 8 | { 9 | using Store.PartnerCenter.Models; 10 | using Store.PartnerCenter.Models.ServiceRequests; 11 | 12 | /// 13 | /// Gets the list of support topics. 14 | /// 15 | public class GetServiceRequestSupportTopics : BasePartnerScenario 16 | { 17 | /// 18 | /// Initializes a new instance of the class. 19 | /// 20 | /// The scenario context. 21 | public GetServiceRequestSupportTopics(IScenarioContext context) : base("Get a list of service request support topics", context) 22 | { 23 | } 24 | 25 | /// 26 | /// executes the get service request support topics scenario. 27 | /// 28 | protected override void RunScenario() 29 | { 30 | var partnerOperations = this.Context.UserPartnerOperations; 31 | 32 | this.Context.ConsoleHelper.StartProgress("Getting support topics"); 33 | 34 | // Get support Topics 35 | ResourceCollection supportTopicsCollection = partnerOperations.ServiceRequests.SupportTopics.Get(); 36 | 37 | this.Context.ConsoleHelper.StopProgress(); 38 | this.Context.ConsoleHelper.WriteObject(supportTopicsCollection); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Settings.StyleCop: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | False 6 | 7 | \.g\.cs$ 8 | \.generated\.cs$ 9 | \.g\.i\.cs$ 10 | TemporaryGeneratedFile_.*\.cs$ 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Subscriptions/GetSubscription.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Subscriptions 8 | { 9 | /// 10 | /// A scenario that retrieves a customer subscription. 11 | /// 12 | public class GetSubscription : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetSubscription(IScenarioContext context) : base("Get customer Subscription", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | string customerId = this.ObtainCustomerId("Enter the ID of the customer whom to retrieve their Subscription"); 30 | string subscriptionID = this.ObtainSubscriptionId(customerId, "Enter the subscription ID to retrieve"); 31 | 32 | this.Context.ConsoleHelper.StartProgress("Retrieving customer Subscription"); 33 | 34 | var customerSubscription = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionID).Get(); 35 | 36 | this.Context.ConsoleHelper.StopProgress(); 37 | this.Context.ConsoleHelper.WriteObject(customerSubscription, "Customer Subscription"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Subscriptions/GetSubscriptionProvisioningStatus.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Subscriptions 8 | { 9 | /// 10 | /// A scenario that retrieves a customer subscription's provisioning status. 11 | /// 12 | public class GetSubscriptionProvisioningStatus : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetSubscriptionProvisioningStatus(IScenarioContext context) : base("Get subscription provisioning status", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | string customerId = this.ObtainCustomerId("Enter the ID of the customer whom to retrieve their Subscription provisioning status"); 30 | string subscriptionID = this.ObtainSubscriptionId(customerId, "Enter the subscription ID to retrieve"); 31 | 32 | this.Context.ConsoleHelper.StartProgress("Retrieving subscription provisioning status"); 33 | 34 | var provisioningStatus = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionID).ProvisioningStatus.Get(); 35 | 36 | this.Context.ConsoleHelper.StopProgress(); 37 | this.Context.ConsoleHelper.WriteObject(provisioningStatus, "Subscription provisioning status"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Subscriptions/GetSubscriptionSupportContact.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Subscriptions 8 | { 9 | /// 10 | /// A scenario that retrieves the support contact of a customer's subscription. 11 | /// 12 | public class GetSubscriptionSupportContact : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetSubscriptionSupportContact(IScenarioContext context) : base("Get subscription support contact", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | string customerId = this.ObtainCustomerId("Enter the ID of the customer whom to retrieve their Subscription"); 30 | string subscriptionID = this.ObtainSubscriptionId(customerId, "Enter the subscription ID to retrieve"); 31 | 32 | this.Context.ConsoleHelper.StartProgress("Retrieving subscription support contact"); 33 | 34 | var supportContact = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionID).SupportContact.Get(); 35 | 36 | this.Context.ConsoleHelper.StopProgress(); 37 | this.Context.ConsoleHelper.WriteObject(supportContact, "Subscription support contact"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Subscriptions/GetSubscriptions.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Subscriptions 8 | { 9 | /// 10 | /// A scenario that retrieves a customer subscription. 11 | /// 12 | public class GetSubscriptions : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetSubscriptions(IScenarioContext context) : base("Get customer Subscriptions", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | string customerId = this.ObtainCustomerId("Enter the ID of the customer whom to retrieve their Subscriptions"); 30 | 31 | this.Context.ConsoleHelper.StartProgress("Retrieving customer Subscriptions"); 32 | 33 | var customerSubscription = partnerOperations.Customers.ById(customerId).Subscriptions.Get(); 34 | 35 | this.Context.ConsoleHelper.StopProgress(); 36 | this.Context.ConsoleHelper.WriteObject(customerSubscription, "Customer Subscriptions"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Subscriptions/GetSubscriptionsByOrder.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Subscriptions 8 | { 9 | /// 10 | /// A scenario that retrieves a customer subscriptions by order. 11 | /// 12 | public class GetSubscriptionsByOrder : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetSubscriptionsByOrder(IScenarioContext context) : base("Get customer subscriptions by order", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | string customerId = this.ObtainCustomerId("Enter the ID of the customer whom to retrieve their subscriptions by order"); 30 | string orderID = this.ObtainOrderID("Enter the Order ID to retrieve"); 31 | 32 | this.Context.ConsoleHelper.StartProgress("Retrieving customer subscriptions by order"); 33 | 34 | var customerSubscriptionsByOrder = partnerOperations.Customers.ById(customerId).Subscriptions.ByOrder(orderID).Get(); 35 | 36 | this.Context.ConsoleHelper.StopProgress(); 37 | this.Context.ConsoleHelper.WriteObject(customerSubscriptionsByOrder, "Customer Subscriptions By Order"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Subscriptions/UpdateSubscription.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Subscriptions 8 | { 9 | /// 10 | /// A scenario that updates an existing customer subscription. 11 | /// 12 | public class UpdateSubscription : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public UpdateSubscription(IScenarioContext context) : base("Update existing customer subscription", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | var customerId = this.ObtainCustomerId(); 29 | var subscriptionId = this.ObtainSubscriptionId(customerId, "Enter the ID of the subscription to update"); 30 | 31 | this.Context.ConsoleHelper.StartProgress("Retrieving customer subscription"); 32 | var existingSubscription = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionId).Get(); 33 | this.Context.ConsoleHelper.StopProgress(); 34 | this.Context.ConsoleHelper.WriteObject(existingSubscription, "Existing subscription"); 35 | 36 | this.Context.ConsoleHelper.StartProgress("Incrementing subscription quantity"); 37 | existingSubscription.Quantity++; 38 | var updatedSubscription = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionId).Patch(existingSubscription); 39 | this.Context.ConsoleHelper.StopProgress(); 40 | 41 | this.Context.ConsoleHelper.WriteObject(updatedSubscription, "Updated subscription"); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/Subscriptions/UpdateSubscriptionSupportContact.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Subscriptions 8 | { 9 | /// 10 | /// A scenario that retrieves a customer subscription. 11 | /// 12 | public class UpdateSubscriptionSupportContact : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public UpdateSubscriptionSupportContact(IScenarioContext context) : base("Update subscription support contact", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | 29 | string customerId = this.ObtainCustomerId("Enter the ID of the customer whom to retrieve their Subscription"); 30 | string subscriptionID = this.ObtainSubscriptionId(customerId, "Enter the subscription ID to retrieve"); 31 | 32 | this.Context.ConsoleHelper.StartProgress("Retrieving subscription support contact"); 33 | 34 | var supportContact = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionID).SupportContact.Get(); 35 | 36 | // Here we are the updating the support contact with the same object retrieved above. You can update it with a new object that has valid VAR values. 37 | var updatedSupportContact = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionID).SupportContact.Update(supportContact); 38 | 39 | this.Context.ConsoleHelper.StopProgress(); 40 | this.Context.ConsoleHelper.WriteObject(updatedSupportContact, "Subscription support contact"); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Source/Partner Center SDK Samples/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | --------------------------------------------------------------------------------