sfmc-fuelsdk-ruby 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +28 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +90 -0
- data/Guardfile +8 -0
- data/LICENSE.md +13 -0
- data/README.md +143 -0
- data/Rakefile +1 -0
- data/lib/marketingcloudsdk/client.rb +296 -0
- data/lib/marketingcloudsdk/http_request.rb +118 -0
- data/lib/marketingcloudsdk/objects.rb +757 -0
- data/lib/marketingcloudsdk/rest.rb +118 -0
- data/lib/marketingcloudsdk/soap.rb +282 -0
- data/lib/marketingcloudsdk/targeting.rb +99 -0
- data/lib/marketingcloudsdk/utils.rb +47 -0
- data/lib/marketingcloudsdk/version.rb +39 -0
- data/lib/marketingcloudsdk.rb +74 -0
- data/lib/new.rb +1240 -0
- data/marketingcloudsdk.gemspec +30 -0
- data/samples/sample-AddSubscriberToList.rb +56 -0
- data/samples/sample-CreateAndStartDataExtensionImport.rb +29 -0
- data/samples/sample-CreateAndStartListImport.rb +27 -0
- data/samples/sample-CreateContentAreas.rb +48 -0
- data/samples/sample-CreateDataExtensions.rb +54 -0
- data/samples/sample-CreateProfileAttributes.rb +48 -0
- data/samples/sample-SendEmailToDataExtension.rb +23 -0
- data/samples/sample-SendEmailToList.rb +23 -0
- data/samples/sample-SendTriggeredSends.rb +30 -0
- data/samples/sample-bounceevent.rb +70 -0
- data/samples/sample-campaign.rb +211 -0
- data/samples/sample-clickevent.rb +71 -0
- data/samples/sample-contentarea.rb +122 -0
- data/samples/sample-dataextension.rb +209 -0
- data/samples/sample-directverb.rb +54 -0
- data/samples/sample-email.rb +122 -0
- data/samples/sample-email.senddefinition.rb +134 -0
- data/samples/sample-folder.rb +143 -0
- data/samples/sample-import.rb +103 -0
- data/samples/sample-list.rb +105 -0
- data/samples/sample-list.subscriber.rb +97 -0
- data/samples/sample-openevent.rb +70 -0
- data/samples/sample-profileattribute.rb +56 -0
- data/samples/sample-sentevent.rb +70 -0
- data/samples/sample-subscriber.rb +135 -0
- data/samples/sample-triggeredsend.rb +129 -0
- data/samples/sample-unsubevent.rb +72 -0
- data/samples/sample_helper.rb.template +10 -0
- data/spec/client_spec.rb +218 -0
- data/spec/default_values_fallback_spec.rb +30 -0
- data/spec/helper_funcs_spec.rb +11 -0
- data/spec/http_request_spec.rb +61 -0
- data/spec/objects_helper_spec.rb +32 -0
- data/spec/objects_spec.rb +484 -0
- data/spec/rest_spec.rb +48 -0
- data/spec/soap_spec.rb +140 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/targeting_spec.rb +44 -0
- metadata +262 -0
@@ -0,0 +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
|
@@ -0,0 +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
|
+
|
@@ -0,0 +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
|
+
|
@@ -0,0 +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
|
+
|
@@ -0,0 +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
|
+
|
@@ -0,0 +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
|
+
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'marketingcloudsdk'
|
2
|
+
require_relative 'sample_helper'
|
3
|
+
|
4
|
+
begin
|
5
|
+
myclient = MarketingCloudSDK::Client.new auth
|
6
|
+
|
7
|
+
## Example using CreateProfileAttributes() method
|
8
|
+
|
9
|
+
NameOfAttributeOne = "ExampleAttributeOne"
|
10
|
+
NameOfAttributeTwo = "ExampleAttributeTwo"
|
11
|
+
|
12
|
+
# Declare a Ruby Hash which contain all of the details for a DataExtension
|
13
|
+
profileAttrOne = {"Name" => NameOfAttributeOne, "PropertyType"=>"string", "Description"=>"New Attribute from the SDK", "IsRequired"=>"false", "IsViewable"=>"false", "IsEditable"=>"true", "IsSendTime"=>"false"}
|
14
|
+
profileAttrTwo = {"Name" => NameOfAttributeTwo, "PropertyType"=>"string", "Description"=>"New Attribute from the SDK", "IsRequired"=>"false", "IsViewable"=>"false", "IsEditable"=>"true", "IsSendTime"=>"false"}
|
15
|
+
|
16
|
+
# Call CreateDataExtensions passing in both DataExtension Hashes as an Array
|
17
|
+
response = myclient.CreateProfileAttributes([profileAttrOne,profileAttrTwo])
|
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 profileAttrOne'
|
25
|
+
profileattr = ET_ProfileAttribute.new
|
26
|
+
profileattr.authStub = myclient
|
27
|
+
profileattr.props = {"Name" => NameOfAttributeOne}
|
28
|
+
delResponse = profileattr.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 profileAttrTwo'
|
35
|
+
profileattr = ET_ProfileAttribute.new
|
36
|
+
profileattr.authStub = myclient
|
37
|
+
profileattr.props = {"Name" => NameOfAttributeTwo}
|
38
|
+
delResponse = profileattr.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
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'marketingcloudsdk'
|
2
|
+
require_relative 'sample_helper'
|
3
|
+
|
4
|
+
begin
|
5
|
+
myclient = MarketingCloudSDK::Client.new auth
|
6
|
+
|
7
|
+
EmailIDForSendDefinition = "3113962"
|
8
|
+
SendClassificationCustomerKey = "2239"
|
9
|
+
SendableDataExtensionCustomerKey = "F6F3871A-D124-499B-BBF5-3EFC0E827A51"
|
10
|
+
|
11
|
+
# Call SendEmailToDataExtension
|
12
|
+
response = myclient.SendEmailToDataExtension(EmailIDForSendDefinition, SendableDataExtensionCustomerKey,SendClassificationCustomerKey)
|
13
|
+
p 'Response Status: ' + response.status.to_s
|
14
|
+
p 'Code: ' + response.code.to_s
|
15
|
+
p 'Message: ' + response.message.to_s
|
16
|
+
p 'Results Length: ' + response.results.length.to_s
|
17
|
+
p 'Results: ' + response.results.to_s
|
18
|
+
|
19
|
+
rescue => e
|
20
|
+
p "Caught exception: #{e.message}"
|
21
|
+
p e.backtrace
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'marketingcloudsdk'
|
2
|
+
require_relative 'sample_helper'
|
3
|
+
|
4
|
+
begin
|
5
|
+
myclient = MarketingCloudSDK::Client.new auth
|
6
|
+
|
7
|
+
EmailIDForSendDefinition = "3113962"
|
8
|
+
ListIDForSendDefinition = "1729515"
|
9
|
+
SendClassificationCustomerKey = "2239"
|
10
|
+
|
11
|
+
# Call SendEmailToList
|
12
|
+
response = myclient.SendEmailToList(EmailIDForSendDefinition, ListIDForSendDefinition,SendClassificationCustomerKey)
|
13
|
+
p 'Response Status: ' + response.status.to_s
|
14
|
+
p 'Code: ' + response.code.to_s
|
15
|
+
p 'Message: ' + response.message.to_s
|
16
|
+
p 'Results Length: ' + response.results.length.to_s
|
17
|
+
p 'Results: ' + response.results.to_s
|
18
|
+
|
19
|
+
rescue => e
|
20
|
+
p "Caught exception: #{e.message}"
|
21
|
+
p e.backtrace
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'marketingcloudsdk'
|
2
|
+
require_relative 'sample_helper'
|
3
|
+
|
4
|
+
begin
|
5
|
+
myclient = MarketingCloudSDK::Client.new auth
|
6
|
+
|
7
|
+
TriggeredSendCustomerKey = "TEXTEXT"
|
8
|
+
AltTriggeredSendCustomerKey = "FailTest"
|
9
|
+
SubscriberEmailAddress = "SDKExample@bh.exacttarget.com"
|
10
|
+
|
11
|
+
# Call SendTriggeredSends which can be used to send emails to multiple definitions with a single request
|
12
|
+
# Limit usage to 50 subscribers per request.
|
13
|
+
tsOne = {"CustomerKey" => TriggeredSendCustomerKey}
|
14
|
+
tsOne['Subscribers'] = [{"EmailAddress"=>SubscriberEmailAddress, "SubscriberKey" => SubscriberEmailAddress}]
|
15
|
+
tsTwo = {"CustomerKey" => AltTriggeredSendCustomerKey}
|
16
|
+
tsTwo['Subscribers'] = [{"EmailAddress"=>SubscriberEmailAddress, "SubscriberKey" => SubscriberEmailAddress}]
|
17
|
+
|
18
|
+
response = myclient.SendTriggeredSends([tsOne,tsTwo])
|
19
|
+
p 'Response Status: ' + response.status.to_s
|
20
|
+
p 'Code: ' + response.code.to_s
|
21
|
+
p 'Message: ' + response.message.to_s
|
22
|
+
p 'Results Length: ' + response.results.length.to_s
|
23
|
+
p 'Results: ' + response.results.to_s
|
24
|
+
|
25
|
+
rescue => e
|
26
|
+
p "Caught exception: #{e.message}"
|
27
|
+
p e.backtrace
|
28
|
+
end
|
29
|
+
|
30
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'marketingcloudsdk'
|
2
|
+
require_relative 'sample_helper'
|
3
|
+
|
4
|
+
begin
|
5
|
+
stubObj = MarketingCloudSDK::Client.new auth
|
6
|
+
|
7
|
+
## Modify the date below to reduce the number of results returned from the request
|
8
|
+
## Setting this too far in the past could result in a very large response size
|
9
|
+
retrieveDate = '2011-01-15T13:00:00.000'
|
10
|
+
|
11
|
+
p '>>> Retrieve Filtered BounceEvents with GetMoreResults'
|
12
|
+
getBounceEvent = MarketingCloudSDK::BounceEvent.new()
|
13
|
+
getBounceEvent.authStub = stubObj
|
14
|
+
getBounceEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
|
15
|
+
getBounceEvent.filter = {'Property' => 'EventDate','SimpleOperator' => 'greaterThan','DateValue' => retrieveDate}
|
16
|
+
getResponse = getBounceEvent.get
|
17
|
+
p 'Retrieve Status: ' + getResponse.status.to_s
|
18
|
+
p 'Code: ' + getResponse.code.to_s
|
19
|
+
p 'Message: ' + getResponse.message.to_s
|
20
|
+
p 'MoreResults: ' + getResponse.more?.to_s
|
21
|
+
p 'RequestID: ' + getResponse.request_id.to_s
|
22
|
+
p 'Results Length: ' + getResponse.results.length.to_s
|
23
|
+
# Since this could potentially return a large number of results, we do not want to print the results
|
24
|
+
p 'Results: ' + getResponse.results.to_s
|
25
|
+
raise 'Failure retrieving bounce events' unless getResponse.success?
|
26
|
+
|
27
|
+
while getResponse.more? do
|
28
|
+
p '>>> Continue Retrieve Filtered BounceEvents with GetMoreResults'
|
29
|
+
getResponse = getBounceEvent.continue
|
30
|
+
p 'Retrieve Status: ' + getResponse.status.to_s
|
31
|
+
p 'Code: ' + getResponse.code.to_s
|
32
|
+
p 'Message: ' + getResponse.message.to_s
|
33
|
+
p 'MoreResults: ' + getResponse.more?.to_s
|
34
|
+
p 'RequestID: ' + getResponse.request_id.to_s
|
35
|
+
p 'Results Length: ' + getResponse.results.length.to_s
|
36
|
+
end
|
37
|
+
|
38
|
+
# The following request could potentially bring back large amounts of data if run against a production account
|
39
|
+
=begin
|
40
|
+
p '>>> Retrieve All BounceEvents with GetMoreResults'
|
41
|
+
getBounceEvent = FuelSDK::BounceEvent.new()
|
42
|
+
getBounceEvent.authStub = stubObj
|
43
|
+
getBounceEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
|
44
|
+
getResponse = getBounceEvent.get
|
45
|
+
p 'Retrieve Status: ' + getResponse.status.to_s
|
46
|
+
p 'Code: ' + getResponse.code.to_s
|
47
|
+
p 'Message: ' + getResponse.message.to_s
|
48
|
+
p 'MoreResults: ' + getResponse.more?.to_s
|
49
|
+
p 'RequestID: ' + getResponse.request_id.to_s
|
50
|
+
p 'Results Length: ' + getResponse.results.length.to_s
|
51
|
+
# Since this could potentially return a large number of results, we do not want to print the results
|
52
|
+
#p 'Results: ' + getResponse.results.to_s
|
53
|
+
|
54
|
+
while getResponse.more? do
|
55
|
+
p '>>> Continue Retrieve All BounceEvents with GetMoreResults'
|
56
|
+
getResponse = getBounceEvent.continue
|
57
|
+
p 'Retrieve Status: ' + getResponse.status.to_s
|
58
|
+
p 'Code: ' + getResponse.code.to_s
|
59
|
+
p 'Message: ' + getResponse.message.to_s
|
60
|
+
p 'MoreResults: ' + getResponse.more?.to_s
|
61
|
+
p 'RequestID: ' + getResponse.request_id.to_s
|
62
|
+
p 'Results Length: ' + getResponse.results.length.to_s
|
63
|
+
end
|
64
|
+
=end
|
65
|
+
|
66
|
+
rescue => e
|
67
|
+
p "Caught exception: #{e.message}"
|
68
|
+
p e.backtrace
|
69
|
+
end
|
70
|
+
|
@@ -0,0 +1,211 @@
|
|
1
|
+
require 'marketingcloudsdk'
|
2
|
+
require_relative 'sample_helper'
|
3
|
+
|
4
|
+
begin
|
5
|
+
stubObj = MarketingCloudSDK::Client.new auth
|
6
|
+
|
7
|
+
# Create List
|
8
|
+
p '>>> Create List'
|
9
|
+
postList = MarketingCloudSDK::List.new
|
10
|
+
postList.authStub = stubObj
|
11
|
+
postList.props = {"ListName" => 'RubyAssetList', "Description" => "This list was created with the RubySDK", "Type" => "Private" }
|
12
|
+
postResponse = postList.post
|
13
|
+
p 'Post Status: ' + postResponse.status.to_s
|
14
|
+
p 'Code: ' + postResponse.code.to_s
|
15
|
+
p 'Message: ' + postResponse.message.to_s
|
16
|
+
p 'Result Count: ' + postResponse.results.length.to_s
|
17
|
+
p 'Results: ' + postResponse.results.inspect
|
18
|
+
|
19
|
+
raise 'Failure creating list for asset' unless postResponse.success?
|
20
|
+
|
21
|
+
# In order for this sample to run, it needs to have an asset that it can associate the campaign to
|
22
|
+
ExampleAssetType = "LIST"
|
23
|
+
ExampleAssetItemID = postResponse.results[0][:new_id]
|
24
|
+
|
25
|
+
# Retrieve all Campaigns
|
26
|
+
p '>>> Retrieve all Campaigns'
|
27
|
+
getCamp = MarketingCloudSDK::Campaign.new
|
28
|
+
getCamp.authStub = stubObj
|
29
|
+
getResponse = getCamp.get
|
30
|
+
p 'Retrieve Status: ' + getResponse.status.to_s
|
31
|
+
p 'Code: ' + getResponse.code.to_s
|
32
|
+
p 'Message: ' + getResponse.message.to_s
|
33
|
+
p 'MoreResults: ' + getResponse.more?.to_s
|
34
|
+
p "Results: #{getResponse.results}"
|
35
|
+
p 'Results(Items) Length: ' + getResponse.results['items'].length.to_s
|
36
|
+
p '-----------------------------'
|
37
|
+
|
38
|
+
raise 'Failure retrieving campaigns' unless getResponse.success?
|
39
|
+
|
40
|
+
while getResponse.more? do
|
41
|
+
p '>>> Continue Retrieve all Campaigns with GetMoreResults'
|
42
|
+
getResponse = getCamp.continue
|
43
|
+
p 'Retrieve Status: ' + getResponse.status.to_s
|
44
|
+
p 'Code: ' + getResponse.code.to_s
|
45
|
+
p 'Message: ' + getResponse.message.to_s
|
46
|
+
p 'MoreResults: ' + getResponse.more?.to_s
|
47
|
+
p 'Results(Items) Length: ' + getResponse.results['items'].length.to_s
|
48
|
+
end
|
49
|
+
|
50
|
+
# Create a new Campaign
|
51
|
+
p '>>> Create a new Campaign'
|
52
|
+
postCamp = MarketingCloudSDK::Campaign.new
|
53
|
+
postCamp.authStub = stubObj
|
54
|
+
postCamp.props = {"name" => "RubySDKCreatedForTest1", "description"=> "RubySDKCreatedForTest", "color"=>"FF9933", "favorite"=>"false"}
|
55
|
+
postResponse = postCamp.post
|
56
|
+
p 'Post Status: ' + postResponse.status.to_s
|
57
|
+
p 'Code: ' + postResponse.code.to_s
|
58
|
+
p 'Message: ' + postResponse.message.to_s
|
59
|
+
p 'Results: ' + postResponse.results.to_json
|
60
|
+
p '-----------------------------'
|
61
|
+
|
62
|
+
raise 'Failure creating campaign' unless postResponse.success?
|
63
|
+
|
64
|
+
IDOfpostCampaign = postResponse.results['id']
|
65
|
+
|
66
|
+
# Retrieve the new Campaign
|
67
|
+
p '>>> Retrieve the new Campaign'
|
68
|
+
getCamp = MarketingCloudSDK::Campaign.new
|
69
|
+
getCamp.authStub = stubObj
|
70
|
+
getCamp.props = {"id" => IDOfpostCampaign}
|
71
|
+
getResponse = getCamp.get
|
72
|
+
p 'Retrieve Status: ' + getResponse.status.to_s
|
73
|
+
p 'Code: ' + getResponse.code.to_s
|
74
|
+
p 'Message: ' + getResponse.message.to_s
|
75
|
+
p 'Results: ' + getResponse.results.to_json
|
76
|
+
p '-----------------------------'
|
77
|
+
|
78
|
+
raise 'Failure retrieving campaign' unless getResponse.success?
|
79
|
+
|
80
|
+
# Update the new Campaign
|
81
|
+
p '>>> Update the new Campaign'
|
82
|
+
patchCamp = MarketingCloudSDK::Campaign.new
|
83
|
+
patchCamp.authStub = stubObj
|
84
|
+
patchCamp.props = {"id"=> IDOfpostCampaign, "name" => "RubySDKCreated-Updated!"}
|
85
|
+
patchResponse = patchCamp.patch
|
86
|
+
p 'Patch Status: ' + patchResponse.status.to_s
|
87
|
+
p 'Code: ' + patchResponse.code.to_s
|
88
|
+
p 'Message: ' + patchResponse.message.to_s
|
89
|
+
p 'Results: ' + patchResponse.results.to_json
|
90
|
+
p '-----------------------------'
|
91
|
+
|
92
|
+
raise 'Failure updating campaign' unless patchResponse.success?
|
93
|
+
|
94
|
+
# Retrieve the updated Campaign
|
95
|
+
p '>>> Retrieve the updated Campaign'
|
96
|
+
getCamp = MarketingCloudSDK::Campaign.new
|
97
|
+
getCamp.authStub = stubObj
|
98
|
+
getCamp.props = {"id" => IDOfpostCampaign}
|
99
|
+
getResponse = getCamp.get
|
100
|
+
p 'Retrieve Status: ' + getResponse.status.to_s
|
101
|
+
p 'Code: ' + getResponse.code.to_s
|
102
|
+
p 'Message: ' + getResponse.message.to_s
|
103
|
+
p 'Results: ' + getResponse.results.to_json
|
104
|
+
p '-----------------------------'
|
105
|
+
|
106
|
+
raise 'Failure retrieving campaign' unless getResponse.success?
|
107
|
+
|
108
|
+
# Create a new Campaign Asset
|
109
|
+
p '>>> Create a new Campaign Asset'
|
110
|
+
postCampAsset = MarketingCloudSDK::Campaign::Asset.new
|
111
|
+
postCampAsset.authStub = stubObj
|
112
|
+
postCampAsset.props = {"id" => IDOfpostCampaign, "ids"=> [ExampleAssetItemID], "type"=> ExampleAssetType}
|
113
|
+
postResponse = postCampAsset.post
|
114
|
+
p 'Post Status: ' + postResponse.status.to_s
|
115
|
+
p 'Code: ' + postResponse.code.to_s
|
116
|
+
p 'Message: ' + postResponse.message.to_s
|
117
|
+
p 'Results: ' + postResponse.results.to_json
|
118
|
+
p '-----------------------------'
|
119
|
+
|
120
|
+
raise 'Failure creating campaign assets' unless postResponse.success?
|
121
|
+
|
122
|
+
IDOfpostCampaignAsset = postResponse.results[0]['id']
|
123
|
+
|
124
|
+
# Retrieve all Campaign Asset for a campaign
|
125
|
+
p '>>> Retrieve all Campaign Asset for a Campaign'
|
126
|
+
getCampAsset = MarketingCloudSDK::Campaign::Asset.new
|
127
|
+
getCampAsset.authStub = stubObj
|
128
|
+
getCampAsset.props = {"id" => IDOfpostCampaign}
|
129
|
+
getResponse = getCampAsset.get
|
130
|
+
p 'Retrieve Status: ' + getResponse.status.to_s
|
131
|
+
p 'Code: ' + getResponse.code.to_s
|
132
|
+
p 'Message: ' + getResponse.message.to_s
|
133
|
+
p 'Results: ' + getResponse.results.inspect
|
134
|
+
p '-----------------------------'
|
135
|
+
|
136
|
+
raise 'Failure retrieving campaign assets' unless getResponse.success?
|
137
|
+
|
138
|
+
# Retrieve a single new Campaign Asset
|
139
|
+
p '>>> Retrieve a single new Campaign Asset'
|
140
|
+
getCampAsset = MarketingCloudSDK::Campaign::Asset.new
|
141
|
+
getCampAsset.authStub = stubObj
|
142
|
+
getCampAsset.props = {"id" => IDOfpostCampaign, "assetId" => IDOfpostCampaignAsset}
|
143
|
+
getResponse = getCampAsset.get
|
144
|
+
p 'Retrieve Status: ' + getResponse.status.to_s
|
145
|
+
p 'Code: ' + getResponse.code.to_s
|
146
|
+
p 'Message: ' + getResponse.message.to_s
|
147
|
+
p 'Results: ' + getResponse.results.inspect
|
148
|
+
p '-----------------------------'
|
149
|
+
|
150
|
+
raise 'Failure retrieving campaign asset' unless getResponse.success?
|
151
|
+
|
152
|
+
# Delete the new Campaign Asset
|
153
|
+
p '>>> Delete the new Campaign Asset'
|
154
|
+
deleteCampAsset = MarketingCloudSDK::Campaign::Asset.new
|
155
|
+
deleteCampAsset.authStub = stubObj
|
156
|
+
deleteCampAsset.props = {"id" => IDOfpostCampaign, "assetId"=> IDOfpostCampaignAsset}
|
157
|
+
deleteResponse = deleteCampAsset.delete
|
158
|
+
p 'Delete Status: ' + deleteResponse.status.to_s
|
159
|
+
p 'Code: ' + deleteResponse.code.to_s
|
160
|
+
p 'Message: ' + deleteResponse.message.to_s
|
161
|
+
p 'Results: ' + deleteResponse.results.to_json
|
162
|
+
p '-----------------------------'
|
163
|
+
|
164
|
+
raise 'Failure deleting campaign asset' unless deleteResponse.success?
|
165
|
+
|
166
|
+
# Get a single a new Campaign Asset to confirm deletion
|
167
|
+
p '>>> Get a single a new Campaign Asset to confirm deletion'
|
168
|
+
getCampAsset = MarketingCloudSDK::Campaign::Asset.new
|
169
|
+
getCampAsset.authStub = stubObj
|
170
|
+
getCampAsset.props = {"id" => IDOfpostCampaign}
|
171
|
+
getResponse = getCampAsset.get
|
172
|
+
p 'Retrieve Status: ' + getResponse.status.to_s
|
173
|
+
p 'Code: ' + getResponse.code.to_s
|
174
|
+
p 'Message: ' + getResponse.message.to_s
|
175
|
+
p 'Results: ' + getResponse.results.inspect
|
176
|
+
p '-----------------------------'
|
177
|
+
|
178
|
+
raise 'Failure retrieving campaign asset' unless getResponse.success?
|
179
|
+
raise 'Failure retrieving campaign asset' unless getResponse.results['totalCount'] == 0
|
180
|
+
|
181
|
+
rescue => e
|
182
|
+
p "Caught exception: #{e.message}"
|
183
|
+
p e.backtrace
|
184
|
+
|
185
|
+
ensure
|
186
|
+
|
187
|
+
# Delete the new Campaign
|
188
|
+
p '>>> Delete the new Campaign'
|
189
|
+
deleteCamp = MarketingCloudSDK::Campaign.new
|
190
|
+
deleteCamp.authStub = stubObj
|
191
|
+
deleteCamp.props = {"id"=> IDOfpostCampaign}
|
192
|
+
deleteResponse = deleteCamp.delete
|
193
|
+
p 'Delete Status: ' + deleteResponse.status.to_s
|
194
|
+
p 'Code: ' + deleteResponse.code.to_s
|
195
|
+
p 'Message: ' + deleteResponse.message.to_s
|
196
|
+
p 'Results: ' + deleteResponse.results.to_json
|
197
|
+
p '-----------------------------'
|
198
|
+
|
199
|
+
raise 'Failure deleting campaign asset' unless deleteResponse.success?
|
200
|
+
|
201
|
+
p '>>> Delete List'
|
202
|
+
deleteSub = MarketingCloudSDK::List.new()
|
203
|
+
deleteSub.authStub = stubObj
|
204
|
+
deleteSub.props = {"ID" => ExampleAssetItemID}
|
205
|
+
deleteResponse = deleteSub.delete
|
206
|
+
p 'Delete Status: ' + deleteResponse.status.to_s
|
207
|
+
p 'Code: ' + deleteResponse.code.to_s
|
208
|
+
p 'Message: ' + deleteResponse.message.to_s
|
209
|
+
p 'Results Length: ' + deleteResponse.results.length.to_s
|
210
|
+
p 'Results: ' + deleteResponse.results.to_s
|
211
|
+
end
|