import { RulesValidationError } from "../error_handling/RulesValidationError" ; import { AuthenticationModel } from "./AuthenticationModel" ; /**
 * Type that describes an object that maps a key to a value.
 */ export type DataProviderHeaders = { [ header ] : string ; } ; /**
 * Data Model to describe external service data providers
 */ export class DataProviderModel { /**
     * Default timeout for external calls
     */ public static readonly defaultTimeoutInMilliseconds = 500 ; param id param authentication param headers param timeoutInMilliseconds constructor ( public readonly id , public readonly authentication , public readonly headers = { } , public readonly timeoutInMilliseconds = DataProviderModel . defaultTimeoutInMilliseconds ) { } param input param authentication static fromJSON ( input , authentication ? ) { const { id , authentication : inputAuthentication , headers = { } , timeoutInMilliseconds = DataProviderModel . defaultTimeoutInMilliseconds } = input ; const authenticationInstance = inputAuthentication ? AuthenticationModel . fromJSON ( inputAuthentication ) : authentication ; if ( ! id ) { throw new RulesValidationError ( 'missing required "id" property' ) ; } if ( ! authenticationInstance ) { throw new RulesValidationError ( 'authentication is not configured' ) ; } return new DataProviderModel ( id , authenticationInstance , headers , timeoutInMilliseconds ) ; } }