Module: MarketingCloudSDK::Soap

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

Instance Attribute Summary collapse

Attributes included from Targeting

#access_token, #endpoint, #soap_endpoint

Instance Method Summary collapse

Methods included from Targeting

#cache_file, #get_soap_endpoint_from_file, #set_soap_endpoint_to_file

Methods included from HTTPRequest

#generate_uri, #request

Instance Attribute Details

#debugObject

, :internal_token



119
120
121
# File 'lib/marketingcloudsdk/soap.rb', line 119

def debug
  @debug
end

#wsdlObject

, :internal_token



119
120
121
# File 'lib/marketingcloudsdk/soap.rb', line 119

def wsdl
  @wsdl
end

Instance Method Details

#headerObject



123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/marketingcloudsdk/soap.rb', line 123

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

#soap_clientObject



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/marketingcloudsdk/soap.rb', line 146

def soap_client
	self.refresh

	soap_client_options = {
			soap_header: header,
			wsdl: wsdl,
			endpoint: endpoint,
			wsse_auth: ["*", "*"],
			raise_errors: false,
			log: debug,
			open_timeout:180,
			read_timeout: 180,
			headers: {'User-Agent' => 'FuelSDK-Ruby-v' + MarketingCloudSDK::VERSION}
	}

	if use_oAuth2_authentication == true then
		soap_client_options.delete(:wsse_auth)
	end

	@soap_client = Savon.client(soap_client_options)
end

#soap_configure(object_type, action, properties) ⇒ Object



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/marketingcloudsdk/soap.rb', line 189

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



247
248
249
# File 'lib/marketingcloudsdk/soap.rb', line 247

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

#soap_describe(object_type) ⇒ Object



168
169
170
171
172
173
174
175
176
177
# File 'lib/marketingcloudsdk/soap.rb', line 168

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



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/marketingcloudsdk/soap.rb', line 206

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



243
244
245
# File 'lib/marketingcloudsdk/soap.rb', line 243

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

#soap_perform(object_type, action, properties) ⇒ Object



179
180
181
182
183
184
185
186
# File 'lib/marketingcloudsdk/soap.rb', line 179

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



239
240
241
# File 'lib/marketingcloudsdk/soap.rb', line 239

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

#soap_put(object_type, properties) ⇒ Object



251
252
253
# File 'lib/marketingcloudsdk/soap.rb', line 251

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