carbone

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package carbone provide an SDK to communicate with Carbone Render Carbone is the most efficient report generator It render from a JSON and template into PDF, DOCX, XLSX, PPTX, ODS and many more reports

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse

type APIResponse struct {
	Success bool            `json:"success"`
	Message string          `json:"message,omitempty"`
	Error   string          `json:"error,omitempty"`
	Data    APIResponseData `json:"data"`
}

APIResponse object created during Carbone Render response.

type APIResponseData

type APIResponseData struct {
	TemplateID            string `json:"templateId,omitempty"`
	RenderID              string `json:"renderId,omitempty"`
	TemplateFileExtension string `json:"inputFileExtension,omitempty"`
}

APIResponseData object created during Carbone Render response.

type CSDK

type CSDK struct {
	// contains filtered or unexported fields
}

CSDK (CarboneSDK) to use Carbone render API easily.

func NewCarboneSDK

func NewCarboneSDK(args ...string) (*CSDK, error)

NewCarboneSDK is a constructor and return a new instance of CSDK

func (*CSDK) AddTemplate

func (csdk *CSDK) AddTemplate(templateFileName string, args ...string) (APIResponse, error)

AddTemplate upload your template to Carbone Render. The first parameter is the template file path, the second is an optional payload.

func (*CSDK) DeleteTemplate

func (csdk *CSDK) DeleteTemplate(templateID string) (APIResponse, error)

DeleteTemplate Delete an uploaded template from a templateID.

func (*CSDK) GenerateTemplateID

func (csdk *CSDK) GenerateTemplateID(filepath string, args ...string) (string, error)

GenerateTemplateID Generate the templateID from a template filepath {string}: file path args {...string}: You can set a payload (args[0]) returns the file TemplateId

func (*CSDK) GetAPIVersion

func (csdk *CSDK) GetAPIVersion() (int, error)

GetAPIVersion get the Carbone Render version

func (*CSDK) GetReport

func (csdk *CSDK) GetReport(renderID string) ([]byte, error)

GetReport Request Carbone Render and return a generated report

func (*CSDK) GetTemplate

func (csdk *CSDK) GetTemplate(templateID string) ([]byte, error)

GetTemplate returns the original template from the templateId (Unique identifier of the template)

func (*CSDK) Render

func (csdk *CSDK) Render(pathOrTemplateID string, jsonData string, args ...string) ([]byte, error)

Render render a report from a templateID OR a template path. pathOrTemplateID {string}: Accept a file path OR a template ID returned by AddTemplate jsonData {string}: stringify json, all options here: https://carbone.io/api-reference.html#rendering-a-report args {...string}: You can pass an optinal payload used during the template upload (AddTemplate) to create a different templateID. It returns a []byte of the file.

func (*CSDK) RenderReport

func (csdk *CSDK) RenderReport(templateID string, jsonData string) (APIResponse, error)

RenderReport a report from a templateID and a json data

func (*CSDK) SetAPIHeaders added in v1.1.0

func (csdk *CSDK) SetAPIHeaders(headers map[string]string)

SetAPIHeaders get the Carbone Render version

func (*CSDK) SetAPIVersion

func (csdk *CSDK) SetAPIVersion(version int)

SetAPIVersion set the Carbone Render version

func (*CSDK) SetAccessToken

func (csdk *CSDK) SetAccessToken(newToken string)

SetAccessToken set the Carbone Render access token

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL