Skip to content

Latest commit

 

History

History
79 lines (60 loc) · 5.46 KB

README.md

File metadata and controls

79 lines (60 loc) · 5.46 KB

Advicement Integration

Description

This example solution showcases how the Advicement APIs can be called from Linx. Use this as the base for your Advicement integration. Data to be populated into the PDFs can be pulled from any data source (database, file, another API), and you can add transformations where required.

There are two main functions:

  • GenerateInvoice - generate an invoice with the Advicement Simple Invoice endpoint
  • GenerateTermSheet - generate an invoice with the Advicement Term Sheet endpoint

There are also generic functions that are used to check the status of a document generation and to download the document.

The solution can be used as a base template when a user wants to start with Advicement integration or as an example solution to work from.

It answers the question: How to call the Advicement APIs and create PDFs with JSON?

The solution has:

  • Types created by importing the JSON objects from Advicement
  • A function to generate a Simple Invoice by calling the API (using test data)
  • A function to generate a Term Sheet by calling the API (using test data)
  • A function to check the status of the document generation
  • A function to download the document to a specified location

Installation

Download the solution and copy the elements you need into your solution, or make changes on this solution as needed. You will need the Linx 6 Designer, get it here.

Usage

The solution has two main functions that call a set of sub-functions. The main functions can

  • Generate a Simple Invoice
  • Generate a Term Sheet

Before you begin, be sure to set the settings for your solution:

Settings

  • Advancement_APIKey - Set your Advicement API key here, this is the Adv-Security-Token (Authentication Guide | DynamicDocs API | Advicement)
  • LogoLocation - Point the solution to a folder containing your logo, and ensure it is in PNG format
  • OutputLocation - The location where documents must be downloaded

Main Functions

  • GenerateInvoice - Main process to generate an invoice. This is done by setting the data for the document body. This data can be pulled from a database, other data source (file) or even another API. The function then calls the generate function, and then the process checks and download the pdf. Set the file name of the download in the GetProgress parameters.
  • GenerateTermSheet - Main process to generate a Term Sheet. This is done by setting the data for the document body. This data can be pulled from a database, other data source (file) or even another API. The function then calls the generate function, and then the process check and download the pdf. Set the file name of the download in the GetProgress parameters.

Generation functions

  • SimpleInvoice_Create - Set up the API body with the correct details in the Type created from the simple invoice JSON object to generate the pdf. Then call the - - - Simple Invoice Endpoint via a CallRESTEndpoint function. Note: Please set the width of your logo in cm in the LogoWidth variable.
  • TermSheet_Create - Set up the API body with the correct details in the Type created from the term sheet JSON object to generate the pdf. Then call the Term Sheet - Endpoint via a CallRESTEndpoint function. Note: Please set the width of your logo in cm in the LogoWidth variable.

Generic Functions

  • DownloadDocument - Download the document to the folder specified in the Settings
  • GetProgress - Get the generation progress and loops until either an error or success is detected. When a file is successfully generated, it will be downloaded (DownloadDocument function).
  • Logo_ToBase64 - Transforms your logo to Base64 encoding so that it can be sent in the JSON object. Ensure that the logo directory is set in the settings.

Types

  • SimpleInvoice_Body - a collection of settings generated by importing the Simple Invoice JSON object
  • TermSheet_Body - a collection of settings generated by importing the Term Sheet JSON object
  • DocumentStatus_ResponseBody - A type to handle the document status
  • CreateDocument_Response - a type to handle the response received when creating a document.

Notes

This solution can be used to build your own Advicement integration.

Here are a few ideas of what you can do: a. Retrieve data from a data source with Linx and then create a PDF with the data. Data sources include

  • Databases
  • Files (Text, csv, Excel, PDF and more)
  • Other APIs (REST, SOAP, GraphQL)
  • Queues
  • More b. Automate PDF generation on a schedule c. Log and keep track of files d. Move, manage and archive files and folders e. Log and handle issues during generation f. Incorporate the pdf generation process into your existing workflow

Contributing

For questions please ask the Linx community or use the Slack channel.

License

MIT