/// <summary> /// Gets a list of customers from Partner Center. /// </summary> /// <param name="customerId">Identifier of the customer.</param> /// <exception cref="System.ArgumentException"> /// <paramref name="customerId"/> is empty or null. /// </exception> private void GetEntitlements(string customerId) { IEnumerable <Entitlement> entitlements; customerId.AssertNotEmpty(nameof(customerId)); entitlements = Partner.Customers[customerId].Entitlements.GetAsync(ShowExpiry.ToBool()).GetAwaiter().GetResult().Items; WriteObject(entitlements.Select(e => new PSEntitlement(e)), true); }
/// <summary> /// Executes the operations associated with the cmdlet. /// </summary> public override void ExecuteCmdlet() { Scheduler.RunTask(async() => { IPartner partner = await PartnerSession.Instance.ClientFactory.CreatePartnerOperationsAsync(CorrelationId, CancellationToken).ConfigureAwait(false); ResourceCollection <Entitlement> entitlements = await partner.Customers[CustomerId].Entitlements.GetAsync(ShowExpiry.ToBool(), CancellationToken).ConfigureAwait(false); if (string.IsNullOrEmpty(OrderId)) { WriteObject(entitlements.Items.Select(e => new PSEntitlement(e)), true); } else { WriteObject(entitlements.Items.Where(e => e.ReferenceOrder.Id == OrderId).Select(e => new PSEntitlement(e)), true); } }, true); }