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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +28 -28
  3. data/Gemfile +3 -3
  4. data/Gemfile.lock +92 -90
  5. data/Guardfile +8 -8
  6. data/LICENSE.md +13 -13
  7. data/README.md +166 -143
  8. data/Rakefile +1 -1
  9. data/lib/marketingcloudsdk.rb +74 -74
  10. data/lib/marketingcloudsdk/client.rb +348 -296
  11. data/lib/marketingcloudsdk/http_request.rb +118 -118
  12. data/lib/marketingcloudsdk/objects.rb +757 -757
  13. data/lib/marketingcloudsdk/rest.rb +118 -118
  14. data/lib/marketingcloudsdk/soap.rb +296 -282
  15. data/lib/marketingcloudsdk/targeting.rb +99 -99
  16. data/lib/marketingcloudsdk/utils.rb +47 -47
  17. data/lib/marketingcloudsdk/version.rb +39 -39
  18. data/lib/new.rb +1240 -1240
  19. data/marketingcloudsdk.gemspec +30 -30
  20. data/samples/sample-AddSubscriberToList.rb +56 -56
  21. data/samples/sample-CreateAndStartDataExtensionImport.rb +29 -29
  22. data/samples/sample-CreateAndStartListImport.rb +27 -27
  23. data/samples/sample-CreateContentAreas.rb +48 -48
  24. data/samples/sample-CreateDataExtensions.rb +54 -54
  25. data/samples/sample-CreateProfileAttributes.rb +48 -48
  26. data/samples/sample-SendEmailToDataExtension.rb +23 -23
  27. data/samples/sample-SendEmailToList.rb +23 -23
  28. data/samples/sample-SendTriggeredSends.rb +30 -30
  29. data/samples/sample-bounceevent.rb +70 -70
  30. data/samples/sample-campaign.rb +211 -211
  31. data/samples/sample-clickevent.rb +71 -71
  32. data/samples/sample-contentarea.rb +122 -122
  33. data/samples/sample-dataextension.rb +209 -209
  34. data/samples/sample-directverb.rb +54 -54
  35. data/samples/sample-email.rb +122 -122
  36. data/samples/sample-email.senddefinition.rb +134 -134
  37. data/samples/sample-folder.rb +143 -143
  38. data/samples/sample-import.rb +103 -103
  39. data/samples/sample-list.rb +105 -105
  40. data/samples/sample-list.subscriber.rb +97 -97
  41. data/samples/sample-openevent.rb +70 -70
  42. data/samples/sample-profileattribute.rb +56 -56
  43. data/samples/sample-sentevent.rb +70 -70
  44. data/samples/sample-subscriber.rb +135 -135
  45. data/samples/sample-triggeredsend.rb +129 -129
  46. data/samples/sample-unsubevent.rb +72 -72
  47. data/samples/sample_helper.rb.template +10 -10
  48. data/spec/client_spec.rb +218 -218
  49. data/spec/default_values_fallback_spec.rb +30 -30
  50. data/spec/helper_funcs_spec.rb +11 -11
  51. data/spec/http_request_spec.rb +61 -61
  52. data/spec/objects_helper_spec.rb +32 -32
  53. data/spec/objects_spec.rb +484 -484
  54. data/spec/rest_spec.rb +48 -48
  55. data/spec/soap_spec.rb +140 -140
  56. data/spec/spec_helper.rb +14 -14
  57. data/spec/targeting_spec.rb +44 -44
  58. metadata +9 -9
@@ -1,54 +1,54 @@
1
- require 'marketingcloudsdk'
2
- require_relative 'sample_helper' # contains auth with credentials
3
-
4
- begin
5
- filter = {'Property' => 'Type','SimpleOperator' => 'equals','Value' => 'Public'}
6
- client = ET_Client.new auth
7
- getResponse = ET_Get.new client, 'List', nil, filter
8
- p "Get Status: #{getResponse.status.to_s}"
9
- p "Code: #{getResponse.code.to_s}"
10
- p "Message: #{getResponse.message.to_s}"
11
- p "Result Count: #{getResponse.results.length.to_s}"
12
- p "Results: #{getResponse.results.inspect}"
13
- raise 'Failure getting List info' unless getResponse.success?
14
-
15
- NewListName = "RubySDKList"
16
- props = {"ListName" => NewListName, "Description" => "This list was created with the RubySDK", "Type" => "Private" }
17
- client = ET_Client.new auth
18
- postResponse = ET_Post.new client, 'List', props
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
- raise 'Failure Creating List' unless postResponse.success?
25
-
26
- if postResponse.success? then
27
- newListID = postResponse.results[0][:new_id]
28
- p "New ID: #{newListID}"
29
-
30
- props = {"ID" => newListID, "Description" => "Update!!!"}
31
- client = ET_Client.new auth
32
- patchResponse = ET_Patch.new client, 'List', props
33
- p "Patch Status: #{patchResponse.status.to_s}"
34
- p "Code: #{patchResponse.code.to_s}"
35
- p "Message: #{patchResponse.message.to_s}"
36
- p "Result Count: #{patchResponse.results.length.to_s}"
37
- p "Results: #{patchResponse.results.inspect}"
38
- raise 'Failure Patching List' unless patchResponse.success?
39
-
40
- props = {"ID" => newListID}
41
- client = ET_Client.new auth
42
- deleteResponse = ET_Delete.new client, 'List', props
43
- p "Delete Status: #{deleteResponse.status.to_s}"
44
- p "Code: #{deleteResponse.code.to_s}"
45
- p "Message: #{deleteResponse.message.to_s}"
46
- p "Result Count: #{deleteResponse.results.length.to_s}"
47
- p "Results: #{deleteResponse.results.inspect}"
48
- raise 'Failure Deleting List' unless deleteResponse.success?
49
- end
50
-
51
- rescue => e
52
- p "Caught exception: #{e.message}"
53
- p e.backtrace
54
- end
1
+ require 'marketingcloudsdk'
2
+ require_relative 'sample_helper' # contains auth with credentials
3
+
4
+ begin
5
+ filter = {'Property' => 'Type','SimpleOperator' => 'equals','Value' => 'Public'}
6
+ client = ET_Client.new auth
7
+ getResponse = ET_Get.new client, 'List', nil, filter
8
+ p "Get Status: #{getResponse.status.to_s}"
9
+ p "Code: #{getResponse.code.to_s}"
10
+ p "Message: #{getResponse.message.to_s}"
11
+ p "Result Count: #{getResponse.results.length.to_s}"
12
+ p "Results: #{getResponse.results.inspect}"
13
+ raise 'Failure getting List info' unless getResponse.success?
14
+
15
+ NewListName = "RubySDKList"
16
+ props = {"ListName" => NewListName, "Description" => "This list was created with the RubySDK", "Type" => "Private" }
17
+ client = ET_Client.new auth
18
+ postResponse = ET_Post.new client, 'List', props
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
+ raise 'Failure Creating List' unless postResponse.success?
25
+
26
+ if postResponse.success? then
27
+ newListID = postResponse.results[0][:new_id]
28
+ p "New ID: #{newListID}"
29
+
30
+ props = {"ID" => newListID, "Description" => "Update!!!"}
31
+ client = ET_Client.new auth
32
+ patchResponse = ET_Patch.new client, 'List', props
33
+ p "Patch Status: #{patchResponse.status.to_s}"
34
+ p "Code: #{patchResponse.code.to_s}"
35
+ p "Message: #{patchResponse.message.to_s}"
36
+ p "Result Count: #{patchResponse.results.length.to_s}"
37
+ p "Results: #{patchResponse.results.inspect}"
38
+ raise 'Failure Patching List' unless patchResponse.success?
39
+
40
+ props = {"ID" => newListID}
41
+ client = ET_Client.new auth
42
+ deleteResponse = ET_Delete.new client, 'List', props
43
+ p "Delete Status: #{deleteResponse.status.to_s}"
44
+ p "Code: #{deleteResponse.code.to_s}"
45
+ p "Message: #{deleteResponse.message.to_s}"
46
+ p "Result Count: #{deleteResponse.results.length.to_s}"
47
+ p "Results: #{deleteResponse.results.inspect}"
48
+ raise 'Failure Deleting List' unless deleteResponse.success?
49
+ end
50
+
51
+ rescue => e
52
+ p "Caught exception: #{e.message}"
53
+ p e.backtrace
54
+ end
@@ -1,122 +1,122 @@
1
- require 'marketingcloudsdk'
2
- require_relative 'sample_helper'
3
-
4
- begin
5
- stubObj = MarketingCloudSDK::Client.new auth
6
-
7
- # Retrieve All Email with GetMoreResults
8
- p '>>> Retrieve All Email with GetMoreResults'
9
- getHTMLBody = MarketingCloudSDK::Email.new()
10
- getHTMLBody.authStub = stubObj
11
- getHTMLBody.props = ["ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Name","Folder","CategoryID","HTMLBody","TextBody","Subject","IsActive","IsHTMLPaste","ClonedFromID","Status","EmailType","CharacterSet","HasDynamicSubjectLine","ContentCheckStatus","Client.PartnerClientKey","ContentAreas","CustomerKey"]
12
- getResponse = getHTMLBody.get
13
- p 'Retrieve Status: ' + getResponse.status.to_s
14
- p 'Code: ' + getResponse.code.to_s
15
- p 'Message: ' + getResponse.message.to_s
16
- p 'MoreResults: ' + getResponse.more?.to_s
17
- p 'Results Length: ' + getResponse.results.length.to_s
18
- #p 'Results: ' + getResponse.results.to_s
19
- raise 'Failure retrieving email' unless getResponse.success?
20
-
21
- while getResponse.more? do
22
- p '>>> Continue Retrieve All Email with GetMoreResults'
23
- getResponse = getHTMLBody.continue
24
- p 'Retrieve Status: ' + getResponse.status.to_s
25
- p 'Code: ' + getResponse.code.to_s
26
- p 'Message: ' + getResponse.message.to_s
27
- p 'MoreResults: ' + getResponse.more?.to_s
28
- p 'RequestID: ' + getResponse.request_id.to_s
29
- p 'Results Length: ' + getResponse.results.length.to_s
30
- end
31
-
32
- NameOfTestEmail = "RubySDKEmail"
33
-
34
- # Create Email
35
- p '>>> Create Email'
36
- postHTMLBody = MarketingCloudSDK::Email.new
37
- postHTMLBody.authStub = stubObj
38
- postHTMLBody.props = {"CustomerKey" => NameOfTestEmail, "Name"=>NameOfTestEmail, "Subject" => "Created Using the RubySDK", "HTMLBody"=> "<b>Some HTML Goes here</b>"}
39
- postResponse = postHTMLBody.post
40
- p 'Post Status: ' + postResponse.status.to_s
41
- p 'Code: ' + postResponse.code.to_s
42
- p 'Message: ' + postResponse.message.to_s
43
- p 'Result Count: ' + postResponse.results.length.to_s
44
- p 'Results: ' + postResponse.results.inspect
45
- raise 'Failure creating email' unless postResponse.success?
46
-
47
- # Retrieve newly created Email
48
- p '>>> Retrieve newly created Email'
49
- getHTMLBody = MarketingCloudSDK::Email.new()
50
- getHTMLBody.authStub = stubObj
51
- getHTMLBody.props = ["ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Name","Folder","CategoryID","HTMLBody","TextBody","Subject","IsActive","IsHTMLPaste","ClonedFromID","Status","EmailType","CharacterSet","HasDynamicSubjectLine","ContentCheckStatus","Client.PartnerClientKey","ContentAreas","CustomerKey"]
52
- getHTMLBody.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestEmail}
53
- getResponse = getHTMLBody.get
54
- p 'Retrieve Status: ' + getResponse.status.to_s
55
- p 'Code: ' + getResponse.code.to_s
56
- p 'Message: ' + getResponse.message.to_s
57
- p 'MoreResults: ' + getResponse.more?.to_s
58
- p 'Results Length: ' + getResponse.results.length.to_s
59
- p 'Results: ' + getResponse.results.to_s
60
- raise 'Failure retrieving email' unless getResponse.success?
61
-
62
- # Update Email
63
- p '>>> Update Email'
64
- patchHTMLBody = MarketingCloudSDK::Email.new
65
- patchHTMLBody.authStub = stubObj
66
- patchHTMLBody.props = {"CustomerKey" => NameOfTestEmail, "Name"=>NameOfTestEmail, "HTMLBody"=> "<b>Some HTML HTMLBody Goes here. NOW WITH NEW HTMLBody</b>"}
67
- patchResponse = patchHTMLBody.patch
68
- p 'Patch Status: ' + patchResponse.status.to_s
69
- p 'Code: ' + patchResponse.code.to_s
70
- p 'Message: ' + patchResponse.message.to_s
71
- p 'Result Count: ' + patchResponse.results.length.to_s
72
- p 'Results: ' + patchResponse.results.inspect
73
- raise 'Failure updating email' unless patchResponse.success?
74
-
75
- # Retrieve updated Email
76
- p '>>> Retrieve updated Email'
77
- getHTMLBody = MarketingCloudSDK::Email.new()
78
- getHTMLBody.authStub = stubObj
79
- getHTMLBody.props = ["ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Name","Folder","CategoryID","HTMLBody","TextBody","Subject","IsActive","IsHTMLPaste","ClonedFromID","Status","EmailType","CharacterSet","HasDynamicSubjectLine","ContentCheckStatus","Client.PartnerClientKey","ContentAreas","CustomerKey"]
80
- getHTMLBody.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestEmail}
81
- getResponse = getHTMLBody.get
82
- p 'Retrieve Status: ' + getResponse.status.to_s
83
- p 'Code: ' + getResponse.code.to_s
84
- p 'Message: ' + getResponse.message.to_s
85
- p 'MoreResults: ' + getResponse.more?.to_s
86
- p 'Results Length: ' + getResponse.results.length.to_s
87
- p 'Results: ' + getResponse.results.to_s
88
- raise 'Failure retrieving email' unless getResponse.success?
89
-
90
- # Delete Email
91
- p '>>> Delete Email'
92
- deleteHTMLBody = MarketingCloudSDK::Email.new
93
- deleteHTMLBody.authStub = stubObj
94
- deleteHTMLBody.props = {"CustomerKey" => NameOfTestEmail, "Name"=>NameOfTestEmail, "HTMLBody"=> "<b>Some HTML HTMLBody Goes here. NOW WITH NEW HTMLBody</b>"}
95
- deleteResponse = deleteHTMLBody.delete
96
- p 'Delete Status: ' + deleteResponse.status.to_s
97
- p 'Code: ' + deleteResponse.code.to_s
98
- p 'Message: ' + deleteResponse.message.to_s
99
- p 'Result Count: ' + deleteResponse.results.length.to_s
100
- p 'Results: ' + deleteResponse.results.inspect
101
- raise 'Failure deleteing email' unless deleteResponse.success?
102
-
103
- # Retrieve Email to confirm deletion
104
- p '>>> Retrieve Email to confirm deletion'
105
- getHTMLBody = MarketingCloudSDK::Email.new()
106
- getHTMLBody.authStub = stubObj
107
- getHTMLBody.props = ["ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Name","Folder","CategoryID","HTMLBody","TextBody","Subject","IsActive","IsHTMLPaste","ClonedFromID","Status","EmailType","CharacterSet","HasDynamicSubjectLine","ContentCheckStatus","Client.PartnerClientKey","ContentAreas","CustomerKey"]
108
- getHTMLBody.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestEmail}
109
- getResponse = getHTMLBody.get
110
- p 'Retrieve Status: ' + getResponse.status.to_s
111
- p 'Code: ' + getResponse.code.to_s
112
- p 'Message: ' + getResponse.message.to_s
113
- p 'MoreResults: ' + getResponse.more?.to_s
114
- p 'Results Length: ' + getResponse.results.length.to_s
115
- p 'Results: ' + getResponse.results.to_s
116
- raise 'Failure retrieving email' unless getResponse.success?
117
-
118
- rescue => e
119
- p "Caught exception: #{e.message}"
120
- p e.backtrace
121
- end
122
-
1
+ require 'marketingcloudsdk'
2
+ require_relative 'sample_helper'
3
+
4
+ begin
5
+ stubObj = MarketingCloudSDK::Client.new auth
6
+
7
+ # Retrieve All Email with GetMoreResults
8
+ p '>>> Retrieve All Email with GetMoreResults'
9
+ getHTMLBody = MarketingCloudSDK::Email.new()
10
+ getHTMLBody.authStub = stubObj
11
+ getHTMLBody.props = ["ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Name","Folder","CategoryID","HTMLBody","TextBody","Subject","IsActive","IsHTMLPaste","ClonedFromID","Status","EmailType","CharacterSet","HasDynamicSubjectLine","ContentCheckStatus","Client.PartnerClientKey","ContentAreas","CustomerKey"]
12
+ getResponse = getHTMLBody.get
13
+ p 'Retrieve Status: ' + getResponse.status.to_s
14
+ p 'Code: ' + getResponse.code.to_s
15
+ p 'Message: ' + getResponse.message.to_s
16
+ p 'MoreResults: ' + getResponse.more?.to_s
17
+ p 'Results Length: ' + getResponse.results.length.to_s
18
+ #p 'Results: ' + getResponse.results.to_s
19
+ raise 'Failure retrieving email' unless getResponse.success?
20
+
21
+ while getResponse.more? do
22
+ p '>>> Continue Retrieve All Email with GetMoreResults'
23
+ getResponse = getHTMLBody.continue
24
+ p 'Retrieve Status: ' + getResponse.status.to_s
25
+ p 'Code: ' + getResponse.code.to_s
26
+ p 'Message: ' + getResponse.message.to_s
27
+ p 'MoreResults: ' + getResponse.more?.to_s
28
+ p 'RequestID: ' + getResponse.request_id.to_s
29
+ p 'Results Length: ' + getResponse.results.length.to_s
30
+ end
31
+
32
+ NameOfTestEmail = "RubySDKEmail"
33
+
34
+ # Create Email
35
+ p '>>> Create Email'
36
+ postHTMLBody = MarketingCloudSDK::Email.new
37
+ postHTMLBody.authStub = stubObj
38
+ postHTMLBody.props = {"CustomerKey" => NameOfTestEmail, "Name"=>NameOfTestEmail, "Subject" => "Created Using the RubySDK", "HTMLBody"=> "<b>Some HTML Goes here</b>"}
39
+ postResponse = postHTMLBody.post
40
+ p 'Post Status: ' + postResponse.status.to_s
41
+ p 'Code: ' + postResponse.code.to_s
42
+ p 'Message: ' + postResponse.message.to_s
43
+ p 'Result Count: ' + postResponse.results.length.to_s
44
+ p 'Results: ' + postResponse.results.inspect
45
+ raise 'Failure creating email' unless postResponse.success?
46
+
47
+ # Retrieve newly created Email
48
+ p '>>> Retrieve newly created Email'
49
+ getHTMLBody = MarketingCloudSDK::Email.new()
50
+ getHTMLBody.authStub = stubObj
51
+ getHTMLBody.props = ["ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Name","Folder","CategoryID","HTMLBody","TextBody","Subject","IsActive","IsHTMLPaste","ClonedFromID","Status","EmailType","CharacterSet","HasDynamicSubjectLine","ContentCheckStatus","Client.PartnerClientKey","ContentAreas","CustomerKey"]
52
+ getHTMLBody.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestEmail}
53
+ getResponse = getHTMLBody.get
54
+ p 'Retrieve Status: ' + getResponse.status.to_s
55
+ p 'Code: ' + getResponse.code.to_s
56
+ p 'Message: ' + getResponse.message.to_s
57
+ p 'MoreResults: ' + getResponse.more?.to_s
58
+ p 'Results Length: ' + getResponse.results.length.to_s
59
+ p 'Results: ' + getResponse.results.to_s
60
+ raise 'Failure retrieving email' unless getResponse.success?
61
+
62
+ # Update Email
63
+ p '>>> Update Email'
64
+ patchHTMLBody = MarketingCloudSDK::Email.new
65
+ patchHTMLBody.authStub = stubObj
66
+ patchHTMLBody.props = {"CustomerKey" => NameOfTestEmail, "Name"=>NameOfTestEmail, "HTMLBody"=> "<b>Some HTML HTMLBody Goes here. NOW WITH NEW HTMLBody</b>"}
67
+ patchResponse = patchHTMLBody.patch
68
+ p 'Patch Status: ' + patchResponse.status.to_s
69
+ p 'Code: ' + patchResponse.code.to_s
70
+ p 'Message: ' + patchResponse.message.to_s
71
+ p 'Result Count: ' + patchResponse.results.length.to_s
72
+ p 'Results: ' + patchResponse.results.inspect
73
+ raise 'Failure updating email' unless patchResponse.success?
74
+
75
+ # Retrieve updated Email
76
+ p '>>> Retrieve updated Email'
77
+ getHTMLBody = MarketingCloudSDK::Email.new()
78
+ getHTMLBody.authStub = stubObj
79
+ getHTMLBody.props = ["ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Name","Folder","CategoryID","HTMLBody","TextBody","Subject","IsActive","IsHTMLPaste","ClonedFromID","Status","EmailType","CharacterSet","HasDynamicSubjectLine","ContentCheckStatus","Client.PartnerClientKey","ContentAreas","CustomerKey"]
80
+ getHTMLBody.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestEmail}
81
+ getResponse = getHTMLBody.get
82
+ p 'Retrieve Status: ' + getResponse.status.to_s
83
+ p 'Code: ' + getResponse.code.to_s
84
+ p 'Message: ' + getResponse.message.to_s
85
+ p 'MoreResults: ' + getResponse.more?.to_s
86
+ p 'Results Length: ' + getResponse.results.length.to_s
87
+ p 'Results: ' + getResponse.results.to_s
88
+ raise 'Failure retrieving email' unless getResponse.success?
89
+
90
+ # Delete Email
91
+ p '>>> Delete Email'
92
+ deleteHTMLBody = MarketingCloudSDK::Email.new
93
+ deleteHTMLBody.authStub = stubObj
94
+ deleteHTMLBody.props = {"CustomerKey" => NameOfTestEmail, "Name"=>NameOfTestEmail, "HTMLBody"=> "<b>Some HTML HTMLBody Goes here. NOW WITH NEW HTMLBody</b>"}
95
+ deleteResponse = deleteHTMLBody.delete
96
+ p 'Delete Status: ' + deleteResponse.status.to_s
97
+ p 'Code: ' + deleteResponse.code.to_s
98
+ p 'Message: ' + deleteResponse.message.to_s
99
+ p 'Result Count: ' + deleteResponse.results.length.to_s
100
+ p 'Results: ' + deleteResponse.results.inspect
101
+ raise 'Failure deleteing email' unless deleteResponse.success?
102
+
103
+ # Retrieve Email to confirm deletion
104
+ p '>>> Retrieve Email to confirm deletion'
105
+ getHTMLBody = MarketingCloudSDK::Email.new()
106
+ getHTMLBody.authStub = stubObj
107
+ getHTMLBody.props = ["ID","PartnerKey","CreatedDate","ModifiedDate","Client.ID","Name","Folder","CategoryID","HTMLBody","TextBody","Subject","IsActive","IsHTMLPaste","ClonedFromID","Status","EmailType","CharacterSet","HasDynamicSubjectLine","ContentCheckStatus","Client.PartnerClientKey","ContentAreas","CustomerKey"]
108
+ getHTMLBody.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestEmail}
109
+ getResponse = getHTMLBody.get
110
+ p 'Retrieve Status: ' + getResponse.status.to_s
111
+ p 'Code: ' + getResponse.code.to_s
112
+ p 'Message: ' + getResponse.message.to_s
113
+ p 'MoreResults: ' + getResponse.more?.to_s
114
+ p 'Results Length: ' + getResponse.results.length.to_s
115
+ p 'Results: ' + getResponse.results.to_s
116
+ raise 'Failure retrieving email' unless getResponse.success?
117
+
118
+ rescue => e
119
+ p "Caught exception: #{e.message}"
120
+ p e.backtrace
121
+ end
122
+
@@ -1,134 +1,134 @@
1
- require 'marketingcloudsdk'
2
- require_relative 'sample_helper'
3
-
4
- begin
5
- stubObj = MarketingCloudSDK::Client.new auth
6
-
7
- NewSendDefinitionName = "PHPSDKSendDefinition";
8
- SendableDataExtensionCustomerKey = "F6F3871A-D124-499B-BBF5-3EFC0E827A51";
9
- EmailIDForSendDefinition = "3113962";
10
- ListIDForSendDefinition = "1729515";
11
- SendClassificationCustomerKey = "2239";
12
-
13
- # Retrieve All Email::SendDefinition with GetMoreResults
14
- p '>>> Retrieve All Email.SendDefinition with GetMoreResults'
15
- sendDef = MarketingCloudSDK::Email::SendDefinition.new()
16
- sendDef.authStub = stubObj
17
- sendDef.props = ["Client.ID", "CreatedDate","ModifiedDate","ObjectID","CustomerKey","Name","CategoryID","Description","SendClassification.CustomerKey","SenderProfile.CustomerKey","SenderProfile.FromName","SenderProfile.FromAddress","DeliveryProfile.CustomerKey","DeliveryProfile.SourceAddressType","DeliveryProfile.PrivateIP","DeliveryProfile.DomainType","DeliveryProfile.PrivateDomain","DeliveryProfile.HeaderSalutationSource","DeliveryProfile.FooterSalutationSource","SuppressTracking","IsSendLogging","Email.ID","BccEmail","AutoBccEmail","TestEmailAddr","EmailSubject","DynamicEmailSubject","IsMultipart","IsWrapped","SendLimit","SendWindowOpen","SendWindowClose","DeduplicateByEmail","ExclusionFilter","Additional"]
18
- getResponse = sendDef.get
19
- p 'Retrieve Status: ' + getResponse.status.to_s
20
- p 'Code: ' + getResponse.code.to_s
21
- p 'Message: ' + getResponse.message.to_s
22
- p 'MoreResults: ' + getResponse.more?.to_s
23
- p 'Results Length: ' + getResponse.results.length.to_s
24
- #p 'Results: ' + getResponse.results.to_s
25
- raise 'Failure retrieving SendDefinition' unless getResponse.success?
26
-
27
-
28
- while getResponse.more? do
29
- p '>>> Continue Retrieve All Email with GetMoreResults'
30
- getResponse = getHTMLBody.continue
31
- p 'Retrieve Status: ' + getResponse.status.to_s
32
- p 'Code: ' + getResponse.code.to_s
33
- p 'Message: ' + getResponse.message.to_s
34
- p 'MoreResults: ' + getResponse.more?.to_s
35
- p 'RequestID: ' + getResponse.request_id.to_s
36
- p 'Results Length: ' + getResponse.results.length.to_s
37
- end
38
-
39
- p '>>> Create New Email.SendDefinition to DataExtension'
40
- postSendDefinition = MarketingCloudSDK::Email::SendDefinition.new()
41
- postSendDefinition.authStub = stubObj
42
- postSendDefinition.props = {}
43
- postSendDefinition.props["Name"] = NewSendDefinitionName
44
- postSendDefinition.props["CustomerKey"] = NewSendDefinitionName
45
- postSendDefinition.props["Description"] = "Created with RubySDK"
46
- postSendDefinition.props["SendClassification"] = {"CustomerKey"=>SendClassificationCustomerKey}
47
- postSendDefinition.props["SendDefinitionList"] = {"CustomerKey"=> SendableDataExtensionCustomerKey, "DataSourceTypeID"=>"CustomObject"}
48
- postSendDefinition.props["Email"] = {"ID"=>EmailIDForSendDefinition}
49
- postResponse = postSendDefinition.post
50
- p 'Post Status: ' + postResponse.status.to_s
51
- p 'Code: ' + postResponse.code.to_s
52
- p 'Message: ' + postResponse.message.to_s
53
- p 'MoreResults: ' + postResponse.more?.to_s
54
- p 'Results Length: ' + postResponse.results.length.to_s
55
- p 'Results: ' + postResponse.results.to_s
56
- #raise 'Failure Creating SendDefinition' unless postResponse.success?
57
-
58
- p '>>> Delete SendDefinition to DataExtension'
59
- deleteSendDefinition = MarketingCloudSDK::Email::SendDefinition.new()
60
- deleteSendDefinition.authStub = stubObj
61
- deleteSendDefinition.props = {"CustomerKey"=> NewSendDefinitionName}
62
- deleteResponse = deleteSendDefinition.delete
63
- p 'Delete Status: ' + deleteResponse.status.to_s
64
- p 'Code: ' + deleteResponse.code.to_s
65
- p 'Message: ' + deleteResponse.message.to_s
66
- p 'MoreResults: ' + deleteResponse.more?.to_s
67
- p 'Results Length: ' + deleteResponse.results.length.to_s
68
- p 'Results: ' + deleteResponse.results.to_s
69
- #raise 'Failure Deleting SendDefinition' unless deleteResponse.success?
70
-
71
-
72
- p '>>> Create New Email.SendDefinition to List'
73
- postSendDefinition = MarketingCloudSDK::Email::SendDefinition.new()
74
- postSendDefinition.authStub = stubObj
75
- postSendDefinition.props = {"Name"=>NewSendDefinitionName}
76
- postSendDefinition.props["CustomerKey"] = NewSendDefinitionName
77
- postSendDefinition.props["Description"] = "Created with PHPSDK"
78
- postSendDefinition.props["SendClassification"] = {"CustomerKey"=>SendClassificationCustomerKey}
79
- postSendDefinition.props["SendDefinitionList"] = {"List"=> {"ID"=>ListIDForSendDefinition}, "DataSourceTypeID"=>"List"}
80
- postSendDefinition.props["Email"] = {"ID"=>EmailIDForSendDefinition}
81
- postResponse = postSendDefinition.post
82
- p 'Post Status: ' + postResponse.status.to_s
83
- p 'Code: ' + postResponse.code.to_s
84
- p 'Message: ' + postResponse.message.to_s
85
- p 'MoreResults: ' + postResponse.more?.to_s
86
- p 'Results Length: ' + postResponse.results.length.to_s
87
- p 'Results: ' + postResponse.results.to_s
88
- raise 'Failure Creating SendDefinition' unless postResponse.success?
89
-
90
- p '>>> Send SendDefinition to List'
91
- sendSendDefinition = MarketingCloudSDK::Email::SendDefinition.new()
92
- sendSendDefinition.authStub = stubObj
93
- sendSendDefinition.props = {"CustomerKey"=> NewSendDefinitionName}
94
- sendResponse = sendSendDefinition.send
95
- p 'Send Status: ' + sendResponse.status.to_s
96
- p 'Code: ' + sendResponse.code.to_s
97
- p 'Message: ' + sendResponse.message.to_s
98
- p 'MoreResults: ' + sendResponse.more?.to_s
99
- p 'Results Length: ' + sendResponse.results.length.to_s
100
- p 'Results: ' + sendResponse.results.to_s
101
- raise 'Failure Sending SendDefinition' unless sendResponse.success?
102
-
103
- emailStatus = ""
104
- while emailStatus != "Canceled" && emailStatus != "Complete" do
105
- p '>>> Checking status in loop'
106
- # Wait a bit before checking the status to give it time to process
107
- sleep 10
108
- statusResponse = sendSendDefinition.status
109
- p 'Status Status: ' + statusResponse.status.to_s
110
- p 'Code: ' + statusResponse.code.to_s
111
- p 'Message: ' + statusResponse.message.to_s
112
- p 'Result Count: ' + statusResponse.results.length.to_s
113
- p 'Results: ' + statusResponse.results.inspect
114
- emailStatus = statusResponse.results[0][:status]
115
- end
116
-
117
- p '>>> Delete SendDefinition to List'
118
- deleteSendDefinition = MarketingCloudSDK::Email::SendDefinition.new()
119
- deleteSendDefinition.authStub = stubObj
120
- deleteSendDefinition.props = {"CustomerKey"=> NewSendDefinitionName}
121
- deleteResponse = deleteSendDefinition.delete
122
- p 'Delete Status: ' + deleteResponse.status.to_s
123
- p 'Code: ' + deleteResponse.code.to_s
124
- p 'Message: ' + deleteResponse.message.to_s
125
- p 'MoreResults: ' + deleteResponse.more?.to_s
126
- p 'Results Length: ' + deleteResponse.results.length.to_s
127
- p 'Results: ' + deleteResponse.results.to_s
128
- raise 'Failure Deleting SendDefinition' unless deleteResponse.success?
129
-
130
- rescue => e
131
- p "Caught exception: #{e.message}"
132
- p e.backtrace
133
- end
134
-
1
+ require 'marketingcloudsdk'
2
+ require_relative 'sample_helper'
3
+
4
+ begin
5
+ stubObj = MarketingCloudSDK::Client.new auth
6
+
7
+ NewSendDefinitionName = "PHPSDKSendDefinition";
8
+ SendableDataExtensionCustomerKey = "F6F3871A-D124-499B-BBF5-3EFC0E827A51";
9
+ EmailIDForSendDefinition = "3113962";
10
+ ListIDForSendDefinition = "1729515";
11
+ SendClassificationCustomerKey = "2239";
12
+
13
+ # Retrieve All Email::SendDefinition with GetMoreResults
14
+ p '>>> Retrieve All Email.SendDefinition with GetMoreResults'
15
+ sendDef = MarketingCloudSDK::Email::SendDefinition.new()
16
+ sendDef.authStub = stubObj
17
+ sendDef.props = ["Client.ID", "CreatedDate","ModifiedDate","ObjectID","CustomerKey","Name","CategoryID","Description","SendClassification.CustomerKey","SenderProfile.CustomerKey","SenderProfile.FromName","SenderProfile.FromAddress","DeliveryProfile.CustomerKey","DeliveryProfile.SourceAddressType","DeliveryProfile.PrivateIP","DeliveryProfile.DomainType","DeliveryProfile.PrivateDomain","DeliveryProfile.HeaderSalutationSource","DeliveryProfile.FooterSalutationSource","SuppressTracking","IsSendLogging","Email.ID","BccEmail","AutoBccEmail","TestEmailAddr","EmailSubject","DynamicEmailSubject","IsMultipart","IsWrapped","SendLimit","SendWindowOpen","SendWindowClose","DeduplicateByEmail","ExclusionFilter","Additional"]
18
+ getResponse = sendDef.get
19
+ p 'Retrieve Status: ' + getResponse.status.to_s
20
+ p 'Code: ' + getResponse.code.to_s
21
+ p 'Message: ' + getResponse.message.to_s
22
+ p 'MoreResults: ' + getResponse.more?.to_s
23
+ p 'Results Length: ' + getResponse.results.length.to_s
24
+ #p 'Results: ' + getResponse.results.to_s
25
+ raise 'Failure retrieving SendDefinition' unless getResponse.success?
26
+
27
+
28
+ while getResponse.more? do
29
+ p '>>> Continue Retrieve All Email with GetMoreResults'
30
+ getResponse = getHTMLBody.continue
31
+ p 'Retrieve Status: ' + getResponse.status.to_s
32
+ p 'Code: ' + getResponse.code.to_s
33
+ p 'Message: ' + getResponse.message.to_s
34
+ p 'MoreResults: ' + getResponse.more?.to_s
35
+ p 'RequestID: ' + getResponse.request_id.to_s
36
+ p 'Results Length: ' + getResponse.results.length.to_s
37
+ end
38
+
39
+ p '>>> Create New Email.SendDefinition to DataExtension'
40
+ postSendDefinition = MarketingCloudSDK::Email::SendDefinition.new()
41
+ postSendDefinition.authStub = stubObj
42
+ postSendDefinition.props = {}
43
+ postSendDefinition.props["Name"] = NewSendDefinitionName
44
+ postSendDefinition.props["CustomerKey"] = NewSendDefinitionName
45
+ postSendDefinition.props["Description"] = "Created with RubySDK"
46
+ postSendDefinition.props["SendClassification"] = {"CustomerKey"=>SendClassificationCustomerKey}
47
+ postSendDefinition.props["SendDefinitionList"] = {"CustomerKey"=> SendableDataExtensionCustomerKey, "DataSourceTypeID"=>"CustomObject"}
48
+ postSendDefinition.props["Email"] = {"ID"=>EmailIDForSendDefinition}
49
+ postResponse = postSendDefinition.post
50
+ p 'Post Status: ' + postResponse.status.to_s
51
+ p 'Code: ' + postResponse.code.to_s
52
+ p 'Message: ' + postResponse.message.to_s
53
+ p 'MoreResults: ' + postResponse.more?.to_s
54
+ p 'Results Length: ' + postResponse.results.length.to_s
55
+ p 'Results: ' + postResponse.results.to_s
56
+ #raise 'Failure Creating SendDefinition' unless postResponse.success?
57
+
58
+ p '>>> Delete SendDefinition to DataExtension'
59
+ deleteSendDefinition = MarketingCloudSDK::Email::SendDefinition.new()
60
+ deleteSendDefinition.authStub = stubObj
61
+ deleteSendDefinition.props = {"CustomerKey"=> NewSendDefinitionName}
62
+ deleteResponse = deleteSendDefinition.delete
63
+ p 'Delete Status: ' + deleteResponse.status.to_s
64
+ p 'Code: ' + deleteResponse.code.to_s
65
+ p 'Message: ' + deleteResponse.message.to_s
66
+ p 'MoreResults: ' + deleteResponse.more?.to_s
67
+ p 'Results Length: ' + deleteResponse.results.length.to_s
68
+ p 'Results: ' + deleteResponse.results.to_s
69
+ #raise 'Failure Deleting SendDefinition' unless deleteResponse.success?
70
+
71
+
72
+ p '>>> Create New Email.SendDefinition to List'
73
+ postSendDefinition = MarketingCloudSDK::Email::SendDefinition.new()
74
+ postSendDefinition.authStub = stubObj
75
+ postSendDefinition.props = {"Name"=>NewSendDefinitionName}
76
+ postSendDefinition.props["CustomerKey"] = NewSendDefinitionName
77
+ postSendDefinition.props["Description"] = "Created with PHPSDK"
78
+ postSendDefinition.props["SendClassification"] = {"CustomerKey"=>SendClassificationCustomerKey}
79
+ postSendDefinition.props["SendDefinitionList"] = {"List"=> {"ID"=>ListIDForSendDefinition}, "DataSourceTypeID"=>"List"}
80
+ postSendDefinition.props["Email"] = {"ID"=>EmailIDForSendDefinition}
81
+ postResponse = postSendDefinition.post
82
+ p 'Post Status: ' + postResponse.status.to_s
83
+ p 'Code: ' + postResponse.code.to_s
84
+ p 'Message: ' + postResponse.message.to_s
85
+ p 'MoreResults: ' + postResponse.more?.to_s
86
+ p 'Results Length: ' + postResponse.results.length.to_s
87
+ p 'Results: ' + postResponse.results.to_s
88
+ raise 'Failure Creating SendDefinition' unless postResponse.success?
89
+
90
+ p '>>> Send SendDefinition to List'
91
+ sendSendDefinition = MarketingCloudSDK::Email::SendDefinition.new()
92
+ sendSendDefinition.authStub = stubObj
93
+ sendSendDefinition.props = {"CustomerKey"=> NewSendDefinitionName}
94
+ sendResponse = sendSendDefinition.send
95
+ p 'Send Status: ' + sendResponse.status.to_s
96
+ p 'Code: ' + sendResponse.code.to_s
97
+ p 'Message: ' + sendResponse.message.to_s
98
+ p 'MoreResults: ' + sendResponse.more?.to_s
99
+ p 'Results Length: ' + sendResponse.results.length.to_s
100
+ p 'Results: ' + sendResponse.results.to_s
101
+ raise 'Failure Sending SendDefinition' unless sendResponse.success?
102
+
103
+ emailStatus = ""
104
+ while emailStatus != "Canceled" && emailStatus != "Complete" do
105
+ p '>>> Checking status in loop'
106
+ # Wait a bit before checking the status to give it time to process
107
+ sleep 10
108
+ statusResponse = sendSendDefinition.status
109
+ p 'Status Status: ' + statusResponse.status.to_s
110
+ p 'Code: ' + statusResponse.code.to_s
111
+ p 'Message: ' + statusResponse.message.to_s
112
+ p 'Result Count: ' + statusResponse.results.length.to_s
113
+ p 'Results: ' + statusResponse.results.inspect
114
+ emailStatus = statusResponse.results[0][:status]
115
+ end
116
+
117
+ p '>>> Delete SendDefinition to List'
118
+ deleteSendDefinition = MarketingCloudSDK::Email::SendDefinition.new()
119
+ deleteSendDefinition.authStub = stubObj
120
+ deleteSendDefinition.props = {"CustomerKey"=> NewSendDefinitionName}
121
+ deleteResponse = deleteSendDefinition.delete
122
+ p 'Delete Status: ' + deleteResponse.status.to_s
123
+ p 'Code: ' + deleteResponse.code.to_s
124
+ p 'Message: ' + deleteResponse.message.to_s
125
+ p 'MoreResults: ' + deleteResponse.more?.to_s
126
+ p 'Results Length: ' + deleteResponse.results.length.to_s
127
+ p 'Results: ' + deleteResponse.results.to_s
128
+ raise 'Failure Deleting SendDefinition' unless deleteResponse.success?
129
+
130
+ rescue => e
131
+ p "Caught exception: #{e.message}"
132
+ p e.backtrace
133
+ end
134
+