Class: PDFGeneratorAPI

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/pdf_generator_api.rb

Instance Method Summary collapse

Constructor Details

#initialize(headers) ⇒ PDFGeneratorAPI

Returns a new instance of PDFGeneratorAPI.



6
7
8
9
# File 'lib/pdf_generator_api.rb', line 6

def initialize(headers)
  $headers = headers
  $base_url = "https://us1.pdfgeneratorapi.com/api/v3/"
end

Instance Method Details

#copy(template, name) ⇒ Object



41
42
43
44
# File 'lib/pdf_generator_api.rb', line 41

def copy(template, name)
  response = HTTParty.post("#{$base_url}templates/#{template}/copy", {headers:  $headers, body: {name: name}})
  response.body
end

#create(name) ⇒ Object



18
19
20
21
# File 'lib/pdf_generator_api.rb', line 18

def  create(name)
  response = HTTParty.post("#{$base_url}templates", {headers:  $headers, body: {name: name}})
  response.body
end

#delete(template) ⇒ Object



37
38
39
40
# File 'lib/pdf_generator_api.rb', line 37

def delete(template)
  response = HTTParty.delete("#{$base_url}templates/#{template}", {headers:  $headers})
  response.body
end

#delete_workspace(workspaces) ⇒ Object



45
46
47
48
# File 'lib/pdf_generator_api.rb', line 45

def delete_workspace(workspaces)
  response = HTTParty.delete("#{$base_url}workspaces/#{workspaces}", {headers:  $headers})
  response.body
end

#editor(template, data, params) ⇒ Object



33
34
35
36
# File 'lib/pdf_generator_api.rb', line 33

def editor(template, data, params)
  response = HTTParty.get("#{$base_url}templates/#{template}/editor" + query_params, {body: data, headers:  $headers})
  response.body
end

#get(template) ⇒ Object



14
15
16
17
# File 'lib/pdf_generator_api.rb', line 14

def get(template)
  response = HTTParty.get("#{$base_url}templates/#{template}", {headers:  $headers})
  response.body
end

#getAll(access, tags) ⇒ Object



10
11
12
13
# File 'lib/pdf_generator_api.rb', line 10

def getAll(access, tags)
    response = HTTParty.get("#{$base_url}templates", {headers:  $headers})
      response.body
end

#output(template, data, format, name, params) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/pdf_generator_api.rb', line 22

def output(template, data, format, name, params)
  config = {
    name: params[:name].nil? ? "sample" : params[:name],
    format: params[:format].nil? ? "pdf" : params[:format],
    output: params[:output].nil? ? "base64" : params[:output]
  }

  query_params = "?name="+ config[:name] + "&&format="+ config[:format] + "&&output=" + config[:output]
  response = HTTParty.post("#{$base_url}templates/#{template}/output" + query_params, {body: data, headers:  $headers})
  response.body
end

#sendRequest(method, resource, config) ⇒ Object



49
50
51
52
53
# File 'lib/pdf_generator_api.rb', line 49

def sendRequest(method, resource, config)
  # base_url = "#{$base_url}"
  # HTTParty

end