dragostsesdk 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 +92 -0
- data/Guardfile +8 -0
- data/LICENSE.md +13 -0
- data/README.md +139 -0
- data/Rakefile +1 -0
- data/lib/marketingcloudsdk.rb +74 -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/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,103 @@
|
|
1
|
+
require 'marketingcloudsdk'
|
2
|
+
require_relative 'sample_helper'
|
3
|
+
|
4
|
+
begin
|
5
|
+
stubObj = MarketingCloudSDK::Client.new auth
|
6
|
+
|
7
|
+
NewImportName = "RubySDKImport"
|
8
|
+
SendableDataExtensionCustomerKey = "62476204-bfd3-de11-95ca-001e0bbae8cc"
|
9
|
+
ListIDForImport = "1956035"
|
10
|
+
|
11
|
+
p '>>> Create Import to DataExtension'
|
12
|
+
postImport = ET_Import.new
|
13
|
+
postImport.authStub = stubObj
|
14
|
+
postImport.props = {"Name"=>NewImportName}
|
15
|
+
postImport.props["CustomerKey"] = NewImportName
|
16
|
+
postImport.props["Description"] = "Created with RubySDK"
|
17
|
+
postImport.props["AllowErrors"] = "true"
|
18
|
+
postImport.props["DestinationObject"] = {"ObjectID"=>SendableDataExtensionCustomerKey}
|
19
|
+
postImport.props["FieldMappingType"] = "InferFromColumnHeadings"
|
20
|
+
postImport.props["FileSpec"] = "RubyExample.csv"
|
21
|
+
postImport.props["FileType"] = "CSV"
|
22
|
+
postImport.props["Notification"] = {"ResponseType"=>"email","ResponseAddress"=>"example@example.com"}
|
23
|
+
postImport.props["RetrieveFileTransferLocation"] = {"CustomerKey"=>"ExactTarget Enhanced FTP"}
|
24
|
+
postImport.props["UpdateType"] = "Overwrite"
|
25
|
+
postResponse = postImport.post
|
26
|
+
p 'Post Status: ' + postResponse.status.to_s
|
27
|
+
p 'Code: ' + postResponse.code.to_s
|
28
|
+
p 'Message: ' + postResponse.message.to_s
|
29
|
+
p 'Result Count: ' + postResponse.results.length.to_s
|
30
|
+
p 'Results: ' + postResponse.results.inspect
|
31
|
+
|
32
|
+
p '>>> Delete Import'
|
33
|
+
deleteImport = ET_Import.new()
|
34
|
+
deleteImport.authStub = stubObj
|
35
|
+
deleteImport.props = {"CustomerKey" => NewImportName}
|
36
|
+
deleteResponse = deleteImport.delete
|
37
|
+
p 'Delete Status: ' + deleteResponse.status.to_s
|
38
|
+
p 'Code: ' + deleteResponse.code.to_s
|
39
|
+
p 'Message: ' + deleteResponse.message.to_s
|
40
|
+
p 'Results Length: ' + deleteResponse.results.length.to_s
|
41
|
+
p 'Results: ' + deleteResponse.results.to_s
|
42
|
+
|
43
|
+
p '>>> Create Import to List'
|
44
|
+
postImport = ET_Import.new
|
45
|
+
postImport.authStub = stubObj
|
46
|
+
postImport.props = {"Name"=>NewImportName}
|
47
|
+
postImport.props["CustomerKey"] = NewImportName
|
48
|
+
postImport.props["Description"] = "Created with RubySDK"
|
49
|
+
postImport.props["AllowErrors"] = "true"
|
50
|
+
postImport.props["DestinationObject"] = {"ID"=>ListIDForImport}
|
51
|
+
postImport.props["FieldMappingType"] = "InferFromColumnHeadings"
|
52
|
+
postImport.props["FileSpec"] = "RubyExample.csv"
|
53
|
+
postImport.props["FileType"] = "CSV"
|
54
|
+
postImport.props["Notification"] = {"ResponseType"=>"email","ResponseAddress"=>"example@example.com"}
|
55
|
+
postImport.props["RetrieveFileTransferLocation"] = {"CustomerKey"=>"ExactTarget Enhanced FTP"}
|
56
|
+
postImport.props["UpdateType"] = "AddAndUpdate"
|
57
|
+
postResponse = postImport.post
|
58
|
+
p 'Post Status: ' + postResponse.status.to_s
|
59
|
+
p 'Code: ' + postResponse.code.to_s
|
60
|
+
p 'Message: ' + postResponse.message.to_s
|
61
|
+
p 'Result Count: ' + postResponse.results.length.to_s
|
62
|
+
p 'Results: ' + postResponse.results.inspect
|
63
|
+
|
64
|
+
p '>>> Start Import to List'
|
65
|
+
startImport = ET_Import.new
|
66
|
+
startImport.authStub = stubObj
|
67
|
+
startImport.props = {"CustomerKey"=>NewImportName}
|
68
|
+
postResponse = startImport.start
|
69
|
+
p 'Start Status: ' + postResponse.status.to_s
|
70
|
+
p 'Code: ' + postResponse.code.to_s
|
71
|
+
p 'Message: ' + postResponse.message.to_s
|
72
|
+
p 'Result Count: ' + postResponse.results.length.to_s
|
73
|
+
p 'Results: ' + postResponse.results.inspect
|
74
|
+
|
75
|
+
importStatus = ""
|
76
|
+
while postResponse.status && importStatus != "Error" && importStatus != "Completed" do
|
77
|
+
p '>>> Checking status in loop'
|
78
|
+
# Wait a bit before checking the status to give it time to process
|
79
|
+
sleep 30
|
80
|
+
statusResponse = startImport.status
|
81
|
+
p 'Status Status: ' + statusResponse.status.to_s
|
82
|
+
p 'Code: ' + statusResponse.code.to_s
|
83
|
+
p 'Message: ' + statusResponse.message.to_s
|
84
|
+
p 'Result Count: ' + statusResponse.results.length.to_s
|
85
|
+
p 'Results: ' + statusResponse.results.inspect
|
86
|
+
importStatus = statusResponse.results[0][:import_status]
|
87
|
+
end
|
88
|
+
|
89
|
+
p '>>> Delete Import'
|
90
|
+
deleteImport = ET_Import.new()
|
91
|
+
deleteImport.authStub = stubObj
|
92
|
+
deleteImport.props = {"CustomerKey" => NewImportName}
|
93
|
+
deleteResponse = deleteImport.delete
|
94
|
+
p 'Delete Status: ' + deleteResponse.status.to_s
|
95
|
+
p 'Code: ' + deleteResponse.code.to_s
|
96
|
+
p 'Message: ' + deleteResponse.message.to_s
|
97
|
+
p 'Results Length: ' + deleteResponse.results.length.to_s
|
98
|
+
p 'Results: ' + deleteResponse.results.to_s
|
99
|
+
|
100
|
+
rescue => e
|
101
|
+
p "Caught exception: #{e.message}"
|
102
|
+
p e.backtrace
|
103
|
+
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'marketingcloudsdk'
|
2
|
+
require_relative 'sample_helper'
|
3
|
+
|
4
|
+
begin
|
5
|
+
stubObj = MarketingCloudSDK::Client.new auth
|
6
|
+
|
7
|
+
NewListName = "RubySDKList"
|
8
|
+
|
9
|
+
# Create List
|
10
|
+
p '>>> Create List'
|
11
|
+
postList = MarketingCloudSDK::List.new
|
12
|
+
postList.authStub = stubObj
|
13
|
+
postList.props = {"ListName" => NewListName, "Description" => "This list was created with the RubySDK", "Type" => "Private" }
|
14
|
+
#postList.folder_id = 1083760
|
15
|
+
postResponse = postList.post
|
16
|
+
p 'Post Status: ' + postResponse.status.to_s
|
17
|
+
p 'Code: ' + postResponse.code.to_s
|
18
|
+
p 'Message: ' + postResponse.message.to_s
|
19
|
+
p 'Result Count: ' + postResponse.results.length.to_s
|
20
|
+
p 'Results: ' + postResponse.results.inspect
|
21
|
+
raise 'Failure creating list' unless postResponse.success?
|
22
|
+
|
23
|
+
# Make sure the list created correctly before
|
24
|
+
if postResponse.success? then
|
25
|
+
|
26
|
+
newListID = postResponse.results[0][:new_id]
|
27
|
+
|
28
|
+
# Retrieve newly created List by ID
|
29
|
+
p '>>> Retrieve newly created List'
|
30
|
+
getList = MarketingCloudSDK::List.new()
|
31
|
+
getList.authStub = stubObj
|
32
|
+
getList.props = ["ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Client.PartnerClientKey","ListName","Description","Category","Type","CustomerKey","ListClassification","AutomatedEmail.ID"]
|
33
|
+
getList.filter = {'Property' => 'ID','SimpleOperator' => 'equals','Value' => newListID}
|
34
|
+
getResponse = getList.get
|
35
|
+
p 'Retrieve Status: ' + getResponse.status.to_s
|
36
|
+
p 'Code: ' + getResponse.code.to_s
|
37
|
+
p 'Message: ' + getResponse.message.to_s
|
38
|
+
p 'MoreResults: ' + getResponse.more?.to_s
|
39
|
+
p 'Results Length: ' + getResponse.results.length.to_s
|
40
|
+
p 'Results: ' + getResponse.results.to_s
|
41
|
+
raise 'Failure retrieving list' unless getResponse.success?
|
42
|
+
|
43
|
+
# Update List
|
44
|
+
p '>>> Update List'
|
45
|
+
patchSub = MarketingCloudSDK::List.new
|
46
|
+
patchSub.authStub = stubObj
|
47
|
+
patchSub.props = {"ID" => newListID, "Description" => "I updated the description"}
|
48
|
+
patchResponse = patchSub.patch
|
49
|
+
p 'Patch Status: ' + patchResponse.status.to_s
|
50
|
+
p 'Code: ' + patchResponse.code.to_s
|
51
|
+
p 'Message: ' + patchResponse.message.to_s
|
52
|
+
p 'Result Count: ' + patchResponse.results.length.to_s
|
53
|
+
p 'Results: ' + patchResponse.results.inspect
|
54
|
+
raise 'Failure updating list' unless patchResponse.success?
|
55
|
+
raise 'Failure updating list' unless patchResponse.results.first[:object][:description] == "I updated the description"
|
56
|
+
|
57
|
+
# Retrieve List that should have description updated
|
58
|
+
p '>>> Retrieve List that should have description updated '
|
59
|
+
getList = MarketingCloudSDK::List.new()
|
60
|
+
getList.authStub = stubObj
|
61
|
+
getList.props = ["ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Client.PartnerClientKey","ListName","Description","Category","Type","CustomerKey","ListClassification","AutomatedEmail.ID"]
|
62
|
+
getList.filter = {'Property' => 'ID','SimpleOperator' => 'equals','Value' => newListID}
|
63
|
+
getResponse = getList.get
|
64
|
+
p 'Retrieve Status: ' + getResponse.status.to_s
|
65
|
+
p 'Code: ' + getResponse.code.to_s
|
66
|
+
p 'Message: ' + getResponse.message.to_s
|
67
|
+
p 'MoreResults: ' + getResponse.more?.to_s
|
68
|
+
p 'Results Length: ' + getResponse.results.length.to_s
|
69
|
+
p 'Results: ' + getResponse.results.to_s
|
70
|
+
raise 'Failure retrieving list' unless getResponse.success?
|
71
|
+
|
72
|
+
# Delete List
|
73
|
+
p '>>> Delete List'
|
74
|
+
deleteSub = MarketingCloudSDK::List.new()
|
75
|
+
deleteSub.authStub = stubObj
|
76
|
+
deleteSub.props = {"ID" => newListID}
|
77
|
+
deleteResponse = deleteSub.delete
|
78
|
+
p 'Delete Status: ' + deleteResponse.status.to_s
|
79
|
+
p 'Code: ' + deleteResponse.code.to_s
|
80
|
+
p 'Message: ' + deleteResponse.message.to_s
|
81
|
+
p 'Results Length: ' + deleteResponse.results.length.to_s
|
82
|
+
p 'Results: ' + deleteResponse.results.to_s
|
83
|
+
raise 'Failure deleting list' unless deleteResponse.success?
|
84
|
+
|
85
|
+
# Retrieve List to confirm deletion
|
86
|
+
p '>>> Retrieve List to confirm deletion'
|
87
|
+
getList = MarketingCloudSDK::List.new()
|
88
|
+
getList.authStub = stubObj
|
89
|
+
getList.props = ["ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Client.PartnerClientKey","ListName","Description","Category","Type","CustomerKey","ListClassification","AutomatedEmail.ID"]
|
90
|
+
getList.filter = {'Property' => 'ID','SimpleOperator' => 'equals','Value' => newListID}
|
91
|
+
getResponse = getList.get
|
92
|
+
p 'Retrieve Status: ' + getResponse.status.to_s
|
93
|
+
p 'Code: ' + getResponse.code.to_s
|
94
|
+
p 'Message: ' + getResponse.message.to_s
|
95
|
+
p 'MoreResults: ' + getResponse.more?.to_s
|
96
|
+
p 'Results Length: ' + getResponse.results.length.to_s
|
97
|
+
p 'Results: ' + getResponse.results.to_s
|
98
|
+
raise 'Failure retrieving list' unless getResponse.success?
|
99
|
+
end
|
100
|
+
|
101
|
+
rescue => e
|
102
|
+
p "Caught exception: #{e.message}"
|
103
|
+
p e.backtrace
|
104
|
+
end
|
105
|
+
|
@@ -0,0 +1,97 @@
|
|
1
|
+
require 'marketingcloudsdk'
|
2
|
+
require_relative 'sample_helper'
|
3
|
+
|
4
|
+
begin
|
5
|
+
stubObj = MarketingCloudSDK::Client.new auth
|
6
|
+
|
7
|
+
# NOTE: These examples only work in accounts where the SubscriberKey functionality is not enabled
|
8
|
+
# SubscriberKey will need to be included in the props if that feature is enabled
|
9
|
+
|
10
|
+
NewListName = "RubySDKListSubscriber"
|
11
|
+
SubscriberTestEmail = "RubySDKListSubscriber@bh.exacttarget.com"
|
12
|
+
|
13
|
+
# Create List
|
14
|
+
p '>>> Create List'
|
15
|
+
postList = MarketingCloudSDK::List.new
|
16
|
+
postList.authStub = stubObj
|
17
|
+
postList.props = {"ListName" => NewListName, "Description" => "This list was created with the RubySDK", "Type" => "Private" }
|
18
|
+
postResponse = postList.post
|
19
|
+
p 'Post Status: ' + postResponse.status.to_s
|
20
|
+
p 'Code: ' + postResponse.code.to_s
|
21
|
+
p 'Message: ' + postResponse.message.to_s
|
22
|
+
p 'Result Count: ' + postResponse.results.length.to_s
|
23
|
+
p 'Results: ' + postResponse.results.inspect
|
24
|
+
|
25
|
+
raise 'Failure posting list' unless postResponse.success?
|
26
|
+
|
27
|
+
|
28
|
+
# Make sure the list created correctly before
|
29
|
+
if postResponse.success? then
|
30
|
+
|
31
|
+
newListID = postResponse.results[0][:new_id]
|
32
|
+
|
33
|
+
# Create Subscriber On List
|
34
|
+
p '>>> Create Subscriber On List'
|
35
|
+
postSub = MarketingCloudSDK::Subscriber.new
|
36
|
+
postSub.authStub = stubObj
|
37
|
+
postSub.props = {"EmailAddress" => SubscriberTestEmail, "Lists" =>[{"ID" => newListID}]}
|
38
|
+
postResponse = postSub.post
|
39
|
+
p 'Post Status: ' + postResponse.status.to_s
|
40
|
+
p 'Code: ' + postResponse.code.to_s
|
41
|
+
p 'Message: ' + postResponse.message.to_s
|
42
|
+
p 'Result Count: ' + postResponse.results.length.to_s
|
43
|
+
p 'Results: ' + postResponse.results.inspect
|
44
|
+
|
45
|
+
if postResponse.success? == false then
|
46
|
+
# If the subscriber already exists in the account then we need to do an update.
|
47
|
+
# Update Subscriber On List
|
48
|
+
if postResponse.results[0][:error_code] == "12014" then
|
49
|
+
# Update Subscriber to add to List
|
50
|
+
p '>>> Update Subscriber to add to List'
|
51
|
+
patchSub = MarketingCloudSDK::Subscriber.new
|
52
|
+
patchSub.authStub = stubObj
|
53
|
+
patchSub.props = {"EmailAddress" => SubscriberTestEmail, "Lists" =>[{"ID" => newListID}]}
|
54
|
+
patchResponse = patchSub.patch
|
55
|
+
p 'Patch Status: ' + patchResponse.status.to_s
|
56
|
+
p 'Code: ' + patchResponse.code.to_s
|
57
|
+
p 'Message: ' + patchResponse.message.to_s
|
58
|
+
p 'Result Count: ' + patchResponse.results.length.to_s
|
59
|
+
p 'Results: ' + patchResponse.results.inspect
|
60
|
+
raise 'Failure updating subscriber' unless patchResponse.success?
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
# Retrieve all Subscribers on the List
|
66
|
+
p '>>> Retrieve all Subscribers on the List'
|
67
|
+
getListSubs = MarketingCloudSDK::List::Subscriber.new
|
68
|
+
getListSubs.authStub = stubObj
|
69
|
+
getListSubs.props = ["ObjectID","SubscriberKey","CreatedDate","Client.ID","Client.PartnerClientKey","ListID","Status"]
|
70
|
+
getListSubs.filter = {'Property' => 'ListID','SimpleOperator' => 'equals','Value' => newListID}
|
71
|
+
getResponse = getListSubs.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 'MoreResults: ' + getResponse.more?.to_s
|
76
|
+
p 'Results Length: ' + getResponse.results.length.to_s
|
77
|
+
p 'Results: ' + getResponse.results.to_s
|
78
|
+
raise 'Failure retrieving subscirbers on list' unless getResponse.success?
|
79
|
+
|
80
|
+
# Delete List
|
81
|
+
p '>>> Delete List'
|
82
|
+
deleteSub = MarketingCloudSDK::List.new()
|
83
|
+
deleteSub.authStub = stubObj
|
84
|
+
deleteSub.props = {"ID" => newListID}
|
85
|
+
deleteResponse = deleteSub.delete
|
86
|
+
p 'Delete Status: ' + deleteResponse.status.to_s
|
87
|
+
p 'Code: ' + deleteResponse.code.to_s
|
88
|
+
p 'Message: ' + deleteResponse.message.to_s
|
89
|
+
p 'Results Length: ' + deleteResponse.results.length.to_s
|
90
|
+
p 'Results: ' + deleteResponse.results.to_s
|
91
|
+
raise 'Failure deleting list' unless deleteResponse.success?
|
92
|
+
end
|
93
|
+
rescue => e
|
94
|
+
p "Caught exception: #{e.message}"
|
95
|
+
p e.backtrace
|
96
|
+
end
|
97
|
+
|
@@ -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 = '2013-01-15T13:00:00.000'
|
10
|
+
|
11
|
+
p '>>> Retrieve Filtered OpenEvents with GetMoreResults'
|
12
|
+
getOpenEvent = MarketingCloudSDK::OpenEvent.new()
|
13
|
+
getOpenEvent.authStub = stubObj
|
14
|
+
getOpenEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
|
15
|
+
getOpenEvent.filter = {'Property' => 'EventDate','SimpleOperator' => 'greaterThan','DateValue' => retrieveDate}
|
16
|
+
getResponse = getOpenEvent.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 open events' unless getResponse.success?
|
26
|
+
|
27
|
+
while getResponse.more? do
|
28
|
+
p '>>> Continue Retrieve Filtered OpenEvents with GetMoreResults'
|
29
|
+
getResponse = getOpenEvent.contine
|
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 OpenEvents with GetMoreResults'
|
41
|
+
getOpenEvent = MarketingCloudSDK::OpenEvent.new()
|
42
|
+
getOpenEvent.authStub = stubObj
|
43
|
+
getOpenEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
|
44
|
+
getResponse = getOpenEvent.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 OpenEvents with GetMoreResults'
|
56
|
+
getResponse = getOpenEvent.contine
|
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,56 @@
|
|
1
|
+
require 'marketingcloudsdk'
|
2
|
+
require_relative 'sample_helper'
|
3
|
+
|
4
|
+
begin
|
5
|
+
stubObj = MarketingCloudSDK::Client.new auth
|
6
|
+
|
7
|
+
NameOfAttribute = 'RubySDKTesting'
|
8
|
+
|
9
|
+
p '>>> Retrieve Profile Attribute'
|
10
|
+
getProfileAttribute = ET_ProfileAttribute.new
|
11
|
+
getProfileAttribute.authStub = stubObj
|
12
|
+
getResponse = getProfileAttribute.get
|
13
|
+
p 'Get Status: ' + getResponse.status.to_s
|
14
|
+
p 'Code: ' + getResponse.code.to_s
|
15
|
+
p 'Message: ' + getResponse.message.to_s
|
16
|
+
p 'Result Count: ' + getResponse.results.length.to_s
|
17
|
+
# p 'Results: ' + getResponse.results.inspect
|
18
|
+
raise 'Failure getting Profile Attribute' unless getResponse.success?
|
19
|
+
|
20
|
+
p '>>> Create ProfileAttribute'
|
21
|
+
postProfileAttribute = ET_ProfileAttribute.new
|
22
|
+
postProfileAttribute.authStub = stubObj
|
23
|
+
postProfileAttribute.props = {"Name" => NameOfAttribute, "PropertyType"=>"string", "Description"=>"New Attribute from the SDK", "IsRequired"=>"false", "IsViewable"=>"false", "IsEditable"=>"true", "IsSendTime"=>"false"}
|
24
|
+
postResponse = postProfileAttribute.post
|
25
|
+
p 'Post Status: ' + postResponse.status.to_s
|
26
|
+
p 'Code: ' + postResponse.code.to_s
|
27
|
+
p 'Message: ' + postResponse.message.to_s
|
28
|
+
p 'Result Count: ' + postResponse.results.length.to_s
|
29
|
+
p 'Results: ' + postResponse.results.inspect
|
30
|
+
|
31
|
+
p '>>> Update ProfileAttribute'
|
32
|
+
patchProfileAttribute = ET_ProfileAttribute.new
|
33
|
+
patchProfileAttribute.authStub = stubObj
|
34
|
+
patchProfileAttribute.props = {"Name" => NameOfAttribute, "PropertyType"=>"string"}
|
35
|
+
patchResponse = patchProfileAttribute.patch
|
36
|
+
p 'Patch Status: ' + patchResponse.status.to_s
|
37
|
+
p 'Code: ' + patchResponse.code.to_s
|
38
|
+
p 'Message: ' + patchResponse.message.to_s
|
39
|
+
p 'Result Count: ' + patchResponse.results.length.to_s
|
40
|
+
p 'Results: ' + patchResponse.results.inspect
|
41
|
+
|
42
|
+
p '>>> Delete ProfileAttribute'
|
43
|
+
deleteProfileAttribute = ET_ProfileAttribute.new
|
44
|
+
deleteProfileAttribute.authStub = stubObj
|
45
|
+
deleteProfileAttribute.props = {"Name" => NameOfAttribute}
|
46
|
+
deleteResponse = deleteProfileAttribute.delete
|
47
|
+
p 'Delete Status: ' + deleteResponse.status.to_s
|
48
|
+
p 'Code: ' + deleteResponse.code.to_s
|
49
|
+
p 'Message: ' + deleteResponse.message.to_s
|
50
|
+
p 'Result Count: ' + deleteResponse.results.length.to_s
|
51
|
+
p 'Results: ' + deleteResponse.results.inspect
|
52
|
+
|
53
|
+
rescue => e
|
54
|
+
p "Caught exception: #{e.message}"
|
55
|
+
p e.backtrace
|
56
|
+
end
|
@@ -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 = '2013-01-15T13:00:00.000'
|
10
|
+
|
11
|
+
p '>>> Retrieve Filtered SentEvents with GetMoreResults'
|
12
|
+
getSentEvent = MarketingCloudSDK::SentEvent.new()
|
13
|
+
getSentEvent.authStub = stubObj
|
14
|
+
getSentEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","ListID","PartnerKey","SubscriberID"]
|
15
|
+
getSentEvent.filter = {'Property' => 'EventDate','SimpleOperator' => 'greaterThan','DateValue' => retrieveDate}
|
16
|
+
getResponse = getSentEvent.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 sent events' unless getResponse.success?
|
26
|
+
|
27
|
+
while getResponse.more? do
|
28
|
+
p '>>> Continue Retrieve Filtered SentEvents with GetMoreResults'
|
29
|
+
getResponse = getSentEvent.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 SentEvents with GetMoreResults'
|
41
|
+
getSentEvent = MarketingCloudSDK::SentEvent.new()
|
42
|
+
getSentEvent.authStub = stubObj
|
43
|
+
getSentEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","ListID","PartnerKey","SubscriberID"]
|
44
|
+
getResponse = getSentEvent.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 SentEvents with GetMoreResults'
|
56
|
+
getResponse = getSentEvent.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
|
+
|