class ExactTargetClient::ExactTargetSoapClient
Constants
- RESPONSE_RESULT_KEYS
Attributes
oauth_token[RW]
wsdl[RW]
Public Class Methods
new() { |self| ... }
click to toggle source
# File lib/exact_target_client/exact_target_soap_client.rb, line 60 def initialize yield self if block_given? end
Public Instance Methods
create(object_type, properties)
click to toggle source
# File lib/exact_target_client/exact_target_soap_client.rb, line 107 def create(object_type, properties) soap_action :create, object_type, properties end
delete(object_type, properties)
click to toggle source
# File lib/exact_target_client/exact_target_soap_client.rb, line 115 def delete(object_type, properties) soap_action :delete, object_type, properties end
header()
click to toggle source
# File lib/exact_target_client/exact_target_soap_client.rb, line 64 def header raise ExactTargetClient::ExactTargetAPI::ClientException.new('OAuth token must be provided to SOAP client!') unless oauth_token { 'fueloauth' => oauth_token, '@xmlns' => 'http://exacttarget.com' } end
retrieve(object_type, properties, filter = nil)
click to toggle source
# File lib/exact_target_client/exact_target_soap_client.rb, line 91 def retrieve(object_type, properties, filter = nil) raise ExactTargetClient::ExactTargetAPI::ClientException.new('Object properties must be specified') unless properties.present? payload = {'ObjectType' => object_type, 'Properties' => properties} if filter.present? values = Array.wrap(filter[:value]) payload['Filter'] = { '@xsi:type' => 'tns:SimpleFilterPart', 'Property' => filter[:property], 'SimpleOperator' => values.one? ? 'equals' : 'IN', 'Value' => values } end message = {'RetrieveRequest' => payload} soap_request :retrieve, message end
set_oauth_token(token)
click to toggle source
# File lib/exact_target_client/exact_target_soap_client.rb, line 86 def set_oauth_token(token) @oauth_token = token soap_client.globals[:soap_header] = header end
soap_client()
click to toggle source
# File lib/exact_target_client/exact_target_soap_client.rb, line 76 def soap_client @soap_client = Savon.client( soap_header: header, wsdl: wsdl, log: false, open_timeout: 120, read_timeout: 120 ) end
update(object_type, properties)
click to toggle source
# File lib/exact_target_client/exact_target_soap_client.rb, line 111 def update(object_type, properties) soap_action :update, object_type, properties end
Private Instance Methods
soap_action(action, object_type, properties)
click to toggle source
# File lib/exact_target_client/exact_target_soap_client.rb, line 121 def soap_action(action, object_type, properties) properties['@xsi:type'] = "tns:#{object_type}" message = { 'Objects' => properties } soap_request action, message end
soap_request(action, message)
click to toggle source
# File lib/exact_target_client/exact_target_soap_client.rb, line 129 def soap_request(action, message) responseObject = SoapResponse begin tries ||= 3 response = soap_client.call(action, :message => message) # TODO - handle other error types rescue Savon::SOAPFault => error message = error.to_hash[:fault][:faultstring] if message == 'Token Expired' raise ExactTargetClient::ExactTargetAPI::TokenExpired elsif message == 'Login Failed' retry unless (tries -= 1).zero? else raise ExactTargetClient::ExactTargetAPI::ClientException.new("SOAP Client Error: #{message}") end end responseObject.new response, RESPONSE_RESULT_KEYS[action], self end