sfmc-fuelsdk-ruby 1.1.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 +7 -0
  2. data/.gitignore +28 -0
  3. data/Gemfile +3 -0
  4. data/Gemfile.lock +90 -0
  5. data/Guardfile +8 -0
  6. data/LICENSE.md +13 -0
  7. data/README.md +143 -0
  8. data/Rakefile +1 -0
  9. data/lib/marketingcloudsdk/client.rb +296 -0
  10. data/lib/marketingcloudsdk/http_request.rb +118 -0
  11. data/lib/marketingcloudsdk/objects.rb +757 -0
  12. data/lib/marketingcloudsdk/rest.rb +118 -0
  13. data/lib/marketingcloudsdk/soap.rb +282 -0
  14. data/lib/marketingcloudsdk/targeting.rb +99 -0
  15. data/lib/marketingcloudsdk/utils.rb +47 -0
  16. data/lib/marketingcloudsdk/version.rb +39 -0
  17. data/lib/marketingcloudsdk.rb +74 -0
  18. data/lib/new.rb +1240 -0
  19. data/marketingcloudsdk.gemspec +30 -0
  20. data/samples/sample-AddSubscriberToList.rb +56 -0
  21. data/samples/sample-CreateAndStartDataExtensionImport.rb +29 -0
  22. data/samples/sample-CreateAndStartListImport.rb +27 -0
  23. data/samples/sample-CreateContentAreas.rb +48 -0
  24. data/samples/sample-CreateDataExtensions.rb +54 -0
  25. data/samples/sample-CreateProfileAttributes.rb +48 -0
  26. data/samples/sample-SendEmailToDataExtension.rb +23 -0
  27. data/samples/sample-SendEmailToList.rb +23 -0
  28. data/samples/sample-SendTriggeredSends.rb +30 -0
  29. data/samples/sample-bounceevent.rb +70 -0
  30. data/samples/sample-campaign.rb +211 -0
  31. data/samples/sample-clickevent.rb +71 -0
  32. data/samples/sample-contentarea.rb +122 -0
  33. data/samples/sample-dataextension.rb +209 -0
  34. data/samples/sample-directverb.rb +54 -0
  35. data/samples/sample-email.rb +122 -0
  36. data/samples/sample-email.senddefinition.rb +134 -0
  37. data/samples/sample-folder.rb +143 -0
  38. data/samples/sample-import.rb +103 -0
  39. data/samples/sample-list.rb +105 -0
  40. data/samples/sample-list.subscriber.rb +97 -0
  41. data/samples/sample-openevent.rb +70 -0
  42. data/samples/sample-profileattribute.rb +56 -0
  43. data/samples/sample-sentevent.rb +70 -0
  44. data/samples/sample-subscriber.rb +135 -0
  45. data/samples/sample-triggeredsend.rb +129 -0
  46. data/samples/sample-unsubevent.rb +72 -0
  47. data/samples/sample_helper.rb.template +10 -0
  48. data/spec/client_spec.rb +218 -0
  49. data/spec/default_values_fallback_spec.rb +30 -0
  50. data/spec/helper_funcs_spec.rb +11 -0
  51. data/spec/http_request_spec.rb +61 -0
  52. data/spec/objects_helper_spec.rb +32 -0
  53. data/spec/objects_spec.rb +484 -0
  54. data/spec/rest_spec.rb +48 -0
  55. data/spec/soap_spec.rb +140 -0
  56. data/spec/spec_helper.rb +14 -0
  57. data/spec/targeting_spec.rb +44 -0
  58. metadata +262 -0
@@ -0,0 +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
+
@@ -0,0 +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
+
@@ -0,0 +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
@@ -0,0 +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
@@ -0,0 +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
+