Class: Effective::QbSyncController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/effective/qb_sync_controller.rb

Instance Method Summary collapse

Instance Method Details

#apiObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/effective/qb_sync_controller.rb', line 6

def api
  # respond successfully to a GET which some versions of the Web Connector send to verify the url
  (render(nothing: true) and return) if request.get?

  # Examine raw post and determine which API call to process
  doc = Nokogiri::XML(request.raw_post)
  @qbwcSupervisor = QbwcSupervisor.new

  api_verb = (doc.at_xpath('//soap:Body').children.first.node_name rescue '')

  case api_verb
  when 'serverVersion'
    @version = '1.0'
  when 'clientVersion'
    @version = nil
  when 'authenticate'
    @token, @message = @qbwcSupervisor.authenticate(doc)
  when 'sendRequestXML'
    @message = @qbwcSupervisor.sendRequestXML(doc)
  when 'receiveResponseXML'
    @message = @qbwcSupervisor.receiveResponseXML(doc)
  when 'getLastError'
    @message = @qbwcSupervisor.getLastError(doc)
  when 'connectionError'
    @message = @qbwcSupervisor.connectionError(doc)
  when 'closeConnection'
    @message = @qbwcSupervisor.closeConnection(doc)
  else
    ''
  end

  render(template: "/effective/qb_sync/#{api_verb}.erb", layout: false, content_type: 'text/xml')
end