Skip to content

blazingdocs/blazingdocs-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BlazingDocs GO client

High-performance document generation API. Generate documents and reports from СSV, JSON, XML with 99,9% uptime and 24/7 monitoring.

Installation

import (
    "github.com/blazingdocs/blazingdocs-go"
    "github.com/blazingdocs/blazingdocs-go/config"
)
go get -u github.com/blazingdocs/blazingdocs-go

Integration basics

Setup

You can get your API Key at https://app.blazingdocs.com

config.Default = config.Init("YOUR-API-KEY")
client := blazingdocs.Client{
    Config: *config.Default,
}

Getting account info

resp, err := client.GetAccount()

Getting merge templates list

var s string
tempResp, tempErr := client.GetTemplates(s)

Getting usage info

usageResp, usageErr := client.GetUsage()

Executing merge

file, _ := ioutil.ReadFile("../PO-Template.json")
s := string(file)

params := parameters.MergeParameters{
    DataSourceName: "data", // data source name
    DataSourceType: utils.JSON_TYPE, // data in json format
    Strict:         true, // keep json types
    ParseColumns:   false, // true if data is csv file with column names
    Sequence:       false, // data is object
}

ffile, _ := os.Open("../PO-Template.docx")
formFile := utils.FormFile{
    Name:    "PO-Template.docx",
    Content: ffile,
}

config.Default = config.Init("YOUR-API-KEY")
client := blazingdocs.Client{
    Config: *config.Default,
}

resp, err := client.MergeWithFile(s, "output.pdf", params, formFile)

Documentation

See more details here https://docs.blazingdocs.com