Skip to content

Commit 47c8254

Browse files
committed
support delete pdf api call
1 parent 725975e commit 47c8254

File tree

7 files changed

+14
-128
lines changed

7 files changed

+14
-128
lines changed

Api2Pdf.DotNet/Api2Pdf.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class Api2PdfResponse
2828
public double Cost { get; set; }
2929
public bool Success { get; set; }
3030
public string Error { get; set; }
31+
public string ResponseId { get; set; }
3132

3233
public void SavePdf(string localPath)
3334
{
@@ -71,6 +72,11 @@ public Api2PdfResponse Merge(IEnumerable<string> pdfUrls, bool inline = false, s
7172

7273
return _httpClient.PostPdfRequest<Api2PdfResponse>($"{API_BASE_URL}/merge", mergeRequest);
7374
}
75+
76+
public Api2PdfResponse Delete(string responseId)
77+
{
78+
return _httpClient.DeletePdfRequest<Api2PdfResponse>($"{API_BASE_URL}/pdf/{responseId}");
79+
}
7480
}
7581

7682
public class LibreOfficeHandler

Api2Pdf.DotNet/Extensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,13 @@ public static T PostPdfRequest<T>(this HttpClient httpClient, string url, object
1717
var content = new StringContent(JsonConvert.SerializeObject(obj, serializerSettings));
1818
return JsonConvert.DeserializeObject<T>(httpClient.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result);
1919
}
20+
21+
public static T DeletePdfRequest<T>(this HttpClient httpClient, string url)
22+
{
23+
var serializerSettings = new JsonSerializerSettings();
24+
serializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
25+
26+
return JsonConvert.DeserializeObject<T>(httpClient.DeleteAsync(url).Result.Content.ReadAsStringAsync().Result);
27+
}
2028
}
2129
}

Examples.ConsoleApp/App.config

Lines changed: 0 additions & 6 deletions
This file was deleted.

Examples.ConsoleApp/Examples.ConsoleApp.csproj

Lines changed: 0 additions & 62 deletions
This file was deleted.

Examples.ConsoleApp/Program.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

Examples.ConsoleApp/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

Examples.ConsoleApp/packages.config

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)