/// <summary> /// Initializes a new instance of the <see cref="ReconciliationLineItemCollectionOperations"/> class. /// </summary> /// <param name="rootPartnerOperations">The partner operations.</param> /// <param name="invoiceId">The invoice identifier.</param> /// <param name="billingProvider">The billing provider type.</param> /// <param name="invoiceLineItemType">The invoice line item type.</param> /// <param name="currencyCode">The currency code.</param> /// <param name="period">The period for unbilled recon.</param> /// <param name="size">The page size.</param> public ReconciliationLineItemCollectionOperations(IPartner rootPartnerOperations, string invoiceId, BillingProvider billingProvider, InvoiceLineItemType invoiceLineItemType, string currencyCode, BillingPeriod period, int?size = null) : base(rootPartnerOperations, invoiceId) { invoiceId.AssertNotEmpty(nameof(invoiceId)); currencyCode.AssertNotEmpty(nameof(currencyCode)); this.billingProvider = billingProvider; this.currencyCode = currencyCode; this.invoiceLineItemType = invoiceLineItemType; pageSize = size ?? maxPageSizeReconLineItems; this.period = period; }
/// <summary> /// Gets the line items for the specified invoice. /// </summary> /// <param name="invoiceId">Identifier for the invoice.</param> /// <param name="billingProvider">The provider of billing information.</param> /// <param name="invoiceLineItemType">Type of invoice line items.</param> /// <returns>A list of line items for the specified invoice.</returns> /// <exception cref="ArgumentException"> /// <paramref name="invoiceId"/> is empty or null. /// </exception> public async Task <List <InvoiceLineItem> > GetInvoiceLineItemsAsync(string invoiceId, BillingProvider billingProvider, InvoiceLineItemType invoiceLineItemType) { CustomerPrincipal principal; DateTime startTime; Dictionary <string, double> eventMetrics; Dictionary <string, string> eventProperties; Guid correlationId; IPartner operations; ResourceCollection <InvoiceLineItem> invoiceLineItems; invoiceId.AssertNotEmpty(nameof(invoiceId)); try { startTime = DateTime.Now; correlationId = Guid.NewGuid(); operations = await this.GetUserOperationsAsync(correlationId); principal = (CustomerPrincipal)HttpContext.Current.User; if (!principal.CustomerId.Equals(this.service.Configuration.PartnerCenterApplicationTenantId)) { throw new UnauthorizedAccessException("You are not authorized to perform this operation."); } invoiceLineItems = await operations.Invoices.ById(invoiceId).By(billingProvider, invoiceLineItemType).GetAsync(); // Track the event measurements for analysis. eventMetrics = new Dictionary <string, double> { { "ElapsedMilliseconds", DateTime.Now.Subtract(startTime).TotalMilliseconds }, { "NumberOfInvoiceLineItems", invoiceLineItems.TotalCount } }; // Capture the request for the customer summary for analysis. eventProperties = new Dictionary <string, string> { { "CustomerId", principal.CustomerId }, { "Name", principal.Name }, { "ParternCenterCorrelationId", correlationId.ToString() } }; this.service.Telemetry.TrackEvent("GetInvoiceLineItemsAsync", eventProperties, eventMetrics); return(new List <InvoiceLineItem>(invoiceLineItems.Items)); } finally { eventMetrics = null; eventProperties = null; invoiceLineItems = null; operations = null; principal = null; } }
/// <summary> /// Creates an invoice line item collection operation given a billing provider and invoice line item type. /// </summary> /// <param name="billingProvider">The billing provider.</param> /// <param name="invoiceLineItemType">The invoice line item type.</param> /// <returns>The invoice line item collection operations.</returns> public IInvoiceLineItemCollection By(BillingProvider billingProvider, InvoiceLineItemType invoiceLineItemType) => new InvoiceLineItemCollectionOperations(Partner, Context, billingProvider, invoiceLineItemType);
/// <summary> /// Creates an invoice line item collection operations given a billing provider and invoice line item type. /// </summary> /// <param name="provider">The provider type.</param> /// <param name="invoiceLineItemType">The invoice line item.</param> /// <param name="currencyCode">The currency code.</param> /// <param name="period">The period for unbilled recon.</param> /// <param name="size">The page size.</param> /// <returns>The recon line item collection operations.</returns> public IReconciliationLineItemCollection By(BillingProvider provider, InvoiceLineItemType invoiceLineItemType, string currencyCode, BillingPeriod period, int?size = null) => new ReconciliationLineItemCollectionOperations(Partner, Context, provider, invoiceLineItemType, currencyCode, period, size);
/// <summary> /// Initializes a new instance of the <see cref="InvoiceLineItemCollectionOperations" /> class. /// </summary> /// <param name="rootPartnerOperations">The partner operations.</param> /// <param name="invoiceId">The invoice identifier.</param> /// <param name="billingProvider">The provider of billing information,</param> /// <param name="invoiceLineItemType">The type of invoice line item.</param> public InvoiceLineItemCollectionOperations(IPartner rootPartnerOperations, string invoiceId, BillingProvider billingProvider, InvoiceLineItemType invoiceLineItemType) : base(rootPartnerOperations, invoiceId) { this.billingProvider = billingProvider; this.invoiceLineItemType = invoiceLineItemType; }