Skip to content

Latest commit

 

History

History

java

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Anvil usage examples in Java

Welcome to Anvil API usage examples in Java! There are example scripts for the following API actions.

All of these files are within the com.useanvil.examples namespace.

Requirements

These examples were built with Java 11 in mind -- mainly for java.net.http.HttpClient. If you would like to run these examples in older versions of Java, the com.useanvil.examples.client clients should be changed to use a different HTTP client.

Usage

All scripts will require that you have an Anvil API key. See the getting started documentation for help grabbing your API key.

Each example is set up to be runnable with minimal input. Once you have an API key, you can clone this repo and run the example scripts from this directory.

Once you have this repo cloned, cd into this java directory and install the dependencies:

cd java

# Download dependencies and built the .jar file
mvn clean package

[INFO] Building jar: /anvil-api-usage-examples/java/target/Examples-1.0-SNAPSHOT.jar

# Run the example that you want.
# Replace `<example-name>` with one of:
# make-graphql-request, fill-pdf,
# generate-html-to-pdf, generate-markdown-to-pdf,
# create-etch-packet, create-update-workflow
ANVIL_API_KEY="YOUR_KEY_HERE" java -jar target/Examples-1.0-SNAPSHOT.jar <example-name>

The program will output filled and generated PDFs into the output directory.

Fill a PDF template:

ANVIL_API_KEY="YOUR_KEY_HERE" java -jar target/Examples-1.0-SNAPSHOT.jar fill-pdf

Generate a PDF from HTML and CSS:

ANVIL_API_KEY="YOUR_KEY_HERE" java -jar target/Examples-1.0-SNAPSHOT.jar generate-html-to-pdf

Generate a PDF from Markdown:

ANVIL_API_KEY="YOUR_KEY_HERE" java -jar target/Examples-1.0-SNAPSHOT.jar generate-markdown-to-pdf

Creating an e-sign packet:

ANVIL_API_KEY="YOUR_KEY_HERE" java -jar target/Examples-1.0-SNAPSHOT.jar create-etch-packet <[email protected]>

Start and update workflow submissions:

ANVIL_API_KEY="YOUR_KEY_HERE" java -jar target/Examples-1.0-SNAPSHOT.jar create-update-workflow <your-org-slug>

Make an arbitrary GraphQL request:

ANVIL_API_KEY="YOUR_KEY_HERE" java -jar target/Examples-1.0-SNAPSHOT.jar make-graphql-request