Module: FuelSDK::Soap

Includes:
Targeting
Included in:
Client
Defined in:
lib/fuelsdk/soap.rb

Instance Attribute Summary collapse

Attributes included from Targeting

#access_token, #endpoint

Instance Method Summary collapse

Instance Attribute Details

#debugObject

, :internal_token



117
118
119
# File 'lib/fuelsdk/soap.rb', line 117

def debug
  @debug
end

#wsdlObject

, :internal_token



117
118
119
# File 'lib/fuelsdk/soap.rb', line 117

def wsdl
  @wsdl
end

Instance Method Details

#headerObject



121
122
123
124
125
126
127
# File 'lib/fuelsdk/soap.rb', line 121

def header
	raise 'Require legacy token for soap header' unless internal_token
	{
		'oAuth' => {'oAuthToken' => internal_token},
		:attributes! => { 'oAuth' => { 'xmlns' => 'http://exacttarget.com' }}
	}
end

#soap_clientObject



137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/fuelsdk/soap.rb', line 137

def soap_client
	self.refresh
	@soap_client = Savon.client(
		soap_header: header,
		wsdl: wsdl,
		endpoint: endpoint,
		wsse_auth: ["*", "*"],
		raise_errors: false,
		log: debug,
		open_timeout:180,
		read_timeout: 180
	)
end

#soap_configure(object_type, action, properties) ⇒ Object



172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/fuelsdk/soap.rb', line 172

def soap_configure  object_type, action, properties
	message = {}
	message['Action'] = action
	message['Configurations'] = {}
	if properties.is_a? Array then
		message['Configurations']['Configuration'] = []
		properties.each do |configItem|
			message['Configurations']['Configuration'] << configItem
		end
	else
		message['Configurations'] = {'Configuration' => properties}
	end
	message['Configurations'][:attributes!] = { 'Configuration' => { 'xsi:type' => ('tns:' + object_type) }}

	soap_request :configure, message
end

#soap_delete(object_type, properties) ⇒ Object



230
231
232
# File 'lib/fuelsdk/soap.rb', line 230

def soap_delete object_type, properties
	soap_cud :delete, object_type, properties
end

#soap_describe(object_type) ⇒ Object



151
152
153
154
155
156
157
158
159
160
# File 'lib/fuelsdk/soap.rb', line 151

def soap_describe object_type
	message = {
		'DescribeRequests' => {
			'ObjectDefinitionRequest' => {
				'ObjectType' => object_type
			}
		}
	}
	soap_request :describe, message
end

#soap_get(object_type, properties = nil, filter = nil) ⇒ Object



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/fuelsdk/soap.rb', line 189

def soap_get object_type, properties=nil, filter=nil
	if properties.nil? or properties.empty?
		rsp = soap_describe object_type
		if rsp.success?
			properties = rsp.retrievable
		else
			rsp.instance_variable_set(:@message, "Unable to get #{object_type}") # back door update
			return rsp
		end
	elsif properties.kind_of? Hash
		properties = properties.keys
	elsif properties.kind_of? String
		properties = [properties]
	end

	message = {'ObjectType' => object_type, 'Properties' => properties}

	if filter and filter.kind_of? Hash
		message['Filter'] = filter
		message[:attributes!] = { 'Filter' => { 'xsi:type' => 'tns:SimpleFilterPart' } }

		if filter.has_key?('LogicalOperator')
			message[:attributes!] = { 'Filter' => { 'xsi:type' => 'tns:ComplexFilterPart' }}
			message['Filter'][:attributes!] = {
				'LeftOperand' => { 'xsi:type' => 'tns:SimpleFilterPart' },
			'RightOperand' => { 'xsi:type' => 'tns:SimpleFilterPart' }}
		end
	end
	message = {'RetrieveRequest' => message}

	soap_request :retrieve, message
end

#soap_patch(object_type, properties) ⇒ Object



226
227
228
# File 'lib/fuelsdk/soap.rb', line 226

def soap_patch object_type, properties
	soap_cud :update, object_type, properties
end

#soap_perform(object_type, action, properties) ⇒ Object



162
163
164
165
166
167
168
169
# File 'lib/fuelsdk/soap.rb', line 162

def soap_perform object_type, action, properties
	message = {}
	message['Action'] = action
	message['Definitions'] = {'Definition' => properties}
	message['Definitions'][:attributes!] = { 'Definition' => { 'xsi:type' => ('tns:' + object_type) }}

	soap_request :perform, message
end

#soap_post(object_type, properties) ⇒ Object



222
223
224
# File 'lib/fuelsdk/soap.rb', line 222

def soap_post object_type, properties
	soap_cud :create, object_type, properties
end

#soap_put(object_type, properties) ⇒ Object



234
235
236
# File 'lib/fuelsdk/soap.rb', line 234

def soap_put object_type, properties
	soap_cud :update, object_type, properties, true
end