Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: findAllCustomerPastUsage API result mismatches from the type #57

Open
avznog opened this issue Nov 21, 2024 · 0 comments
Open

[BUG]: findAllCustomerPastUsage API result mismatches from the type #57

avznog opened this issue Nov 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@avznog
Copy link

avznog commented Nov 21, 2024

Describe the bug
Hello,
When using the client to fetch the PastUsage of a customer using the findAllCustomerPastUsage method, the typing differs from what is returned from the API :
The typing returns a CustomerPastUsage type which has a usage_period: CustomerUsage[] attribute, but the data itself returned has a usage_period: CustomerUsageObject[] attribute instead.

To Reproduce
Steps to reproduce the behavior:

  1. Implement this method:
async getCurrentUsage(subscriptions: Subscription) {
    const currentUsage: {
      subscription: Subscription;
      customerPastUsage: CustomerPastUsage;
    }[] = [];
    await Promise.all(
      subscriptions.map(async sub => {
        const usage = await this.client.customers.findAllCustomerPastUsage(id, {
          external_subscription_id: sub.external_id
        });
        currentUsage.push({ subscription: sub, customerPastUsage: usage.data });
      })
    );
    console.log(currentUsage[2].customerPastUsage.usage_periods[0]);
    console.log(
      currentUsage[2].customerPastUsage.usage_periods[0].customer_usage
    );
    return currentUsage;
  }
  1. Check the data returned
{
  "from_datetime": "2024-11-18T12:56:43Z",
  "to_datetime": "2024-11-18T12:57:29Z",
  "issuing_date": "2024-11-18",
  "currency": "EUR",
  "amount_cents": 333,
  "total_amount_cents": 400,
  "taxes_amount_cents": 67,
  "lago_invoice_id": "8c69-8c69-8c69-8c69-4a08847d3318",
  "charges_usage": [
    {
      "units": "0.0",
      "events_count": 0,
      "amount_cents": 0,
      "amount_currency": "EUR",
      "charge": {
        "lago_id": "1e981898-8c69-8c69-8c69-a9f9bc3158ba",
        "charge_model": "standard",
        "invoice_display_name": ""
      },
      "billable_metric": {
        "lago_id": "1e656c4f-8c69-8c69-8c69-d45b442ab0a1",
        "name": "MyPlan active user seat",
        "code": "plan:active-user",
        "aggregation_type": "unique_count_agg"
      },
      "filters": [],
      "groups": [],
      "grouped_usage": []
    },
    {
      "units": "0.0",
      "events_count": 0,
      "amount_cents": 0,
      "amount_currency": "EUR",
      "charge": {
        "lago_id": "5a6896d3-8c69-8c69-8c69-775f2bfacb3b",
        "charge_model": "standard",
        "invoice_display_name": ""
      },
      "billable_metric": {
        "lago_id": "3253c24e-8c69-8c69-8c69-b13ca62525c2",
        "name": "myplan tome",
        "code": "myplan:ingested-tome",
        "aggregation_type": "count_agg"
      },
      "filters": [],
      "groups": [],
      "grouped_usage": []
    },
    {
      "units": "0.0",
      "events_count": 0,
      "amount_cents": 0,
      "amount_currency": "EUR",
      "charge": {
        "lago_id": "e434918d-8c69-8c69-8c69-895d8ada1510",
        "charge_model": "standard",
        "invoice_display_name": ""
      },
      "billable_metric": {
        "lago_id": "75ede326-8c69-8c69-8c69-bb8570e302b1",
        "name": "My plan query",
        "code": "myplan:user-query",
        "aggregation_type": "count_agg"
      },
      "filters": [],
      "groups": [],
      "grouped_usage": []
    }
  ]
}

Expected behavior
The API data returned should match the typing : as the documentation of Lago API Ref mentions here, the typing and the API should return a usage_period: CustomerUsage[] object.

Screenshots
image
image
The returned data

Support

  • OS: Linux Ubuntu
  • Browser: safari
@avznog avznog added the bug Something isn't working label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant