()
| 15 | |
| 16 | export class ProdNpsStatusLookup implements NpsStatusLookup { |
| 17 | async status(): Promise<NpsStatus> { |
| 18 | const resp = await fetch(npsStatusUrl.href) |
| 19 | |
| 20 | if (resp.status === 404) { |
| 21 | return {} |
| 22 | } |
| 23 | if (!resp.ok) { |
| 24 | throw new Error(`Failed to fetch NPS survey status: ${resp.statusText}`) |
| 25 | } |
| 26 | |
| 27 | const obj = await resp.json() |
| 28 | if (!this.checkSchema(obj)) { |
| 29 | throw new Error('Invalid NPS status schema') |
| 30 | } |
| 31 | return obj |
| 32 | } |
| 33 | |
| 34 | checkSchema(obj: any): obj is NpsStatus { |
| 35 | return ( |
no test coverage detected