Skip to content

Instantly share code, notes, and snippets.

@jcuffe
Created August 3, 2012 21:41
Show Gist options
  • Save jcuffe/3251780 to your computer and use it in GitHub Desktop.
Save jcuffe/3251780 to your computer and use it in GitHub Desktop.
class SoapReport
def initialize(report_name, request_date)
@soap_client = LolSoap::Client.new(ACS_SOAP[:definitions][:report_data_service])
soap_request = build_request report_name, Date.parse(request_date)
response = build_response soap_request
puts response
end
def build_request(report_name, request_date)
soap_request = @soap_client.request 'GetMonthlyReportData'
soap_request.body do |b|
b.ReportName report_name
b.ReportYear request_date.year
b.ReportMonth request_date.strftime "%m"
end
soap_request
end
def build_response(soap_request)
request_uri = URI.parse soap_request.url
request_http = Patron::Session.new
request_http.timeout = 10
request_http.base_url = request_uri.host
raw_response = request_http.post(request_uri.path, soap_request.content, soap_request.headers).body
response = @soap_client.response soap_request, raw_response
parsed_response = JSON.parse response.body_hash['GetMonthlyReportDataResult']
parsed_response['resultSet']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment