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,71 +1,71 @@
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 ClickEvents with GetMoreResults'
12
- getClickEvent = MarketingCloudSDK::ClickEvent.new()
13
- getClickEvent.authStub = stubObj
14
- getClickEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
15
- getClickEvent.filter = {'Property' => 'EventDate','SimpleOperator' => 'greaterThan','DateValue' => retrieveDate}
16
- getResponse = getClickEvent.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
- #
26
- raise 'Failure retrieving click events' unless getResponse.success?
27
-
28
- while getResponse.more? do
29
- p '>>> Continue Retrieve Filtered ClickEvents with GetMoreResults'
30
- getResponse = getClickEvent.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
- # The following request could potentially bring back large amounts of data if run against a production account
40
- =begin
41
- p '>>> Retrieve All ClickEvents with GetMoreResults'
42
- getClickEvent = MarketingCloudSDK::ClickEvent.new()
43
- getClickEvent.authStub = stubObj
44
- getClickEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
45
- getResponse = getClickEvent.get
46
- p 'Retrieve Status: ' + getResponse.status.to_s
47
- p 'Code: ' + getResponse.code.to_s
48
- p 'Message: ' + getResponse.message.to_s
49
- p 'MoreResults: ' + getResponse.more?.to_s
50
- p 'RequestID: ' + getResponse.request_id.to_s
51
- p 'Results Length: ' + getResponse.results.length.to_s
52
- # Since this could potentially return a large number of results, we do not want to print the results
53
- #p 'Results: ' + getResponse.results.to_s
54
-
55
- while getResponse.more? do
56
- p '>>> Continue Retrieve All ClickEvents with GetMoreResults'
57
- getResponse = getClickEvent.continue
58
- p 'Retrieve Status: ' + getResponse.status.to_s
59
- p 'Code: ' + getResponse.code.to_s
60
- p 'Message: ' + getResponse.message.to_s
61
- p 'MoreResults: ' + getResponse.more?.to_s
62
- p 'RequestID: ' + getResponse.request_id.to_s
63
- p 'Results Length: ' + getResponse.results.length.to_s
64
- end
65
- =end
66
-
67
- rescue => e
68
- p "Caught exception: #{e.message}"
69
- p e.backtrace
70
- end
71
-
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 ClickEvents with GetMoreResults'
12
+ getClickEvent = MarketingCloudSDK::ClickEvent.new()
13
+ getClickEvent.authStub = stubObj
14
+ getClickEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
15
+ getClickEvent.filter = {'Property' => 'EventDate','SimpleOperator' => 'greaterThan','DateValue' => retrieveDate}
16
+ getResponse = getClickEvent.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
+ #
26
+ raise 'Failure retrieving click events' unless getResponse.success?
27
+
28
+ while getResponse.more? do
29
+ p '>>> Continue Retrieve Filtered ClickEvents with GetMoreResults'
30
+ getResponse = getClickEvent.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
+ # The following request could potentially bring back large amounts of data if run against a production account
40
+ =begin
41
+ p '>>> Retrieve All ClickEvents with GetMoreResults'
42
+ getClickEvent = MarketingCloudSDK::ClickEvent.new()
43
+ getClickEvent.authStub = stubObj
44
+ getClickEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
45
+ getResponse = getClickEvent.get
46
+ p 'Retrieve Status: ' + getResponse.status.to_s
47
+ p 'Code: ' + getResponse.code.to_s
48
+ p 'Message: ' + getResponse.message.to_s
49
+ p 'MoreResults: ' + getResponse.more?.to_s
50
+ p 'RequestID: ' + getResponse.request_id.to_s
51
+ p 'Results Length: ' + getResponse.results.length.to_s
52
+ # Since this could potentially return a large number of results, we do not want to print the results
53
+ #p 'Results: ' + getResponse.results.to_s
54
+
55
+ while getResponse.more? do
56
+ p '>>> Continue Retrieve All ClickEvents with GetMoreResults'
57
+ getResponse = getClickEvent.continue
58
+ p 'Retrieve Status: ' + getResponse.status.to_s
59
+ p 'Code: ' + getResponse.code.to_s
60
+ p 'Message: ' + getResponse.message.to_s
61
+ p 'MoreResults: ' + getResponse.more?.to_s
62
+ p 'RequestID: ' + getResponse.request_id.to_s
63
+ p 'Results Length: ' + getResponse.results.length.to_s
64
+ end
65
+ =end
66
+
67
+ rescue => e
68
+ p "Caught exception: #{e.message}"
69
+ p e.backtrace
70
+ end
71
+
@@ -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 ContentArea with GetMoreResults
8
- p '>>> Retrieve All ContentArea with GetMoreResults'
9
- getContent = MarketingCloudSDK::ContentArea.new()
10
- getContent.authStub = stubObj
11
- getContent.props = ["RowObjectID","ObjectID","ID","CustomerKey","Client.ID","ModifiedDate","CreatedDate","CategoryID","Name","Layout","IsDynamicContent","Content","IsSurvey","IsBlank","Key"]
12
- getResponse = getContent.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 contentarea' unless getResponse.success?
20
-
21
- while getResponse.more? do
22
- p '>>> Continue Retrieve All ContentArea with GetMoreResults'
23
- getResponse = getContent.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
- NameOfTestContentArea = "RubySDKContentArea"
33
-
34
- # Create ContentArea
35
- p '>>> Create ContentArea'
36
- postContent = MarketingCloudSDK::ContentArea.new
37
- postContent.authStub = stubObj
38
- postContent.props = {"CustomerKey" => NameOfTestContentArea, "Name"=>NameOfTestContentArea, "Content"=> "<b>Some HTML Content Goes here</b>"}
39
- postResponse = postContent.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 contentarea' unless postResponse.success?
46
-
47
- # Retrieve newly created ContentArea
48
- p '>>> Retrieve newly created ContentArea'
49
- getContent = MarketingCloudSDK::ContentArea.new()
50
- getContent.authStub = stubObj
51
- getContent.props = ["RowObjectID","ObjectID","ID","CustomerKey","Client.ID","ModifiedDate","CreatedDate","CategoryID","Name","Layout","IsDynamicContent","Content","IsSurvey","IsBlank","Key"]
52
- getContent.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestContentArea}
53
- getResponse = getContent.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 contentarea' unless getResponse.success?
61
-
62
- # Update ContentArea
63
- p '>>> Update ContentArea'
64
- patchContent = MarketingCloudSDK::ContentArea.new
65
- patchContent.authStub = stubObj
66
- patchContent.props = {"CustomerKey" => NameOfTestContentArea, "Name"=>NameOfTestContentArea, "Content"=> "<b>Some HTML Content Goes here. NOW WITH NEW CONTENT</b>"}
67
- patchResponse = patchContent.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 contentarea' unless patchResponse.success?
74
-
75
- # Retrieve updated ContentArea
76
- p '>>> Retrieve updated ContentArea'
77
- getContent = MarketingCloudSDK::ContentArea.new()
78
- getContent.authStub = stubObj
79
- getContent.props = ["RowObjectID","ObjectID","ID","CustomerKey","Client.ID","ModifiedDate","CreatedDate","CategoryID","Name","Layout","IsDynamicContent","Content","IsSurvey","IsBlank","Key"]
80
- getContent.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestContentArea}
81
- getResponse = getContent.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 contentarea' unless getResponse.success?
89
-
90
- # Delete ContentArea
91
- p '>>> Delete ContentArea'
92
- deleteContent = MarketingCloudSDK::ContentArea.new
93
- deleteContent.authStub = stubObj
94
- deleteContent.props = {"CustomerKey" => NameOfTestContentArea, "Name"=>NameOfTestContentArea, "Content"=> "<b>Some HTML Content Goes here. NOW WITH NEW CONTENT</b>"}
95
- deleteResponse = deleteContent.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 deleting contentarea' unless deleteResponse.success?
102
-
103
- # Retrieve ContentArea to confirm deletion
104
- p '>>> Retrieve ContentArea to confirm deletion'
105
- getContent = MarketingCloudSDK::ContentArea.new()
106
- getContent.authStub = stubObj
107
- getContent.props = ["RowObjectID","ObjectID","ID","CustomerKey","Client.ID","ModifiedDate","CreatedDate","CategoryID","Name","Layout","IsDynamicContent","Content","IsSurvey","IsBlank","Key"]
108
- getContent.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestContentArea}
109
- getResponse = getContent.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 contentarea' 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 ContentArea with GetMoreResults
8
+ p '>>> Retrieve All ContentArea with GetMoreResults'
9
+ getContent = MarketingCloudSDK::ContentArea.new()
10
+ getContent.authStub = stubObj
11
+ getContent.props = ["RowObjectID","ObjectID","ID","CustomerKey","Client.ID","ModifiedDate","CreatedDate","CategoryID","Name","Layout","IsDynamicContent","Content","IsSurvey","IsBlank","Key"]
12
+ getResponse = getContent.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 contentarea' unless getResponse.success?
20
+
21
+ while getResponse.more? do
22
+ p '>>> Continue Retrieve All ContentArea with GetMoreResults'
23
+ getResponse = getContent.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
+ NameOfTestContentArea = "RubySDKContentArea"
33
+
34
+ # Create ContentArea
35
+ p '>>> Create ContentArea'
36
+ postContent = MarketingCloudSDK::ContentArea.new
37
+ postContent.authStub = stubObj
38
+ postContent.props = {"CustomerKey" => NameOfTestContentArea, "Name"=>NameOfTestContentArea, "Content"=> "<b>Some HTML Content Goes here</b>"}
39
+ postResponse = postContent.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 contentarea' unless postResponse.success?
46
+
47
+ # Retrieve newly created ContentArea
48
+ p '>>> Retrieve newly created ContentArea'
49
+ getContent = MarketingCloudSDK::ContentArea.new()
50
+ getContent.authStub = stubObj
51
+ getContent.props = ["RowObjectID","ObjectID","ID","CustomerKey","Client.ID","ModifiedDate","CreatedDate","CategoryID","Name","Layout","IsDynamicContent","Content","IsSurvey","IsBlank","Key"]
52
+ getContent.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestContentArea}
53
+ getResponse = getContent.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 contentarea' unless getResponse.success?
61
+
62
+ # Update ContentArea
63
+ p '>>> Update ContentArea'
64
+ patchContent = MarketingCloudSDK::ContentArea.new
65
+ patchContent.authStub = stubObj
66
+ patchContent.props = {"CustomerKey" => NameOfTestContentArea, "Name"=>NameOfTestContentArea, "Content"=> "<b>Some HTML Content Goes here. NOW WITH NEW CONTENT</b>"}
67
+ patchResponse = patchContent.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 contentarea' unless patchResponse.success?
74
+
75
+ # Retrieve updated ContentArea
76
+ p '>>> Retrieve updated ContentArea'
77
+ getContent = MarketingCloudSDK::ContentArea.new()
78
+ getContent.authStub = stubObj
79
+ getContent.props = ["RowObjectID","ObjectID","ID","CustomerKey","Client.ID","ModifiedDate","CreatedDate","CategoryID","Name","Layout","IsDynamicContent","Content","IsSurvey","IsBlank","Key"]
80
+ getContent.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestContentArea}
81
+ getResponse = getContent.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 contentarea' unless getResponse.success?
89
+
90
+ # Delete ContentArea
91
+ p '>>> Delete ContentArea'
92
+ deleteContent = MarketingCloudSDK::ContentArea.new
93
+ deleteContent.authStub = stubObj
94
+ deleteContent.props = {"CustomerKey" => NameOfTestContentArea, "Name"=>NameOfTestContentArea, "Content"=> "<b>Some HTML Content Goes here. NOW WITH NEW CONTENT</b>"}
95
+ deleteResponse = deleteContent.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 deleting contentarea' unless deleteResponse.success?
102
+
103
+ # Retrieve ContentArea to confirm deletion
104
+ p '>>> Retrieve ContentArea to confirm deletion'
105
+ getContent = MarketingCloudSDK::ContentArea.new()
106
+ getContent.authStub = stubObj
107
+ getContent.props = ["RowObjectID","ObjectID","ID","CustomerKey","Client.ID","ModifiedDate","CreatedDate","CategoryID","Name","Layout","IsDynamicContent","Content","IsSurvey","IsBlank","Key"]
108
+ getContent.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestContentArea}
109
+ getResponse = getContent.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 contentarea' unless getResponse.success?
117
+
118
+ rescue => e
119
+ p "Caught exception: #{e.message}"
120
+ p e.backtrace
121
+ end
122
+
@@ -1,209 +1,209 @@
1
- require 'marketingcloudsdk'
2
- require_relative 'sample_helper'
3
- require 'pry'
4
-
5
- begin
6
- stubObj = ET_Client.new auth
7
-
8
- # Specify a name for the data extension that will be used for testing
9
- # Note: Name and CustomerKey will be the same value
10
- # WARNING: Data Extension will be deleted so don't use the name of a
11
- # production data extension
12
- NameOfDE = "ThisWillBeDeleted-Testz"
13
-
14
- # Get all of the DataExtensions in an Account
15
- p '>>> Get all of the DataExtensions in an Account'
16
- de = ET_DataExtension.new
17
- de.authStub = stubObj
18
- de.props = ["CustomerKey", "Name"]
19
- getResponse = de.get
20
- p 'Retrieve Status: ' + getResponse.status.to_s
21
- p 'Code: ' + getResponse.code.to_s
22
- p 'Message: ' + getResponse.message.to_s
23
- p 'MoreResults: ' + getResponse.more?.to_s
24
- p 'RequestID: ' + getResponse.request_id.to_s
25
- p 'Results Length: ' + getResponse.results.length.to_s
26
- #p 'Results: ' + getResponse.results.to_s
27
- raise 'Failure retrieving data extensions' unless getResponse.success?
28
-
29
- # Create Data Extension
30
- p '>>> Create Data Extension'
31
- de2 = ET_DataExtension.new
32
- de2.authStub = stubObj
33
- de2.props = {"Name" => NameOfDE,"CustomerKey" => NameOfDE}
34
- de2.columns = [{"Name" => "Name", "FieldType" => "Text", "IsPrimaryKey" => "true", "MaxLength" => "100", "IsRequired" => "true"},
35
- {"Name" => "OtherField", "FieldType" => "Text"}]
36
- postResponse = de2.post
37
- p 'Post Status: ' + postResponse.status.to_s
38
- p 'Code: ' + postResponse.code.to_s
39
- p 'Message: ' + postResponse.message.to_s
40
- p 'Results: ' + postResponse.results.inspect
41
- raise 'Failure creating data extension' unless postResponse.success?
42
-
43
- # Update DE to add new field
44
- p '>>> Update DE to add new field'
45
- de3 = ET_DataExtension.new
46
- de3.authStub = stubObj
47
- de3.props = {"Name" => NameOfDE,"CustomerKey" => NameOfDE}
48
- de3.columns = [{"Name" => "AddedField", "FieldType" => "Text"}]
49
- patchResponse = de3.patch
50
- p 'Patch Status: ' + patchResponse.status.to_s
51
- p 'Code: ' + patchResponse.code.to_s
52
- p 'Message: ' + patchResponse.message.to_s
53
- p 'Results: ' + patchResponse.results.inspect
54
- raise 'Failure updating data extension' unless patchResponse.success?
55
-
56
- # Retrieve all columns for data extension
57
- p '>>> Retrieve all columns for data extension '
58
- myDEColumn = ET_DataExtension::Column.new
59
- myDEColumn.authStub = stubObj
60
- myDEColumn.props = ["Name"]
61
- myDEColumn.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfDE}
62
- getResponse = myDEColumn.get
63
- p 'Retrieve Status: ' + getResponse.status.to_s
64
- p 'Code: ' + getResponse.code.to_s
65
- p 'Message: ' + getResponse.message.to_s
66
- p 'MoreResults: ' + getResponse.more?.to_s
67
- p 'RequestID: ' + getResponse.request_id.to_s
68
- p 'Results Length: ' + getResponse.results.length.to_s
69
- p 'Results: ' + getResponse.results.to_s
70
- raise 'Failure retrieving data extension columns' unless getResponse.success?
71
- raise 'Failure retrieving correct number of data extension columns' unless getResponse.results.count == 3
72
-
73
- # Add a row to a data extension (using CustomerKey)
74
- p '>>> Add a row to a data extension'
75
- de4 = ET_DataExtension::Row.new
76
- de4.CustomerKey = NameOfDE;
77
- de4.authStub = stubObj
78
- de4.props = {"Name" => "MAC3", "OtherField" => "Text3"}
79
- postResponse = de4.post
80
- p 'Post Status: ' + postResponse.status.to_s
81
- p 'Code: ' + postResponse.code.to_s
82
- p 'Message: ' + postResponse.message.to_s
83
- p 'Results: ' + postResponse.results.inspect
84
- raise 'Failure creating data extension row' unless postResponse.success?
85
-
86
- # Add a row to a data extension (Using Name)
87
- p '>>> Add a row to a data extension'
88
- de4 = ET_DataExtension::Row.new
89
- de4.authStub = stubObj
90
- de4.Name = NameOfDE
91
- de4.props = {"Name" => "MAC4", "OtherField" => "Text3"}
92
- postResponse = de4.post
93
- p 'Post Status: ' + postResponse.status.to_s
94
- p 'Code: ' + postResponse.code.to_s
95
- p 'Message: ' + postResponse.message.to_s
96
- p 'Results: ' + postResponse.results.inspect
97
- raise 'Failure creating data extension row' unless postResponse.success?
98
-
99
- # Retrieve all rows
100
- p '>>> Retrieve all rows'
101
- row = ET_DataExtension::Row.new()
102
- row.authStub = stubObj
103
- row.CustomerKey = NameOfDE
104
- row.props = ["Name","OtherField"]
105
- getResponse = row.get
106
- p 'Retrieve Status: ' + getResponse.status.to_s
107
- p 'Code: ' + getResponse.code.to_s
108
- p 'Message: ' + getResponse.message.to_s
109
- p 'MoreResults: ' + getResponse.more?.to_s
110
- p 'RequestID: ' + getResponse.request_id.to_s
111
- p 'Results Length: ' + getResponse.results.length.to_s
112
- p 'Results: ' + getResponse.results.to_s
113
- raise 'Failure retrieving data extension rows' unless getResponse.success?
114
- raise 'Failure retrieving correct number of data extension rows' unless getResponse.results.count == 2
115
-
116
- # Update a row in a data extension
117
- p '>>> Update a row in a data extension'
118
- de4 = ET_DataExtension::Row.new
119
- de4.authStub = stubObj
120
- de4.CustomerKey = NameOfDE
121
- de4.props = {"Name" => "MAC3", "OtherField" => "UPDATED!"}
122
- patchResponse = de4.patch
123
- p 'Patch Status: ' + patchResponse.status.to_s
124
- p 'Code: ' + patchResponse.code.to_s
125
- p 'Message: ' + patchResponse.message.to_s
126
- p 'Results: ' + patchResponse.results.inspect
127
- raise 'Failure updating data extension row' unless patchResponse.success?
128
-
129
- # Retrieve only updated row
130
- p '>>> Retrieve only updated row'
131
- row = ET_DataExtension::Row.new()
132
- row.authStub = stubObj
133
- row.CustomerKey = NameOfDE
134
- row.props = ["Name","OtherField"]
135
- row.filter = {'Property' => 'Name','SimpleOperator' => 'equals','Value' => 'MAC3'}
136
- getResponse = row.get
137
- p 'Retrieve Status: ' + getResponse.status.to_s
138
- p 'Code: ' + getResponse.code.to_s
139
- p 'Message: ' + getResponse.message.to_s
140
- p 'MoreResults: ' + getResponse.more?.to_s
141
- p 'RequestID: ' + getResponse.request_id.to_s
142
- p 'Results Length: ' + getResponse.results.length.to_s
143
- p 'Results: ' + getResponse.results.to_s
144
- raise 'Failure retrieving data extension rows' unless getResponse.success?
145
-
146
- # Delete a row from a data extension
147
- p '>>> Delete a row from a data extension'
148
- de4 = ET_DataExtension::Row.new
149
- de4.authStub = stubObj
150
- de4.CustomerKey = NameOfDE
151
- de4.props = {"Name" => "MAC3"}
152
- deleteResponse = de4.delete
153
- p 'Delete Status: ' + deleteResponse.status.to_s
154
- p 'Code: ' + deleteResponse.code.to_s
155
- p 'Message: ' + deleteResponse.message.to_s
156
- p 'Results: ' + deleteResponse.results.inspect
157
- raise 'Failure deleting data extension row' unless deleteResponse.success?
158
-
159
- # Delete a Data Extension
160
- p '>>> Delete a Data Extension'
161
- de5 = ET_DataExtension.new
162
- de5.authStub = stubObj
163
- de5.props = {"Name" => NameOfDE,"CustomerKey" => NameOfDE}
164
- delResponse = de5.delete
165
- p 'Post Status: ' + delResponse.status.to_s
166
- p 'Code: ' + delResponse.code.to_s
167
- p 'Message: ' + delResponse.message.to_s
168
- p 'Results: ' + delResponse.results.inspect
169
- raise 'Failure deleting data extension' unless deleteResponse.success?
170
-
171
- =begin
172
- # Retrieve lots of rows with more?
173
- p '>>> Retrieve lots of rows with more?'
174
- row = ET_DataExtension::Row.new()
175
- row.authStub = stubObj
176
- row.Name = "zipstolong"
177
- row.props = ["zip","latitude","longitude"]
178
- getResponse = row.get
179
- p 'Retrieve Status: ' + getResponse.status.to_s
180
- p 'Code: ' + getResponse.code.to_s
181
- p 'Message: ' + getResponse.message.to_s
182
- p 'MoreResults: ' + getResponse.more?.to_s
183
- p 'RequestID: ' + getResponse.request_id.to_s
184
- p 'Results Length: ' + getResponse.results.length.to_s
185
- #p 'Results: ' + getResponse.results.to_s
186
- raise 'Failure retrieving data extension rows' unless getResponse.success?
187
-
188
- while getResponse.more? do
189
- p '>>> Continue Retrieve lots of rows with more?'
190
- getResponse = row.getMoreResults
191
- p 'Retrieve Status: ' + getResponse.status.to_s
192
- p 'Code: ' + getResponse.code.to_s
193
- p 'Message: ' + getResponse.message.to_s
194
- p 'MoreResults: ' + getResponse.more?.to_s
195
- p 'RequestID: ' + getResponse.request_id.to_s
196
- p 'Results Length: ' + getResponse.results.length.to_s
197
- end
198
- =end
199
-
200
- rescue => e
201
- p "Caught exception: #{e.message}"
202
- p e.backtrace
203
-
204
- de5 = ET_DataExtension.new
205
- de5.authStub = stubObj
206
- de5.props = {"Name" => NameOfDE,"CustomerKey" => NameOfDE}
207
- de5.delete
208
-
209
- end
1
+ require 'marketingcloudsdk'
2
+ require_relative 'sample_helper'
3
+ require 'pry'
4
+
5
+ begin
6
+ stubObj = ET_Client.new auth
7
+
8
+ # Specify a name for the data extension that will be used for testing
9
+ # Note: Name and CustomerKey will be the same value
10
+ # WARNING: Data Extension will be deleted so don't use the name of a
11
+ # production data extension
12
+ NameOfDE = "ThisWillBeDeleted-Testz"
13
+
14
+ # Get all of the DataExtensions in an Account
15
+ p '>>> Get all of the DataExtensions in an Account'
16
+ de = ET_DataExtension.new
17
+ de.authStub = stubObj
18
+ de.props = ["CustomerKey", "Name"]
19
+ getResponse = de.get
20
+ p 'Retrieve Status: ' + getResponse.status.to_s
21
+ p 'Code: ' + getResponse.code.to_s
22
+ p 'Message: ' + getResponse.message.to_s
23
+ p 'MoreResults: ' + getResponse.more?.to_s
24
+ p 'RequestID: ' + getResponse.request_id.to_s
25
+ p 'Results Length: ' + getResponse.results.length.to_s
26
+ #p 'Results: ' + getResponse.results.to_s
27
+ raise 'Failure retrieving data extensions' unless getResponse.success?
28
+
29
+ # Create Data Extension
30
+ p '>>> Create Data Extension'
31
+ de2 = ET_DataExtension.new
32
+ de2.authStub = stubObj
33
+ de2.props = {"Name" => NameOfDE,"CustomerKey" => NameOfDE}
34
+ de2.columns = [{"Name" => "Name", "FieldType" => "Text", "IsPrimaryKey" => "true", "MaxLength" => "100", "IsRequired" => "true"},
35
+ {"Name" => "OtherField", "FieldType" => "Text"}]
36
+ postResponse = de2.post
37
+ p 'Post Status: ' + postResponse.status.to_s
38
+ p 'Code: ' + postResponse.code.to_s
39
+ p 'Message: ' + postResponse.message.to_s
40
+ p 'Results: ' + postResponse.results.inspect
41
+ raise 'Failure creating data extension' unless postResponse.success?
42
+
43
+ # Update DE to add new field
44
+ p '>>> Update DE to add new field'
45
+ de3 = ET_DataExtension.new
46
+ de3.authStub = stubObj
47
+ de3.props = {"Name" => NameOfDE,"CustomerKey" => NameOfDE}
48
+ de3.columns = [{"Name" => "AddedField", "FieldType" => "Text"}]
49
+ patchResponse = de3.patch
50
+ p 'Patch Status: ' + patchResponse.status.to_s
51
+ p 'Code: ' + patchResponse.code.to_s
52
+ p 'Message: ' + patchResponse.message.to_s
53
+ p 'Results: ' + patchResponse.results.inspect
54
+ raise 'Failure updating data extension' unless patchResponse.success?
55
+
56
+ # Retrieve all columns for data extension
57
+ p '>>> Retrieve all columns for data extension '
58
+ myDEColumn = ET_DataExtension::Column.new
59
+ myDEColumn.authStub = stubObj
60
+ myDEColumn.props = ["Name"]
61
+ myDEColumn.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfDE}
62
+ getResponse = myDEColumn.get
63
+ p 'Retrieve Status: ' + getResponse.status.to_s
64
+ p 'Code: ' + getResponse.code.to_s
65
+ p 'Message: ' + getResponse.message.to_s
66
+ p 'MoreResults: ' + getResponse.more?.to_s
67
+ p 'RequestID: ' + getResponse.request_id.to_s
68
+ p 'Results Length: ' + getResponse.results.length.to_s
69
+ p 'Results: ' + getResponse.results.to_s
70
+ raise 'Failure retrieving data extension columns' unless getResponse.success?
71
+ raise 'Failure retrieving correct number of data extension columns' unless getResponse.results.count == 3
72
+
73
+ # Add a row to a data extension (using CustomerKey)
74
+ p '>>> Add a row to a data extension'
75
+ de4 = ET_DataExtension::Row.new
76
+ de4.CustomerKey = NameOfDE;
77
+ de4.authStub = stubObj
78
+ de4.props = {"Name" => "MAC3", "OtherField" => "Text3"}
79
+ postResponse = de4.post
80
+ p 'Post Status: ' + postResponse.status.to_s
81
+ p 'Code: ' + postResponse.code.to_s
82
+ p 'Message: ' + postResponse.message.to_s
83
+ p 'Results: ' + postResponse.results.inspect
84
+ raise 'Failure creating data extension row' unless postResponse.success?
85
+
86
+ # Add a row to a data extension (Using Name)
87
+ p '>>> Add a row to a data extension'
88
+ de4 = ET_DataExtension::Row.new
89
+ de4.authStub = stubObj
90
+ de4.Name = NameOfDE
91
+ de4.props = {"Name" => "MAC4", "OtherField" => "Text3"}
92
+ postResponse = de4.post
93
+ p 'Post Status: ' + postResponse.status.to_s
94
+ p 'Code: ' + postResponse.code.to_s
95
+ p 'Message: ' + postResponse.message.to_s
96
+ p 'Results: ' + postResponse.results.inspect
97
+ raise 'Failure creating data extension row' unless postResponse.success?
98
+
99
+ # Retrieve all rows
100
+ p '>>> Retrieve all rows'
101
+ row = ET_DataExtension::Row.new()
102
+ row.authStub = stubObj
103
+ row.CustomerKey = NameOfDE
104
+ row.props = ["Name","OtherField"]
105
+ getResponse = row.get
106
+ p 'Retrieve Status: ' + getResponse.status.to_s
107
+ p 'Code: ' + getResponse.code.to_s
108
+ p 'Message: ' + getResponse.message.to_s
109
+ p 'MoreResults: ' + getResponse.more?.to_s
110
+ p 'RequestID: ' + getResponse.request_id.to_s
111
+ p 'Results Length: ' + getResponse.results.length.to_s
112
+ p 'Results: ' + getResponse.results.to_s
113
+ raise 'Failure retrieving data extension rows' unless getResponse.success?
114
+ raise 'Failure retrieving correct number of data extension rows' unless getResponse.results.count == 2
115
+
116
+ # Update a row in a data extension
117
+ p '>>> Update a row in a data extension'
118
+ de4 = ET_DataExtension::Row.new
119
+ de4.authStub = stubObj
120
+ de4.CustomerKey = NameOfDE
121
+ de4.props = {"Name" => "MAC3", "OtherField" => "UPDATED!"}
122
+ patchResponse = de4.patch
123
+ p 'Patch Status: ' + patchResponse.status.to_s
124
+ p 'Code: ' + patchResponse.code.to_s
125
+ p 'Message: ' + patchResponse.message.to_s
126
+ p 'Results: ' + patchResponse.results.inspect
127
+ raise 'Failure updating data extension row' unless patchResponse.success?
128
+
129
+ # Retrieve only updated row
130
+ p '>>> Retrieve only updated row'
131
+ row = ET_DataExtension::Row.new()
132
+ row.authStub = stubObj
133
+ row.CustomerKey = NameOfDE
134
+ row.props = ["Name","OtherField"]
135
+ row.filter = {'Property' => 'Name','SimpleOperator' => 'equals','Value' => 'MAC3'}
136
+ getResponse = row.get
137
+ p 'Retrieve Status: ' + getResponse.status.to_s
138
+ p 'Code: ' + getResponse.code.to_s
139
+ p 'Message: ' + getResponse.message.to_s
140
+ p 'MoreResults: ' + getResponse.more?.to_s
141
+ p 'RequestID: ' + getResponse.request_id.to_s
142
+ p 'Results Length: ' + getResponse.results.length.to_s
143
+ p 'Results: ' + getResponse.results.to_s
144
+ raise 'Failure retrieving data extension rows' unless getResponse.success?
145
+
146
+ # Delete a row from a data extension
147
+ p '>>> Delete a row from a data extension'
148
+ de4 = ET_DataExtension::Row.new
149
+ de4.authStub = stubObj
150
+ de4.CustomerKey = NameOfDE
151
+ de4.props = {"Name" => "MAC3"}
152
+ deleteResponse = de4.delete
153
+ p 'Delete Status: ' + deleteResponse.status.to_s
154
+ p 'Code: ' + deleteResponse.code.to_s
155
+ p 'Message: ' + deleteResponse.message.to_s
156
+ p 'Results: ' + deleteResponse.results.inspect
157
+ raise 'Failure deleting data extension row' unless deleteResponse.success?
158
+
159
+ # Delete a Data Extension
160
+ p '>>> Delete a Data Extension'
161
+ de5 = ET_DataExtension.new
162
+ de5.authStub = stubObj
163
+ de5.props = {"Name" => NameOfDE,"CustomerKey" => NameOfDE}
164
+ delResponse = de5.delete
165
+ p 'Post Status: ' + delResponse.status.to_s
166
+ p 'Code: ' + delResponse.code.to_s
167
+ p 'Message: ' + delResponse.message.to_s
168
+ p 'Results: ' + delResponse.results.inspect
169
+ raise 'Failure deleting data extension' unless deleteResponse.success?
170
+
171
+ =begin
172
+ # Retrieve lots of rows with more?
173
+ p '>>> Retrieve lots of rows with more?'
174
+ row = ET_DataExtension::Row.new()
175
+ row.authStub = stubObj
176
+ row.Name = "zipstolong"
177
+ row.props = ["zip","latitude","longitude"]
178
+ getResponse = row.get
179
+ p 'Retrieve Status: ' + getResponse.status.to_s
180
+ p 'Code: ' + getResponse.code.to_s
181
+ p 'Message: ' + getResponse.message.to_s
182
+ p 'MoreResults: ' + getResponse.more?.to_s
183
+ p 'RequestID: ' + getResponse.request_id.to_s
184
+ p 'Results Length: ' + getResponse.results.length.to_s
185
+ #p 'Results: ' + getResponse.results.to_s
186
+ raise 'Failure retrieving data extension rows' unless getResponse.success?
187
+
188
+ while getResponse.more? do
189
+ p '>>> Continue Retrieve lots of rows with more?'
190
+ getResponse = row.getMoreResults
191
+ p 'Retrieve Status: ' + getResponse.status.to_s
192
+ p 'Code: ' + getResponse.code.to_s
193
+ p 'Message: ' + getResponse.message.to_s
194
+ p 'MoreResults: ' + getResponse.more?.to_s
195
+ p 'RequestID: ' + getResponse.request_id.to_s
196
+ p 'Results Length: ' + getResponse.results.length.to_s
197
+ end
198
+ =end
199
+
200
+ rescue => e
201
+ p "Caught exception: #{e.message}"
202
+ p e.backtrace
203
+
204
+ de5 = ET_DataExtension.new
205
+ de5.authStub = stubObj
206
+ de5.props = {"Name" => NameOfDE,"CustomerKey" => NameOfDE}
207
+ de5.delete
208
+
209
+ end