Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDFCLOUD-4066 Add up-toolkit samples #79

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions DotNET/Endpoint Examples/JSON Payload/up-toolkit.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
14 changes: 14 additions & 0 deletions DotNET/Endpoint Examples/Multipart Payload/up-toolkit.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
31 changes: 31 additions & 0 deletions Java/Endpoint Examples/JSON Payload/UpToolkit.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
31 changes: 31 additions & 0 deletions Java/Endpoint Examples/Multipart Payload/UpToolkit.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
19 changes: 19 additions & 0 deletions JavaScript/Endpoint Examples/JSON Payload/up-toolkit.js
Original file line number Diff line number Diff line change
@@ -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);
});
19 changes: 19 additions & 0 deletions JavaScript/Endpoint Examples/Multipart Payload/up-toolkit.js
Original file line number Diff line number Diff line change
@@ -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);
});
29 changes: 29 additions & 0 deletions PHP/Endpoint Examples/JSON Payload/up-toolkit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

// This request demonstrates how to check the status of the API servers
$up_url = "https://api.pdfrest.com/up-toolkit";

// Initialize a cURL session.
$ch = curl_init();

// Set the url that will be sent to the up-toolkit endpoint.
curl_setopt($ch, CURLOPT_URL, $up_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// up-forms and up-office can be used to query the other tools
print "Sending GET request to /up-toolkit endpoint...\n";
$response = curl_exec($ch);

print "Response status code: " . curl_getinfo($ch, CURLINFO_HTTP_CODE) . "\n";

if($response === false){
print 'Error: ' . curl_error($ch) . "\n";
}else{

print json_encode(json_decode($response), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
print "\n";

}

curl_close($ch);
?>
29 changes: 29 additions & 0 deletions PHP/Endpoint Examples/Multipart Payload/up-toolkit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

// This request demonstrates how to check the status of the API servers
$up_url = "https://api.pdfrest.com/up-toolkit";

// Initialize a cURL session.
$ch = curl_init();

// Set the url that will be sent to the up-toolkit endpoint.
curl_setopt($ch, CURLOPT_URL, $up_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

// up-forms and up-office can be used to query the other tools
print "Sending GET request to /up-toolkit endpoint...\n";
$response = curl_exec($ch);

print "Response status code: " . curl_getinfo($ch, CURLINFO_HTTP_CODE) . "\n";

if($response === false){
print 'Error: ' . curl_error($ch) . "\n";
}else{

print json_encode(json_decode($response), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
print "\n";

}

curl_close($ch);
?>
16 changes: 16 additions & 0 deletions Python/Endpoint Examples/JSON Payload/up-toolkit.py
Original file line number Diff line number Diff line change
@@ -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)
16 changes: 16 additions & 0 deletions Python/Endpoint Examples/Multipart Payload/up-toolkit.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions cURL/Endpoint Examples/JSON Payload/up-toolkit.sh
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 2 additions & 0 deletions cURL/Endpoint Examples/Multipart Payload/up-toolkit.sh
Original file line number Diff line number Diff line change
@@ -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"
Loading