Class: Docxmerge::Docxmerge
- Inherits:
-
Object
- Object
- Docxmerge::Docxmerge
- Defined in:
- lib/docxmerge.rb
Overview
Your code goes hereā¦
Instance Method Summary collapse
-
#initialize(api_key, tenant, base_uri) ⇒ Docxmerge
constructor
A new instance of Docxmerge.
- #render_file(file_param, data, conversion_type) ⇒ Object
- #render_template(template_name, data, conversion_type, version = "") ⇒ Object
- #render_url(url, data, conversion_type, version = "") ⇒ Object
Constructor Details
#initialize(api_key, tenant, base_uri) ⇒ Docxmerge
Returns a new instance of Docxmerge.
12 13 14 15 16 |
# 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 |
Instance Method Details
#render_file(file_param, data, conversion_type) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# 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 = "") ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# 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 = "") ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# 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 |