in src/PowerShell/Commands/GetPartnerProduct.cs [72:105]
public override void ExecuteCmdlet()
{
Scheduler.RunTask(async () =>
{
IPartner partner = await PartnerSession.Instance.ClientFactory.CreatePartnerOperationsAsync(CorrelationId, CancellationToken).ConfigureAwait(false);
IProductCollectionByCountry operations = partner.Products.ByCountry(string.IsNullOrEmpty(CountryCode) ? PartnerSession.Instance.Context.CountryCode : CountryCode);
if (ParameterSetName == ByProductIdParameterSetName)
{
WriteObject(new PSProduct(await operations.ById(ProductId).GetAsync(CancellationToken).ConfigureAwait(false)));
}
else if (ParameterSetName == ByReservationScopeParameterSetName)
{
WriteObject(
new PSProduct(
await operations.ById(ProductId).ByReservationScope(ReservationScope).GetAsync(CancellationToken).ConfigureAwait(false)));
}
else if (ParameterSetName == ByTargetViewParameterSetName)
{
ResourceCollection<Product> products;
if (string.IsNullOrEmpty(Segment))
{
products = await operations.ByTargetView(Catalog).GetAsync(CancellationToken).ConfigureAwait(false);
}
else
{
products = await operations.ByTargetView(Catalog).ByTargetSegment(Segment).GetAsync(CancellationToken).ConfigureAwait(false);
}
WriteObject(products.Items.Select(p => new PSProduct(p)), true);
}
}, true);
}