-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from datalogics-tsmith/up-samples
PDFCLOUD-4066 Add up-toolkit samples
- Loading branch information
Showing
12 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
19
JavaScript/Endpoint Examples/Multipart Payload/up-toolkit.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |