Skip to content
This repository was archived by the owner on Jul 22, 2024. It is now read-only.

Commit 8202e36

Browse files
idwilliams-2joelst
authored andcommitted
Added the ability to purchase add-ons using the order feature. (#89)
1 parent daf4a56 commit 8202e36

14 files changed

Lines changed: 264 additions & 42 deletions

docs/help/Connect-PartnerCenter.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,21 @@ Connects to Partner Center with an authenticated account for use with cmdlet req
1515
## SYNTAX
1616

1717
### User (Default)
18+
1819
```powershell
1920
Connect-PartnerCenter -ApplicationId <String> [-EnforceMFA] [-Environment <EnvironmentName>]
2021
[-TenantId <String>] [<CommonParameters>]
2122
```
2223

2324
### AccessToken
25+
2426
```powershell
2527
Connect-PartnerCenter -AccessToken <String> -ApplicationId <String> [-Credential <PSCredential>] [-EnforceMFA]
2628
[-Environment <EnvironmentName>] [-TenantId <String>] [<CommonParameters>]
2729
```
2830

2931
### ServicePrincipal
32+
3033
```powershell
3134
Connect-PartnerCenter [-ApplicationId <String>] -Credential <PSCredential> [-EnforceMFA]
3235
[-Environment <EnvironmentName>] -TenantId <String> [<CommonParameters>]
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
content_git_url: https://github.com/Microsoft/Partner-Center-PowerShell/blob/master/docs/help/Get-PartnerCustomerSubscriptionAddOn.md
3+
external help file: Microsoft.Store.PartnerCenter.PowerShell.dll-Help.xml
4+
Module Name: PartnerCenter
5+
online version: https://docs.microsoft.com/powershell/module/partnercenter/Get-PartnerCustomerSubscriptionAddOn
6+
original_content_git_url: https://github.com/Microsoft/Partner-Center-PowerShell/blob/master/docs/help/Get-PartnerCustomerSubscriptionAddOn.md
7+
8+
schema: 2.0.0
9+
---
10+
11+
# Get-PartnerCustomerSubscriptionAddOn
12+
13+
## SYNOPSIS
14+
Gets the purchased add-ons for the specified subscription.
15+
16+
## SYNTAX
17+
18+
```powershell
19+
Get-PartnerCustomerSubscriptionAddOn -CustomerId <String> -SubscriptionId <String> [<CommonParameters>]
20+
```
21+
22+
## DESCRIPTION
23+
Gets the purchased add-ons for the specified subscription.
24+
25+
## EXAMPLES
26+
27+
### Example 1
28+
```powershell
29+
PS C:\> Get-PartnerCustomerSubscriptionAddOn -CustomerId '46a62ece-10ad-42e5-b3f1-b2ed53e6fc08' -SubscriptionId '775440e2-3a09-4685-bc9e-f1638955c41e'
30+
```
31+
32+
Gets the add-ons for the specified subscription.
33+
34+
## PARAMETERS
35+
36+
### -CustomerId
37+
The identifier for the customer.
38+
39+
```yaml
40+
Type: String
41+
Parameter Sets: (All)
42+
Aliases:
43+
44+
Required: True
45+
Position: Named
46+
Default value: None
47+
Accept pipeline input: False
48+
Accept wildcard characters: False
49+
```
50+
51+
### -SubscriptionId
52+
The identifier for the subscription.
53+
54+
```yaml
55+
Type: String
56+
Parameter Sets: (All)
57+
Aliases:
58+
59+
Required: True
60+
Position: Named
61+
Default value: None
62+
Accept pipeline input: False
63+
Accept wildcard characters: False
64+
```
65+
66+
### CommonParameters
67+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).
68+
69+
## INPUTS
70+
71+
### None
72+
73+
## OUTPUTS
74+
75+
### Microsoft.Store.PartnerCenter.PowerShell.Models.Subscriptions.PSSubscription
76+
77+
## NOTES
78+
79+
## RELATED LINKS

docs/help/New-PartnerCustomerOrder.md

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,18 @@ Create a new order for the specified services on behalf of the customer.
1414

1515
## SYNTAX
1616

17-
```powershell
17+
### Subscription (Default)
18+
```
1819
New-PartnerCustomerOrder -CustomerId <String> -LineItems <PSOrderLineItem[]> [-WhatIf] [-Confirm]
1920
[<CommonParameters>]
2021
```
2122

23+
### AddOn
24+
```
25+
New-PartnerCustomerOrder -CustomerId <String> -LineItems <PSOrderLineItem[]> -OrderId <String> [-WhatIf]
26+
[-Confirm] [<CommonParameters>]
27+
```
28+
2229
## DESCRIPTION
2330
Create a new order for the specified services on behalf of the customer.
2431

@@ -33,10 +40,29 @@ PS C:\> $lineItem.LineItemNumber = 0
3340
PS C:\> $lineItem.OfferId = '031C9E47-4802-4248-838E-778FB1D2CC05'
3441
PS C:\> $lineItem.Quantity = 1
3542
PS C:\>
36-
PS C:\> New-PartnerCustomerOrder -CustomerId '46a62ece-10ad-42e5-b3f1-b2ed53e6fc08' -LineItems $lineItem
43+
PS C:\> New-PartnerCustomerOrder -CustomerId '46a62ece-10ad-42e5-b3f1-b2ed53e6fc08' -LineItems @($lineItem)
3744
```
3845

39-
Create a new order for the specified services on behalf of the customer.
46+
Creates a new order for the specified services on behalf of the customer.
47+
48+
### Example 2
49+
50+
```powershell
51+
PS C:\> $s = Get-PartnerCustomer -CustomerId '46a62ece-10ad-42e5-b3f1-b2ed53e6fc08' -SubscriptionId '10704f2f-3fc6-4e42-8acf-08df4f81c93c'
52+
PS C:\> $addOn = Get-PartnerOfferAddon -OfferId $s.OfferId | Where-Object {$_.Name -eq 'Microsoft MyAnalytics'}
53+
PS C:\>
54+
PS C:\> $lineItem = New-Object -TypeName Microsoft.Store.PartnerCenter.PowerShell.Models.Orders.PSOrderLineItem
55+
PS C:\>
56+
PS C:\> $lineItem.LineItemNumber = 0
57+
PS C:\> $lineItem.OfferId = $addOn.OfferId
58+
PS C:\> $lineItem.Quantity = 1
59+
PS C:\> $lineItem.FriendlyName = $addOn.Name
60+
PS C:\> $lineItem.ParentSubscriptionId = $s.SubscriptionId
61+
PS C:\>
62+
PS C:\> New-PartnerCustomerOrder -CustomerId '46a62ece-10ad-42e5-b3f1-b2ed53e6fc08' -LineItems @($lineItem) -OrderId $s.OrderId
63+
```
64+
65+
Creates an order to purchase an add-on for the specific subscription on behalf of the customer. This example shows how to purchase the Microsoft MyAnalytics add-on for the specified subscription. In this case the specified subscription is an Office 365 E3 subscription.
4066

4167
## PARAMETERS
4268

@@ -71,6 +97,21 @@ Accept pipeline input: False
7197
Accept wildcard characters: False
7298
```
7399
100+
### -OrderId
101+
The order identifier used when purchasing an add-on.
102+
103+
```yaml
104+
Type: String
105+
Parameter Sets: AddOn
106+
Aliases:
107+
108+
Required: True
109+
Position: Named
110+
Default value: None
111+
Accept pipeline input: False
112+
Accept wildcard characters: False
113+
```
114+
74115
### -Confirm
75116
Prompts you for confirmation before running the cmdlet.
76117

docs/help/PartnerCenter.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ Gets a list of licenses available to users of the specified customer.
8686
### [Get-PartnerCustomerSubscription](Get-PartnerCustomerSubscription.md)
8787
Gets a list or a single customer subscription.
8888

89+
### [Get-PartnerCustomerSubscriptionAddOn](Get-PartnerCustomerSubscriptionAddOn.md)
90+
Gets the purchased add-ons for the specified subscription.
91+
8992
### [Get-PartnerCustomerSubscriptionProvisioningStatus](Get-PartnerCustomerSubscriptionProvisioningStatus.md)
9093
Gets the provisioning status for the specified subscription.
9194

@@ -258,7 +261,7 @@ Update a subscription's support contact to one of the partner's value added rese
258261
Updates the specified customer user account.
259262

260263
### [Set-PartnerCustomerUserLicense](Set-PartnerCustomerUserLicense.md)
261-
Adds or removes licenses for a Microsoft online service to the list of assigned licenses for a user.
264+
Adds or removes licenses for a Microsoft online service to the list of assigned licenses for a user.
262265

263266
### [Set-PartnerLegalProfile](Set-PartnerLegalProfile.md)
264267
Updates the partner's legal profile.
@@ -279,4 +282,5 @@ Checks out the specified cart.
279282
Tests whether or not the specified address is valid.
280283

281284
### [Test-PartnerDomainAvailability](Test-PartnerDomainAvailability.md)
282-
Tests if the specified domain name is available for creating a new tenant.
285+
Tests if the specified domain name is available for creating a new tenant.
286+

src/PartnerCenter.TestFramework/PartnerCenter.TestFramework.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<PackageProjectUrl>https://github.com/Microsoft/Partner-Center-PowerShell</PackageProjectUrl>
1313
<RepositoryUrl>https://github.com/Microsoft/Partner-Center-PowerShell.git</RepositoryUrl>
1414
<RepositoryType>git</RepositoryType>
15-
<Version>1.5.1902.4</Version>
15+
<Version>1.5.1902.5</Version>
1616
<NeutralLanguage>en-US</NeutralLanguage>
1717
</PropertyGroup>
1818

src/PartnerCenter/Models/Orders/Order.cs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ namespace Microsoft.Store.PartnerCenter.Models.Orders
88
{
99
using System;
1010
using System.Collections.Generic;
11-
using Newtonsoft.Json;
1211
using Offers;
1312

1413
/// <summary>
@@ -17,44 +16,43 @@ namespace Microsoft.Store.PartnerCenter.Models.Orders
1716
public sealed class Order : ResourceBase
1817
{
1918
/// <summary>
20-
/// Gets or sets the order identifier.
19+
/// Gets or sets the type of billing cycle for the selected offers.
2120
/// </summary>
22-
public string Id { get; set; }
21+
public BillingCycleType BillingCycle { get; set; }
2322

2423
/// <summary>
25-
/// Gets or sets the reference customer identifier.
24+
/// Gets or sets the creation date of the order.
2625
/// </summary>
27-
public string ReferenceCustomerId { get; set; }
26+
public DateTime? CreationDate { get; set; }
2827

2928
/// <summary>
30-
/// Gets or sets the type of billing cycle for the selected offers.
29+
/// Gets or sets the currency code.
3130
/// </summary>
32-
public BillingCycleType BillingCycle { get; set; }
31+
public string CurrencyCode { get; set; }
3332

3433
/// <summary>
35-
/// Gets or sets the currency code.
34+
/// Gets or sets the order identifier.
3635
/// </summary>
37-
[JsonProperty]
38-
public string CurrencyCode { get; set; }
36+
public string Id { get; set; }
3937

4038
/// <summary>
4139
/// Gets or sets the Order line items. Each order line item refers to one offer's purchase data.
4240
/// </summary>
4341
public IEnumerable<OrderLineItem> LineItems { get; set; }
4442

4543
/// <summary>
46-
/// Gets or sets the creation date of the order.
44+
/// Gets or sets the links corresponding to the order.
4745
/// </summary>
48-
public DateTime? CreationDate { get; set; }
46+
public OrderLinks Links { get; set; }
4947

5048
/// <summary>
5149
/// Gets or sets the order status.
5250
/// </summary>
5351
public string Status { get; set; }
5452

5553
/// <summary>
56-
/// Gets or sets the links corresponding to the order.
54+
/// Gets or sets the reference customer identifier.
5755
/// </summary>
58-
public OrderLinks Links { get; set; }
56+
public string ReferenceCustomerId { get; set; }
5957
}
60-
}
58+
}

src/PartnerCenter/Models/Orders/OrderLineItems.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ namespace Microsoft.Store.PartnerCenter.Models.Orders
1313
/// </summary>
1414
public sealed class OrderLineItem : ResourceBaseWithLinks<OrderLineItemLinks>
1515
{
16+
/// <summary>
17+
/// Initializes a new instance of the <see cref="OrderLineItem" /> class.
18+
/// </summary>
19+
public OrderLineItem()
20+
{
21+
ProvisioningContext = new Dictionary<string, string>();
22+
}
23+
1624
/// <summary>
1725
/// Gets or sets the line item number.
1826
/// </summary>
@@ -52,6 +60,6 @@ public sealed class OrderLineItem : ResourceBaseWithLinks<OrderLineItemLinks>
5260
/// <summary>
5361
/// Gets or sets the provisioning context for the offer.
5462
/// </summary>
55-
public Dictionary<string, string> ProvisioningContext { get; set; }
63+
public Dictionary<string, string> ProvisioningContext { get; private set; }
5664
}
57-
}
65+
}

src/PartnerCenter/Network/PartnerServiceClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,7 @@ private JsonSerializerSettings GetSerializationSettings(JsonConverter converter
920920
}
921921
},
922922
ContractResolver = new PrivateContractResolver(),
923+
CheckAdditionalContent = true,
923924
DateFormatHandling = DateFormatHandling.IsoDateFormat,
924925
DateTimeZoneHandling = DateTimeZoneHandling.Utc,
925926
NullValueHandling = NullValueHandling.Ignore,

src/PartnerCenter/PartnerCenter.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<Copyright>Copyright © 2019</Copyright>
1010
<NeutralLanguage>en-US</NeutralLanguage>
1111
<Product>Microsoft Partner Center</Product>
12-
<Version>1.5.1902.4</Version>
12+
<Version>1.5.1902.5</Version>
1313
<PackageLicenseUrl>https://github.com/Microsoft/Partner-Center-PowerShell/blob/master/LICENSE</PackageLicenseUrl>
1414
<PackageProjectUrl>https://github.com/Microsoft/Partner-Center-PowerShell</PackageProjectUrl>
1515
<RepositoryUrl>https://github.com/Microsoft/Partner-Center-PowerShell.git</RepositoryUrl>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// -----------------------------------------------------------------------
2+
// <copyright file=GetPartnerCustomerSubscriptionAddOn.cs" company="Microsoft">
3+
// Copyright (c) Microsoft Corporation. All rights reserved.
4+
// </copyright>
5+
// -----------------------------------------------------------------------
6+
7+
namespace Microsoft.Store.PartnerCenter.PowerShell.Commands
8+
{
9+
using System.Linq;
10+
using System.Management.Automation;
11+
using System.Text.RegularExpressions;
12+
using Models.Subscriptions;
13+
using PartnerCenter.Models;
14+
using PartnerCenter.Models.Subscriptions;
15+
16+
[Cmdlet(VerbsCommon.Get, "PartnerCustomerSubscriptionAddOn"), OutputType(typeof(PSSubscription))]
17+
public class GetPartnerCustomerSubscriptionAddOn : PartnerPSCmdlet
18+
{
19+
/// <summary>
20+
/// Gets or sets the customer identifier.
21+
/// </summary>
22+
[Parameter(HelpMessage = "The identifier for the customer.", Mandatory = true)]
23+
[ValidatePattern(@"^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$", Options = RegexOptions.Compiled | RegexOptions.IgnoreCase)]
24+
public string CustomerId { get; set; }
25+
26+
/// <summary>
27+
/// Gets or sets the subscription identifier.
28+
/// </summary>
29+
[Parameter(HelpMessage = "The identifier for the subscription.", Mandatory = true)]
30+
[ValidatePattern(@"^(\{){0,1}[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}(\}){0,1}$", Options = RegexOptions.Compiled | RegexOptions.IgnoreCase)]
31+
public string SubscriptionId { get; set; }
32+
33+
/// <summary>
34+
/// Executes the operations associated with the cmdlet.
35+
/// </summary>
36+
public override void ExecuteCmdlet()
37+
{
38+
ResourceCollection<Subscription> subscripions = Partner.Customers[CustomerId].Subscriptions[SubscriptionId].AddOns.Get();
39+
WriteObject(subscripions.Items.Select(s => new PSSubscription(s)), true);
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)