private static IdfyException BuildIdfyException(IdfyResponse response, HttpStatusCode statusCode, string requestUri, string responseContent) { var idfyError = Mapper <IdfyError> .MapFromJson(responseContent, response); return(new IdfyException(statusCode, idfyError, idfyError.Message) { IdfyResponse = response }); }
public static T MapFromJson(string json, IdfyResponse idfyResponse = null) { var result = JsonConvert.DeserializeObject <T>(json); if (idfyResponse == null) { return(result); } foreach (var prop in result.GetType().GetRuntimeProperties()) { if (prop.Name == nameof(IdfyResponse)) { prop.SetValue(result, idfyResponse); } } return(result); }
public static T MapFromJson(IdfyResponse idfyResponse) { return(MapFromJson(idfyResponse.ResponseJson, idfyResponse)); }