Class: Effective::QbwcSupervisor

Inherits:
Object
  • Object
show all
Defined in:
app/models/effective/qbwc_supervisor.rb

Constant Summary collapse

QBXML =
'http://developer.intuit.com/'

Instance Method Summary collapse

Instance Method Details

#authenticate(doc) ⇒ Object



5
6
7
8
9
10
11
12
# File 'app/models/effective/qbwc_supervisor.rb', line 5

def authenticate(doc)
  username = doc.at_xpath('//qbxml:strUserName', 'qbxml' => QBXML).content
  password = doc.at_xpath('//qbxml:strPassword', 'qbxml' => QBXML).content

  attempt do |m|
    return [m.ticket.id.to_s, m.op_authenticate(username, password)]
  end
end

#closeConnection(doc) ⇒ Object



59
60
61
62
63
64
65
# File 'app/models/effective/qbwc_supervisor.rb', line 59

def closeConnection(doc)
  ticket = doc.at_xpath('//qbxml:ticket', 'qbxml' => QBXML).content

  attempt(ticket) do |m|
    return m.op_close_connection
  end
end

#connectionError(doc) ⇒ Object



49
50
51
52
53
54
55
56
57
# File 'app/models/effective/qbwc_supervisor.rb', line 49

def connectionError(doc)
  ticket = doc.at_xpath('//qbxml:ticket', 'qbxml' => QBXML).content
  hresult = doc.at_xpath('//qbxml:hresult', 'qbxml' => QBXML).content
  message = doc.at_xpath('//qbxml:message', 'qbxml' => QBXML).content

  attempt(ticket) do |m|
    return m.op_connection_error(hresult, message)
  end
end

#getLastError(doc) ⇒ Object



67
68
69
70
71
72
73
# File 'app/models/effective/qbwc_supervisor.rb', line 67

def getLastError(doc)
  ticket = doc.at_xpath('//qbxml:ticket', 'qbxml' => QBXML).content

  attempt(ticket) do |m|
    return m.op_last_error
  end
end

#receiveResponseXML(doc) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'app/models/effective/qbwc_supervisor.rb', line 36

def receiveResponseXML(doc)
  ticket = doc.at_xpath('//qbxml:ticket', 'qbxml' => QBXML).content
  response = doc.at_xpath('//qbxml:response', 'qbxml' => QBXML).content
  hresult = doc.at_xpath('//qbxml:hresult', 'qbxml' => QBXML).content
  message = doc.at_xpath('//qbxml:message', 'qbxml' => QBXML).content

  params = { ticket: ticket, response: response, hresult: hresult, message: message }

  attempt(ticket) do |m|
    return m.op_receive_response_xml(params)
  end
end

#sendRequestXML(doc) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'app/models/effective/qbwc_supervisor.rb', line 14

def sendRequestXML(doc)
  ticket = doc.at_xpath('//qbxml:ticket', 'qbxml' => QBXML).content
  strHCPResponse = doc.at_xpath('//qbxml:strHCPResponse', 'qbxml' => QBXML).content
  strCompanyFileName = doc.at_xpath('//qbxml:strCompanyFileName', 'qbxml' => QBXML).content
  qbXMLCountry = doc.at_xpath('//qbxml:qbXMLCountry', 'qbxml' => QBXML).content
  qbXMLMajorVers = doc.at_xpath('//qbxml:qbXMLMajorVers', 'qbxml' => QBXML).content
  qbXMLMinorVers = doc.at_xpath('//qbxml:qbXMLMinorVers', 'qbxml' => QBXML).content

  params = {
    ticket: ticket,
    hcpresponse: strHCPResponse,
    company: strCompanyFileName,
    country: qbXMLCountry,
    major_ver: qbXMLMajorVers,
    minor_ver: qbXMLMinorVers
  }

  attempt(ticket) do |m|
    return m.op_send_request_xml(params)
  end
end