├── .gitattributes ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── BUG_REPORT.md │ └── FEATURE_REQUEST.md └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── MCARefreshBulkAttestationCLITool ├── .gitignore ├── AppSettings.cs ├── Http │ └── McaHttpClientExtensions.cs ├── Interfaces │ ├── ICustomerProvider.cs │ ├── IFileProvider.cs │ └── ITokenProvider.cs ├── MCARefreshBulkAttestationCLITool.csproj ├── Models │ ├── CustomerAgreementRecord.cs │ ├── FetchCustomerAgreementRecordResponse.cs │ ├── LastAgreementPrimaryContact.cs │ └── ReAttestationRequest.cs ├── Program.cs └── Providers │ ├── CsvProvider.cs │ ├── CustomerProvider.cs │ └── TokenProvider.cs ├── README.md ├── SECURITY.md ├── azure-pipelines.yml ├── nce-bulk-migration-tool ├── NCEBulkMigrationTool.sln ├── NCEBulkMigrationTool │ ├── AppSettings.cs │ ├── CsvProvider.cs │ ├── CustomerProvider.cs │ ├── GlobalUsings.cs │ ├── ICustomerProvider.cs │ ├── INewCommerceMigrationProvider.cs │ ├── INewCommerceMigrationScheduleProvider.cs │ ├── ISubscriptionProvider.cs │ ├── ITokenProvider.cs │ ├── Models.cs │ ├── NCEBulkMigrationTool.csproj │ ├── NewCommerceMigrationProvider.cs │ ├── NewCommerceMigrationScheduleProvider.cs │ ├── Program.cs │ ├── SubscriptionProvider.cs │ ├── TokenProvider.cs │ ├── appsettings.json │ ├── installncebulkmigrationtool.cmd │ └── updatencebulkmigrationtool.cmd ├── Readme.md ├── assets │ └── images │ │ ├── AccountSettings.png │ │ ├── AppAuthenticationOptions.png │ │ ├── AppRegistrations.png │ │ ├── BatchMigrationWorkflow.png │ │ ├── CheckMigrationStatusCSVOutput.png │ │ ├── CheckMigrationStatusCsvOutput.png │ │ ├── CheckMigrationStatusExample.png │ │ ├── CheckMigrationStatusFileOutput.png │ │ ├── CheckMigrationStatusToolOutput.png │ │ ├── ConsoleAppLoaded.png │ │ ├── CustomerInputExample.png │ │ ├── ExportNCESubscriptionsCSVOutput.png │ │ ├── ExportNceSubscriptionsCsvOutput.png │ │ ├── ExportSubscriptionsExample.png │ │ ├── ExportSubscriptionsToolOutput.png │ │ ├── ExportedCustomersExample.png │ │ ├── InputOutputFolderExample.png │ │ ├── MigrationsFolderOutputExample.png │ │ ├── NceBulkMigrationToolLoaded.png │ │ ├── OutputSubscriptionsResult.png │ │ ├── SubscriptionsOutput.png │ │ ├── UploadMigrationsExample.png │ │ ├── UploadMigrationsToolOutput.png │ │ └── UploadedMigrationsCsvOutput.png └── nuget.config ├── sdk ├── README.md ├── SdkSamples.sln └── SdkSamples │ ├── AggregatePartnerScenario.cs │ ├── Agreements │ ├── CreateCustomerAgreement.cs │ ├── GetAgreementDetails.cs │ ├── GetAgreementDocument.cs │ ├── GetAllCustomersAgreements.cs │ ├── GetCustomerAgreements.cs │ ├── GetDirectSignedCustomerAgreementStatus.cs │ └── ImportCustomersAgreement.cs │ ├── Analytics │ ├── GetCustomerLicensesDeploymentAnalytics.cs │ ├── GetCustomerLicensesUsageAnalytics.cs │ ├── GetPartnerLicensesDeploymentAnalytics.cs │ └── GetPartnerLicensesUsageAnalytics.cs │ ├── App.config │ ├── Auditing │ ├── QueryAuditRecords.cs │ ├── SearchAuditRecords.cs │ ├── SearchAuditRecordsByCustomerId.cs │ └── SearchAuditRecordsByResourceType.cs │ ├── AzureEntitlement │ ├── CancelAzureEntitlement.cs │ └── GetAzureEntitlement.cs │ ├── BasePartnerScenario.cs │ ├── Carts │ ├── CheckoutCart.cs │ ├── CreateCart.cs │ ├── CreateCartAddonWithExistingSubscription.cs │ ├── CreateCartWithAddons.cs │ └── UpdateCart.cs │ ├── Compliance │ └── GetAgreementSignatureStatus.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 │ ├── 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 │ ├── CreateCustomerQualification.cs │ ├── CreateCustomerQualificationWithGCC.cs │ ├── DeleteCustomerFromTipAccount.cs │ ├── DeletePartnerCustomerDap.cs │ ├── DeletePartnerCustomerRelationship.cs │ ├── FilterCustomers.cs │ ├── GetCustomerDetails.cs │ ├── GetCustomerManagedServices.cs │ ├── GetCustomerQualifications.cs │ ├── GetCustomerRelationshipRequest.cs │ ├── GetPagedCustomers.cs │ ├── GetValidationStatus.cs │ ├── UpdateCustomerBillingProfile.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 │ ├── GetBillingLineItemsForOpenPeriodPaging.cs │ ├── GetEstimatesLinks.cs │ ├── GetInvoice.cs │ ├── GetInvoiceLineItems.cs │ ├── GetInvoiceStatement.cs │ ├── GetInvoiceSummaries.cs │ ├── GetInvoiceTaxReceiptStatement.cs │ ├── GetPagedInvoices.cs │ ├── GetUsageLineItemsForClosePeriodPaging.cs │ └── GetUsageLineItemsForOpenPeriodPaging.cs │ ├── NewCommerceMigrations │ ├── ValidateAndCreateNewCommerceMigration.cs │ └── ValidateAndCreateNewCommerceMigrationWithAddOn.cs │ ├── Offers │ ├── GetCustomerOfferCategories.cs │ ├── GetCustomerOffers.cs │ ├── GetOffer.cs │ ├── GetOfferCategories.cs │ ├── GetOffers.cs │ └── GetPagedOffers.cs │ ├── Orders │ ├── CreateAzureReservationOrder.cs │ ├── CreateOrder.cs │ ├── DownloadPoDocuments.cs │ ├── GetLineItemActivationLink.cs │ ├── GetOrderDetails.cs │ ├── GetOrderProvisioningStatus.cs │ ├── GetOrders.cs │ ├── GetOrdersByBillingCycleType.cs │ ├── UpdateOrder.cs │ └── UploadPoDocuments.cs │ ├── Products │ ├── CheckInventory.cs │ ├── GetAvailabilities.cs │ ├── GetAvailabilitiesByTargetSegment.cs │ ├── GetAvailability.cs │ ├── GetProduct.cs │ ├── GetProductPromotion.cs │ ├── GetProductPromotions.cs │ ├── GetProducts.cs │ ├── GetProductsByTargetSegment.cs │ ├── GetSku.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 │ ├── PromotionEligibilities │ └── PostPromotionEligibilities.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── RateCards │ ├── GetAzureRateCard.cs │ └── GetAzureSharedRateCard.cs │ ├── RatedUsage │ ├── GetCustomerSubscriptionsUsage.cs │ ├── GetCustomerUsageSummary.cs │ ├── GetSubscriptionUsageRecords.cs │ └── GetSubscriptionUsageSummary.cs │ ├── ScenarioExecution │ ├── AggregateScenarioExecutionStrategy.cs │ ├── IScenarioExecutionStrategy.cs │ └── PromptExecutionStrategy.cs │ ├── SdkSamples.csproj │ ├── SelfServePolicies │ ├── CreateSelfServePolicies.cs │ ├── DeleteSelfServePolicies.cs │ └── GetSelfServePolicies.cs │ ├── ServiceIncidents │ └── GetServiceIncidents.cs │ ├── ServiceRequests │ ├── GetCustomerServiceRequests.cs │ ├── GetPagedPartnerServiceRequests.cs │ ├── GetPartnerServiceRequestDetails.cs │ └── UpdatePartnerServiceRequest.cs │ ├── Subscriptions │ ├── ActivateSandboxThirdPartySubscription.cs │ ├── AddSubscriptionAddOn.cs │ ├── CancelSaaSSubscription.cs │ ├── ConvertTrialSubscription.cs │ ├── GetSubscription.cs │ ├── GetSubscriptionProvisioningStatus.cs │ ├── GetSubscriptionSupportContact.cs │ ├── GetSubscriptionTransitions.cs │ ├── GetSubscriptionTransitionsByOperationId.cs │ ├── GetSubscriptions.cs │ ├── GetSubscriptionsByOrder.cs │ ├── ToggleSubscriptionAutoRenew.cs │ ├── TransitionSubscription.cs │ ├── UpdateOverage.cs │ ├── UpdateSubscription.cs │ ├── UpdateSubscriptionScheduledChange.cs │ ├── UpdateSubscriptionSupportContact.cs │ └── UpgradeSubscription.cs │ ├── Utilization │ └── GetAzureSubscriptionUtilization.cs │ ├── Validations │ ├── AddressValidation.cs │ └── ValidateAddress.cs │ └── packages.config └── secure-app-model ├── README.md └── keyvault ├── CPVApplication.sln ├── CPVApplication ├── App.config ├── CPVApplication.csproj ├── CPVApplication.sln ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── Utilities │ ├── ApiCalls.cs │ ├── AuthorizationUtilities.cs │ └── KeyVaultProvider.cs └── packages.config ├── CSPApplication.sln ├── CSPApplication ├── App.config ├── CSPApplication.csproj ├── Exceptions │ └── AuthenticationException.cs ├── Models │ ├── AuthenticationResponse.cs │ └── AuthenticationResult.cs ├── Network │ └── PartnerServiceClient.cs ├── Program.cs ├── Properties │ └── AssemblyInfo.cs ├── Utilities │ ├── ApiCalls.cs │ ├── AuthorizationUtilities.cs │ └── KeyVaultProvider.cs └── packages.config ├── PartnerConsent.sln └── PartnerConsent ├── App_Start ├── BundleConfig.cs ├── FilterConfig.cs ├── RouteConfig.cs └── Startup.Auth.cs ├── ApplicationInsights.config ├── Content └── Site.css ├── Controllers └── HomeController.cs ├── Global.asax ├── Global.asax.cs ├── PartnerConsent.csproj ├── Properties └── AssemblyInfo.cs ├── Startup.cs ├── Utilities ├── AuthorizationUtilities.cs └── KeyVaultProvider.cs ├── Views ├── Home │ └── Index.cshtml ├── Shared │ ├── Error.cshtml │ └── _Layout.cshtml ├── Web.config └── _ViewStart.cshtml ├── Web.Debug.config ├── Web.Release.config ├── Web.config ├── favicon.ico └── packages.config /.gitattributes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/.gitattributes -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # This is a comment. 2 | # Each line is a file pattern followed by one or more owners. 3 | 4 | # These owners will be the default owners for everything in 5 | # the repo. Unless a later match takes precedence, 6 | # @brijeshp-ms, @kaminasy, or @isaiahwilliams will be requested for 7 | # review when someone opens a pull request. 8 | * @brijeshp-ms @kaminasy @isaiahwilliams 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/BUG_REPORT.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | 5 | --- 6 | 7 | # Steps to reproduce 8 | 9 | > What steps can reproduce the defect? 10 | > Please share the setup, sample project, version of Java etc. 11 | 12 | ## Expected behavior 13 | 14 | > Share the expected output 15 | 16 | ## Actual behavior 17 | 18 | > What is the behavior observed? 19 | 20 | ## Diagnostic logs 21 | 22 | > Please share test platform diagnostics logs. 23 | > The logs may contain test assembly paths, kindly review and mask those before sharing. 24 | 25 | ## Environment 26 | 27 | > Please share additional details about your environment. 28 | > Version -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | # Feature Request 8 | 9 | **Is your feature request related to a problem? Please describe.** 10 | A clear and concise description of what the problem is. Ex. I am always frustrated when [...] 11 | 12 | **Describe the solution you would like** 13 | A clear and concise description of what you want to happen. 14 | 15 | **Describe alternatives you have considered** 16 | A clear and concise description of any alternative solutions or features you have considered. 17 | 18 | **Additional context** 19 | Add any other context or screenshots about the feature request here. -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Description 2 | 3 | Please add a meaningful description for this change. Ensure the PR has required unit tests. 4 | 5 | ## Related issue 6 | 7 | Kindly link any related issues (e.g. Fixes #xyz). -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Code of Conduct 2 | 3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 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 | -------------------------------------------------------------------------------- /MCARefreshBulkAttestationCLITool/.gitignore: -------------------------------------------------------------------------------- 1 | Logs/ 2 | bin/ 3 | obj/ 4 | .vs/ 5 | .vscode/ 6 | -------------------------------------------------------------------------------- /MCARefreshBulkAttestationCLITool/AppSettings.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | 5 | namespace MCARefreshBulkAttestationCLITool 6 | { 7 | public record AppSettings 8 | { 9 | public string ApplicationId { get; init; } = string.Empty; 10 | 11 | public string UserPrincipalName { get; init; } = string.Empty; 12 | 13 | public bool IsMfaExcluded { get; init; } 14 | 15 | public string Domain 16 | { 17 | get 18 | { 19 | var index = this.UserPrincipalName.LastIndexOf("@"); 20 | if (index == -1) { return string.Empty; } 21 | return this.UserPrincipalName[++index..]; 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MCARefreshBulkAttestationCLITool/Http/McaHttpClientExtensions.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | 5 | namespace MCARefreshBulkAttestationCLITool 6 | { 7 | using System; 8 | using System.Net.Http; 9 | using System.Net.Http.Headers; 10 | using System.Threading.Tasks; 11 | using MCARefreshBulkAttestationCLITool.Interfaces; 12 | using Microsoft.Extensions.Logging; 13 | 14 | public static class McaHttpClientExtensions 15 | { 16 | public class PartnerCenterAuthorizationHandler : DelegatingHandler 17 | { 18 | private readonly ITokenProvider tokenProvider; 19 | private readonly ILogger logger; 20 | 21 | public PartnerCenterAuthorizationHandler(ITokenProvider tokenProvider) 22 | { 23 | this.tokenProvider = tokenProvider ?? throw new ArgumentNullException(nameof(tokenProvider)); 24 | } 25 | 26 | protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) 27 | { 28 | var authenticationToken = await this.tokenProvider.GetTokenAsync(); 29 | 30 | request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", authenticationToken); 31 | 32 | request.Headers.Add("MS-CorrelationId", Guid.NewGuid().ToString()); 33 | request.Headers.Add("MS-RequestId", Guid.NewGuid().ToString()); 34 | 35 | return await base.SendAsync(request, cancellationToken); 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /MCARefreshBulkAttestationCLITool/Interfaces/ICustomerProvider.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | 5 | namespace MCARefreshBulkAttestationCLITool.Interfaces 6 | { 7 | using System.Threading.Tasks; 8 | using MCARefreshBulkAttestationCLITool.Models; 9 | using Refit; 10 | 11 | public interface ICustomerProvider 12 | { 13 | Task FetchAndSaveCustomerAgreementRecords(); 14 | 15 | Task UpdateCustomerAgreementRecords(string partnerTenantId); 16 | } 17 | 18 | public interface ICustomerAgreementsClient 19 | { 20 | Task GetCustomerAgreementRecords(CancellationToken cancellationToken = default) => this.GetCustomerAgreementRecords(null, cancellationToken); 21 | 22 | [Get("/v1/partners/customeragreementrecords")] 23 | Task GetCustomerAgreementRecords([AliasAs("continuation_token")][Query] string? continuationToken, CancellationToken cancellationToken = default); 24 | 25 | [Post("/v1/CreateBulkReAttestation")] 26 | Task CreateBulkReAttestation(IEnumerable request, CancellationToken cancellationToken = default); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /MCARefreshBulkAttestationCLITool/Interfaces/IFileProvider.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | 5 | namespace MCARefreshBulkAttestationCLITool.Interfaces 6 | { 7 | using System.Collections.Generic; 8 | using MCARefreshBulkAttestationCLITool.Models; 9 | 10 | public interface IFileProvider 11 | { 12 | /// 13 | /// Reads the file from the local file system. 14 | /// 15 | /// 16 | /// 17 | Task> ReadFromLocalFile(string fileName); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /MCARefreshBulkAttestationCLITool/Interfaces/ITokenProvider.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | 5 | namespace MCARefreshBulkAttestationCLITool.Interfaces 6 | { 7 | using System.Threading.Tasks; 8 | 9 | public interface ITokenProvider 10 | { 11 | Task GetTokenAsync(); 12 | 13 | Task GetTenantIdAsync(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /MCARefreshBulkAttestationCLITool/MCARefreshBulkAttestationCLITool.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net7.0 6 | enable 7 | enable 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /MCARefreshBulkAttestationCLITool/Models/CustomerAgreementRecord.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | 5 | namespace MCARefreshBulkAttestationCLITool.Models 6 | { 7 | using System.Text.Json.Serialization; 8 | 9 | public class CustomerAgreementRecord 10 | { 11 | [JsonPropertyName("customerTenantId")] 12 | public string CustomerTenantId { get; set; } 13 | 14 | [JsonPropertyName("lastAgreementPrimaryContact")] 15 | public LastAgreementPrimaryContact LastAgreementPrimaryContact { get; set; } 16 | 17 | [JsonPropertyName("lastAgreementDateEpoch")] 18 | public long LastAgreementDateEpoch { get; set; } 19 | 20 | public string LastAgreementDate 21 | { 22 | get 23 | { 24 | if (this.LastAgreementDateEpoch == default) 25 | { 26 | return string.Empty; 27 | } 28 | 29 | var offset = $"{this.LastAgreementDateEpoch}".Length > 10 ? DateTimeOffset.FromUnixTimeMilliseconds(this.LastAgreementDateEpoch) : DateTimeOffset.FromUnixTimeSeconds(this.LastAgreementDateEpoch); 30 | return offset.ToString("yyyy-MM-dd HH:mm:ss"); 31 | } 32 | } 33 | 34 | [JsonPropertyName("partnerAttestationCompleted")] 35 | public bool PartnerAttestationCompleted { get; set; } = false; 36 | 37 | public string CustomerAccountLink 38 | { 39 | get => $"https://partner.microsoft.com/dashboard/v2/customers/{this.CustomerTenantId}/account"; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /MCARefreshBulkAttestationCLITool/Models/FetchCustomerAgreementRecordResponse.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | 5 | namespace MCARefreshBulkAttestationCLITool.Models 6 | { 7 | using System.Collections.Generic; 8 | using System.Text.Json.Serialization; 9 | 10 | public class FetchCustomerAgreementRecordResponse 11 | { 12 | [JsonPropertyName("customerAgreementRecords")] 13 | public List CustomerAgreementRecords { get; set; } 14 | 15 | [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] 16 | [JsonPropertyName("continuationToken")] 17 | public string ContinuationToken { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /MCARefreshBulkAttestationCLITool/Models/LastAgreementPrimaryContact.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | 5 | namespace MCARefreshBulkAttestationCLITool.Models 6 | { 7 | using System.Text.Json.Serialization; 8 | 9 | public class LastAgreementPrimaryContact 10 | { 11 | [JsonPropertyName("firstName")] 12 | public string FirstName { get; set; } 13 | 14 | [JsonPropertyName("lastName")] 15 | public string LastName { get; set; } 16 | 17 | [JsonPropertyName("email")] 18 | public string Email { get; set; } 19 | 20 | [JsonPropertyName("phoneNumber")] 21 | public string PhoneNumber { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /MCARefreshBulkAttestationCLITool/Models/ReAttestationRequest.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (c) Microsoft Corporation. All rights reserved. 3 | // 4 | 5 | namespace MCARefreshBulkAttestationCLITool.Models 6 | { 7 | using System.Text.Json.Serialization; 8 | 9 | public class ReAttestationRequest 10 | { 11 | [JsonPropertyName("partnerId")] 12 | public string PartnerId { get; set; } 13 | 14 | [JsonPropertyName("customerId")] 15 | public string CustomerId { get; set; } 16 | 17 | [JsonPropertyName("agreement")] 18 | public Agreement Agreement { get; set; } 19 | 20 | [JsonPropertyName("customerDirectAcceptance")] 21 | public bool CustomerDirectAcceptance { get; set; } 22 | } 23 | 24 | public class Agreement 25 | { 26 | public static readonly string MicrosoftCustomerAgreementTemplateId = "117a77b0-9360-443b-8795-c6dedc750cf9"; 27 | 28 | [JsonPropertyName("templateId")] 29 | public string TemplateId { get; set; } 30 | 31 | [JsonPropertyName("primaryContact")] 32 | public LastAgreementPrimaryContact PrimaryContact { get; set; } 33 | 34 | [JsonPropertyName("dateAgreed")] 35 | public DateTime DateAgreed { get; set; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Partner Center SDK for .NET Samples 2 | 3 | This repository contains samples for the Partner Center SDK for .NET. 4 | 5 | ## Samples List 6 | 7 | | Sample Name | Description | 8 | |-------------|-------------| 9 | | [SDK Samples](sdk/README.md) | Console application that demonstrates each scenario the Partner Center .NET SDK is capable of performing.| 10 | | [Secure App Model](secure-app-model/README.md) | A set of projects that demonstrate how a Control Panel Vendor (CPV) and a Cloud Solution Provider (CSP) should implement the Secure App Model. | 11 | 12 | ## Reporting Security Issues 13 | 14 | Security issues and bugs should be reported privately, via email, to the Microsoft Security Response Center (MSRC) at [secure@microsoft.com](mailto:secure@microsoft.com). You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Further information, including the [MSRC PGP](https://technet.microsoft.com/en-us/security/dn606155) key, can be found in the [Security TechCenter](https://technet.microsoft.com/en-us/security/default). 15 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | strategy: 2 | matrix: 3 | Windows: 4 | imageName: 'windows-2019' 5 | 6 | trigger: 7 | - master 8 | 9 | pool: 10 | vmImage: $(imageName) 11 | 12 | variables: 13 | solution: '$(Build.SourcesDirectory)/**/sdk/*.sln;$(Build.SourcesDirectory)/**/secure-app-model/**/*.sln' 14 | buildPlatform: 'Any CPU' 15 | buildConfiguration: 'Release' 16 | 17 | steps: 18 | - task: CredScan@2 19 | displayName: CredScan 20 | inputs: 21 | toolMajorVersion: 'V2' 22 | condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) 23 | 24 | - task: PoliCheck@1 25 | displayName: PoliCheck 26 | inputs: 27 | inputType: 'Basic' 28 | targetType: 'F' 29 | targetArgument: '$(Build.SourcesDirectory)' 30 | result: 'PoliCheck.xml' 31 | condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) 32 | 33 | - task: NuGetToolInstaller@1 34 | displayName: Use NuGet 5.4.0 35 | inputs: 36 | versionSpec: 5.4.0 37 | 38 | - task: NuGetCommand@2 39 | inputs: 40 | restoreSolution: '$(solution)' 41 | 42 | - task: VSBuild@1 43 | inputs: 44 | solution: '$(solution)' 45 | platform: '$(buildPlatform)' 46 | configuration: '$(buildConfiguration)' 47 | 48 | - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 49 | displayName: 'Component Detection' 50 | 51 | - task: BinSkim@3 52 | displayName: BinSkim 53 | inputs: 54 | InputType: 'Basic' 55 | Function: 'analyze' 56 | AnalyzeTarget: 'sdk\SdkSamples\bin\$(buildConfiguration)\*.dll;' 57 | condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) 58 | -------------------------------------------------------------------------------- /nce-bulk-migration-tool/NCEBulkMigrationTool.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.32112.339 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NCEBulkMigrationTool", "NCEBulkMigrationTool\NCEBulkMigrationTool.csproj", "{E38DE1C2-FBDC-45A9-9260-E8A84D4AA944}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{FA662682-F134-4839-B591-495F741EB4E5}" 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 | {E38DE1C2-FBDC-45A9-9260-E8A84D4AA944}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 20 | {E38DE1C2-FBDC-45A9-9260-E8A84D4AA944}.Debug|Any CPU.Build.0 = Debug|Any CPU 21 | {E38DE1C2-FBDC-45A9-9260-E8A84D4AA944}.Release|Any CPU.ActiveCfg = Release|Any CPU 22 | {E38DE1C2-FBDC-45A9-9260-E8A84D4AA944}.Release|Any CPU.Build.0 = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(SolutionProperties) = preSolution 25 | HideSolutionNode = FALSE 26 | EndGlobalSection 27 | GlobalSection(ExtensibilityGlobals) = postSolution 28 | SolutionGuid = {A4D8510A-2D70-40AC-BA22-2C4B6DBADA1B} 29 | EndGlobalSection 30 | EndGlobal 31 | -------------------------------------------------------------------------------- /nce-bulk-migration-tool/NCEBulkMigrationTool/AppSettings.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace NCEBulkMigrationTool; 8 | 9 | /// 10 | /// The app settings record. 11 | /// 12 | internal record AppSettings 13 | { 14 | /// 15 | /// Gets or sets the application id. 16 | /// 17 | public string AppId { get; init; } = string.Empty; 18 | 19 | /// 20 | /// Gets or sets the user principal name. 21 | /// 22 | public string Upn { get; init; } = string.Empty; 23 | 24 | /// 25 | /// Gets the domain from the user principal name. 26 | /// 27 | public string Domain 28 | { 29 | get 30 | { 31 | var index = this.Upn.LastIndexOf("@"); 32 | if (index == -1) { return string.Empty; } 33 | return this.Upn[++index..]; 34 | } 35 | } 36 | 37 | /// 38 | /// Gets or sets a flag indicating whether to use app only token. 39 | /// 40 | public bool UseAppToken { get; set; } 41 | } -------------------------------------------------------------------------------- /nce-bulk-migration-tool/NCEBulkMigrationTool/CsvProvider.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace NCEBulkMigrationTool; 8 | 9 | /// 10 | /// The CsvProvider class. 11 | /// 12 | internal class CsvProvider 13 | { 14 | /// 15 | /// Exports provided data to CSV format. 16 | /// 17 | /// The type of data to be translated to CSV format. 18 | /// The list of data to export to CSV. 19 | /// The filename to write CSV data to. 20 | /// No return. 21 | public async Task ExportCsv(IEnumerable data, string fileName) 22 | { 23 | int index = fileName.LastIndexOf('/'); 24 | var directory = fileName[..index]; 25 | Directory.CreateDirectory(directory); 26 | 27 | using var subscriptionsWriter = new StreamWriter(fileName); 28 | using var subscriptionsCsvWriter = new CsvWriter(subscriptionsWriter, CultureInfo.InvariantCulture); 29 | await subscriptionsCsvWriter.WriteRecordsAsync(data); 30 | } 31 | } -------------------------------------------------------------------------------- /nce-bulk-migration-tool/NCEBulkMigrationTool/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | global using System.Net.Http.Headers; 8 | global using System.Net.Http.Json; 9 | global using System.Text; 10 | global using System.Text.Json; 11 | global using System.Text.Json.Serialization; 12 | global using NCEBulkMigrationTool; 13 | global using CsvHelper; 14 | global using System.Collections.Concurrent; 15 | global using System.Globalization; 16 | global using Microsoft.Identity.Client; 17 | global using System.Net; 18 | global using System.Configuration; 19 | global using Microsoft.Extensions.Configuration; 20 | global using System.Diagnostics; 21 | global using Microsoft.Extensions.DependencyInjection; 22 | global using Microsoft.Extensions.Hosting; -------------------------------------------------------------------------------- /nce-bulk-migration-tool/NCEBulkMigrationTool/ICustomerProvider.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace NCEBulkMigrationTool; 8 | 9 | /// 10 | /// The ICustomerProvider interface. 11 | /// 12 | internal interface ICustomerProvider 13 | { 14 | /// 15 | /// Export all customers into CSV file. 16 | /// 17 | /// Bool for success/ failure. 18 | Task ExportCustomersAsync(); 19 | } -------------------------------------------------------------------------------- /nce-bulk-migration-tool/NCEBulkMigrationTool/INewCommerceMigrationProvider.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace NCEBulkMigrationTool; 8 | 9 | /// 10 | /// The INewCommerceMigrationProvider interface. 11 | /// 12 | internal interface INewCommerceMigrationProvider 13 | { 14 | /// 15 | /// Uploads New Commerce Migrations based on CSV files in the input folders and writes the migration data to a new CSV file. 16 | /// 17 | /// Bool indicating success/ failure. 18 | Task UploadNewCommerceMigrationsAsync(); 19 | 20 | /// 21 | /// Exports the latest New Commerce Migration Status for given input migrations into a new CSV file. 22 | /// 23 | /// Bool indicating success/ failure. 24 | Task ExportNewCommerceMigrationStatusAsync(); 25 | } -------------------------------------------------------------------------------- /nce-bulk-migration-tool/NCEBulkMigrationTool/INewCommerceMigrationScheduleProvider.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace NCEBulkMigrationTool 8 | { 9 | internal interface INewCommerceMigrationScheduleProvider 10 | { 11 | /// 12 | /// Exports legacy commerce subscriptions with their migration eligibility to an output CSV file so that 13 | /// they can be scheduled as needed. 14 | /// 15 | /// Bool indicating success/ failure. 16 | Task ValidateAndGetSubscriptionsToScheduleMigrationAsync(); 17 | 18 | /// 19 | /// Uploads New Commerce Migration Schedules based on CSV files in the input folders and writes the schedule migration data to a new CSV file. 20 | /// 21 | /// Bool indicating success/ failure. 22 | Task UploadNewCommerceMigrationSchedulesAsync(); 23 | 24 | /// 25 | /// Exports all the New Commerce Migration Schedules for the given input list of customers. 26 | /// 27 | /// Bool indicating success/ failure. 28 | Task ExportNewCommerceMigrationSchedulesAsync(); 29 | 30 | /// 31 | /// Cancels the New Commerce Migration Schedules based on the CSV input files and writes the output with the updated Schedule Migration Status. 32 | /// 33 | /// Bool indicating success/ failure. 34 | Task CancelNewCommerceMigrationSchedulesAsync(); 35 | } 36 | } -------------------------------------------------------------------------------- /nce-bulk-migration-tool/NCEBulkMigrationTool/ISubscriptionProvider.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace NCEBulkMigrationTool; 8 | 9 | /// 10 | /// The ISubscriptionProvider interface. 11 | /// 12 | internal interface ISubscriptionProvider 13 | { 14 | /// 15 | /// Exports legacy commerce subscriptions with their migration eligibility to an output CSV file. 16 | /// 17 | /// Bool indicating success/ failure. 18 | Task ExportLegacySubscriptionsAsync(); 19 | 20 | /// 21 | /// Exports NCE subscriptions to an output CSV file. 22 | /// 23 | /// Bool indicating success/ failure. 24 | Task ExportModernSubscriptionsAsync(); 25 | } -------------------------------------------------------------------------------- /nce-bulk-migration-tool/NCEBulkMigrationTool/ITokenProvider.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace NCEBulkMigrationTool; 8 | 9 | /// 10 | /// The ITokenProvider interface. 11 | /// 12 | internal interface ITokenProvider 13 | { 14 | /// 15 | /// Gets a Partner token to authenticate with Partner Center APIs. 16 | /// 17 | /// AuthenticationResult containing the token. 18 | Task GetTokenAsync(); 19 | } -------------------------------------------------------------------------------- /nce-bulk-migration-tool/NCEBulkMigrationTool/NCEBulkMigrationTool.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net6.0 6 | enable 7 | enable 8 | true 9 | ncebulkmigration 10 | ./nupkg 11 | false 12 | 0.5.0 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | Always 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /nce-bulk-migration-tool/NCEBulkMigrationTool/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "useAppToken": false, 3 | "clientId": "", 4 | "clientSecret": "", 5 | "tenantId": "" 6 | } -------------------------------------------------------------------------------- /nce-bulk-migration-tool/NCEBulkMigrationTool/installncebulkmigrationtool.cmd: -------------------------------------------------------------------------------- 1 | dotnet new tool-manifest --force 2 | dotnet tool install -g --add-source . NCEBulkMigrationTool -------------------------------------------------------------------------------- /nce-bulk-migration-tool/NCEBulkMigrationTool/updatencebulkmigrationtool.cmd: -------------------------------------------------------------------------------- 1 | dotnet tool update -g ncebulkmigrationtool --add-source . -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/AccountSettings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/AccountSettings.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/AppAuthenticationOptions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/AppAuthenticationOptions.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/AppRegistrations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/AppRegistrations.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/BatchMigrationWorkflow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/BatchMigrationWorkflow.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/CheckMigrationStatusCSVOutput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/CheckMigrationStatusCSVOutput.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/CheckMigrationStatusCsvOutput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/CheckMigrationStatusCsvOutput.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/CheckMigrationStatusExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/CheckMigrationStatusExample.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/CheckMigrationStatusFileOutput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/CheckMigrationStatusFileOutput.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/CheckMigrationStatusToolOutput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/CheckMigrationStatusToolOutput.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/ConsoleAppLoaded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/ConsoleAppLoaded.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/CustomerInputExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/CustomerInputExample.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/ExportNCESubscriptionsCSVOutput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/ExportNCESubscriptionsCSVOutput.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/ExportNceSubscriptionsCsvOutput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/ExportNceSubscriptionsCsvOutput.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/ExportSubscriptionsExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/ExportSubscriptionsExample.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/ExportSubscriptionsToolOutput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/ExportSubscriptionsToolOutput.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/ExportedCustomersExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/ExportedCustomersExample.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/InputOutputFolderExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/InputOutputFolderExample.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/MigrationsFolderOutputExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/MigrationsFolderOutputExample.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/NceBulkMigrationToolLoaded.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/NceBulkMigrationToolLoaded.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/OutputSubscriptionsResult.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/OutputSubscriptionsResult.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/SubscriptionsOutput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/SubscriptionsOutput.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/UploadMigrationsExample.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/UploadMigrationsExample.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/UploadMigrationsToolOutput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/UploadMigrationsToolOutput.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/assets/images/UploadedMigrationsCsvOutput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/nce-bulk-migration-tool/assets/images/UploadedMigrationsCsvOutput.png -------------------------------------------------------------------------------- /nce-bulk-migration-tool/nuget.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /sdk/SdkSamples.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28010.2050 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SdkSamples", "SdkSamples\SdkSamples.csproj", "{AC93E5CC-549C-4F13-9675-A86860918C2B}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {AC93E5CC-549C-4F13-9675-A86860918C2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {AC93E5CC-549C-4F13-9675-A86860918C2B}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {AC93E5CC-549C-4F13-9675-A86860918C2B}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {AC93E5CC-549C-4F13-9675-A86860918C2B}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {8E53D670-F5E9-41B1-B567-8819B3AD3DCF} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | } -------------------------------------------------------------------------------- /sdk/SdkSamples/Agreements/GetDirectSignedCustomerAgreementStatus.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Agreements 8 | { 9 | /// 10 | /// Gets the status of a customer's direct signing (direct acceptance) of Microsoft Customer Agreement. 11 | /// 12 | public class GetDirectSignedCustomerAgreementStatus : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetDirectSignedCustomerAgreementStatus(IScenarioContext context) : base("Get customer's MCA direct signing status.", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the get customer's MCA direct signing status scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var selectedCustomerId = this.ObtainCustomerId("Enter the ID of the customer to get MCA direct signing status for"); 28 | 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | 31 | this.Context.ConsoleHelper.StartProgress($"Retrieving MCA direct signing status for customer with ID {selectedCustomerId}"); 32 | 33 | var signingStatus = partnerOperations.Customers.ById(selectedCustomerId).Agreements.GetDirectSignedCustomerAgreementStatus(); 34 | 35 | this.Context.ConsoleHelper.StopProgress(); 36 | this.Context.ConsoleHelper.WriteObject(signingStatus, "MCA Direct Signing Status of Customer"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | } -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/Customers/DeletePartnerCustomerDap.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Customers 8 | { 9 | using Models.Customers; 10 | 11 | /// 12 | /// Deletes a partner customer Dap. 13 | /// 14 | public class DeletePartnerCustomerDap : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public DeletePartnerCustomerDap(IScenarioContext context) : base("Delete Partner Customer Dap", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | 31 | // prompt the user the enter the customer ID 32 | var customerIdToDeleteRelationshipOf = this.Context.ConsoleHelper.ReadNonEmptyString("Please enter the ID of the customer you want to delete Dap with", "The customer ID can't be empty"); 33 | 34 | // Delete the partner customer dap 35 | this.Context.ConsoleHelper.StartProgress("Deleting partner customer Dap"); 36 | 37 | Customer customer = new Customer 38 | { 39 | AllowDelegatedAccess = false 40 | }; 41 | 42 | partnerOperations.Customers.ById(customerIdToDeleteRelationshipOf).Patch(customer); 43 | 44 | this.Context.ConsoleHelper.Success("Partner customer Dap successfully deleted"); 45 | 46 | this.Context.ConsoleHelper.StopProgress(); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/Customers/GetCustomerQualifications.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | namespace Microsoft.Store.PartnerCenter.Samples.Customers 7 | { 8 | /// 9 | /// Gets a customer's qualifications using the asynchronous qualifications APIs. 10 | /// 11 | public class GetCustomerQualifications : BasePartnerScenario 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | /// The scenario context. 17 | public GetCustomerQualifications(IScenarioContext context) : base("Get customer qualifications", context) 18 | { 19 | } 20 | 21 | /// 22 | /// Executes the get customer qualifications scenario. 23 | /// 24 | protected override void RunScenario() 25 | { 26 | string customerIdToRetrieve = this.ObtainCustomerId("Enter the ID of the customer to retrieve qualifications for"); 27 | 28 | var partnerOperations = this.Context.UserPartnerOperations; 29 | this.Context.ConsoleHelper.StartProgress("Retrieving customer qualifications"); 30 | 31 | var customerQualifications = partnerOperations.Customers.ById(customerIdToRetrieve).Qualification.GetQualifications(); 32 | 33 | this.Context.ConsoleHelper.StopProgress(); 34 | this.Context.ConsoleHelper.WriteObject(customerQualifications, "Customer Qualifications"); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/Customers/GetValidationStatus.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.ValidationStatus.Enums; 10 | 11 | /// 12 | /// A scenario that showcases retrieving a customer's validation status. 13 | /// 14 | public class GetValidationStatus : BasePartnerScenario 15 | { 16 | /// 17 | /// Initializes a new instance of the class. 18 | /// 19 | /// The scenario context. 20 | public GetValidationStatus(IScenarioContext context) : base("Get customer validation status.", context) 21 | { 22 | } 23 | 24 | /// 25 | /// Executes the scenario. 26 | /// 27 | protected override void RunScenario() 28 | { 29 | string customerIdToRetrieve = this.ObtainCustomerId("Enter the customer ID to retrieve the validation status for:"); 30 | 31 | var partnerOperations = this.Context.UserPartnerOperations; 32 | this.Context.ConsoleHelper.StartProgress($"Retrieving customer's validation status for type: {ValidationType.Account}"); 33 | 34 | var validationTypeToFetch = ValidationType.Account; 35 | 36 | var customerValidationStatus = partnerOperations.Customers.ById(customerIdToRetrieve).ValidationStatus.GetValidationStatus(validationTypeToFetch); 37 | 38 | this.Context.ConsoleHelper.StopProgress(); 39 | this.Context.ConsoleHelper.WriteObject(customerValidationStatus, "Customer Validation Status"); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/Orders/DownloadPoDocuments.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 updates a customer order by downloading PO attachment. 11 | /// 12 | public class DownloadPoDocuments : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public DownloadPoDocuments(IScenarioContext context) : base("Download PO documents of a customer 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 orders"); 30 | string orderId = this.ObtainOrderID("Enter the ID of order to retrieve"); 31 | string attachmentId = this.ObtainOrderID("Enter the ID of attachment to retrieve"); 32 | 33 | this.Context.ConsoleHelper.StartProgress("Retrieving attachment"); 34 | 35 | var attachment = partnerOperations.Customers.ById(customerId).Orders.ById(orderId).Attachments.ById(attachmentId).Download(); 36 | this.Context.ConsoleHelper.StopProgress(); 37 | this.Context.ConsoleHelper.WriteObject(attachment, "The document that was uploaded to customer order"); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/SelfServePolicies/DeleteSelfServePolicies.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | 8 | namespace Microsoft.Store.PartnerCenter.Samples.SelfServePolicies 9 | { 10 | /// 11 | /// A scenario that deletes a self serve policy for a customer. 12 | /// 13 | public class DeleteSelfServePolicies : BasePartnerScenario 14 | { 15 | /// 16 | /// Initializes a new instance of the class. 17 | /// 18 | /// The scenario context. 19 | public DeleteSelfServePolicies(IScenarioContext context) : base("Deletes self serve policy", context) 20 | { 21 | } 22 | 23 | /// 24 | /// Executes the scenario. 25 | /// 26 | protected override void RunScenario() 27 | { 28 | string policyId = this.ObtainCustomerId("Enter the self serve policy ID to delete"); 29 | 30 | var partnerOperations = this.Context.UserPartnerOperations; 31 | 32 | // deletes the self serve policies 33 | this.Context.ConsoleHelper.StartProgress($"Deleting the self serve policy id: { policyId }"); 34 | partnerOperations.SelfServePolicies.ById(policyId).Delete(); 35 | this.Context.ConsoleHelper.StopProgress(); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /sdk/SdkSamples/SelfServePolicies/GetSelfServePolicies.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.SelfServePolicies 8 | { 9 | /// 10 | /// A scenario that gets a self serve policy for a customer. 11 | /// 12 | public class GetSelfServePolicies : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetSelfServePolicies(IScenarioContext context) : base("Gets self serve policies", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | string customerIdAsEntity = this.ObtainCustomerId("Enter the ID of the customer to get policies for"); 28 | 29 | var partnerOperations = this.Context.UserPartnerOperations; 30 | this.Context.ConsoleHelper.StartProgress($"Getting self serve policies for customerId { customerIdAsEntity }"); 31 | 32 | // gets the self serve policies 33 | var SelfServePolicies = partnerOperations.SelfServePolicies.Get(customerIdAsEntity); 34 | this.Context.ConsoleHelper.StopProgress(); 35 | 36 | this.Context.ConsoleHelper.WriteObject(SelfServePolicies, $"Self serve policies for customerId { customerIdAsEntity }"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/Subscriptions/ActivateSandboxThirdPartySubscription.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Subscriptions 8 | { 9 | /// 10 | /// Activate Sandbox 3PP subscription. 11 | /// 12 | public class ActivateSandboxThirdPartySubscription : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public ActivateSandboxThirdPartySubscription(IScenarioContext context) : base("Activate Sandbox third party 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 activate"); 30 | var subscriptionOperations = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionId); 31 | 32 | this.Context.ConsoleHelper.StartProgress("Activating subscription"); 33 | var subscriptionActivationResult = subscriptionOperations.Activate(); 34 | this.Context.ConsoleHelper.StopProgress(); 35 | 36 | this.Context.ConsoleHelper.WriteObject(subscriptionActivationResult, "Subscription activation result"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/Subscriptions/GetSubscriptionTransitions.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 transitions. 11 | /// 12 | public class GetSubscriptionTransitions : BasePartnerScenario 13 | { 14 | /// 15 | /// Initializes a new instance of the class. 16 | /// 17 | /// The scenario context. 18 | public GetSubscriptionTransitions(IScenarioContext context) : base("Get customer subscription transitions", context) 19 | { 20 | } 21 | 22 | /// 23 | /// Executes the scenario. 24 | /// 25 | protected override void RunScenario() 26 | { 27 | var partnerOperations = this.Context.UserPartnerOperations; 28 | string customerId = this.ObtainCustomerId("Enter the ID of the customer whom to retrieve their subscriptions"); 29 | string subscriptionId = this.ObtainSubscriptionId(customerId, "Enter the ID of the subscription to find transitions for"); 30 | var subscriptionOperations = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionId); 31 | 32 | this.Context.ConsoleHelper.StartProgress("Retrieving customer subscription transitions"); 33 | var transitions = subscriptionOperations.Transitions.Get(); 34 | this.Context.ConsoleHelper.StopProgress(); 35 | 36 | this.Context.ConsoleHelper.WriteObject(transitions, "Customer subscription transitions"); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/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 | -------------------------------------------------------------------------------- /sdk/SdkSamples/Subscriptions/ToggleSubscriptionAutoRenew.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Microsoft.Store.PartnerCenter.Samples.Subscriptions 8 | { 9 | class ToggleSubscriptionAutoRenew : BasePartnerScenario 10 | 11 | { 12 | public ToggleSubscriptionAutoRenew(IScenarioContext context) : base("Toggle Subcription Autorenew", context) 13 | { 14 | } 15 | 16 | /// 17 | /// Executes the scenario. 18 | /// 19 | protected override void RunScenario() 20 | { 21 | var partnerOperations = this.Context.UserPartnerOperations; 22 | 23 | string customerId = this.ObtainCustomerId("Enter the ID of the customer whom to retrieve their subscription"); 24 | string subscriptionId = this.ObtainSubscriptionId(customerId); 25 | 26 | this.Context.ConsoleHelper.StartProgress("Retrieving customer subscription"); 27 | 28 | this.Context.ConsoleHelper.StartProgress("Retrieving customer subscription"); 29 | var existingSubscription = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionId).Get(); 30 | this.Context.ConsoleHelper.StopProgress(); 31 | this.Context.ConsoleHelper.WriteObject(existingSubscription, "Existing subscription"); 32 | 33 | this.Context.ConsoleHelper.StartProgress("Toggling subscription autorenew"); 34 | existingSubscription.AutoRenewEnabled = !existingSubscription.AutoRenewEnabled; 35 | var updatedSubscription = partnerOperations.Customers.ById(customerId).Subscriptions.ById(subscriptionId).Patch(existingSubscription); 36 | this.Context.ConsoleHelper.StopProgress(); 37 | this.Context.ConsoleHelper.WriteObject(updatedSubscription, "Subscription after update"); 38 | } 39 | } 40 | } 41 | 42 | -------------------------------------------------------------------------------- /sdk/SdkSamples/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/CPVApplication.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2026 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CPVApplication", "CPVApplication\CPVApplication.csproj", "{9283AF7A-6CA9-4373-93CB-F5D2130E1889}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {9283AF7A-6CA9-4373-93CB-F5D2130E1889}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {9283AF7A-6CA9-4373-93CB-F5D2130E1889}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {9283AF7A-6CA9-4373-93CB-F5D2130E1889}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {9283AF7A-6CA9-4373-93CB-F5D2130E1889}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {3CBE281A-E046-480F-8FC6-34536B951BEC} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/CPVApplication/CPVApplication.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.136 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CPVApplication", "CPVApplication.csproj", "{9283AF7A-6CA9-4373-93CB-F5D2130E1889}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {9283AF7A-6CA9-4373-93CB-F5D2130E1889}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {9283AF7A-6CA9-4373-93CB-F5D2130E1889}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {9283AF7A-6CA9-4373-93CB-F5D2130E1889}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {9283AF7A-6CA9-4373-93CB-F5D2130E1889}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {3A06FFB3-C870-4EE7-A03D-0ECB09F84BB6} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/CPVApplication/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("CPVApplication")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("CPVApplication")] 12 | [assembly: AssemblyCopyright("Copyright © 2018")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("9283af7a-6ca9-4373-93cb-f5d2130e1889")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/CPVApplication/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/CSPApplication.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2026 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSPApplication", "CSPApplication\CSPApplication.csproj", "{9283AF7A-6CA9-4373-93CB-F5D2130E1889}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {9283AF7A-6CA9-4373-93CB-F5D2130E1889}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {9283AF7A-6CA9-4373-93CB-F5D2130E1889}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {9283AF7A-6CA9-4373-93CB-F5D2130E1889}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {9283AF7A-6CA9-4373-93CB-F5D2130E1889}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {3CBE281A-E046-480F-8FC6-34536B951BEC} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/CSPApplication/Models/AuthenticationResponse.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace CSPApplication.Models 8 | { 9 | using System.Runtime.Serialization; 10 | 11 | /// 12 | /// Represents a response for the authentication system. 13 | /// 14 | [DataContract] 15 | internal sealed class AuthenticationResponse 16 | { 17 | [DataMember(IsRequired = false, Name = "access_token")] 18 | public string AccessToken { get; set; } 19 | 20 | [DataMember(IsRequired = false, Name = "created_on")] 21 | public long CreatedOn { get; set; } 22 | 23 | [DataMember(IsRequired = false, Name = "error")] 24 | public string Error { get; set; } 25 | 26 | [DataMember(IsRequired = false, Name = "error_codes")] 27 | public string[] ErrorCodes { get; set; } 28 | 29 | [DataMember(IsRequired = false, Name = "error_description")] 30 | public string ErrorDescription { get; set; } 31 | 32 | [DataMember(IsRequired = false, Name = "expires_in")] 33 | public long ExpiresIn { get; set; } 34 | 35 | [DataMember(IsRequired = false, Name = "expires_on")] 36 | public long ExpiresOn { get; set; } 37 | 38 | [DataMember(IsRequired = false, Name = "id_token")] 39 | public string IdTokenString { get; set; } 40 | 41 | [DataMember(IsRequired = false, Name = "refresh_token")] 42 | public string RefreshToken { get; set; } 43 | 44 | [DataMember(IsRequired = false, Name = "resource")] 45 | public string Resource { get; set; } 46 | 47 | [DataMember(IsRequired = false, Name = "token_type")] 48 | public string TokenType { get; set; } 49 | } 50 | } -------------------------------------------------------------------------------- /secure-app-model/keyvault/CSPApplication/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("CSPApplication")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("CSPApplication")] 12 | [assembly: AssemblyCopyright("Copyright © 2018")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("9283af7a-6ca9-4373-93cb-f5d2130e1889")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Build and Revision Numbers 32 | // by using the '*' as shown below: 33 | // [assembly: AssemblyVersion("1.0.*")] 34 | [assembly: AssemblyVersion("1.0.0.0")] 35 | [assembly: AssemblyFileVersion("1.0.0.0")] 36 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/CSPApplication/Utilities/KeyVaultProvider.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace CSPApplication.Utilities 8 | { 9 | using System.Configuration; 10 | using System.Net.Http; 11 | using System.Threading.Tasks; 12 | using Microsoft.Azure.KeyVault; 13 | using Microsoft.Azure.KeyVault.Models; 14 | using Newtonsoft.Json.Linq; 15 | 16 | /// 17 | /// Provider for accessing secrets from the Azure KeyVault 18 | /// 19 | public class KeyVaultProvider 20 | { 21 | private readonly string KeyVaultClientId = ConfigurationManager.AppSettings["ida:KeyVaultClientId"]; 22 | private readonly string KeyVaultClientSecret = ConfigurationManager.AppSettings["ida:KeyVaultClientSecret"]; 23 | private readonly string BaseUrl = ConfigurationManager.AppSettings["KeyVaultEndpoint"]; 24 | 25 | /// 26 | /// The client used to perform HTTP operations. 27 | /// 28 | private static readonly HttpClient httpClient = new HttpClient(); 29 | 30 | public async Task GetSecretAsync(string key) 31 | { 32 | KeyVaultClient keyVault = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(GetToken), httpClient); 33 | 34 | SecretBundle secret = await keyVault.GetSecretAsync(BaseUrl, key.Replace("@", string.Empty).Replace(".", string.Empty)); 35 | return secret.Value; 36 | } 37 | 38 | private async Task GetToken(string authority, string resource, string scope) 39 | { 40 | JObject tokenResult = await AuthorizationUtilities.GetADAppToken(authority, resource, KeyVaultClientId, KeyVaultClientSecret); 41 | return tokenResult["access_token"].ToString(); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /secure-app-model/keyvault/CSPApplication/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27130.2026 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PartnerConsent", "PartnerConsent\PartnerConsent.csproj", "{CCD6D318-8E1F-4825-9A2F-AFA6DF76933C}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {CCD6D318-8E1F-4825-9A2F-AFA6DF76933C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {CCD6D318-8E1F-4825-9A2F-AFA6DF76933C}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {CCD6D318-8E1F-4825-9A2F-AFA6DF76933C}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {CCD6D318-8E1F-4825-9A2F-AFA6DF76933C}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {52BF6D3C-3E96-42D3-A9C7-0F0C18A3D962} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/App_Start/BundleConfig.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace PartnerConsent 8 | { 9 | using System.Web.Optimization; 10 | 11 | public static class BundleConfig 12 | { 13 | public static void RegisterBundles(BundleCollection bundles) 14 | { 15 | bundles.Add(new StyleBundle("~/Content/css").Include( 16 | "~/Content/site.css")); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/App_Start/FilterConfig.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace PartnerConsent 8 | { 9 | using System.Web.Mvc; 10 | 11 | public static class FilterConfig 12 | { 13 | public static void RegisterGlobalFilters(GlobalFilterCollection filters) 14 | { 15 | filters.Add(new HandleErrorAttribute()); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/App_Start/RouteConfig.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace PartnerConsent 8 | { 9 | using System.Web.Mvc; 10 | using System.Web.Routing; 11 | 12 | public static class RouteConfig 13 | { 14 | /// 15 | /// Register ASP.NET routes for the web application 16 | /// 17 | /// 18 | public static void RegisterRoutes(RouteCollection routes) 19 | { 20 | routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); 21 | 22 | routes.MapRoute( 23 | name: "Default", 24 | url: "{controller}/{action}/{id}", 25 | defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } 26 | ); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/ApplicationInsights.config: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/Content/Site.css: -------------------------------------------------------------------------------- 1 | body { 2 | padding-top: 50px; 3 | padding-bottom: 20px; 4 | } 5 | 6 | /* Set padding to keep content from hitting the edges */ 7 | .body-content { 8 | padding-left: 15px; 9 | padding-right: 15px; 10 | } 11 | 12 | /* Override the default bootstrap behavior where horizontal description lists 13 | will truncate terms that are too long to fit in the left column 14 | */ 15 | .dl-horizontal dt { 16 | white-space: normal; 17 | } 18 | 19 | /* Set width on the form input elements since they're 100% wide by default */ 20 | input, 21 | select, 22 | textarea { 23 | max-width: 280px; 24 | } 25 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/Controllers/HomeController.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace PartnerConsent.Controllers 8 | { 9 | using System.Linq; 10 | using System.Security.Claims; 11 | using System.Web.Mvc; 12 | 13 | [Authorize] 14 | public class HomeController : Controller 15 | { 16 | /// 17 | /// Homepage - this is an example of response the consent application can present 18 | /// 19 | /// 20 | public ActionResult Index() 21 | { 22 | ClaimsIdentity identity = HttpContext.User.Identity as ClaimsIdentity; 23 | 24 | return View(identity.Claims.Where(m => m.Type.Equals(@"http://schemas.microsoft.com/claims/authnmethodsreferences"))); 25 | } 26 | 27 | /// 28 | /// Error page controller to capture exceptions. 29 | /// This is default implementation and must be tuned to specific experience for an application 30 | /// 31 | /// 32 | public ActionResult Error() 33 | { 34 | return View(); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.asax.cs" Inherits="PartnerConsent.MvcApplication" Language="C#" %> 2 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/Global.asax.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | namespace PartnerConsent 8 | { 9 | using System.Web.Mvc; 10 | using System.Web.Optimization; 11 | using System.Web.Routing; 12 | 13 | public class MvcApplication : System.Web.HttpApplication 14 | { 15 | protected void Application_Start() 16 | { 17 | AreaRegistration.RegisterAllAreas(); 18 | FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); 19 | RouteConfig.RegisterRoutes(RouteTable.Routes); 20 | BundleConfig.RegisterBundles(BundleTable.Bundles); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | // General Information about an assembly is controlled through the following 5 | // set of attributes. Change these attribute values to modify the information 6 | // associated with an assembly. 7 | [assembly: AssemblyTitle("PartnerConsent")] 8 | [assembly: AssemblyDescription("")] 9 | [assembly: AssemblyConfiguration("")] 10 | [assembly: AssemblyCompany("")] 11 | [assembly: AssemblyProduct("PartnerConsent")] 12 | [assembly: AssemblyCopyright("Copyright © 2018")] 13 | [assembly: AssemblyTrademark("")] 14 | [assembly: AssemblyCulture("")] 15 | 16 | // Setting ComVisible to false makes the types in this assembly not visible 17 | // to COM components. If you need to access a type in this assembly from 18 | // COM, set the ComVisible attribute to true on that type. 19 | [assembly: ComVisible(false)] 20 | 21 | // The following GUID is for the ID of the typelib if this project is exposed to COM 22 | [assembly: Guid("4fcd2826-5f2b-45ba-9268-172736b3e212")] 23 | 24 | // Version information for an assembly consists of the following four values: 25 | // 26 | // Major Version 27 | // Minor Version 28 | // Build Number 29 | // Revision 30 | // 31 | // You can specify all the values or you can default the Revision and Build Numbers 32 | // by using the '*' as shown below: 33 | [assembly: AssemblyVersion("1.0.0.0")] 34 | [assembly: AssemblyFileVersion("1.0.0.0")] 35 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/Startup.cs: -------------------------------------------------------------------------------- 1 | // ----------------------------------------------------------------------- 2 | // 3 | // Copyright (c) Microsoft Corporation. All rights reserved. 4 | // 5 | // ----------------------------------------------------------------------- 6 | 7 | [assembly: Microsoft.Owin.OwinStartup(typeof(PartnerConsent.Startup))] 8 | 9 | namespace PartnerConsent 10 | { 11 | using Owin; 12 | 13 | public partial class Startup 14 | { 15 | public void Configuration(IAppBuilder app) 16 | { 17 | ConfigureAuth(app); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/Views/Home/Index.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Collections.Generic; 2 | @using System.Linq 3 | @using System.Security.Claims 4 | 5 |
6 |

Partner Consent

7 |
8 | 9 |
10 |
11 |

Consent successful

12 |

13 | Partner consent to application has been granted. 14 | For more information on how to manage the application in your Active directory tenant, please check here 15 | You can manage applications at https://myapps.microsoft.com 16 |

17 |

18 | close 19 |

20 |

21 | 22 | @{ 23 | IEnumerable claims = Model; 24 | Claim mfaClaim = claims.FirstOrDefault(c => c.Value.Equals("mfa", StringComparison.InvariantCultureIgnoreCase)); 25 | 26 | if (mfaClaim == null) 27 | { 28 |

29 | Warning You have not authenticated using multi-factor authentication. 30 |

31 | } 32 | } 33 |

34 |
35 |
-------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/Views/Shared/Error.cshtml: -------------------------------------------------------------------------------- 1 | @model System.Web.Mvc.HandleErrorInfo 2 | 3 | @{ 4 | ViewBag.Title = "Error"; 5 | } 6 | 7 |

Error.

8 |

An error occurred while processing your request.

9 | 10 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/Views/Shared/_Layout.cshtml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | Partner Consent 7 | @Styles.Render("~/Content/css") 8 | @Scripts.Render("~/bundles/modernizr") 9 | 10 | 11 |
12 | @RenderBody() 13 |
14 | @RenderSection("scripts", required: false) 15 | 16 | 17 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/Views/Web.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/Views/_ViewStart.cshtml: -------------------------------------------------------------------------------- 1 | @{ 2 | Layout = "~/Views/Shared/_Layout.cshtml"; 3 | } 4 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/Web.Debug.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/Web.Release.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /secure-app-model/keyvault/PartnerConsent/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/Partner-Center-DotNet-Samples/103415a19e6b142bd718f76786bf54ecac756f36/secure-app-model/keyvault/PartnerConsent/favicon.ico --------------------------------------------------------------------------------