Class: Py3oFusion
- Inherits:
-
Object
- Object
- Py3oFusion
- Defined in:
- lib/py3o_fusion.rb
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
- #data(data) ⇒ Object
- #generate_pdf(path) ⇒ Object
-
#initialize(endpoint, options = {}) ⇒ Py3oFusion
constructor
A new instance of Py3oFusion.
- #static_image(name, file) ⇒ Object
- #template(template) ⇒ Object
Constructor Details
#initialize(endpoint, options = {}) ⇒ Py3oFusion
Returns a new instance of Py3oFusion.
6 7 8 9 10 11 |
# File 'lib/py3o_fusion.rb', line 6 def initialize(endpoint, = {}) @endpoint = endpoint @payload = {} @image_mapping = {} = end |
Instance Method Details
#data(data) ⇒ Object
18 19 20 21 |
# File 'lib/py3o_fusion.rb', line 18 def data(data) @data = data self end |
#generate_pdf(path) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/py3o_fusion.rb', line 29 def generate_pdf(path) response = post if response.code == 200 store path, response.body else error = JSON.parse(response.body) raise Error.new "Error generating PDF: #{error['reasons']}" end end |
#static_image(name, file) ⇒ Object
23 24 25 26 27 |
# File 'lib/py3o_fusion.rb', line 23 def static_image(name, file) @payload[name.to_sym] = File.open(file) @image_mapping[name.to_sym] = "staticimage.#{name}" self end |
#template(template) ⇒ Object
13 14 15 16 |
# File 'lib/py3o_fusion.rb', line 13 def template(template) @payload[:tmpl_file] = File.open(template) self end |