class Docxmerge::Docxmerge

Your code goes here…

Public Class Methods

new(api_key, tenant, base_uri) click to toggle source
# File lib/docxmerge.rb, line 12
def initialize(api_key, tenant, base_uri)
  @api_key = api_key
  @tenant = tenant || "default"
  @base_uri = base_uri || "https://api.docxmerge.com"
end

Public Instance Methods

render_file(file_param, data, conversion_type) click to toggle source
# File lib/docxmerge.rb, line 35
def render_file(file_param, data, conversion_type)
  uri = "#{@base_uri}/api/v1/Admin/RenderFile"
  response = RestClient.post(uri,
                             {
                                 :multipart => true,
                                 :file => file_param,
                                 :data => data.to_json,
                                 :conversionType => conversion_type,
                             },
                             get_headers,
  )
  raise BadRequestError.new unless response.code == 200
  response.body
end
render_template(template_name, data, conversion_type, version = "") click to toggle source
# File lib/docxmerge.rb, line 18
def render_template(template_name, data, conversion_type, version = "")
  uri = "#{@base_uri}/api/v1/Admin/RenderTemplate"
  headers = get_headers
  headers["content-type"] = "application/json"
  response = RestClient.post(uri,
                             {
                                 template: template_name,
                                 data: data,
                                 version: version,
                                 conversionType: conversion_type,
                             }.to_json,
                             headers,
  )
  raise BadRequestError.new unless response.code == 200
  response.body
end
render_url(url, data, conversion_type, version = "") click to toggle source
# File lib/docxmerge.rb, line 50
def render_url(url, data, conversion_type, version = "")
  uri = "#{@base_uri}/api/v1/Admin/RenderUrl"
  headers = get_headers
  headers["content-type"] = "application/json"
  response = RestClient.post(uri,
                             {
                                 url: url,
                                 data: data,
                                 version: version,
                                 conversionType: conversion_type,
                             }.to_json,
                             headers,
  )
  raise BadRequestError.new unless response.code == 200
  response.body
end

Private Instance Methods

get_headers() click to toggle source
# File lib/docxmerge.rb, line 69
def get_headers
  {
      "api-key" => @api_key,
      "x-tenant" => @tenant,
  }
end