Skip to content

Latest commit

 

History

History
584 lines (413 loc) · 16.4 KB

TemplatesApi.md

File metadata and controls

584 lines (413 loc) · 16.4 KB

PDFGeneratorAPI::TemplatesApi

All URIs are relative to https://us1.pdfgeneratorapi.com/api/v4

Method HTTP request Description
copy_template POST /templates/{templateId}/copy Copy template
create_template POST /templates Create template
delete_template DELETE /templates/{templateId} Delete template
get_template GET /templates/{templateId} Get template
get_template_data GET /templates/{templateId}/data Get template data fields
get_templates GET /templates Get templates
open_editor POST /templates/{templateId}/editor Open editor
update_template PUT /templates/{templateId} Update template

copy_template

copy_template(template_id, opts)

Copy template

Creates a copy of a template to the workspace specified in authentication parameters.

Examples

require 'time'
require 'pdf_generator_api_client'
# setup authorization
PDFGeneratorAPI.configure do |config|
  # Configure Bearer authorization (JWT): JSONWebTokenAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = PDFGeneratorAPI::TemplatesApi.new
template_id = 19375 # Integer | Template unique identifier
opts = {
  copy_template_request: PDFGeneratorAPI::CopyTemplateRequest.new # CopyTemplateRequest | 
}

begin
  # Copy template
  result = api_instance.copy_template(template_id, opts)
  p result
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling TemplatesApi->copy_template: #{e}"
end

Using the copy_template_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> copy_template_with_http_info(template_id, opts)

begin
  # Copy template
  data, status_code, headers = api_instance.copy_template_with_http_info(template_id, opts)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <CreateTemplate201Response>
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling TemplatesApi->copy_template_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
template_id Integer Template unique identifier
copy_template_request CopyTemplateRequest [optional]

Return type

CreateTemplate201Response

Authorization

JSONWebTokenAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

create_template

create_template(template_definition_new)

Create template

Creates a new template. If template configuration is not specified in the request body then an empty template is created. Template is placed to the workspace specified in authentication params. Template configuration must be sent in the request body.

Examples

require 'time'
require 'pdf_generator_api_client'
# setup authorization
PDFGeneratorAPI.configure do |config|
  # Configure Bearer authorization (JWT): JSONWebTokenAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = PDFGeneratorAPI::TemplatesApi.new
template_definition_new = PDFGeneratorAPI::TemplateDefinitionNew.new({name: 'Invoice template'}) # TemplateDefinitionNew | Template configuration

begin
  # Create template
  result = api_instance.create_template(template_definition_new)
  p result
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling TemplatesApi->create_template: #{e}"
end

Using the create_template_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> create_template_with_http_info(template_definition_new)

begin
  # Create template
  data, status_code, headers = api_instance.create_template_with_http_info(template_definition_new)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <CreateTemplate201Response>
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling TemplatesApi->create_template_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
template_definition_new TemplateDefinitionNew Template configuration

Return type

CreateTemplate201Response

Authorization

JSONWebTokenAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

delete_template

delete_template(template_id)

Delete template

Deletes the template from workspace

Examples

require 'time'
require 'pdf_generator_api_client'
# setup authorization
PDFGeneratorAPI.configure do |config|
  # Configure Bearer authorization (JWT): JSONWebTokenAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = PDFGeneratorAPI::TemplatesApi.new
template_id = 19375 # Integer | Template unique identifier

begin
  # Delete template
  api_instance.delete_template(template_id)
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling TemplatesApi->delete_template: #{e}"
end

Using the delete_template_with_http_info variant

This returns an Array which contains the response data (nil in this case), status code and headers.

<Array(nil, Integer, Hash)> delete_template_with_http_info(template_id)

begin
  # Delete template
  data, status_code, headers = api_instance.delete_template_with_http_info(template_id)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => nil
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling TemplatesApi->delete_template_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
template_id Integer Template unique identifier

Return type

nil (empty response body)

Authorization

JSONWebTokenAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

get_template

get_template(template_id)

Get template

Returns template configuration

Examples

require 'time'
require 'pdf_generator_api_client'
# setup authorization
PDFGeneratorAPI.configure do |config|
  # Configure Bearer authorization (JWT): JSONWebTokenAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = PDFGeneratorAPI::TemplatesApi.new
template_id = 19375 # Integer | Template unique identifier

begin
  # Get template
  result = api_instance.get_template(template_id)
  p result
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling TemplatesApi->get_template: #{e}"
end

Using the get_template_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> get_template_with_http_info(template_id)

begin
  # Get template
  data, status_code, headers = api_instance.get_template_with_http_info(template_id)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <CreateTemplate201Response>
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling TemplatesApi->get_template_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
template_id Integer Template unique identifier

Return type

CreateTemplate201Response

Authorization

JSONWebTokenAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

get_template_data

get_template_data(template_id)

Get template data fields

Returns all data fields used in the template. Returns structured JSON data that can be used to check which data fields are used in template or autogenerate sample data.

Examples

require 'time'
require 'pdf_generator_api_client'
# setup authorization
PDFGeneratorAPI.configure do |config|
  # Configure Bearer authorization (JWT): JSONWebTokenAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = PDFGeneratorAPI::TemplatesApi.new
template_id = 19375 # Integer | Template unique identifier

begin
  # Get template data fields
  result = api_instance.get_template_data(template_id)
  p result
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling TemplatesApi->get_template_data: #{e}"
end

Using the get_template_data_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> get_template_data_with_http_info(template_id)

begin
  # Get template data fields
  data, status_code, headers = api_instance.get_template_data_with_http_info(template_id)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <GetTemplateData200Response>
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling TemplatesApi->get_template_data_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
template_id Integer Template unique identifier

Return type

GetTemplateData200Response

Authorization

JSONWebTokenAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

get_templates

get_templates(opts)

Get templates

Returns a list of templates available for the authenticated workspace

Examples

require 'time'
require 'pdf_generator_api_client'
# setup authorization
PDFGeneratorAPI.configure do |config|
  # Configure Bearer authorization (JWT): JSONWebTokenAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = PDFGeneratorAPI::TemplatesApi.new
opts = {
  name: 'name_example', # String | Filter template by name
  tags: 'tags_example', # String | Filter template by tags
  access: 'private', # String | Filter template by access type. No values returns all templates. private - returns only private templates, organization - returns only organization templates.
  page: 1, # Integer | Pagination: page to return
  per_page: 20 # Integer | Pagination: How many records to return per page
}

begin
  # Get templates
  result = api_instance.get_templates(opts)
  p result
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling TemplatesApi->get_templates: #{e}"
end

Using the get_templates_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> get_templates_with_http_info(opts)

begin
  # Get templates
  data, status_code, headers = api_instance.get_templates_with_http_info(opts)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <GetTemplates200Response>
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling TemplatesApi->get_templates_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
name String Filter template by name [optional]
tags String Filter template by tags [optional]
access String Filter template by access type. No values returns all templates. private - returns only private templates, organization - returns only organization templates. [optional][default to '']
page Integer Pagination: page to return [optional][default to 1]
per_page Integer Pagination: How many records to return per page [optional][default to 15]

Return type

GetTemplates200Response

Authorization

JSONWebTokenAuth

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

open_editor

open_editor(template_id, open_editor_request)

Open editor

Returns an unique URL which you can use to redirect your user to the editor from your application or use the generated URL as iframe source to show the editor within your application. When using iframe, make sure that your browser allows third-party cookies.

Examples

require 'time'
require 'pdf_generator_api_client'
# setup authorization
PDFGeneratorAPI.configure do |config|
  # Configure Bearer authorization (JWT): JSONWebTokenAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = PDFGeneratorAPI::TemplatesApi.new
template_id = 19375 # Integer | Template unique identifier
open_editor_request = PDFGeneratorAPI::OpenEditorRequest.new # OpenEditorRequest | 

begin
  # Open editor
  result = api_instance.open_editor(template_id, open_editor_request)
  p result
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling TemplatesApi->open_editor: #{e}"
end

Using the open_editor_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> open_editor_with_http_info(template_id, open_editor_request)

begin
  # Open editor
  data, status_code, headers = api_instance.open_editor_with_http_info(template_id, open_editor_request)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <OpenEditor200Response>
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling TemplatesApi->open_editor_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
template_id Integer Template unique identifier
open_editor_request OpenEditorRequest

Return type

OpenEditor200Response

Authorization

JSONWebTokenAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

update_template

update_template(template_id, template_definition_new)

Update template

Updates template configuration. The template configuration for pages and layout must be complete as the entire configuration is replaced and not merged.

Examples

require 'time'
require 'pdf_generator_api_client'
# setup authorization
PDFGeneratorAPI.configure do |config|
  # Configure Bearer authorization (JWT): JSONWebTokenAuth
  config.access_token = 'YOUR_BEARER_TOKEN'
end

api_instance = PDFGeneratorAPI::TemplatesApi.new
template_id = 19375 # Integer | Template unique identifier
template_definition_new = PDFGeneratorAPI::TemplateDefinitionNew.new({name: 'Invoice template'}) # TemplateDefinitionNew | Template configuration

begin
  # Update template
  result = api_instance.update_template(template_id, template_definition_new)
  p result
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling TemplatesApi->update_template: #{e}"
end

Using the update_template_with_http_info variant

This returns an Array which contains the response data, status code and headers.

<Array(, Integer, Hash)> update_template_with_http_info(template_id, template_definition_new)

begin
  # Update template
  data, status_code, headers = api_instance.update_template_with_http_info(template_id, template_definition_new)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <CreateTemplate201Response>
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling TemplatesApi->update_template_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
template_id Integer Template unique identifier
template_definition_new TemplateDefinitionNew Template configuration

Return type

CreateTemplate201Response

Authorization

JSONWebTokenAuth

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json