Skip to content

Commit

Permalink
Add up-toolkit samples
Browse files Browse the repository at this point in the history
  • Loading branch information
datalogics-tsmith committed Sep 18, 2024
1 parent a68ab70 commit 08a6605
Show file tree
Hide file tree
Showing 12 changed files with 244 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);
}
}
42 changes: 42 additions & 0 deletions Java/Endpoint Examples/JSON Payload/UpToolkit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONObject;

import java.io.Console;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;

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);
}
}
42 changes: 42 additions & 0 deletions Java/Endpoint Examples/Multipart Payload/UpToolkit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.json.JSONObject;

import java.io.Console;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;

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 08a6605

Please sign in to comment.