class ExactTargetClient::SoapResponse

Attributes

body[R]
code[R]
message[R]
request_id[R]
result_key[R]
results[R]

Public Class Methods

new(response, result_key, client) click to toggle source
# File lib/exact_target_client/exact_target_soap_client.rb, line 5
def initialize(response, result_key, client)
  @results = []
  @result_key = result_key
  @client = client
  parse_response response
rescue => e
  raise ExactTargetClient::ExactTargetAPI::ClientException.new("SOAP Client Error: #{e.message}")
end

Public Instance Methods

success?() click to toggle source
# File lib/exact_target_client/exact_target_soap_client.rb, line 14
def success?
  @success ||= false
end

Private Instance Methods

get_more() click to toggle source
# File lib/exact_target_client/exact_target_soap_client.rb, line 20
def get_more
  parse_results @client.soap_client.call(:retrieve, :message => {'ContinueRequest' => request_id})
end
parse_body(response) click to toggle source
# File lib/exact_target_client/exact_target_soap_client.rb, line 29
def parse_body(response)
  @request_id = response.body[result_key][:request_id]
  @success = response.body[result_key][:overall_status] == 'OK'
  @results = result_key == :retrieve_response_msg ? parse_results(response) : response.body[result_key][:results]
  @message = @results.present? ? response.body[result_key][:results][:status_message] : response.body[result_key][:overall_status]
rescue
  @message = response.http.body
  @body = response.http.body unless @body
end
parse_response(response) click to toggle source
# File lib/exact_target_client/exact_target_soap_client.rb, line 24
def parse_response(response)
  @code = response.http.code
  parse_body response
end
parse_results(response) click to toggle source
# File lib/exact_target_client/exact_target_soap_client.rb, line 39
def parse_results(response)
  res = response.body[result_key][:results] || []
  if response.body[result_key][:overall_status] == 'MoreDataAvailable'
    res += get_more
  end
  Array.wrap(res)
rescue
  []
end