lib/exactly/client.rb in exactly-0.0.3 vs lib/exactly/client.rb in exactly-0.0.4

- old
+ new

@@ -1,14 +1,22 @@ module Exactly - class TriggeredSendFailed < StandardError + class ExactlyError < StandardError attr_reader :response def initialize(response) @response = response super(message) end + end + class UpsertDataExtensionFailed < ExactlyError def message + @response.to_hash[:update_response][:results][:status_message] + end + end + + class TriggeredSendFailed < ExactlyError + def message @response.to_hash[:create_response][:results][:status_message] end end class Client @@ -19,11 +27,11 @@ def client @client ||= ::Savon::Client.new("https://webservice.s6.exacttarget.com/etframework.wsdl") end def upsert_data_extension(customer_key, properties) - client.request "UpdateRequest", :xmlns => "http://exacttarget.com/wsdl/partnerAPI" do + response = client.request "UpdateRequest", :xmlns => "http://exacttarget.com/wsdl/partnerAPI" do http.headers['SOAPAction'] = 'Update' soap.body = { "Options" => { "SaveOptions" => [ "SaveOption" => { @@ -40,9 +48,12 @@ end } }, :attributes! => { "Objects" => { "xsi:type" => "DataExtensionObject" }} } + end + if response.to_hash[:update_response][:overall_status] != 'OK' + raise Exactly::UpsertDataExtensionFailed.new(response) end end def delete_from_data_extension(customer_key, properties) client.request "DeleteRequest", :xmlns => "http://exacttarget.com/wsdl/partnerAPI" do