Class: PrexViewService::Transform

Inherits:
Object
  • Object
show all
Defined in:
lib/PrexView/prex_view_service.rb

Instance Method Summary collapse

Constructor Details

#initialize(data_string, options = {}) ⇒ Transform

Returns a new instance of Transform.



8
9
10
11
12
13
14
15
16
17
# File 'lib/PrexView/prex_view_service.rb', line 8

def initialize data_string, options = {}
  @data_string   = data_string

  @uri    = URI("https://api.prexview.com/v1/transform")
  @token  = options.fetch(:token, "#{ENV['PREXVIEW_TOKEN']}")
  @type   = options.fetch(:type, nil)
  @design = options.fetch(:design, nil)
  @output = options.fetch(:options, 'pdf')
  @note   = options.fetch(:note, '')
end

Instance Method Details

#send_jsonObject



24
25
26
27
# File 'lib/PrexView/prex_view_service.rb', line 24

def send_json
  body = { "json" => JSON.dump(@data_string), "design" => @design, "output" => @output, "note" => @note}
  _post body
end

#send_xmlObject



19
20
21
22
# File 'lib/PrexView/prex_view_service.rb', line 19

def send_xml
  body = { "xml" => @data_string, "design" => @design, "output" => @output, "note" => @note}
  _post body
end