Obtient les éléments de ligne de facturation commerciale non facturésGet invoice unbilled commercial consumption line items

S’applique à :Applies to:

  • Espace partenairesPartner Center

Procédure d’obtention d’un regroupement de détails sur les lignes de consommation commerciale non facturées.How to get a collection of unbilled commercial consumption line item details.

Vous pouvez utiliser les méthodes suivantes pour obtenir une collection de détails lignes de consommation commerciale non facturées (également appelées « éléments de ligne d’utilisation ouverts ») par programmation.You can use the following methods to get a collection of details unbilled commercial consumption line items (also known as open usage line items) programmatically.

Notes

L’utilisation à l’aide d’une évaluation quotidienne prend normalement 24 heures pour s’afficher dans l’espace partenaires ou pour être accessible via l’API.Daily-rated usage normally takes 24 hours to appear in Partner Center or to be accessed through the API.

PrérequisPrerequisites

  • Informations d’identification, comme décrit dans Authentification auprès de l’Espace partenaires.Credentials as described in Partner Center authentication. Ce scénario prend en charge l’authentification avec les informations d’identification de l’application autonome et de l’application + utilisateur.This scenario supports authentication with both standalone App and App+User credentials.

  • Identificateur de la facture.An invoice identifier. Cela permet d’identifier la facture pour laquelle récupérer les éléments de ligne.This identifies the invoice for which to retrieve the line items.

C#C#

Pour obtenir les lignes de la facture spécifiée :To get the line items for the specified invoice:

  1. Appelez la méthode méthode BYID pour obtenir une interface permettant de facturer les opérations pour la facture spécifiée.Call the ById method to get an interface to invoice operations for the specified invoice.

  2. Appelez la méthode GetAsync pour récupérer l’objet de la facture .Call the Get or GetAsync method to retrieve the invoice object.

L' objet Invoice contient toutes les informations relatives à la facture spécifiée.The invoice object contains all of the information for the specified invoice. Le fournisseur identifie la source des informations de détail non facturées (par exemple, OneTime).The Provider identifies the source of the unbilled detail information (for example, OneTime). InvoiceLineItemType spécifie le type (par exemple, UsageLineItem).The InvoiceLineItemType specifies the type (for example, UsageLineItem).

L’exemple de code suivant utilise une boucle foreach pour traiter la collection InvoiceLineItems .The following example code uses a foreach loop to process the InvoiceLineItems collection. Une collection distincte d’éléments de ligne est récupérée pour chaque InvoiceLineItemType.A separate collection of line items is retrieved for each InvoiceLineItemType.

Pour obtenir une collection d’éléments de ligne qui correspondent à une instance InvoiceDetail :To get a collection of line items that correspond to an InvoiceDetail instance:

  1. Transmettez le BillingProvider et le InvoiceLineItemType de l’instance à la méthode par .Pass the instance's BillingProvider and InvoiceLineItemType to the By method.

  2. Appelez la méthode GetAsync pour récupérer les éléments de ligne associés.Call the Get or GetAsync method to retrieve the associated line items.

  3. Créez un énumérateur pour parcourir la collection comme indiqué dans l’exemple suivant.Create an enumerator to traverse the collection as shown in the following example.

// IAggregatePartner partnerOperations;
// string curencyCode;
// string period;
// int pageMaxSizeReconLineItems = 2000;

// all the operations executed on this partner operation instance will share the same correlation Id but will differ in request Id
IPartner scopedPartnerOperations = partnerOperations.With(RequestContextFactory.Instance.Create(Guid.NewGuid()));

var seekBasedResourceCollection = scopedPartnerOperations.Invoices.ById("unbilled").By("onetime", "usagelineitems", curencyCode, period, pageMaxSizeReconLineItems).Get();

var fetchNext = true;

ConsoleKeyInfo keyInfo;

var itemNumber = 1;
while (fetchNext)
{
    Console.Out.WriteLine("\tLine items count: " + seekBasedResourceCollection.Items.Count());

    seekBasedResourceCollection.Items.ToList().ForEach(item =>
    {
        // Instance of type DailyRatedUsageLineItem
        if (item is DailyRatedUsageLineItem)
        {
            Type t = typeof(DailyRatedUsageLineItem);
            PropertyInfo[] properties = t.GetProperties();

            foreach (PropertyInfo property in properties)
            {
                // Insert code here to work with the line item properties
            }
        }
        itemNumber++;
    });

    Console.Out.WriteLine("\tPress any key to fetch next data. Press the Escape (Esc) key to quit: \n");
    keyInfo = Console.ReadKey();

    if (keyInfo.Key == ConsoleKey.Escape)
    {
        break;
    }

    fetchNext = !string.IsNullOrWhiteSpace(seekBasedResourceCollection.ContinuationToken);

    if (fetchNext)
    {
        if (seekBasedResourceCollection.Links.Next.Headers != null && seekBasedResourceCollection.Links.Next.Headers.Any())
        {
            seekBasedResourceCollection = scopedPartnerOperations.Invoices.ById("unbilled").By("onetime", "usagelineitems", curencyCode, period, pageMaxSizeReconLineItems).Seek(seekBasedResourceCollection.ContinuationToken, SeekOperation.Next);
        }
    }
}

Pour obtenir un exemple similaire, consultez :For a similar example, see:

  • Exemple : Application de test de consoleSample: Console test app
  • Projet : exemples du kit de développement logiciel (SDK) Partner CenterProject: Partner Center SDK Samples
  • Classe : GetUnBilledConsumptionReconLineItemsPaging.csClass: GetUnBilledConsumptionReconLineItemsPaging.cs

Demande RESTREST request

Syntaxe de la requêteRequest syntax

Vous pouvez utiliser les syntaxes suivantes pour votre demande REST, en fonction de votre cas d’utilisation.You can use the following syntaxes for your REST request, depending on your use case. Pour plus d’informations, consultez les descriptions de chaque syntaxe.For more information, see the descriptions for each syntax.

MéthodeMethod URI de requêteRequest URI Description du cas d’usage de syntaxeDescription of syntax use case
GETGET {baseURL}/v1/Invoices/unbilled/LineItems ? Provider = OneTime&invoicelineitemtype = usagelineitems&CurrencyCode = {currencycode} &période = {period} http/1.1{baseURL}/v1/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems&currencycode={currencycode}&period={period} HTTP/1.1 Utilisez cette syntaxe pour retourner une liste complète de chaque élément de ligne pour la facture donnée.Use this syntax to return a full list of every line item for the given invoice.
GETGET {baseURL}/v1/Invoices/unbilled/LineItems ? Provider = OneTime&invoicelineitemtype = usagelineitems&CurrencyCode = {currencycode} &période = {period} &Size = {Size} http/1.1{baseURL}/v1/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems&currencycode={currencycode}&period={period}&size={size} HTTP/1.1 Utilisez cette syntaxe pour les factures volumineuses.Use this syntax for large invoices. Utilisez cette syntaxe avec une taille spécifiée et un décalage de base 0 pour retourner une liste paginée d’éléments de ligne.Use this syntax with a specified size and 0-based offset to return a paged list of line items.
GETGET {baseURL}/v1/Invoices/unbilled/LineItems ? Provider = OneTime&invoicelineitemtype = usagelineitems&CurrencyCode = {currencycode} &période = {period} &Size = {size} &SeekOperation = Next{baseURL}/v1/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems&currencycode={currencycode}&period={period}&size={size}&seekOperation=Next Utilisez cette syntaxe pour accéder à la page suivante des éléments de ligne de rapprochement à l’aide de seekOperation = "Next" .Use this syntax to get the next page of reconciliation line items using seekOperation = "Next".

Paramètres d’URIURI parameters

Utilisez l’URI et les paramètres de requête suivants lors de la création de la demande.Use the following URI and query parameters when creating the request.

NomName TypeType ObligatoireRequired DescriptionDescription
providerprovider stringstring OuiYes Le fournisseur : «OneTime».The provider: "OneTime".
invoice-line-item-typeinvoice-line-item-type stringstring OuiYes Type de détail de la facture : «UsageLineItems», «UsageLineItems».The type of invoice detail: "UsageLineItems", "UsageLineItems".
currencyCodecurrencyCode stringstring OuiYes Code de la devise pour les éléments de ligne non facturés.The currency code for the unbilled line items.
periodperiod stringstring OuiYes Période pour le rapprochement non facturé (par exemple : actuel, précédent).The period for unbilled recon (for example: current, previous).

Précédent : si le cycle de facturation est de 01/01/2020 – 01/31/2020, il est probable que votre facture soit générée entre 02/06/2020 et 02/08/2020 heure UTC.Previous – if the billing cycle is 01/01/2020 – 01/31/2020 then, most likely that your invoice is generated between 02/06/2020 and 02/08/2020 UTC time. Si vous avez besoin d’interroger vos données d’utilisation non facturées du cycle de facturation (01/01/2020 – 01/31/2020) à tout moment entre 02/01/2020 et la date générée par la facture (qui est comprise entre 02/06/2020 et 02/08/2020 heure UTC), vous devez choisir période comme « précédent ».If you need to query your unbilled usage data of the billing cycle (01/01/2020 – 01/31/2020) on any time between 02/01/2020 and the invoice-generated date (which is between 02/06/2020 and 02/08/2020 UTC time), then, you need to choose Period as "Previous".

Actuel : si le cycle de facturation est de 01/01/2020 – 01/31/2020, il est probable que votre facture soit générée entre 02/06/2020 et 02/08/2020 heure UTC.Current – if the billing cycle is 01/01/2020 – 01/31/2020 then, most likely that your invoice is generated between 02/06/2020 and 02/08/2020 UTC time. Si vous avez besoin d’interroger vos données d’utilisation non facturées du cycle de facturation (01/01/2020 – 01/31/2020) à tout moment entre 01/01/2020 et 01/31/2020 qui se trouve dans votre cycle de facturation, vous devez choisir période comme « en cours ».If you need to query your unbilled usage data of the billing cycle (01/01/2020 – 01/31/2020) on any time between 01/01/2020 and 01/31/2020 which is within your billing cycle, then, you need to choose Period as "Current".
taillesize nombrenumber NonNo Nombre maximal d’éléments à retourner.The maximum number of items to return. La taille par défaut est 2000.The default size is 2000.
seekOperationseekOperation stringstring NonNo Défini seekOperation=Next pour afficher la page suivante des éléments de ligne de rapprochement.Set seekOperation=Next to get the next page of reconciliation line items.

En-têtes de requêteRequest headers

Pour plus d’informations, consultez En-têtes REST de l’Espace Partenaires.For more information, see Partner Center REST headers.

Corps de demandeRequest body

Aucun.None.

Réponse RESTREST response

En cas de réussite, la réponse contient la collection des détails de l’élément de ligne.If successful, the response contains the collection of line item details.

Pour l’élément de ligne ChargeType, la valeur Purchase est mappée sur New et le remboursement de valeur est mappé sur Cancel.For the line item ChargeType, the value Purchase is mapped to New and the value Refund is mapped to Cancel.

Codes d’erreur et de réussite de la réponseResponse success and error codes

Chaque réponse est accompagnée d’un code d’état HTTP qui indique la réussite ou l’échec ainsi que des informations de débogage supplémentaires.Each response comes with an HTTP status code that indicates success or failure and additional debugging information. Utilisez un outil de trace réseau pour lire ce code, le type d’erreur et des paramètres supplémentaires.Use a network trace tool to read this code, error type, and additional parameters. Pour obtenir la liste complète, consultez Codes d’erreur REST de l’Espace partenaires.For the full list, see Partner Center REST error codes.

Exemples de requêtes-réponsesRequest-response examples

Exemple de requête-réponse 1Request-response example 1

Les détails suivants s’appliquent à cet exemple :The following details apply to this example:

  • Fournisseur: OneTimeProvider: OneTime
  • InvoiceLineItemType: UsageLineItemsInvoiceLineItemType: UsageLineItems
  • Période: précédentePeriod: Previous

Exemple de requête 1Request example 1

GET https://api.partnercenter.microsoft.com/v1//invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems&currencycode=usd&period=previous&size=2000 HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-RequestId: 1234ecb8-37af-45f4-a1a1-358de3ca2b9e
MS-CorrelationId: 5e612512-4345-4bb0-866e-47aeda031234
X-Locale: en-US
MS-PartnerCenter-Application: Partner Center .NET SDK Samples
Host: api.partnercenter.microsoft.com

Exemple de réponse 1Response example 1

HTTP/1.1 200 OK
Content-Length: 2484
Content-Type: application/json; charset=utf-8
MS-CorrelationId: 5e612512-4345-4bb0-866e-47aeda031234
MS-RequestId: 1234ecb8-37af-45f4-a1a1-358de3ca2b9e
MS-CV: bpqyomePDUqrSSYC.0
MS-ServerId: 202010406
Date: Wed, 20 Feb 2019 19:59:27 GMT

{
    "totalCount": 2,
    "items": [
        {
            "partnerId": "00083575-bbd0-54de-b2ad-0f5b0e927d71",
            "partnerName": "MTBC",
            "customerId": "",
            "customerName": "",
            "customerDomainName": "",
            "invoiceNumber": "",
            "productId": "",
            "skuId": "",
            "availabilityId": "",
            "skuName": "VM-Series Next-Generation Firewall (Bundle 2 PAYG)",
            "productName": "VM-Series Next Generation Firewall",
            "publisherName": "Test Alto Networks, Inc.",
            "publisherId": "",
            "subscriptionId": "12345678-04d9-421c-baf8-e3b8dd62ddba",
            "subscriptionDescription": "Pay-As-You-Go",
            "chargeStartDate": "2019-01-01T00:00:00Z",
            "chargeEndDate": "2019-02-01T00:00:00Z",
            "usageDate": "2019-01-01T00:00:00Z",
            "meterType": "1 Compute Hour - 4core",
            "meterCategory": "Virtual Machine Licenses",
            "meterId": "4core",
            "meterSubCategory": "VM-Series Next Generation Firewall",
            "meterName": "VM-Series Next Generation Firewall - VM-Series Next-Generation Firewall (Bundle 2 PAYG) - 4 Core Hours",
            "meterRegion": "",
            "unitOfMeasure": "1 Hour",
            "resourceLocation": "EASTUS",
            "consumedService": "Microsoft.Compute",
            "resourceGroup": "ECH-PAN-RG",
            "resourceUri": "/subscriptions/12345678-04d9-421c-baf8-e3b8dd62ddba/resourceGroups/ECH-PAN-RG/providers/Microsoft.Compute/virtualMachines/echpanfw",
            "tags": "",
            "additionalInfo": "{  \"ImageType\": null,  \"ServiceType\": \"Standard_D3_v2\",  \"VMName\": null,  \"VMProperties\": null,  \"UsageType\": \"ComputeHR_SW\"}",
            "serviceInfo1": "",
            "serviceInfo2": "",
            "customerCountry": "",
            "mpnId": "1234567",
            "resellerMpnId": "",
            "chargeType": "",
            "unitPrice": 1.2799888920023,
            "quantity": 24.0,
            "unitType": "",
            "billingPreTaxTotal": 30.7197334080551,
            "billingCurrency": "USD",
            "pricingPreTaxTotal": 30.7197334080551,
            "pricingCurrency": "USD",
            "entitlementId": "1234547f-b249-4edd-9319-637862d8c0b4",
            "entitlementDescription": "Partner Subscription",
            "pcToBCExchangeRate": 1,
            "pcToBCExchangeRateDate": "2019-08-01T00:00:00Z",
            "effectiveUnitPrice": 0,
            "rateOfPartnerEarnedCredit": 0,
            "invoiceLineItemType": "usage_line_items",
            "billingProvider": "marketplace",
            "attributes": {
                "objectType": "DailyRatedUsageLineItem"
            }
         },
         {
            "partnerId": "00083575-bbd0-54de-b2ad-0f5b0e927d71",
            "partnerName": "MTBC",
            "customerId": "",
            "customerName": "",
            "customerDomainName": "",
            "invoiceNumber": "",
            "productId": "",
            "skuId": "",
            "availabilityId": "",
            "skuName": "VM-Series Next-Generation Firewall (Bundle 2 PAYG)",
            "productName": "VM-Series Next Generation Firewall",
            "publisherName": "Test Alto Networks, Inc.",
            "publisherId": "",
            "subscriptionId": "12345678-04d9-421c-baf8-e3b8dd62ddba",
            "subscriptionDescription": "Pay-As-You-Go",
            "chargeStartDate": "2019-01-01T00:00:00Z",
            "chargeEndDate": "2019-02-01T00:00:00Z",
            "usageDate": "2019-01-02T00:00:00Z",
            "meterType": "1 Compute Hour - 4core",
            "meterCategory": "Virtual Machine Licenses",
            "meterId": "4core",
            "meterSubCategory": "VM-Series Next Generation Firewall",
            "meterName": "VM-Series Next Generation Firewall - VM-Series Next-Generation Firewall (Bundle 2 PAYG) - 4 Core Hours",
            "meterRegion": "",
            "unitOfMeasure": "1 Hour",
            "resourceLocation": "EASTUS",
            "consumedService": "Microsoft.Compute",
            "resourceGroup": "ECH-PAN-RG",
            "resourceUri": "/subscriptions/12345678-04d9-421c-baf8-e3b8dd62ddba/resourceGroups/ECH-PAN-RG/providers/Microsoft.Compute/virtualMachines/echpanfw",
            "tags": "",
            "additionalInfo": "{  \"ImageType\": null,  \"ServiceType\": \"Standard_D3_v2\",  \"VMName\": null,  \"VMProperties\": null,  \"UsageType\": \"ComputeHR_SW\"}",
            "serviceInfo1": "",
            "serviceInfo2": "",
            "customerCountry": "",
            "mpnId": "1234567",
            "resellerMpnId": "",
            "chargeType": "",
            "unitPrice": 1.2799888920023,
            "quantity": 24.0,
            "unitType": "",
            "billingPreTaxTotal": 30.7197334080551,
            "billingCurrency": "USD",
            "pricingPreTaxTotal": 30.7197334080551,
            "pricingCurrency": "USD",
            "entitlementId": "31cdf47f-b249-4edd-9319-637862d12345",
            "entitlementDescription": "Partner Subscription",
            "pcToBCExchangeRate": 1,
            "pcToBCExchangeRateDate": "2019-08-01T00:00:00Z",
            "effectiveUnitPrice": 0,
            "rateOfPartnerEarnedCredit": 0,
            "invoiceLineItemType": "usage_line_items",
            "billingProvider": "marketplace",
            "attributes": {
                "objectType": "DailyRatedUsageLineItem"
            }
        }
    ],
    "links": {
        "self": {
            "uri": "/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems&currencycode=usd&period=previous&size=2000",
            "method": "GET",
            "headers": []
        },
        "next": {
            "uri": "/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems&currencycode=usd&period=previous&size=2000&seekOperation=Next",
            "method": "GET",
            "headers": [
                {
                    "key": "MS-ContinuationToken",
                    "value": "AQAAAA=="
                }
            ]
        }
    },
    "attributes": {
        "objectType": "Collection"
    }
}

Exemple de requête-réponse 2Request-response example 2

Les détails suivants s’appliquent à cet exemple :The following details apply to this example:

  • Fournisseur: OneTimeProvider: OneTime
  • InvoiceLineItemType: UsageLineItemsInvoiceLineItemType: UsageLineItems
  • Période: précédentePeriod: Previous
  • SeekOperation: suivantSeekOperation: Next

Exemple de requête 2Request example 2

GET https://api.partnercenter.microsoft.com/v1/invoices/unbilled/lineitems?provider=onetime&invoiceLineItemType=usagelineitems&currencyCode=usd&period=previous&size=2000&seekoperation=next HTTP/1.1
Authorization: Bearer <token>
Accept: application/json
MS-ContinuationToken: d19617b8-fbe5-4684-a5d8-0230972fb0cf,0705c4a9-39f7-4261-ba6d-53e24a9ce47d_a4ayc/80/OGda4BO/1o/V0etpOqiLx1JwB5S3beHW0s=,0d81c700-98b4-4b13-9129-ffd5620f72e7
MS-RequestId: 1234ecb8-37af-45f4-a1a1-358de3ca2b9e
MS-CorrelationId: 5e612512-4345-4bb0-866e-47aeda031234
X-Locale: en-US
MS-PartnerCenter-Application: Partner Center .NET SDK Samples
Host: api.partnercenter.microsoft.com

Exemple de réponse 2Response example 2

HTTP/1.1 200 OK
Content-Length: 2484
Content-Type: application/json; charset=utf-8
MS-CorrelationId: 5e612512-4345-4bb0-866e-47aeda031234
MS-RequestId: 1234ecb8-37af-45f4-a1a1-358de3ca2b9e
MS-CV: bpqyomePDUqrSSYC.0
MS-ServerId: 202010406
Date: Wed, 20 Feb 2019 19:59:27 GMT

{
    "totalCount": 1,
    "items": [
        {
            "partnerId": "00083575-bbd0-54de-b2ad-0f5b0e927d71",
            "partnerName": "MTBC",
            "customerId": "",
            "customerName": "",
            "customerDomainName": "",
            "invoiceNumber": "",
            "productId": "",
            "skuId": "",
            "availabilityId": "",
            "skuName": "VM-Series Next-Generation Firewall (Bundle 2 PAYG)",
            "productName": "VM-Series Next Generation Firewall",
            "publisherName": "Test Alto Networks, Inc.",
            "publisherId": "",
            "subscriptionId": "12345678-04d9-421c-baf8-e3b8dd62ddba",
            "subscriptionDescription": "Pay-As-You-Go",
            "chargeStartDate": "2019-01-01T00:00:00Z",
            "chargeEndDate": "2019-02-01T00:00:00Z",
            "usageDate": "2019-01-02T00:00:00Z",
            "meterType": "1 Compute Hour - 4core",
            "meterCategory": "Virtual Machine Licenses",
            "meterId": "4core",
            "meterSubCategory": "VM-Series Next Generation Firewall",
            "meterName": "VM-Series Next Generation Firewall - VM-Series Next-Generation Firewall (Bundle 2 PAYG) - 4 Core Hours",
            "meterRegion": "",
            "unitOfMeasure": "1 Hour",
            "resourceLocation": "EASTUS",
            "consumedService": "Microsoft.Compute",
            "resourceGroup": "ECH-PAN-RG",
            "resourceUri": "/subscriptions/12345678-04d9-421c-baf8-e3b8dd62ddba/resourceGroups/ECH-PAN-RG/providers/Microsoft.Compute/virtualMachines/echpanfw",
            "tags": "",
            "additionalInfo": "{  \"ImageType\": null,  \"ServiceType\": \"Standard_D3_v2\",  \"VMName\": null,  \"VMProperties\": null,  \"UsageType\": \"ComputeHR_SW\"}",
            "serviceInfo1": "",
            "serviceInfo2": "",
            "customerCountry": "",
            "mpnId": "1234567",
            "resellerMpnId": "",
            "chargeType": "",
            "unitPrice": 1.2799888920023,
            "quantity": 24.0,
            "unitType": "",
            "billingPreTaxTotal": 30.7197334080551,
            "billingCurrency": "USD",
            "pricingPreTaxTotal": 30.7197334080551,
            "pricingCurrency": "USD",
            "entitlementId": "31cdf47f-b249-4edd-9319-637862d8c0b4",
            "entitlementDescription": "Partner Subscription",
            "pcToBCExchangeRate": 1,
            "pcToBCExchangeRateDate": "2019-08-01T00:00:00Z",
            "effectiveUnitPrice": 0,
            "rateOfPartnerEarnedCredit": 0,
            "invoiceLineItemType": "usage_line_items",
            "billingProvider": "marketplace",
            "attributes": {
                "objectType": "DailyRatedUsageLineItem"
            }
        }
    ],
    "links": {
        "self": {
             "uri": "/invoices/unbilled/lineitems?provider=onetime&invoicelineitemtype=usagelineitems&currencycode=usd&period=previous&size=2000",
            "method": "GET",
            "headers": []
        }
    },
    "attributes": {
        "objectType": "Collection"
    }
}