Skip to content

Commit

Permalink
fix: accept type null from usage prop from Onomondo API
Browse files Browse the repository at this point in the history
Closes #19
  • Loading branch information
Lenakh97 committed Jul 1, 2024
1 parent b2154de commit 0e929c2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lambda/onomondo/fetchOnomondoSimDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export const fetchOnomondoSIMDetails = async ({

export const SimInfo = Type.Object({
data_limit: Type.Object({
used: Type.Number({ minimum: 0, examples: [0, 100, 1000] }),
used: Type.Union([
Type.Number({ minimum: 0, examples: [0, 100, 1000] }),
Type.Null(),
]),
total: Type.Number({ examples: [4000, 40000, 400000] }),
}),
})
Expand Down
2 changes: 1 addition & 1 deletion lambda/onomondo/getUsageData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { SimInfoType } from './fetchOnomondoSimDetails.js'

export const getUsageData = (apiData: SimInfoType): SimDetails => {
return {
usedBytes: apiData.data_limit.used,
usedBytes: apiData.data_limit.used ?? 0,
totalBytes: apiData.data_limit.total,
}
}

0 comments on commit 0e929c2

Please sign in to comment.