private static IllegalApiResponseException GetInvalidAccessTokenException(OmniKassaErrorResponse response) { if (response.ErrorMessage != null) { return(new InvalidAccessTokenException(response.ErrorMessage)); } return(new InvalidAccessTokenException()); }
/// <summary> /// Helper function to initialize an IllegalApiResponseException by parsing the JSON /// </summary> /// <param name="json">JSON containing the API error</param> /// <returns>New instance of IllegalApiResponseException</returns> public static IllegalApiResponseException Of(String json) { OmniKassaErrorResponse response = JsonConvert.DeserializeObject <OmniKassaErrorResponse>(json); if (response.ErrorCode == InvalidAccessTokenException.INVALID_AUTHORIZATION_ERROR_CODE) { if (response.ConsumerMessage != null && response.ConsumerMessage.ToLower().Equals("invalid or missing signature")) { return(new IllegalSignatureException(response.ErrorCode, response.ConsumerMessage)); } else { return(GetInvalidAccessTokenException(response)); } } if (response.ConsumerMessage != null) { return(new IllegalApiResponseException(response.ErrorCode, response.ConsumerMessage)); } return(new IllegalApiResponseException(response.ErrorCode)); }