Module: MarketingCloudSDK::Objects::Soap::CUD

Included in:
ContentArea, DataExtension, DataExtension::Row, DataFolder, Delete, Email, Email::SendDefinition, Import, List, Patch, Post, Subscriber, TriggeredSend
Defined in:
lib/marketingcloudsdk/objects.rb

Overview

create, update, delete

Instance Method Summary collapse

Instance Method Details

#deleteObject



109
110
111
# File 'lib/marketingcloudsdk/objects.rb', line 109

def delete
	client.soap_delete id, properties
end

#patchObject



105
106
107
# File 'lib/marketingcloudsdk/objects.rb', line 105

def patch
	client.soap_patch id, properties
end

#postObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/marketingcloudsdk/objects.rb', line 52

def post
	if self.respond_to?('folder_property') && !self.folder_id.nil?
		properties[self.folder_property]  = self.folder_id
	elsif self.respond_to?('folder_property') && !self.folder_property.nil? && !client.package_name.nil? then
		if client.package_folders.nil? then
			getPackageFolder = ET_Folder.new
			getPackageFolder.authStub = client
			getPackageFolder.properties = ["ID", "ContentType"]
			getPackageFolder.filter = {"Property" => "Name", "SimpleOperator" => "equals", "Value" => client.package_name}
			resultPackageFolder = getPackageFolder.get
			if resultPackageFolder.status then
				client.package_folders = {}
				resultPackageFolder.results.each do |value|
					client.package_folders[value[:content_type]] = value[:id]
				end
			else
				raise "Unable to retrieve folders from account due to: #{resultPackageFolder.message}"
			end
		end

		if !client.package_folders.has_key?(self.folder_media_type) then
			if client.parentFolders.nil? then
				parentFolders = ET_Folder.new
				parentFolders.authStub = client
				parentFolders.properties = ["ID", "ContentType"]
				parentFolders.filter = {"Property" => "ParentFolder.ID", "SimpleOperator" => "equals", "Value" => "0"}
				resultParentFolders = parentFolders.get
				if resultParentFolders.status then
					client.parent_folders = {}
					resultParentFolders.results.each do |value|
						client.parent_folders[value[:content_type]] = value[:id]
					end
				else
					raise "Unable to retrieve folders from account due to: #{resultParentFolders.message}"
				end
			end

			newFolder = ET_Folder.new
			newFolder.authStub = client
			newFolder.properties = {"Name" => client.package_name, "Description" => client.package_name, "ContentType"=> self.folder_media_type, "IsEditable"=>"true", "ParentFolder" => {"ID" => client.parentFolders[self.folder_media_type]}}
			folderResult = newFolder.post
			if folderResult.status then
				client.package_folders[self.folder_media_type]  = folderResult.results[0][:new_id]
			else
				raise "Unable to create folder for Post due to: #{folderResult.message}"
			end

		end
		properties[self.folder_property] = client.package_folders[self.folder_media_type]
	end
	client.soap_post id, properties
end