/// <summary> /// Gets the specified customer order from Partner Center. /// </summary> /// <param name="customerId">Identifier of the customer.</param> /// <param name="orderId">Identifier of the order.</param> /// <exception cref="System.ArgumentException"> /// <paramref name="customerId"/> is empty or null. /// or /// <paramref name="orderId"/> is empty or null. /// </exception> private void GetCustomerOrder(string customerId, string orderId) { Order order; bool includePrice = IncludePrice.ToBool(); customerId.AssertNotEmpty(nameof(customerId)); orderId.AssertNotEmpty(nameof(orderId)); order = Partner.Customers.ById(customerId).Orders.ById(orderId).GetAsync(includePrice).GetAwaiter().GetResult(); WriteObject(new PSOrder(order)); }
/// <summary> /// Gets a list of customer orders from Partner Center. /// </summary> /// <param name="customerId">Identifier of the customer.</param> /// <param name="billingCycle">BillingCycle identifier.</param> /// <exception cref="System.ArgumentException"> /// <paramref name="customerId"/> is empty or null. /// </exception> private void GetCustomerOrders(string customerId, BillingCycleType?billingCycle) { IEnumerable <Order> orders; bool includePrice = IncludePrice.ToBool(); customerId.AssertNotEmpty(nameof(customerId)); if (billingCycle.HasValue) { orders = Partner.Customers.ById(customerId).Orders.ByBillingCycleType(billingCycle.Value).GetAsync(includePrice).GetAwaiter().GetResult().Items; } else { orders = Partner.Customers.ById(customerId).Orders.GetAsync(includePrice).GetAwaiter().GetResult().Items; } WriteObject(orders.Select(o => new PSOrder(o)), 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); if (string.IsNullOrEmpty(OrderId)) { ResourceCollection <Order> orders; if (BillingCycle.HasValue) { orders = await partner.Customers.ById(CustomerId).Orders.ByBillingCycleType(BillingCycle.Value).GetAsync(IncludePrice.ToBool(), CancellationToken).ConfigureAwait(false); } else { orders = await partner.Customers.ById(CustomerId).Orders.GetAsync(IncludePrice.ToBool(), CancellationToken).ConfigureAwait(false); } WriteObject(orders.Items.Select(o => new PSOrder(o)), true); } else { Order order = await partner.Customers.ById(CustomerId).Orders.ById(OrderId).GetAsync(IncludePrice.ToBool(), CancellationToken).ConfigureAwait(false); WriteObject(new PSOrder(order)); } }, true); }