Skip to content

Latest commit

 

History

History
506 lines (356 loc) · 16.6 KB

DocumentsApi.md

File metadata and controls

506 lines (356 loc) · 16.6 KB

PDFGeneratorAPI::DocumentsApi

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

Method HTTP request Description
delete_document DELETE /documents/{publicId} Delete document
generate_document POST /documents/generate Generate document
generate_document_asynchronous POST /documents/generate/async Generate document (async)
generate_document_batch POST /documents/generate/batch Generate document (batch)
generate_document_batch_asynchronous POST /documents/generate/batch/async Generate document (batch + async)
get_document GET /documents/{publicId} Get document
get_documents GET /documents Get documents

delete_document

delete_document(public_id)

Delete document

Delete document from the Document Storage

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::DocumentsApi.new
public_id = 'bac8381bce1982e5f6957a0f52371336' # String | Resource public id

begin
  # Delete document
  api_instance.delete_document(public_id)
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling DocumentsApi->delete_document: #{e}"
end

Using the delete_document_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_document_with_http_info(public_id)

begin
  # Delete document
  data, status_code, headers = api_instance.delete_document_with_http_info(public_id)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => nil
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling DocumentsApi->delete_document_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
public_id String Resource public id

Return type

nil (empty response body)

Authorization

JSONWebTokenAuth

HTTP request headers

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

generate_document

generate_document(generate_document_request)

Generate document

Merges template with data and returns base64 encoded document or a public URL to a document. NB! When the public URL option is used, the document is stored for 30 days and automatically deleted.

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::DocumentsApi.new
generate_document_request = PDFGeneratorAPI::GenerateDocumentRequest.new # GenerateDocumentRequest | Request parameters, including template id, data and formats.

begin
  # Generate document
  result = api_instance.generate_document(generate_document_request)
  p result
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling DocumentsApi->generate_document: #{e}"
end

Using the generate_document_with_http_info variant

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

<Array(, Integer, Hash)> generate_document_with_http_info(generate_document_request)

begin
  # Generate document
  data, status_code, headers = api_instance.generate_document_with_http_info(generate_document_request)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <GenerateDocument201Response>
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling DocumentsApi->generate_document_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
generate_document_request GenerateDocumentRequest Request parameters, including template id, data and formats.

Return type

GenerateDocument201Response

Authorization

JSONWebTokenAuth

HTTP request headers

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

generate_document_asynchronous

generate_document_asynchronous(generate_document_asynchronous_request)

Generate document (async)

Merges template with data as asynchronous job and makes POST request to callback URL defined in the request. Request uses the same format as response of synchronous generation endpoint. The job id is also added to the callback request as header PDF-API-Job-Id Example payload for callback URL: { \"response\": \"https://us1.pdfgeneratorapi.com/share/12821/VBERi0xLjcKJeLjz9MKNyAwIG9i\", \"meta\": { \"name\": \"a2bd25b8921f3dc7a440fd7f427f90a4.pdf\", \"display_name\": \"a2bd25b8921f3dc7a440fd7f427f90a4\", \"encoding\": \"binary\", \"content-type\": \"application/pdf\" } }

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::DocumentsApi.new
generate_document_asynchronous_request = PDFGeneratorAPI::GenerateDocumentAsynchronousRequest.new # GenerateDocumentAsynchronousRequest | Request parameters, including template id, data and formats.

begin
  # Generate document (async)
  result = api_instance.generate_document_asynchronous(generate_document_asynchronous_request)
  p result
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling DocumentsApi->generate_document_asynchronous: #{e}"
end

Using the generate_document_asynchronous_with_http_info variant

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

<Array(, Integer, Hash)> generate_document_asynchronous_with_http_info(generate_document_asynchronous_request)

begin
  # Generate document (async)
  data, status_code, headers = api_instance.generate_document_asynchronous_with_http_info(generate_document_asynchronous_request)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <GenerateDocumentAsynchronous201Response>
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling DocumentsApi->generate_document_asynchronous_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
generate_document_asynchronous_request GenerateDocumentAsynchronousRequest Request parameters, including template id, data and formats.

Return type

GenerateDocumentAsynchronous201Response

Authorization

JSONWebTokenAuth

HTTP request headers

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

generate_document_batch

generate_document_batch(generate_document_batch_request)

Generate document (batch)

Allows to merge multiple templates with data and returns base64 encoded document or public URL to a document. NB! When the public URL option is used, the document is stored for 30 days and automatically deleted.

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::DocumentsApi.new
generate_document_batch_request = PDFGeneratorAPI::GenerateDocumentBatchRequest.new # GenerateDocumentBatchRequest | Request parameters, including template id, data and formats.

begin
  # Generate document (batch)
  result = api_instance.generate_document_batch(generate_document_batch_request)
  p result
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling DocumentsApi->generate_document_batch: #{e}"
end

Using the generate_document_batch_with_http_info variant

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

<Array(, Integer, Hash)> generate_document_batch_with_http_info(generate_document_batch_request)

begin
  # Generate document (batch)
  data, status_code, headers = api_instance.generate_document_batch_with_http_info(generate_document_batch_request)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <GenerateDocument201Response>
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling DocumentsApi->generate_document_batch_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
generate_document_batch_request GenerateDocumentBatchRequest Request parameters, including template id, data and formats.

Return type

GenerateDocument201Response

Authorization

JSONWebTokenAuth

HTTP request headers

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

generate_document_batch_asynchronous

generate_document_batch_asynchronous(generate_document_batch_asynchronous_request)

Generate document (batch + async)

Merges template with data as asynchronous job and makes POST request to callback URL defined in the request. Request uses the same format as response of synchronous generation endpoint. The job id is also added to the callback request as header PDF-API-Job-Id Example payload for callback URL: { \"response\": \"https://us1.pdfgeneratorapi.com/share/12821/VBERi0xLjcKJeLjz9MKNyAwIG9i\", \"meta\": { \"name\": \"a2bd25b8921f3dc7a440fd7f427f90a4.pdf\", \"display_name\": \"a2bd25b8921f3dc7a440fd7f427f90a4\", \"encoding\": \"binary\", \"content-type\": \"application/pdf\" } }

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::DocumentsApi.new
generate_document_batch_asynchronous_request = PDFGeneratorAPI::GenerateDocumentBatchAsynchronousRequest.new # GenerateDocumentBatchAsynchronousRequest | Request parameters, including template id, data and formats.

begin
  # Generate document (batch + async)
  result = api_instance.generate_document_batch_asynchronous(generate_document_batch_asynchronous_request)
  p result
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling DocumentsApi->generate_document_batch_asynchronous: #{e}"
end

Using the generate_document_batch_asynchronous_with_http_info variant

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

<Array(, Integer, Hash)> generate_document_batch_asynchronous_with_http_info(generate_document_batch_asynchronous_request)

begin
  # Generate document (batch + async)
  data, status_code, headers = api_instance.generate_document_batch_asynchronous_with_http_info(generate_document_batch_asynchronous_request)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <GenerateDocumentAsynchronous201Response>
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling DocumentsApi->generate_document_batch_asynchronous_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
generate_document_batch_asynchronous_request GenerateDocumentBatchAsynchronousRequest Request parameters, including template id, data and formats.

Return type

GenerateDocumentAsynchronous201Response

Authorization

JSONWebTokenAuth

HTTP request headers

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

get_document

get_document(public_id)

Get document

Returns document stored in the Document Storage

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::DocumentsApi.new
public_id = 'bac8381bce1982e5f6957a0f52371336' # String | Resource public id

begin
  # Get document
  result = api_instance.get_document(public_id)
  p result
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling DocumentsApi->get_document: #{e}"
end

Using the get_document_with_http_info variant

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

<Array(, Integer, Hash)> get_document_with_http_info(public_id)

begin
  # Get document
  data, status_code, headers = api_instance.get_document_with_http_info(public_id)
  p status_code # => 2xx
  p headers # => { ... }
  p data # => <GetDocument200Response>
rescue PDFGeneratorAPI::ApiError => e
  puts "Error when calling DocumentsApi->get_document_with_http_info: #{e}"
end

Parameters

Name Type Description Notes
public_id String Resource public id

Return type

GetDocument200Response

Authorization

JSONWebTokenAuth

HTTP request headers

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

get_documents

get_documents(opts)

Get documents

Returns a list of generated documents created by authorized workspace and stored in PDF Generator API. If master user is specified as workspace in JWT then all documents created in the organization are returned. NB! This endpoint returns only documents generated using the output=url option.

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::DocumentsApi.new
opts = {
  template_id: 19375, # Integer | Template unique identifier
  start_date: '2022-08-01 12:00:00', # String | Start date. Format: Y-m-d H:i:s
  end_date: '2022-08-05 12:00:00', # String | End date. Format: Y-m-d H:i:s. Defaults to current timestamp
  page: 1, # Integer | Pagination: page to return
  per_page: 20 # Integer | Pagination: How many records to return per page
}

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

Using the get_documents_with_http_info variant

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

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

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

Parameters

Name Type Description Notes
template_id Integer Template unique identifier [optional]
start_date String Start date. Format: Y-m-d H:i:s [optional]
end_date String End date. Format: Y-m-d H:i:s. Defaults to current timestamp [optional]
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

GetDocuments200Response

Authorization

JSONWebTokenAuth

HTTP request headers

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