sfmc-fuelsdk-ruby 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +28 -28
- data/Gemfile +3 -3
- data/Gemfile.lock +92 -90
- data/Guardfile +8 -8
- data/LICENSE.md +13 -13
- data/README.md +166 -143
- data/Rakefile +1 -1
- data/lib/marketingcloudsdk.rb +74 -74
- data/lib/marketingcloudsdk/client.rb +348 -296
- data/lib/marketingcloudsdk/http_request.rb +118 -118
- data/lib/marketingcloudsdk/objects.rb +757 -757
- data/lib/marketingcloudsdk/rest.rb +118 -118
- data/lib/marketingcloudsdk/soap.rb +296 -282
- data/lib/marketingcloudsdk/targeting.rb +99 -99
- data/lib/marketingcloudsdk/utils.rb +47 -47
- data/lib/marketingcloudsdk/version.rb +39 -39
- data/lib/new.rb +1240 -1240
- data/marketingcloudsdk.gemspec +30 -30
- data/samples/sample-AddSubscriberToList.rb +56 -56
- data/samples/sample-CreateAndStartDataExtensionImport.rb +29 -29
- data/samples/sample-CreateAndStartListImport.rb +27 -27
- data/samples/sample-CreateContentAreas.rb +48 -48
- data/samples/sample-CreateDataExtensions.rb +54 -54
- data/samples/sample-CreateProfileAttributes.rb +48 -48
- data/samples/sample-SendEmailToDataExtension.rb +23 -23
- data/samples/sample-SendEmailToList.rb +23 -23
- data/samples/sample-SendTriggeredSends.rb +30 -30
- data/samples/sample-bounceevent.rb +70 -70
- data/samples/sample-campaign.rb +211 -211
- data/samples/sample-clickevent.rb +71 -71
- data/samples/sample-contentarea.rb +122 -122
- data/samples/sample-dataextension.rb +209 -209
- data/samples/sample-directverb.rb +54 -54
- data/samples/sample-email.rb +122 -122
- data/samples/sample-email.senddefinition.rb +134 -134
- data/samples/sample-folder.rb +143 -143
- data/samples/sample-import.rb +103 -103
- data/samples/sample-list.rb +105 -105
- data/samples/sample-list.subscriber.rb +97 -97
- data/samples/sample-openevent.rb +70 -70
- data/samples/sample-profileattribute.rb +56 -56
- data/samples/sample-sentevent.rb +70 -70
- data/samples/sample-subscriber.rb +135 -135
- data/samples/sample-triggeredsend.rb +129 -129
- data/samples/sample-unsubevent.rb +72 -72
- data/samples/sample_helper.rb.template +10 -10
- data/spec/client_spec.rb +218 -218
- data/spec/default_values_fallback_spec.rb +30 -30
- data/spec/helper_funcs_spec.rb +11 -11
- data/spec/http_request_spec.rb +61 -61
- data/spec/objects_helper_spec.rb +32 -32
- data/spec/objects_spec.rb +484 -484
- data/spec/rest_spec.rb +48 -48
- data/spec/soap_spec.rb +140 -140
- data/spec/spec_helper.rb +14 -14
- data/spec/targeting_spec.rb +44 -44
- metadata +9 -9
data/marketingcloudsdk.gemspec
CHANGED
@@ -1,30 +1,30 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'marketingcloudsdk/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "sfmc-fuelsdk-ruby"
|
8
|
-
spec.version = MarketingCloudSDK::VERSION
|
9
|
-
spec.authors = ["Salesforce"]
|
10
|
-
spec.email = ["mcsdkadmin@salesforce.com"]
|
11
|
-
spec.description = %q{API wrapper for SOAP and REST API with Salesforce Marketing Cloud (ExactTarget)}
|
12
|
-
spec.summary = %q{Fuel Client Library for Ruby}
|
13
|
-
spec.homepage = "https://github.com/ExactTarget/FuelSDK-Ruby"
|
14
|
-
spec.license = ""
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(samples|test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler","~> 1.3"
|
22
|
-
spec.add_development_dependency 'rake','~>0.9'
|
23
|
-
spec.add_development_dependency "rspec",'~> 2.0'
|
24
|
-
spec.add_development_dependency "guard",'~> 1.1'
|
25
|
-
spec.add_development_dependency "guard-rspec",'~> 2.0'
|
26
|
-
|
27
|
-
spec.add_dependency "savon", "2.2.0"
|
28
|
-
spec.add_dependency "json", "~>1.8",">= 1.8.1"
|
29
|
-
spec.add_dependency "jwt", "~>1.0",">= 1.0.0"
|
30
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'marketingcloudsdk/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sfmc-fuelsdk-ruby"
|
8
|
+
spec.version = MarketingCloudSDK::VERSION
|
9
|
+
spec.authors = ["Salesforce"]
|
10
|
+
spec.email = ["mcsdkadmin@salesforce.com"]
|
11
|
+
spec.description = %q{API wrapper for SOAP and REST API with Salesforce Marketing Cloud (ExactTarget)}
|
12
|
+
spec.summary = %q{Fuel Client Library for Ruby}
|
13
|
+
spec.homepage = "https://github.com/ExactTarget/FuelSDK-Ruby"
|
14
|
+
spec.license = ""
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(samples|test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler","~> 1.3"
|
22
|
+
spec.add_development_dependency 'rake','~>0.9'
|
23
|
+
spec.add_development_dependency "rspec",'~> 2.0'
|
24
|
+
spec.add_development_dependency "guard",'~> 1.1'
|
25
|
+
spec.add_development_dependency "guard-rspec",'~> 2.0'
|
26
|
+
|
27
|
+
spec.add_dependency "savon", "2.2.0"
|
28
|
+
spec.add_dependency "json", "~>1.8",">= 1.8.1"
|
29
|
+
spec.add_dependency "jwt", "~>1.0",">= 1.0.0"
|
30
|
+
end
|
@@ -1,56 +1,56 @@
|
|
1
|
-
require 'marketingcloudsdk'
|
2
|
-
require_relative 'sample_helper'
|
3
|
-
|
4
|
-
begin
|
5
|
-
stubObj = ET_Client.new auth
|
6
|
-
|
7
|
-
NewListName = "RubySDKList"
|
8
|
-
|
9
|
-
## Example using AddSubscriberToList() method
|
10
|
-
## Typically this method will be used with a pre-existing list but for testing purposes one is being created.
|
11
|
-
|
12
|
-
# Create List
|
13
|
-
p '>>> Create List'
|
14
|
-
postList = ET_List.new
|
15
|
-
postList.authStub = stubObj
|
16
|
-
postList.props = {"ListName" => NewListName, "Description" => "This list was created with the RubySDK", "Type" => "Private" }
|
17
|
-
postResponse = postList.post
|
18
|
-
p 'Post Status: ' + postResponse.status.to_s
|
19
|
-
p 'Code: ' + postResponse.code.to_s
|
20
|
-
p 'Message: ' + postResponse.message.to_s
|
21
|
-
p 'Result Count: ' + postResponse.results.length.to_s
|
22
|
-
p 'Results: ' + postResponse.results.inspect
|
23
|
-
raise 'Failure creating list' unless postResponse.success?
|
24
|
-
|
25
|
-
if postResponse.status then
|
26
|
-
|
27
|
-
newListID = postResponse.results[0][:new_id]
|
28
|
-
# Adding Subscriber To a List
|
29
|
-
p '>>> Add Subscriber To a List'
|
30
|
-
AddSubResponse = stubObj.AddSubscriberToList("AddSubTesting@bh.exacttarget.com", [newListID], "Test")
|
31
|
-
p 'AddSubResponse Status: ' + AddSubResponse.status.to_s
|
32
|
-
p 'Code: ' + AddSubResponse.code.to_s
|
33
|
-
p 'Message: ' + AddSubResponse.message.to_s
|
34
|
-
p 'Result Count: ' + AddSubResponse.results.length.to_s
|
35
|
-
p 'Results: ' + AddSubResponse.results.inspect
|
36
|
-
raise 'Failure adding user to list' unless AddSubResponse.success?
|
37
|
-
|
38
|
-
# Delete List
|
39
|
-
p '>>> Delete List'
|
40
|
-
deleteSub = ET_List.new()
|
41
|
-
deleteSub.authStub = stubObj
|
42
|
-
deleteSub.props = {"ID" => newListID}
|
43
|
-
deleteResponse = deleteSub.delete
|
44
|
-
p 'Delete Status: ' + deleteResponse.status.to_s
|
45
|
-
p 'Code: ' + deleteResponse.code.to_s
|
46
|
-
p 'Message: ' + deleteResponse.message.to_s
|
47
|
-
p 'Results Length: ' + deleteResponse.results.length.to_s
|
48
|
-
p 'Results: ' + deleteResponse.results.to_s
|
49
|
-
raise 'Failure deleting list' unless deleteResponse.success?
|
50
|
-
end
|
51
|
-
|
52
|
-
rescue => e
|
53
|
-
p "Caught exception: #{e.message}"
|
54
|
-
p e.backtrace
|
55
|
-
end
|
56
|
-
|
1
|
+
require 'marketingcloudsdk'
|
2
|
+
require_relative 'sample_helper'
|
3
|
+
|
4
|
+
begin
|
5
|
+
stubObj = ET_Client.new auth
|
6
|
+
|
7
|
+
NewListName = "RubySDKList"
|
8
|
+
|
9
|
+
## Example using AddSubscriberToList() method
|
10
|
+
## Typically this method will be used with a pre-existing list but for testing purposes one is being created.
|
11
|
+
|
12
|
+
# Create List
|
13
|
+
p '>>> Create List'
|
14
|
+
postList = ET_List.new
|
15
|
+
postList.authStub = stubObj
|
16
|
+
postList.props = {"ListName" => NewListName, "Description" => "This list was created with the RubySDK", "Type" => "Private" }
|
17
|
+
postResponse = postList.post
|
18
|
+
p 'Post Status: ' + postResponse.status.to_s
|
19
|
+
p 'Code: ' + postResponse.code.to_s
|
20
|
+
p 'Message: ' + postResponse.message.to_s
|
21
|
+
p 'Result Count: ' + postResponse.results.length.to_s
|
22
|
+
p 'Results: ' + postResponse.results.inspect
|
23
|
+
raise 'Failure creating list' unless postResponse.success?
|
24
|
+
|
25
|
+
if postResponse.status then
|
26
|
+
|
27
|
+
newListID = postResponse.results[0][:new_id]
|
28
|
+
# Adding Subscriber To a List
|
29
|
+
p '>>> Add Subscriber To a List'
|
30
|
+
AddSubResponse = stubObj.AddSubscriberToList("AddSubTesting@bh.exacttarget.com", [newListID], "Test")
|
31
|
+
p 'AddSubResponse Status: ' + AddSubResponse.status.to_s
|
32
|
+
p 'Code: ' + AddSubResponse.code.to_s
|
33
|
+
p 'Message: ' + AddSubResponse.message.to_s
|
34
|
+
p 'Result Count: ' + AddSubResponse.results.length.to_s
|
35
|
+
p 'Results: ' + AddSubResponse.results.inspect
|
36
|
+
raise 'Failure adding user to list' unless AddSubResponse.success?
|
37
|
+
|
38
|
+
# Delete List
|
39
|
+
p '>>> Delete List'
|
40
|
+
deleteSub = ET_List.new()
|
41
|
+
deleteSub.authStub = stubObj
|
42
|
+
deleteSub.props = {"ID" => newListID}
|
43
|
+
deleteResponse = deleteSub.delete
|
44
|
+
p 'Delete Status: ' + deleteResponse.status.to_s
|
45
|
+
p 'Code: ' + deleteResponse.code.to_s
|
46
|
+
p 'Message: ' + deleteResponse.message.to_s
|
47
|
+
p 'Results Length: ' + deleteResponse.results.length.to_s
|
48
|
+
p 'Results: ' + deleteResponse.results.to_s
|
49
|
+
raise 'Failure deleting list' unless deleteResponse.success?
|
50
|
+
end
|
51
|
+
|
52
|
+
rescue => e
|
53
|
+
p "Caught exception: #{e.message}"
|
54
|
+
p e.backtrace
|
55
|
+
end
|
56
|
+
|
@@ -1,29 +1,29 @@
|
|
1
|
-
require 'marketingcloudsdk'
|
2
|
-
require_relative 'sample_helper'
|
3
|
-
|
4
|
-
begin
|
5
|
-
myclient = MarketingCloudSDK::Client.new auth
|
6
|
-
|
7
|
-
DataExtensionCustomerKey = "62476204-bfd3-de11-95ca-001e0bbae8cc"
|
8
|
-
CSVFileName = "SDKExample.csv"
|
9
|
-
|
10
|
-
=begin
|
11
|
-
* Parameters:
|
12
|
-
* Data Extension CustomerKey - CustomerKey values are displayed in the UI as External Key
|
13
|
-
* File Name - File must be a CSV located on your ExactTarget FTP Site
|
14
|
-
* Overwrite (Boolean) - Set to True in order to overwrite all existing data in the data extension. Required if Data Extension does not have a primary key.
|
15
|
-
=end
|
16
|
-
|
17
|
-
response = myclient.CreateAndStartDataExtensionImport(DataExtensionCustomerKey, CSVFileName, true)
|
18
|
-
p 'Response Status: ' + response.status.to_s
|
19
|
-
p 'Code: ' + response.code.to_s
|
20
|
-
p 'Message: ' + response.message.to_s
|
21
|
-
p 'Results Length: ' + response.results.length.to_s
|
22
|
-
p 'Results: ' + response.results.to_s
|
23
|
-
|
24
|
-
rescue => e
|
25
|
-
p "Caught exception: #{e.message}"
|
26
|
-
p e.backtrace
|
27
|
-
end
|
28
|
-
|
29
|
-
|
1
|
+
require 'marketingcloudsdk'
|
2
|
+
require_relative 'sample_helper'
|
3
|
+
|
4
|
+
begin
|
5
|
+
myclient = MarketingCloudSDK::Client.new auth
|
6
|
+
|
7
|
+
DataExtensionCustomerKey = "62476204-bfd3-de11-95ca-001e0bbae8cc"
|
8
|
+
CSVFileName = "SDKExample.csv"
|
9
|
+
|
10
|
+
=begin
|
11
|
+
* Parameters:
|
12
|
+
* Data Extension CustomerKey - CustomerKey values are displayed in the UI as External Key
|
13
|
+
* File Name - File must be a CSV located on your ExactTarget FTP Site
|
14
|
+
* Overwrite (Boolean) - Set to True in order to overwrite all existing data in the data extension. Required if Data Extension does not have a primary key.
|
15
|
+
=end
|
16
|
+
|
17
|
+
response = myclient.CreateAndStartDataExtensionImport(DataExtensionCustomerKey, CSVFileName, true)
|
18
|
+
p 'Response Status: ' + response.status.to_s
|
19
|
+
p 'Code: ' + response.code.to_s
|
20
|
+
p 'Message: ' + response.message.to_s
|
21
|
+
p 'Results Length: ' + response.results.length.to_s
|
22
|
+
p 'Results: ' + response.results.to_s
|
23
|
+
|
24
|
+
rescue => e
|
25
|
+
p "Caught exception: #{e.message}"
|
26
|
+
p e.backtrace
|
27
|
+
end
|
28
|
+
|
29
|
+
|
@@ -1,27 +1,27 @@
|
|
1
|
-
require 'marketingcloudsdk'
|
2
|
-
require_relative 'sample_helper'
|
3
|
-
|
4
|
-
begin
|
5
|
-
myclient = MarketingCloudSDK::Client.new auth
|
6
|
-
ListID = "1956035"
|
7
|
-
CSVFileName = "SDKExample.csv"
|
8
|
-
|
9
|
-
=begin
|
10
|
-
* Parameters:
|
11
|
-
* List ID
|
12
|
-
* File Name - File must be a CSV located on your ExactTarget FTP Site
|
13
|
-
=end
|
14
|
-
|
15
|
-
response = myclient.CreateAndStartListImport(ListID, CSVFileName)
|
16
|
-
p 'Response Status: ' + response.status.to_s
|
17
|
-
p 'Code: ' + response.code.to_s
|
18
|
-
p 'Message: ' + response.message.to_s
|
19
|
-
p 'Results Length: ' + response.results.length.to_s
|
20
|
-
p 'Results: ' + response.results.to_s
|
21
|
-
|
22
|
-
rescue => e
|
23
|
-
p "Caught exception: #{e.message}"
|
24
|
-
p e.backtrace
|
25
|
-
end
|
26
|
-
|
27
|
-
|
1
|
+
require 'marketingcloudsdk'
|
2
|
+
require_relative 'sample_helper'
|
3
|
+
|
4
|
+
begin
|
5
|
+
myclient = MarketingCloudSDK::Client.new auth
|
6
|
+
ListID = "1956035"
|
7
|
+
CSVFileName = "SDKExample.csv"
|
8
|
+
|
9
|
+
=begin
|
10
|
+
* Parameters:
|
11
|
+
* List ID
|
12
|
+
* File Name - File must be a CSV located on your ExactTarget FTP Site
|
13
|
+
=end
|
14
|
+
|
15
|
+
response = myclient.CreateAndStartListImport(ListID, CSVFileName)
|
16
|
+
p 'Response Status: ' + response.status.to_s
|
17
|
+
p 'Code: ' + response.code.to_s
|
18
|
+
p 'Message: ' + response.message.to_s
|
19
|
+
p 'Results Length: ' + response.results.length.to_s
|
20
|
+
p 'Results: ' + response.results.to_s
|
21
|
+
|
22
|
+
rescue => e
|
23
|
+
p "Caught exception: #{e.message}"
|
24
|
+
p e.backtrace
|
25
|
+
end
|
26
|
+
|
27
|
+
|
@@ -1,48 +1,48 @@
|
|
1
|
-
require 'marketingcloudsdk'
|
2
|
-
require_relative 'sample_helper'
|
3
|
-
|
4
|
-
begin
|
5
|
-
myclient = MarketingCloudSDK::Client.new auth
|
6
|
-
|
7
|
-
## Example using CreateContentAreas() method
|
8
|
-
|
9
|
-
NameOfContentAreaOne = "ExampleContentAreaOne"
|
10
|
-
NameOfContentAreaTwo = "ExampleContentAreaTwo"
|
11
|
-
|
12
|
-
# Declare a Ruby Hash which contain all of the details for a DataExtension
|
13
|
-
contAreaOne = {"CustomerKey" => NameOfContentAreaOne, "Name"=>NameOfContentAreaOne, "Content"=> "<b>Some HTML Content Goes here</b>"}
|
14
|
-
contAreaTwo = {"CustomerKey" => NameOfContentAreaTwo, "Name"=>NameOfContentAreaTwo, "Content"=> "<b>Some Different HTML Content Goes here</b>"}
|
15
|
-
|
16
|
-
# Call CreateDataExtensions passing in both DataExtension Hashes as an Array
|
17
|
-
response = myclient.CreateContentAreas([contAreaOne,contAreaTwo])
|
18
|
-
p 'Response Status: ' + response.status.to_s
|
19
|
-
p 'Code: ' + response.code.to_s
|
20
|
-
p 'Message: ' + response.message.to_s
|
21
|
-
p 'Results Length: ' + response.results.length.to_s
|
22
|
-
p 'Results: ' + response.results.to_s
|
23
|
-
|
24
|
-
p '>>> Delete contAreaOne'
|
25
|
-
contArea = ET_ContentArea.new
|
26
|
-
contArea.authStub = myclient
|
27
|
-
contArea.props = {"CustomerKey" => NameOfContentAreaOne}
|
28
|
-
delResponse = contArea.delete
|
29
|
-
p 'Delete Status: ' + delResponse.status.to_s
|
30
|
-
p 'Code: ' + delResponse.code.to_s
|
31
|
-
p 'Message: ' + delResponse.message.to_s
|
32
|
-
p 'Results: ' + delResponse.results.inspect
|
33
|
-
|
34
|
-
p '>>> Delete contAreaTwo'
|
35
|
-
contArea = ET_ContentArea.new
|
36
|
-
contArea.authStub = myclient
|
37
|
-
contArea.props = {"CustomerKey" => NameOfContentAreaTwo}
|
38
|
-
delResponse = contArea.delete
|
39
|
-
p 'Delete Status: ' + delResponse.status.to_s
|
40
|
-
p 'Code: ' + delResponse.code.to_s
|
41
|
-
p 'Message: ' + delResponse.message.to_s
|
42
|
-
p 'Results: ' + delResponse.results.inspect
|
43
|
-
|
44
|
-
rescue => e
|
45
|
-
p "Caught exception: #{e.message}"
|
46
|
-
p e.backtrace
|
47
|
-
end
|
48
|
-
|
1
|
+
require 'marketingcloudsdk'
|
2
|
+
require_relative 'sample_helper'
|
3
|
+
|
4
|
+
begin
|
5
|
+
myclient = MarketingCloudSDK::Client.new auth
|
6
|
+
|
7
|
+
## Example using CreateContentAreas() method
|
8
|
+
|
9
|
+
NameOfContentAreaOne = "ExampleContentAreaOne"
|
10
|
+
NameOfContentAreaTwo = "ExampleContentAreaTwo"
|
11
|
+
|
12
|
+
# Declare a Ruby Hash which contain all of the details for a DataExtension
|
13
|
+
contAreaOne = {"CustomerKey" => NameOfContentAreaOne, "Name"=>NameOfContentAreaOne, "Content"=> "<b>Some HTML Content Goes here</b>"}
|
14
|
+
contAreaTwo = {"CustomerKey" => NameOfContentAreaTwo, "Name"=>NameOfContentAreaTwo, "Content"=> "<b>Some Different HTML Content Goes here</b>"}
|
15
|
+
|
16
|
+
# Call CreateDataExtensions passing in both DataExtension Hashes as an Array
|
17
|
+
response = myclient.CreateContentAreas([contAreaOne,contAreaTwo])
|
18
|
+
p 'Response Status: ' + response.status.to_s
|
19
|
+
p 'Code: ' + response.code.to_s
|
20
|
+
p 'Message: ' + response.message.to_s
|
21
|
+
p 'Results Length: ' + response.results.length.to_s
|
22
|
+
p 'Results: ' + response.results.to_s
|
23
|
+
|
24
|
+
p '>>> Delete contAreaOne'
|
25
|
+
contArea = ET_ContentArea.new
|
26
|
+
contArea.authStub = myclient
|
27
|
+
contArea.props = {"CustomerKey" => NameOfContentAreaOne}
|
28
|
+
delResponse = contArea.delete
|
29
|
+
p 'Delete Status: ' + delResponse.status.to_s
|
30
|
+
p 'Code: ' + delResponse.code.to_s
|
31
|
+
p 'Message: ' + delResponse.message.to_s
|
32
|
+
p 'Results: ' + delResponse.results.inspect
|
33
|
+
|
34
|
+
p '>>> Delete contAreaTwo'
|
35
|
+
contArea = ET_ContentArea.new
|
36
|
+
contArea.authStub = myclient
|
37
|
+
contArea.props = {"CustomerKey" => NameOfContentAreaTwo}
|
38
|
+
delResponse = contArea.delete
|
39
|
+
p 'Delete Status: ' + delResponse.status.to_s
|
40
|
+
p 'Code: ' + delResponse.code.to_s
|
41
|
+
p 'Message: ' + delResponse.message.to_s
|
42
|
+
p 'Results: ' + delResponse.results.inspect
|
43
|
+
|
44
|
+
rescue => e
|
45
|
+
p "Caught exception: #{e.message}"
|
46
|
+
p e.backtrace
|
47
|
+
end
|
48
|
+
|
@@ -1,54 +1,54 @@
|
|
1
|
-
require 'marketingcloudsdk'
|
2
|
-
require_relative 'sample_helper'
|
3
|
-
|
4
|
-
begin
|
5
|
-
myclient = ET_Client.new auth
|
6
|
-
|
7
|
-
## Example using CreateDataExtensions() method
|
8
|
-
|
9
|
-
# Declare a Ruby Hash which contain all of the details for a DataExtension
|
10
|
-
deOne = {"Name" => "HelperDEOne","CustomerKey" => "HelperDEOne"}
|
11
|
-
deOne['columns'] = [{"Name" => "Name", "FieldType" => "Text", "IsPrimaryKey" => "true", "MaxLength" => "100", "IsRequired" => "true"},{"Name" => "OtherField", "FieldType" => "Text"}]
|
12
|
-
|
13
|
-
# Declare a 2nd Ruby Hash which contain all of the details for a DataExtension
|
14
|
-
deTwo = {"Name" => "HelperDETwo","CustomerKey" => "HelperDETwo"}
|
15
|
-
deTwo['columns'] = [{"Name" => "Name", "FieldType" => "Text", "IsPrimaryKey" => "true", "MaxLength" => "100", "IsRequired" => "true"},{"Name" => "OtherField", "FieldType" => "Text"}]
|
16
|
-
|
17
|
-
# Call CreateDataExtensions passing in both DataExtension Hashes as an Array
|
18
|
-
createDEResponse = myclient.CreateDataExtensions([deOne, deTwo])
|
19
|
-
p 'CreateDataExtensions Status: ' + createDEResponse.status.to_s
|
20
|
-
p 'Code: ' + createDEResponse.code.to_s
|
21
|
-
p 'Message: ' + createDEResponse.message.to_s
|
22
|
-
p 'Results Length: ' + createDEResponse.results.length.to_s
|
23
|
-
p 'Results: ' + createDEResponse.results.to_s
|
24
|
-
raise 'Failure creating data extensions' unless createDEResponse.success?
|
25
|
-
raise 'Failure creating data extensions' unless createDEResponse.results.count == 2
|
26
|
-
|
27
|
-
# Cleaning up the newly created DEs
|
28
|
-
# Delete deOne
|
29
|
-
p '>>> Delete deOne'
|
30
|
-
de5 = ET_DataExtension.new
|
31
|
-
de5.authStub = myclient
|
32
|
-
de5.props = {"CustomerKey" => "HelperDEOne"}
|
33
|
-
delResponse = de5.delete
|
34
|
-
p 'Delete Status: ' + delResponse.status.to_s
|
35
|
-
p 'Code: ' + delResponse.code.to_s
|
36
|
-
p 'Message: ' + delResponse.message.to_s
|
37
|
-
p 'Results: ' + delResponse.results.inspect
|
38
|
-
|
39
|
-
# Delete deTwo
|
40
|
-
p '>>> Delete deTwo'
|
41
|
-
de5 = ET_DataExtension.new
|
42
|
-
de5.authStub = myclient
|
43
|
-
de5.props = {"CustomerKey" => "HelperDETwo"}
|
44
|
-
delResponse = de5.delete
|
45
|
-
p 'Delete Status: ' + delResponse.status.to_s
|
46
|
-
p 'Code: ' + delResponse.code.to_s
|
47
|
-
p 'Message: ' + delResponse.message.to_s
|
48
|
-
p 'Results: ' + delResponse.results.inspect
|
49
|
-
|
50
|
-
rescue => e
|
51
|
-
p "Caught exception: #{e.message}"
|
52
|
-
p e.backtrace
|
53
|
-
end
|
54
|
-
|
1
|
+
require 'marketingcloudsdk'
|
2
|
+
require_relative 'sample_helper'
|
3
|
+
|
4
|
+
begin
|
5
|
+
myclient = ET_Client.new auth
|
6
|
+
|
7
|
+
## Example using CreateDataExtensions() method
|
8
|
+
|
9
|
+
# Declare a Ruby Hash which contain all of the details for a DataExtension
|
10
|
+
deOne = {"Name" => "HelperDEOne","CustomerKey" => "HelperDEOne"}
|
11
|
+
deOne['columns'] = [{"Name" => "Name", "FieldType" => "Text", "IsPrimaryKey" => "true", "MaxLength" => "100", "IsRequired" => "true"},{"Name" => "OtherField", "FieldType" => "Text"}]
|
12
|
+
|
13
|
+
# Declare a 2nd Ruby Hash which contain all of the details for a DataExtension
|
14
|
+
deTwo = {"Name" => "HelperDETwo","CustomerKey" => "HelperDETwo"}
|
15
|
+
deTwo['columns'] = [{"Name" => "Name", "FieldType" => "Text", "IsPrimaryKey" => "true", "MaxLength" => "100", "IsRequired" => "true"},{"Name" => "OtherField", "FieldType" => "Text"}]
|
16
|
+
|
17
|
+
# Call CreateDataExtensions passing in both DataExtension Hashes as an Array
|
18
|
+
createDEResponse = myclient.CreateDataExtensions([deOne, deTwo])
|
19
|
+
p 'CreateDataExtensions Status: ' + createDEResponse.status.to_s
|
20
|
+
p 'Code: ' + createDEResponse.code.to_s
|
21
|
+
p 'Message: ' + createDEResponse.message.to_s
|
22
|
+
p 'Results Length: ' + createDEResponse.results.length.to_s
|
23
|
+
p 'Results: ' + createDEResponse.results.to_s
|
24
|
+
raise 'Failure creating data extensions' unless createDEResponse.success?
|
25
|
+
raise 'Failure creating data extensions' unless createDEResponse.results.count == 2
|
26
|
+
|
27
|
+
# Cleaning up the newly created DEs
|
28
|
+
# Delete deOne
|
29
|
+
p '>>> Delete deOne'
|
30
|
+
de5 = ET_DataExtension.new
|
31
|
+
de5.authStub = myclient
|
32
|
+
de5.props = {"CustomerKey" => "HelperDEOne"}
|
33
|
+
delResponse = de5.delete
|
34
|
+
p 'Delete Status: ' + delResponse.status.to_s
|
35
|
+
p 'Code: ' + delResponse.code.to_s
|
36
|
+
p 'Message: ' + delResponse.message.to_s
|
37
|
+
p 'Results: ' + delResponse.results.inspect
|
38
|
+
|
39
|
+
# Delete deTwo
|
40
|
+
p '>>> Delete deTwo'
|
41
|
+
de5 = ET_DataExtension.new
|
42
|
+
de5.authStub = myclient
|
43
|
+
de5.props = {"CustomerKey" => "HelperDETwo"}
|
44
|
+
delResponse = de5.delete
|
45
|
+
p 'Delete Status: ' + delResponse.status.to_s
|
46
|
+
p 'Code: ' + delResponse.code.to_s
|
47
|
+
p 'Message: ' + delResponse.message.to_s
|
48
|
+
p 'Results: ' + delResponse.results.inspect
|
49
|
+
|
50
|
+
rescue => e
|
51
|
+
p "Caught exception: #{e.message}"
|
52
|
+
p e.backtrace
|
53
|
+
end
|
54
|
+
|