项目作者: blazingdocs

项目描述 :
BlazingDocs Go client
高级语言:
项目地址: git://github.com/blazingdocs/blazingdocs-go.git
创建时间: 2021-08-20T13:40:44Z
项目社区:https://github.com/blazingdocs/blazingdocs-go

开源协议:MIT License

下载


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

  1. import (
  2. "github.com/blazingdocs/blazingdocs-go"
  3. "github.com/blazingdocs/blazingdocs-go/config"
  4. )
  1. go get -u github.com/blazingdocs/blazingdocs-go

Integration basics

Setup

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

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

Getting account info

  1. resp, err := client.GetAccount()

Getting merge templates list

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

Getting usage info

  1. usageResp, usageErr := client.GetUsage()

Executing merge

  1. file, _ := ioutil.ReadFile("../PO-Template.json")
  2. s := string(file)
  3. params := parameters.MergeParameters{
  4. DataSourceName: "data", // data source name
  5. DataSourceType: utils.JSON_TYPE, // data in json format
  6. Strict: true, // keep json types
  7. ParseColumns: false, // true if data is csv file with column names
  8. Sequence: false, // data is object
  9. }
  10. ffile, _ := os.Open("../PO-Template.docx")
  11. formFile := utils.FormFile{
  12. Name: "PO-Template.docx",
  13. Content: ffile,
  14. }
  15. config.Default = config.Init("YOUR-API-KEY")
  16. client := blazingdocs.Client{
  17. Config: *config.Default,
  18. }
  19. resp, err := client.MergeWithFile(s, "output.pdf", params, formFile)

Documentation

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