DeepLcom / deepl-php

Official PHP library for the DeepL language translation API.
MIT License
202 stars 23 forks source link

Usage API may not return limit #33

Closed dsgrillo closed 10 months ago

dsgrillo commented 11 months ago

Currently, the API is only returning the character_count and not the character_limit:

11:31:06 INFO      [app] DeepL API response POST https://api.deepl.com/v2/usage 200
11:31:06 DEBUG     [app] Response details: {"character_count":151629018}

In my use case, we only need to have the character_count, but the implementation discards the response if both are not present:

 private function buildUsageDetail(string $prefix, array $json): ?UsageDetail
    {
        $count = "{$prefix}_count";
        $limit = "{$prefix}_limit";
        if (array_key_exists($count, $json) && array_key_exists($limit, $json)) {
            return new UsageDetail($json[$count], $json[$limit]);
        }
        return null;
    }
daniel-jones-deepl commented 11 months ago

Hi @dsgrillo, thanks for reporting this. I haven't been able to reproduce this, but we're looking into it. The character_limit should always accompany the character_count field. Does the problem occur still?

dsgrillo commented 11 months ago

Thanks for looking into it! Yes, it's still happening. It started around 12:00 on September 18th and has been happening since then. I can also add that the dashboard on the DeepL website is apparently showing wrong numbers.

daniel-jones-deepl commented 11 months ago

I'd like to give an update: we've reproduced the problem and pinpointed the issue; we're working on a fix.

daniel-jones-deepl commented 10 months ago

This issue should be fixed as of Oct 13.