(estimatedCostUsd: number)
| 73 | }; |
| 74 | |
| 75 | function convertUsdToCredits(estimatedCostUsd: number) { |
| 76 | if (estimatedCostUsd <= 0) { |
| 77 | return 0; |
| 78 | } |
| 79 | |
| 80 | // If a request costs any non-zero amount, charge at least 1 credit, then |
| 81 | // round up so partial credits always become a whole credit. |
| 82 | return Math.max(1, Math.ceil(estimatedCostUsd / USD_PER_CREDIT)); |
| 83 | }; |
| 84 | |
| 85 | |
| 86 | export function calculateCreditsForUsage({ |
no outgoing calls
no test coverage detected