Skip to content

Commit cf1d068

Browse files
authored
Add Document Field Detection endpoint (#567)
1 parent 03e3935 commit cf1d068

180 files changed

Lines changed: 13773 additions & 401 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Text.Json;
5+
6+
using Dropbox.Sign.Api;
7+
using Dropbox.Sign.Client;
8+
using Dropbox.Sign.Model;
9+
10+
namespace Dropbox.SignSandbox;
11+
12+
public class DocumentDetectFieldsExample
13+
{
14+
public static void Run()
15+
{
16+
var config = new Configuration();
17+
config.Username = "YOUR_API_KEY";
18+
// config.AccessToken = "YOUR_ACCESS_TOKEN";
19+
20+
var documentFieldDetectionRequest = new DocumentFieldDetectionRequest(
21+
detectionMode: "annotations",
22+
file: new FileStream(
23+
path: "./example_document.pdf",
24+
mode: FileMode.Open
25+
),
26+
pageRange: "all"
27+
);
28+
29+
try
30+
{
31+
var response = new DocumentApi(config).DocumentDetectFields(
32+
documentFieldDetectionRequest: documentFieldDetectionRequest
33+
);
34+
35+
Console.WriteLine(response);
36+
}
37+
catch (ApiException e)
38+
{
39+
Console.WriteLine("Exception when calling DocumentApi#DocumentDetectFields: " + e.Message);
40+
Console.WriteLine("Status Code: " + e.ErrorCode);
41+
Console.WriteLine(e.StackTrace);
42+
}
43+
}
44+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.dropbox.sign_sandbox;
2+
3+
import com.dropbox.sign.ApiException;
4+
import com.dropbox.sign.Configuration;
5+
import com.dropbox.sign.api.*;
6+
import com.dropbox.sign.auth.*;
7+
import com.dropbox.sign.JSON;
8+
import com.dropbox.sign.model.*;
9+
10+
import java.io.File;
11+
import java.math.BigDecimal;
12+
import java.time.LocalDate;
13+
import java.time.OffsetDateTime;
14+
import java.util.ArrayList;
15+
import java.util.List;
16+
import java.util.Map;
17+
18+
public class DocumentDetectFieldsExample
19+
{
20+
public static void main(String[] args)
21+
{
22+
var config = Configuration.getDefaultApiClient();
23+
((HttpBasicAuth) config.getAuthentication("api_key")).setUsername("YOUR_API_KEY");
24+
// ((HttpBearerAuth) config.getAuthentication("oauth2")).setBearerToken("YOUR_ACCESS_TOKEN");
25+
26+
var documentFieldDetectionRequest = new DocumentFieldDetectionRequest();
27+
documentFieldDetectionRequest.detectionMode("annotations");
28+
documentFieldDetectionRequest._file(new File("./example_document.pdf"));
29+
documentFieldDetectionRequest.pageRange("all");
30+
31+
try
32+
{
33+
var response = new DocumentApi(config).documentDetectFields(
34+
documentFieldDetectionRequest
35+
);
36+
37+
System.out.println(response);
38+
} catch (ApiException e) {
39+
System.err.println("Exception when calling DocumentApi#documentDetectFields");
40+
System.err.println("Status code: " + e.getCode());
41+
System.err.println("Reason: " + e.getResponseBody());
42+
System.err.println("Response headers: " + e.getResponseHeaders());
43+
e.printStackTrace();
44+
}
45+
}
46+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace Dropbox\SignSandbox;
4+
5+
require_once __DIR__ . '/../vendor/autoload.php';
6+
7+
use SplFileObject;
8+
use Dropbox;
9+
10+
$config = Dropbox\Sign\Configuration::getDefaultConfiguration();
11+
$config->setUsername("YOUR_API_KEY");
12+
// $config->setAccessToken("YOUR_ACCESS_TOKEN");
13+
14+
$document_field_detection_request = (new Dropbox\Sign\Model\DocumentFieldDetectionRequest())
15+
->setDetectionMode("annotations")
16+
->setFile(new SplFileObject("./example_document.pdf"))
17+
->setPageRange("all");
18+
19+
try {
20+
$response = (new Dropbox\Sign\Api\DocumentApi(config: $config))->documentDetectFields(
21+
document_field_detection_request: $document_field_detection_request,
22+
);
23+
24+
print_r($response);
25+
} catch (Dropbox\Sign\ApiException $e) {
26+
echo "Exception when calling DocumentApi#documentDetectFields: {$e->getMessage()}";
27+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import json
2+
from datetime import date, datetime
3+
from pprint import pprint
4+
5+
from dropbox_sign import ApiClient, ApiException, Configuration, api, models
6+
7+
configuration = Configuration(
8+
username="YOUR_API_KEY",
9+
# access_token="YOUR_ACCESS_TOKEN",
10+
)
11+
12+
with ApiClient(configuration) as api_client:
13+
document_field_detection_request = models.DocumentFieldDetectionRequest(
14+
detection_mode="annotations",
15+
file=open("./example_document.pdf", "rb").read(),
16+
page_range="all",
17+
)
18+
19+
try:
20+
response = api.DocumentApi(api_client).document_detect_fields(
21+
document_field_detection_request=document_field_detection_request,
22+
)
23+
24+
pprint(response)
25+
except ApiException as e:
26+
print("Exception when calling DocumentApi#document_detect_fields: %s\n" % e)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
require "json"
2+
require "dropbox-sign"
3+
4+
Dropbox::Sign.configure do |config|
5+
config.username = "YOUR_API_KEY"
6+
# config.access_token = "YOUR_ACCESS_TOKEN"
7+
end
8+
9+
document_field_detection_request = Dropbox::Sign::DocumentFieldDetectionRequest.new
10+
document_field_detection_request.detection_mode = "annotations"
11+
document_field_detection_request.file = File.new("./example_document.pdf", "r")
12+
document_field_detection_request.page_range = "all"
13+
14+
begin
15+
response = Dropbox::Sign::DocumentApi.new.document_detect_fields(
16+
document_field_detection_request,
17+
)
18+
19+
p response
20+
rescue Dropbox::Sign::ApiError => e
21+
puts "Exception when calling DocumentApi#document_detect_fields: #{e}"
22+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
curl -X POST 'https://api.hellosign.com/v3/document/detect_fields' \
2+
-u 'YOUR_API_KEY:' \
3+
-F 'file=@example_document.pdf' \
4+
-F 'detection_mode=annotations' \
5+
-F 'page_range=all'
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as fs from 'fs';
2+
import api from "@dropbox/sign"
3+
import models from "@dropbox/sign"
4+
5+
const apiCaller = new api.DocumentApi();
6+
apiCaller.username = "YOUR_API_KEY";
7+
// apiCaller.accessToken = "YOUR_ACCESS_TOKEN";
8+
9+
const documentFieldDetectionRequest: models.DocumentFieldDetectionRequest = {
10+
detectionMode: "annotations",
11+
file: fs.createReadStream("./example_document.pdf"),
12+
pageRange: "all",
13+
};
14+
15+
apiCaller.documentDetectFields(
16+
documentFieldDetectionRequest,
17+
).then(response => {
18+
console.log(response.body);
19+
}).catch(error => {
20+
console.log("Exception when calling DocumentApi#documentDetectFields:");
21+
console.log(error.body);
22+
});

0 commit comments

Comments
 (0)