From a0d741680c862bf505de9f9255bb24f54e346d48 Mon Sep 17 00:00:00 2001 From: Taylor Smith Date: Wed, 18 Sep 2024 11:51:35 -0500 Subject: [PATCH] Add up-toolkit samples --- .../JSON Payload/up-toolkit.cs | 14 +++++++++ .../Multipart Payload/up-toolkit.cs | 14 +++++++++ .../JSON Payload/UpToolkit.java | 31 +++++++++++++++++++ .../Multipart Payload/UpToolkit.java | 31 +++++++++++++++++++ .../JSON Payload/up-toolkit.js | 19 ++++++++++++ .../Multipart Payload/up-toolkit.js | 19 ++++++++++++ .../JSON Payload/up-toolkit.php | 29 +++++++++++++++++ .../Multipart Payload/up-toolkit.php | 29 +++++++++++++++++ .../JSON Payload/up-toolkit.py | 16 ++++++++++ .../Multipart Payload/up-toolkit.py | 16 ++++++++++ .../JSON Payload/up-toolkit.sh | 2 ++ .../Multipart Payload/up-toolkit.sh | 2 ++ 12 files changed, 222 insertions(+) create mode 100644 DotNET/Endpoint Examples/JSON Payload/up-toolkit.cs create mode 100644 DotNET/Endpoint Examples/Multipart Payload/up-toolkit.cs create mode 100644 Java/Endpoint Examples/JSON Payload/UpToolkit.java create mode 100644 Java/Endpoint Examples/Multipart Payload/UpToolkit.java create mode 100644 JavaScript/Endpoint Examples/JSON Payload/up-toolkit.js create mode 100644 JavaScript/Endpoint Examples/Multipart Payload/up-toolkit.js create mode 100644 PHP/Endpoint Examples/JSON Payload/up-toolkit.php create mode 100644 PHP/Endpoint Examples/Multipart Payload/up-toolkit.php create mode 100644 Python/Endpoint Examples/JSON Payload/up-toolkit.py create mode 100644 Python/Endpoint Examples/Multipart Payload/up-toolkit.py create mode 100755 cURL/Endpoint Examples/JSON Payload/up-toolkit.sh create mode 100755 cURL/Endpoint Examples/Multipart Payload/up-toolkit.sh diff --git a/DotNET/Endpoint Examples/JSON Payload/up-toolkit.cs b/DotNET/Endpoint Examples/JSON Payload/up-toolkit.cs new file mode 100644 index 0000000..64f36f5 --- /dev/null +++ b/DotNET/Endpoint Examples/JSON Payload/up-toolkit.cs @@ -0,0 +1,14 @@ +using (var httpClient = new HttpClient { BaseAddress = new Uri("https://api.pdfrest.com") }) +{ + // up-forms and up-office can be used to query the other tools + using (var request = new HttpRequestMessage(HttpMethod.Get, "up-toolkit")) + { + + var response = await httpClient.SendAsync(request); + + var apiResult = await response.Content.ReadAsStringAsync(); + + Console.WriteLine("API response received."); + Console.WriteLine(apiResult); + } +} diff --git a/DotNET/Endpoint Examples/Multipart Payload/up-toolkit.cs b/DotNET/Endpoint Examples/Multipart Payload/up-toolkit.cs new file mode 100644 index 0000000..64f36f5 --- /dev/null +++ b/DotNET/Endpoint Examples/Multipart Payload/up-toolkit.cs @@ -0,0 +1,14 @@ +using (var httpClient = new HttpClient { BaseAddress = new Uri("https://api.pdfrest.com") }) +{ + // up-forms and up-office can be used to query the other tools + using (var request = new HttpRequestMessage(HttpMethod.Get, "up-toolkit")) + { + + var response = await httpClient.SendAsync(request); + + var apiResult = await response.Content.ReadAsStringAsync(); + + Console.WriteLine("API response received."); + Console.WriteLine(apiResult); + } +} diff --git a/Java/Endpoint Examples/JSON Payload/UpToolkit.java b/Java/Endpoint Examples/JSON Payload/UpToolkit.java new file mode 100644 index 0000000..561cb4b --- /dev/null +++ b/Java/Endpoint Examples/JSON Payload/UpToolkit.java @@ -0,0 +1,31 @@ +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import org.json.JSONObject; + +public class UpToolkit { + + public static void main(String[] args) { + // up-forms and up-office can be used to query the other tools + Request request = new Request.Builder().url("https://api.pdfrest.com/up-toolkit").get().build(); + try { + OkHttpClient client = + new OkHttpClient().newBuilder().readTimeout(60, TimeUnit.SECONDS).build(); + + Response response = client.newCall(request).execute(); + System.out.println("Processing Result code " + response.code()); + if (response.body() != null) { + System.out.println(prettyJson(response.body().string())); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private static String prettyJson(String json) { + // https://stackoverflow.com/a/9583835/11996393 + return new JSONObject(json).toString(4); + } +} diff --git a/Java/Endpoint Examples/Multipart Payload/UpToolkit.java b/Java/Endpoint Examples/Multipart Payload/UpToolkit.java new file mode 100644 index 0000000..561cb4b --- /dev/null +++ b/Java/Endpoint Examples/Multipart Payload/UpToolkit.java @@ -0,0 +1,31 @@ +import java.io.IOException; +import java.util.concurrent.TimeUnit; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; +import org.json.JSONObject; + +public class UpToolkit { + + public static void main(String[] args) { + // up-forms and up-office can be used to query the other tools + Request request = new Request.Builder().url("https://api.pdfrest.com/up-toolkit").get().build(); + try { + OkHttpClient client = + new OkHttpClient().newBuilder().readTimeout(60, TimeUnit.SECONDS).build(); + + Response response = client.newCall(request).execute(); + System.out.println("Processing Result code " + response.code()); + if (response.body() != null) { + System.out.println(prettyJson(response.body().string())); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private static String prettyJson(String json) { + // https://stackoverflow.com/a/9583835/11996393 + return new JSONObject(json).toString(4); + } +} diff --git a/JavaScript/Endpoint Examples/JSON Payload/up-toolkit.js b/JavaScript/Endpoint Examples/JSON Payload/up-toolkit.js new file mode 100644 index 0000000..bb20131 --- /dev/null +++ b/JavaScript/Endpoint Examples/JSON Payload/up-toolkit.js @@ -0,0 +1,19 @@ +// This request demonstrates how to check the status of the API servers +const axios = require("axios"); + +let config = { + method: "get", + maxBodyLength: Infinity, // set maximum length of the request body + url: "https://api.pdfrest.com/up-toolkit", // up-forms and up-office can be used to query the other tools + headers: {}, +}; + +// define configuration options for axios request +axios + .request(config) + .then((response) => { + console.log(JSON.stringify(response.data)); + }) + .catch((error) => { + console.log(error); + }); diff --git a/JavaScript/Endpoint Examples/Multipart Payload/up-toolkit.js b/JavaScript/Endpoint Examples/Multipart Payload/up-toolkit.js new file mode 100644 index 0000000..bb20131 --- /dev/null +++ b/JavaScript/Endpoint Examples/Multipart Payload/up-toolkit.js @@ -0,0 +1,19 @@ +// This request demonstrates how to check the status of the API servers +const axios = require("axios"); + +let config = { + method: "get", + maxBodyLength: Infinity, // set maximum length of the request body + url: "https://api.pdfrest.com/up-toolkit", // up-forms and up-office can be used to query the other tools + headers: {}, +}; + +// define configuration options for axios request +axios + .request(config) + .then((response) => { + console.log(JSON.stringify(response.data)); + }) + .catch((error) => { + console.log(error); + }); diff --git a/PHP/Endpoint Examples/JSON Payload/up-toolkit.php b/PHP/Endpoint Examples/JSON Payload/up-toolkit.php new file mode 100644 index 0000000..47be1ea --- /dev/null +++ b/PHP/Endpoint Examples/JSON Payload/up-toolkit.php @@ -0,0 +1,29 @@ + diff --git a/PHP/Endpoint Examples/Multipart Payload/up-toolkit.php b/PHP/Endpoint Examples/Multipart Payload/up-toolkit.php new file mode 100644 index 0000000..47be1ea --- /dev/null +++ b/PHP/Endpoint Examples/Multipart Payload/up-toolkit.php @@ -0,0 +1,29 @@ + diff --git a/Python/Endpoint Examples/JSON Payload/up-toolkit.py b/Python/Endpoint Examples/JSON Payload/up-toolkit.py new file mode 100644 index 0000000..ba27e23 --- /dev/null +++ b/Python/Endpoint Examples/JSON Payload/up-toolkit.py @@ -0,0 +1,16 @@ +import requests +import json + +# up-forms and up-office can be used to query the other tools +up_url = f"https://api.pdfrest.com/up-toolkit" + +print("Sending GET request to /up-toolkit endpoint...") +response = requests.get(up_url) + +print("Response status code: " + str(response.status_code)) + +if response.ok: + response_json = response.json() + print(json.dumps(response_json, indent = 2)) +else: + print(response.text) diff --git a/Python/Endpoint Examples/Multipart Payload/up-toolkit.py b/Python/Endpoint Examples/Multipart Payload/up-toolkit.py new file mode 100644 index 0000000..ba27e23 --- /dev/null +++ b/Python/Endpoint Examples/Multipart Payload/up-toolkit.py @@ -0,0 +1,16 @@ +import requests +import json + +# up-forms and up-office can be used to query the other tools +up_url = f"https://api.pdfrest.com/up-toolkit" + +print("Sending GET request to /up-toolkit endpoint...") +response = requests.get(up_url) + +print("Response status code: " + str(response.status_code)) + +if response.ok: + response_json = response.json() + print(json.dumps(response_json, indent = 2)) +else: + print(response.text) diff --git a/cURL/Endpoint Examples/JSON Payload/up-toolkit.sh b/cURL/Endpoint Examples/JSON Payload/up-toolkit.sh new file mode 100755 index 0000000..e66dd9e --- /dev/null +++ b/cURL/Endpoint Examples/JSON Payload/up-toolkit.sh @@ -0,0 +1,2 @@ +#up-forms and up-office can be used to query the other tools +curl -X GET "https://api.pdfrest.com/up-toolkit" diff --git a/cURL/Endpoint Examples/Multipart Payload/up-toolkit.sh b/cURL/Endpoint Examples/Multipart Payload/up-toolkit.sh new file mode 100755 index 0000000..e66dd9e --- /dev/null +++ b/cURL/Endpoint Examples/Multipart Payload/up-toolkit.sh @@ -0,0 +1,2 @@ +#up-forms and up-office can be used to query the other tools +curl -X GET "https://api.pdfrest.com/up-toolkit"