function SpotifyApiResponseValidator(e,t){function f(){l(),u&&c()}function l(){n=SpotifyWorker.ResponseMessageCode.SUCCESS,r="",i=0,o="NO_ERROR",u=t,a={valid:!1}}function c(t){var a,f=t||u,l,c;for(c=0;c<f.responses.length;c++){s=f.responses[c].status?f.responses[c].status.toString():"",l=f.responses[c].responseJSON;if(l){if(l.error){if(typeof l.error=="string")n=l.error,r=l.error_description,i=e.errorDefines.getErrorCode("MUSIC_SERVICE_ACCOUNT_LOGIN_AUTHENTICATION_FAILED"),o="MUSIC_SERVICE_ACCOUNT_LOGIN_AUTHENTICATION_FAILED";else{n=l.error.status,r=l.error.message;switch(n){case SpotifyWorker.ResponseMessageCode.UNAUTHORIZED:i=e.errorDefines.getErrorCode("SPOTIFY_UNAUTHORIZED_ACCESS"),o="SPOTIFY_UNAUTHORIZED_ACCESS";break;case SpotifyWorker.ResponseMessageCode.BAD_REQUEST:i=e.errorDefines.getErrorCode("MUSIC_SERVICE_API_ERROR"),o="MUSIC_SERVICE_API_ERROR";break;case SpotifyWorker.ResponseMessageCode.NO_CONTENT:i=e.errorDefines.getErrorCode("MUSIC_SERVICE_EMPTY_RESPONSE"),o="MUSIC_SERVICE_EMPTY_RESPONSE";break;case SpotifyWorker.ResponseMessageCode.FORBIDDEN:i=e.errorDefines.getErrorCode("SPOTIFY_FORBIDDEN_RESOURCE"),o="SPOTIFY_FORBIDDEN_RESOURCE";break;case SpotifyWorker.ResponseMessageCode.SERVICE_UNAVAILABLE:i=e.errorDefines.getErrorCode("MUSIC_SERVICE_COULD_NOT_CONNECT"),o="MUSIC_SERVICE_COULD_NOT_CONNECT";break;default:i=e.errorDefines.getErrorCode("MUSIC_SERVICE_API_ERROR"),o="MUSIC_SERVICE_RETRIVING_DATA_FAILED"}}break}}else try{var h=JSON.parse(f.responses[c].responseText);if(h.error){r=h.error_description||"",n=h.error||"",i=e.errorDefines.getErrorCode("MUSIC_SERVICE_API_ERROR"),o="MUSIC_SERVICE_RETRIVING_DATA_FAILED";break}}catch(p){i=e.errorDefines.getErrorCode("MUSIC_SERVICE_PARSE_ERROR"),o="MUSIC_SERVICE_PARSE_ERROR";break}}}function h(){return n===SpotifyWorker.ResponseMessageCode.UNAUTHORIZED}function p(){var e={valid:!0};if(n!==SpotifyWorker.ResponseMessageCode.SUCCESS||i!==0)e={valid:!1,errorCode:i,errorName:o,errorResponse:s,spotifyErrorCode:n,spotifyErrorMessage:r};return e}function d(){return n===SpotifyWorker.ResponseMessageCode.SUCCESS&&i===0}var n,r,i,s,o,u,a;this.getValidationResults=p,this.isValid=d,this.needToRefreshAccessToken=h,f()};