public static async Task <bool> ProcessToCsv(this FormRegisterRequestBuilder builder, PyrusClient client, string filePath, CsvSettings settings = null) { var csvResult = await ProcessToCsv(builder, client, settings); System.IO.File.WriteAllText(filePath, csvResult.Csv, settings?.Encoding ?? Encoding.UTF8); return(csvResult.Success); }
public static async Task <CsvResponse> ProcessToCsv(this FormRegisterRequestBuilder builder, PyrusClient client, CsvSettings settings = null) { FormRegisterRequest request = builder; request.Encoding = settings?.Encoding?.EncodingName; request.Delimiter = settings?.Delimiter; request.SimpleFormat = settings?.SimpleFormat ?? false; request.ResponseFormat = ResponseFormat.Csv; var response = await client.GetRegistry(builder.FormId, request); if (response?.ErrorCode != null) { return new CsvResponse { Csv = $"Unexpected error occured: {JsonConvert.SerializeObject(response)}", Success = false } } ; return(new CsvResponse { Csv = response?.Csv, Success = true }); } #endregion }
public static async Task <FormRegisterResponse> Process(this FormRegisterRequestBuilder builder, PyrusClient client) { return(await client.GetRegistry(builder.FormId, builder)); }