Skip to content

Commit

Permalink
Merge pull request #79 from datalogics-tsmith/up-samples
Browse files Browse the repository at this point in the history
PDFCLOUD-4066 Add up-toolkit samples
  • Loading branch information
datalogics-jacksonm authored Sep 24, 2024
2 parents 9e8b30d + a0d7416 commit bbd4177
Show file tree
Hide file tree
Showing 12 changed files with 222 additions and 0 deletions.
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"

0 comments on commit bbd4177

Please sign in to comment.