(payload)
| 1051 | } |
| 1052 | |
| 1053 | function creditsFromPayload(payload) { |
| 1054 | const required = numberField(payload, 'required'); |
| 1055 | const available = numberField(payload, 'available'); |
| 1056 | const estimated = firstNumberField(payload, ['estimated', 'estimate']); |
| 1057 | const charged = numberField(payload, 'charged'); |
| 1058 | const balanceKind = safeTokenField(stringField(payload, 'balance_kind') || stringField(payload, 'balanceKind')); |
| 1059 | const out = {}; |
| 1060 | if (required !== undefined) out.required = required; |
| 1061 | if (available !== undefined) out.available = available; |
| 1062 | if (estimated !== undefined) out.estimated = estimated; |
| 1063 | if (charged !== undefined) out.charged = charged; |
| 1064 | if (balanceKind) out.balance_kind = balanceKind; |
| 1065 | return Object.keys(out).length ? out : undefined; |
| 1066 | } |
| 1067 | |
| 1068 | function normalizePublishStatus(body) { |
| 1069 | const b = record(body) || {}; |
no test coverage detected