import { ErrorCode } from '@ulangi/ulangi-common/enums' ; import * as _ from 'lodash' ; export class IapErrorConverter { private errorCodeMapping : { [ P in string ] : ErrorCode ; } = { E_USER_CANCELLED : ErrorCode . GENERAL__USER_CANCELLED , } ; public isIapError ( error ) { return _ . includes ( _ . keys ( this . errorCodeMapping ) , _ . get ( error , 'code' ) ) ; } public convertToErrorCode ( error ) { if ( this . isIapError ( error ) ) { return this . errorCodeMapping [ error . code ] ; } else { return ErrorCode . GENERAL__UNKNOWN_ERROR ; } } }