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,143 +1,143 @@
1
- require 'marketingcloudsdk'
2
- require_relative 'sample_helper'
3
-
4
- begin
5
- stubObj = MarketingCloudSDK::Client.new auth
6
-
7
- # Retrieve All Folder with GetMoreResults
8
- p '>>> Retrieve All Folder with GetMoreResults'
9
- getFolder = MarketingCloudSDK::Folder.new()
10
- getFolder.authStub = stubObj
11
- getFolder.props = ["ID", "Client.ID", "ParentFolder.ID", "ParentFolder.CustomerKey", "ParentFolder.ObjectID", "ParentFolder.Name", "ParentFolder.Description", "ParentFolder.ContentType", "ParentFolder.IsActive", "ParentFolder.IsEditable", "ParentFolder.AllowChildren", "Name", "Description", "ContentType", "IsActive", "IsEditable", "AllowChildren", "CreatedDate", "ModifiedDate", "Client.ModifiedBy", "ObjectID", "CustomerKey", "Client.EnterpriseID", "Client.CreatedBy"]
12
- getResponse = getFolder.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 Folders' unless getResponse.success?
20
-
21
- while getResponse.more? do
22
- p '>>> Continue Retrieve All Folder with GetMoreResults'
23
- getResponse.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
- NameOfTestFolder = "RubySDKFolder"
33
-
34
- # Retrieve Specific Folder for Email Folder ParentID
35
- p '>>> Retrieve Specific Folder for Email Folder ParentID'
36
- getFolder = MarketingCloudSDK::Folder.new()
37
- getFolder.authStub = stubObj
38
- getFolder.props = ["ID"]
39
- getFolder.filter = {'LeftOperand' => {'Property' => 'ParentFolder.ID','SimpleOperator' => 'equals','Value' => '0'}, 'LogicalOperator' => 'AND', 'RightOperand' => {'Property' => 'ContentType','SimpleOperator' => 'equals','Value' => 'EMAIL'}}
40
- getResponse = getFolder.get
41
- p 'Retrieve Status: ' + getResponse.status.to_s
42
- p 'Code: ' + getResponse.code.to_s
43
- p 'Message: ' + getResponse.message.to_s
44
- p 'MoreResults: ' + getResponse.more?.to_s
45
- p 'Results Length: ' + getResponse.results.length.to_s
46
- p 'Results: ' + getResponse.results.to_s
47
- raise 'Failure retrieving Folder' unless getResponse.success?
48
-
49
- if getResponse.success? then
50
- ParentIDForEmail = getResponse.results[0][:id]
51
- p "Parent Folder for Email: #{ParentIDForEmail}"
52
-
53
- # Create Folder
54
- p '>>> Create Folder'
55
- postFolder = MarketingCloudSDK::Folder.new
56
- postFolder.authStub = stubObj
57
- postFolder.props = {"CustomerKey" => NameOfTestFolder, "Name" => NameOfTestFolder, "Description" => NameOfTestFolder, "ContentType"=> "EMAIL", "ParentFolder" => {"ID" => ParentIDForEmail}}
58
- postResponse = postFolder.post
59
- p 'Post Status: ' + postResponse.status.to_s
60
- p 'Code: ' + postResponse.code.to_s
61
- p 'Message: ' + postResponse.message.to_s
62
- p 'Result Count: ' + postResponse.results.length.to_s
63
- p 'Results: ' + postResponse.results.inspect
64
- raise 'Failure creating Folder' unless postResponse.success?
65
-
66
- # Retrieve newly created Folder
67
- p '>>> Retrieve newly created Folder'
68
- getFolder = MarketingCloudSDK::Folder.new()
69
- getFolder.authStub = stubObj
70
- getFolder.props = ["ID", "Client.ID", "ParentFolder.ID", "ParentFolder.CustomerKey", "ParentFolder.ObjectID", "ParentFolder.Name", "ParentFolder.Description", "ParentFolder.ContentType", "ParentFolder.IsActive", "ParentFolder.IsEditable", "ParentFolder.AllowChildren", "Name", "Description", "ContentType", "IsActive", "IsEditable", "AllowChildren", "CreatedDate", "ModifiedDate", "Client.ModifiedBy", "ObjectID", "CustomerKey", "Client.EnterpriseID", "Client.CreatedBy"]
71
- getFolder.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestFolder}
72
- getResponse = getFolder.get
73
- p 'Retrieve Status: ' + getResponse.status.to_s
74
- p 'Code: ' + getResponse.code.to_s
75
- p 'Message: ' + getResponse.message.to_s
76
- p 'MoreResults: ' + getResponse.more?.to_s
77
- p 'Results Length: ' + getResponse.results.length.to_s
78
- p 'Results: ' + getResponse.results.to_s
79
- raise 'Failure retrieving Folder' unless getResponse.success?
80
- raise 'Failure verifying created Folder' if getResponse.results.empty?
81
-
82
- # Update Folder
83
- p '>>> Update Folder'
84
- patchFolder = MarketingCloudSDK::Folder.new
85
- patchFolder.authStub = stubObj
86
- patchFolder.props = {"CustomerKey" => NameOfTestFolder, "Description" => "New Description"}
87
- patchResponse = patchFolder.patch
88
- p 'Patch Status: ' + patchResponse.status.to_s
89
- p 'Code: ' + patchResponse.code.to_s
90
- p 'Message: ' + patchResponse.message.to_s
91
- p 'Result Count: ' + patchResponse.results.length.to_s
92
- p 'Results: ' + patchResponse.results.inspect
93
- raise 'Failure updating Folder' unless patchResponse.success?
94
-
95
- # Retrieve updated Folder
96
- p '>>> Retrieve updated Folder'
97
- getFolder = MarketingCloudSDK::Folder.new()
98
- getFolder.authStub = stubObj
99
- getFolder.props = ["ID", "Client.ID", "ParentFolder.ID", "ParentFolder.CustomerKey", "ParentFolder.ObjectID", "ParentFolder.Name", "ParentFolder.Description", "ParentFolder.ContentType", "ParentFolder.IsActive", "ParentFolder.IsEditable", "ParentFolder.AllowChildren", "Name", "Description", "ContentType", "IsActive", "IsEditable", "AllowChildren", "CreatedDate", "ModifiedDate", "Client.ModifiedBy", "ObjectID", "CustomerKey", "Client.EnterpriseID", "Client.CreatedBy"]
100
- getFolder.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestFolder}
101
- getResponse = getFolder.get
102
- p 'Retrieve Status: ' + getResponse.status.to_s
103
- p 'Code: ' + getResponse.code.to_s
104
- p 'Message: ' + getResponse.message.to_s
105
- p 'MoreResults: ' + getResponse.more?.to_s
106
- p 'Results Length: ' + getResponse.results.length.to_s
107
- p 'Results: ' + getResponse.results.to_s
108
- raise 'Failure retrieving Folder' unless getResponse.success?
109
-
110
- # Delete Folder
111
- p '>>> Delete Folder'
112
- deleteFolder = MarketingCloudSDK::Folder.new
113
- deleteFolder.authStub = stubObj
114
- deleteFolder.props = {"CustomerKey" => NameOfTestFolder, "Name"=>NameOfTestFolder, "Content"=> "<b>Some HTML Content Goes here. NOW WITH NEW CONTENT</b>"}
115
- deleteResponse = deleteFolder.delete
116
- p 'Delete Status: ' + deleteResponse.status.to_s
117
- p 'Code: ' + deleteResponse.code.to_s
118
- p 'Message: ' + deleteResponse.message.to_s
119
- p 'Result Count: ' + deleteResponse.results.length.to_s
120
- p 'Results: ' + deleteResponse.results.inspect
121
- raise 'Failure deleting Folder' unless deleteResponse.success?
122
-
123
- # Retrieve Folder to confirm deletion
124
- p '>>> Retrieve Folder to confirm deletion'
125
- getFolder = MarketingCloudSDK::Folder.new()
126
- getFolder.authStub = stubObj
127
- getFolder.props = ["ID"]
128
- getFolder.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestFolder}
129
- getResponse = getFolder.get
130
- p 'Retrieve Status: ' + getResponse.status.to_s
131
- p 'Code: ' + getResponse.code.to_s
132
- p 'Message: ' + getResponse.message.to_s
133
- p 'MoreResults: ' + getResponse.more?.to_s
134
- p 'Results Length: ' + getResponse.results.length.to_s
135
- p 'Results: ' + getResponse.results.to_s
136
- raise 'Failure verifying deleted Folder' unless getResponse.success?
137
- raise 'Failure verifying deleted Folder' unless getResponse.results.empty?
138
- end
139
- rescue => e
140
- p "Caught exception: #{e.message}"
141
- p e.backtrace
142
- end
143
-
1
+ require 'marketingcloudsdk'
2
+ require_relative 'sample_helper'
3
+
4
+ begin
5
+ stubObj = MarketingCloudSDK::Client.new auth
6
+
7
+ # Retrieve All Folder with GetMoreResults
8
+ p '>>> Retrieve All Folder with GetMoreResults'
9
+ getFolder = MarketingCloudSDK::Folder.new()
10
+ getFolder.authStub = stubObj
11
+ getFolder.props = ["ID", "Client.ID", "ParentFolder.ID", "ParentFolder.CustomerKey", "ParentFolder.ObjectID", "ParentFolder.Name", "ParentFolder.Description", "ParentFolder.ContentType", "ParentFolder.IsActive", "ParentFolder.IsEditable", "ParentFolder.AllowChildren", "Name", "Description", "ContentType", "IsActive", "IsEditable", "AllowChildren", "CreatedDate", "ModifiedDate", "Client.ModifiedBy", "ObjectID", "CustomerKey", "Client.EnterpriseID", "Client.CreatedBy"]
12
+ getResponse = getFolder.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 Folders' unless getResponse.success?
20
+
21
+ while getResponse.more? do
22
+ p '>>> Continue Retrieve All Folder with GetMoreResults'
23
+ getResponse.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
+ NameOfTestFolder = "RubySDKFolder"
33
+
34
+ # Retrieve Specific Folder for Email Folder ParentID
35
+ p '>>> Retrieve Specific Folder for Email Folder ParentID'
36
+ getFolder = MarketingCloudSDK::Folder.new()
37
+ getFolder.authStub = stubObj
38
+ getFolder.props = ["ID"]
39
+ getFolder.filter = {'LeftOperand' => {'Property' => 'ParentFolder.ID','SimpleOperator' => 'equals','Value' => '0'}, 'LogicalOperator' => 'AND', 'RightOperand' => {'Property' => 'ContentType','SimpleOperator' => 'equals','Value' => 'EMAIL'}}
40
+ getResponse = getFolder.get
41
+ p 'Retrieve Status: ' + getResponse.status.to_s
42
+ p 'Code: ' + getResponse.code.to_s
43
+ p 'Message: ' + getResponse.message.to_s
44
+ p 'MoreResults: ' + getResponse.more?.to_s
45
+ p 'Results Length: ' + getResponse.results.length.to_s
46
+ p 'Results: ' + getResponse.results.to_s
47
+ raise 'Failure retrieving Folder' unless getResponse.success?
48
+
49
+ if getResponse.success? then
50
+ ParentIDForEmail = getResponse.results[0][:id]
51
+ p "Parent Folder for Email: #{ParentIDForEmail}"
52
+
53
+ # Create Folder
54
+ p '>>> Create Folder'
55
+ postFolder = MarketingCloudSDK::Folder.new
56
+ postFolder.authStub = stubObj
57
+ postFolder.props = {"CustomerKey" => NameOfTestFolder, "Name" => NameOfTestFolder, "Description" => NameOfTestFolder, "ContentType"=> "EMAIL", "ParentFolder" => {"ID" => ParentIDForEmail}}
58
+ postResponse = postFolder.post
59
+ p 'Post Status: ' + postResponse.status.to_s
60
+ p 'Code: ' + postResponse.code.to_s
61
+ p 'Message: ' + postResponse.message.to_s
62
+ p 'Result Count: ' + postResponse.results.length.to_s
63
+ p 'Results: ' + postResponse.results.inspect
64
+ raise 'Failure creating Folder' unless postResponse.success?
65
+
66
+ # Retrieve newly created Folder
67
+ p '>>> Retrieve newly created Folder'
68
+ getFolder = MarketingCloudSDK::Folder.new()
69
+ getFolder.authStub = stubObj
70
+ getFolder.props = ["ID", "Client.ID", "ParentFolder.ID", "ParentFolder.CustomerKey", "ParentFolder.ObjectID", "ParentFolder.Name", "ParentFolder.Description", "ParentFolder.ContentType", "ParentFolder.IsActive", "ParentFolder.IsEditable", "ParentFolder.AllowChildren", "Name", "Description", "ContentType", "IsActive", "IsEditable", "AllowChildren", "CreatedDate", "ModifiedDate", "Client.ModifiedBy", "ObjectID", "CustomerKey", "Client.EnterpriseID", "Client.CreatedBy"]
71
+ getFolder.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestFolder}
72
+ getResponse = getFolder.get
73
+ p 'Retrieve Status: ' + getResponse.status.to_s
74
+ p 'Code: ' + getResponse.code.to_s
75
+ p 'Message: ' + getResponse.message.to_s
76
+ p 'MoreResults: ' + getResponse.more?.to_s
77
+ p 'Results Length: ' + getResponse.results.length.to_s
78
+ p 'Results: ' + getResponse.results.to_s
79
+ raise 'Failure retrieving Folder' unless getResponse.success?
80
+ raise 'Failure verifying created Folder' if getResponse.results.empty?
81
+
82
+ # Update Folder
83
+ p '>>> Update Folder'
84
+ patchFolder = MarketingCloudSDK::Folder.new
85
+ patchFolder.authStub = stubObj
86
+ patchFolder.props = {"CustomerKey" => NameOfTestFolder, "Description" => "New Description"}
87
+ patchResponse = patchFolder.patch
88
+ p 'Patch Status: ' + patchResponse.status.to_s
89
+ p 'Code: ' + patchResponse.code.to_s
90
+ p 'Message: ' + patchResponse.message.to_s
91
+ p 'Result Count: ' + patchResponse.results.length.to_s
92
+ p 'Results: ' + patchResponse.results.inspect
93
+ raise 'Failure updating Folder' unless patchResponse.success?
94
+
95
+ # Retrieve updated Folder
96
+ p '>>> Retrieve updated Folder'
97
+ getFolder = MarketingCloudSDK::Folder.new()
98
+ getFolder.authStub = stubObj
99
+ getFolder.props = ["ID", "Client.ID", "ParentFolder.ID", "ParentFolder.CustomerKey", "ParentFolder.ObjectID", "ParentFolder.Name", "ParentFolder.Description", "ParentFolder.ContentType", "ParentFolder.IsActive", "ParentFolder.IsEditable", "ParentFolder.AllowChildren", "Name", "Description", "ContentType", "IsActive", "IsEditable", "AllowChildren", "CreatedDate", "ModifiedDate", "Client.ModifiedBy", "ObjectID", "CustomerKey", "Client.EnterpriseID", "Client.CreatedBy"]
100
+ getFolder.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestFolder}
101
+ getResponse = getFolder.get
102
+ p 'Retrieve Status: ' + getResponse.status.to_s
103
+ p 'Code: ' + getResponse.code.to_s
104
+ p 'Message: ' + getResponse.message.to_s
105
+ p 'MoreResults: ' + getResponse.more?.to_s
106
+ p 'Results Length: ' + getResponse.results.length.to_s
107
+ p 'Results: ' + getResponse.results.to_s
108
+ raise 'Failure retrieving Folder' unless getResponse.success?
109
+
110
+ # Delete Folder
111
+ p '>>> Delete Folder'
112
+ deleteFolder = MarketingCloudSDK::Folder.new
113
+ deleteFolder.authStub = stubObj
114
+ deleteFolder.props = {"CustomerKey" => NameOfTestFolder, "Name"=>NameOfTestFolder, "Content"=> "<b>Some HTML Content Goes here. NOW WITH NEW CONTENT</b>"}
115
+ deleteResponse = deleteFolder.delete
116
+ p 'Delete Status: ' + deleteResponse.status.to_s
117
+ p 'Code: ' + deleteResponse.code.to_s
118
+ p 'Message: ' + deleteResponse.message.to_s
119
+ p 'Result Count: ' + deleteResponse.results.length.to_s
120
+ p 'Results: ' + deleteResponse.results.inspect
121
+ raise 'Failure deleting Folder' unless deleteResponse.success?
122
+
123
+ # Retrieve Folder to confirm deletion
124
+ p '>>> Retrieve Folder to confirm deletion'
125
+ getFolder = MarketingCloudSDK::Folder.new()
126
+ getFolder.authStub = stubObj
127
+ getFolder.props = ["ID"]
128
+ getFolder.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestFolder}
129
+ getResponse = getFolder.get
130
+ p 'Retrieve Status: ' + getResponse.status.to_s
131
+ p 'Code: ' + getResponse.code.to_s
132
+ p 'Message: ' + getResponse.message.to_s
133
+ p 'MoreResults: ' + getResponse.more?.to_s
134
+ p 'Results Length: ' + getResponse.results.length.to_s
135
+ p 'Results: ' + getResponse.results.to_s
136
+ raise 'Failure verifying deleted Folder' unless getResponse.success?
137
+ raise 'Failure verifying deleted Folder' unless getResponse.results.empty?
138
+ end
139
+ rescue => e
140
+ p "Caught exception: #{e.message}"
141
+ p e.backtrace
142
+ end
143
+
@@ -1,103 +1,103 @@
1
- require 'marketingcloudsdk'
2
- require_relative 'sample_helper'
3
-
4
- begin
5
- stubObj = MarketingCloudSDK::Client.new auth
6
-
7
- NewImportName = "RubySDKImport"
8
- SendableDataExtensionCustomerKey = "62476204-bfd3-de11-95ca-001e0bbae8cc"
9
- ListIDForImport = "1956035"
10
-
11
- p '>>> Create Import to DataExtension'
12
- postImport = ET_Import.new
13
- postImport.authStub = stubObj
14
- postImport.props = {"Name"=>NewImportName}
15
- postImport.props["CustomerKey"] = NewImportName
16
- postImport.props["Description"] = "Created with RubySDK"
17
- postImport.props["AllowErrors"] = "true"
18
- postImport.props["DestinationObject"] = {"ObjectID"=>SendableDataExtensionCustomerKey}
19
- postImport.props["FieldMappingType"] = "InferFromColumnHeadings"
20
- postImport.props["FileSpec"] = "RubyExample.csv"
21
- postImport.props["FileType"] = "CSV"
22
- postImport.props["Notification"] = {"ResponseType"=>"email","ResponseAddress"=>"example@example.com"}
23
- postImport.props["RetrieveFileTransferLocation"] = {"CustomerKey"=>"ExactTarget Enhanced FTP"}
24
- postImport.props["UpdateType"] = "Overwrite"
25
- postResponse = postImport.post
26
- p 'Post Status: ' + postResponse.status.to_s
27
- p 'Code: ' + postResponse.code.to_s
28
- p 'Message: ' + postResponse.message.to_s
29
- p 'Result Count: ' + postResponse.results.length.to_s
30
- p 'Results: ' + postResponse.results.inspect
31
-
32
- p '>>> Delete Import'
33
- deleteImport = ET_Import.new()
34
- deleteImport.authStub = stubObj
35
- deleteImport.props = {"CustomerKey" => NewImportName}
36
- deleteResponse = deleteImport.delete
37
- p 'Delete Status: ' + deleteResponse.status.to_s
38
- p 'Code: ' + deleteResponse.code.to_s
39
- p 'Message: ' + deleteResponse.message.to_s
40
- p 'Results Length: ' + deleteResponse.results.length.to_s
41
- p 'Results: ' + deleteResponse.results.to_s
42
-
43
- p '>>> Create Import to List'
44
- postImport = ET_Import.new
45
- postImport.authStub = stubObj
46
- postImport.props = {"Name"=>NewImportName}
47
- postImport.props["CustomerKey"] = NewImportName
48
- postImport.props["Description"] = "Created with RubySDK"
49
- postImport.props["AllowErrors"] = "true"
50
- postImport.props["DestinationObject"] = {"ID"=>ListIDForImport}
51
- postImport.props["FieldMappingType"] = "InferFromColumnHeadings"
52
- postImport.props["FileSpec"] = "RubyExample.csv"
53
- postImport.props["FileType"] = "CSV"
54
- postImport.props["Notification"] = {"ResponseType"=>"email","ResponseAddress"=>"example@example.com"}
55
- postImport.props["RetrieveFileTransferLocation"] = {"CustomerKey"=>"ExactTarget Enhanced FTP"}
56
- postImport.props["UpdateType"] = "AddAndUpdate"
57
- postResponse = postImport.post
58
- p 'Post Status: ' + postResponse.status.to_s
59
- p 'Code: ' + postResponse.code.to_s
60
- p 'Message: ' + postResponse.message.to_s
61
- p 'Result Count: ' + postResponse.results.length.to_s
62
- p 'Results: ' + postResponse.results.inspect
63
-
64
- p '>>> Start Import to List'
65
- startImport = ET_Import.new
66
- startImport.authStub = stubObj
67
- startImport.props = {"CustomerKey"=>NewImportName}
68
- postResponse = startImport.start
69
- p 'Start Status: ' + postResponse.status.to_s
70
- p 'Code: ' + postResponse.code.to_s
71
- p 'Message: ' + postResponse.message.to_s
72
- p 'Result Count: ' + postResponse.results.length.to_s
73
- p 'Results: ' + postResponse.results.inspect
74
-
75
- importStatus = ""
76
- while postResponse.status && importStatus != "Error" && importStatus != "Completed" do
77
- p '>>> Checking status in loop'
78
- # Wait a bit before checking the status to give it time to process
79
- sleep 30
80
- statusResponse = startImport.status
81
- p 'Status Status: ' + statusResponse.status.to_s
82
- p 'Code: ' + statusResponse.code.to_s
83
- p 'Message: ' + statusResponse.message.to_s
84
- p 'Result Count: ' + statusResponse.results.length.to_s
85
- p 'Results: ' + statusResponse.results.inspect
86
- importStatus = statusResponse.results[0][:import_status]
87
- end
88
-
89
- p '>>> Delete Import'
90
- deleteImport = ET_Import.new()
91
- deleteImport.authStub = stubObj
92
- deleteImport.props = {"CustomerKey" => NewImportName}
93
- deleteResponse = deleteImport.delete
94
- p 'Delete Status: ' + deleteResponse.status.to_s
95
- p 'Code: ' + deleteResponse.code.to_s
96
- p 'Message: ' + deleteResponse.message.to_s
97
- p 'Results Length: ' + deleteResponse.results.length.to_s
98
- p 'Results: ' + deleteResponse.results.to_s
99
-
100
- rescue => e
101
- p "Caught exception: #{e.message}"
102
- p e.backtrace
103
- end
1
+ require 'marketingcloudsdk'
2
+ require_relative 'sample_helper'
3
+
4
+ begin
5
+ stubObj = MarketingCloudSDK::Client.new auth
6
+
7
+ NewImportName = "RubySDKImport"
8
+ SendableDataExtensionCustomerKey = "62476204-bfd3-de11-95ca-001e0bbae8cc"
9
+ ListIDForImport = "1956035"
10
+
11
+ p '>>> Create Import to DataExtension'
12
+ postImport = ET_Import.new
13
+ postImport.authStub = stubObj
14
+ postImport.props = {"Name"=>NewImportName}
15
+ postImport.props["CustomerKey"] = NewImportName
16
+ postImport.props["Description"] = "Created with RubySDK"
17
+ postImport.props["AllowErrors"] = "true"
18
+ postImport.props["DestinationObject"] = {"ObjectID"=>SendableDataExtensionCustomerKey}
19
+ postImport.props["FieldMappingType"] = "InferFromColumnHeadings"
20
+ postImport.props["FileSpec"] = "RubyExample.csv"
21
+ postImport.props["FileType"] = "CSV"
22
+ postImport.props["Notification"] = {"ResponseType"=>"email","ResponseAddress"=>"example@example.com"}
23
+ postImport.props["RetrieveFileTransferLocation"] = {"CustomerKey"=>"ExactTarget Enhanced FTP"}
24
+ postImport.props["UpdateType"] = "Overwrite"
25
+ postResponse = postImport.post
26
+ p 'Post Status: ' + postResponse.status.to_s
27
+ p 'Code: ' + postResponse.code.to_s
28
+ p 'Message: ' + postResponse.message.to_s
29
+ p 'Result Count: ' + postResponse.results.length.to_s
30
+ p 'Results: ' + postResponse.results.inspect
31
+
32
+ p '>>> Delete Import'
33
+ deleteImport = ET_Import.new()
34
+ deleteImport.authStub = stubObj
35
+ deleteImport.props = {"CustomerKey" => NewImportName}
36
+ deleteResponse = deleteImport.delete
37
+ p 'Delete Status: ' + deleteResponse.status.to_s
38
+ p 'Code: ' + deleteResponse.code.to_s
39
+ p 'Message: ' + deleteResponse.message.to_s
40
+ p 'Results Length: ' + deleteResponse.results.length.to_s
41
+ p 'Results: ' + deleteResponse.results.to_s
42
+
43
+ p '>>> Create Import to List'
44
+ postImport = ET_Import.new
45
+ postImport.authStub = stubObj
46
+ postImport.props = {"Name"=>NewImportName}
47
+ postImport.props["CustomerKey"] = NewImportName
48
+ postImport.props["Description"] = "Created with RubySDK"
49
+ postImport.props["AllowErrors"] = "true"
50
+ postImport.props["DestinationObject"] = {"ID"=>ListIDForImport}
51
+ postImport.props["FieldMappingType"] = "InferFromColumnHeadings"
52
+ postImport.props["FileSpec"] = "RubyExample.csv"
53
+ postImport.props["FileType"] = "CSV"
54
+ postImport.props["Notification"] = {"ResponseType"=>"email","ResponseAddress"=>"example@example.com"}
55
+ postImport.props["RetrieveFileTransferLocation"] = {"CustomerKey"=>"ExactTarget Enhanced FTP"}
56
+ postImport.props["UpdateType"] = "AddAndUpdate"
57
+ postResponse = postImport.post
58
+ p 'Post Status: ' + postResponse.status.to_s
59
+ p 'Code: ' + postResponse.code.to_s
60
+ p 'Message: ' + postResponse.message.to_s
61
+ p 'Result Count: ' + postResponse.results.length.to_s
62
+ p 'Results: ' + postResponse.results.inspect
63
+
64
+ p '>>> Start Import to List'
65
+ startImport = ET_Import.new
66
+ startImport.authStub = stubObj
67
+ startImport.props = {"CustomerKey"=>NewImportName}
68
+ postResponse = startImport.start
69
+ p 'Start Status: ' + postResponse.status.to_s
70
+ p 'Code: ' + postResponse.code.to_s
71
+ p 'Message: ' + postResponse.message.to_s
72
+ p 'Result Count: ' + postResponse.results.length.to_s
73
+ p 'Results: ' + postResponse.results.inspect
74
+
75
+ importStatus = ""
76
+ while postResponse.status && importStatus != "Error" && importStatus != "Completed" do
77
+ p '>>> Checking status in loop'
78
+ # Wait a bit before checking the status to give it time to process
79
+ sleep 30
80
+ statusResponse = startImport.status
81
+ p 'Status Status: ' + statusResponse.status.to_s
82
+ p 'Code: ' + statusResponse.code.to_s
83
+ p 'Message: ' + statusResponse.message.to_s
84
+ p 'Result Count: ' + statusResponse.results.length.to_s
85
+ p 'Results: ' + statusResponse.results.inspect
86
+ importStatus = statusResponse.results[0][:import_status]
87
+ end
88
+
89
+ p '>>> Delete Import'
90
+ deleteImport = ET_Import.new()
91
+ deleteImport.authStub = stubObj
92
+ deleteImport.props = {"CustomerKey" => NewImportName}
93
+ deleteResponse = deleteImport.delete
94
+ p 'Delete Status: ' + deleteResponse.status.to_s
95
+ p 'Code: ' + deleteResponse.code.to_s
96
+ p 'Message: ' + deleteResponse.message.to_s
97
+ p 'Results Length: ' + deleteResponse.results.length.to_s
98
+ p 'Results: ' + deleteResponse.results.to_s
99
+
100
+ rescue => e
101
+ p "Caught exception: #{e.message}"
102
+ p e.backtrace
103
+ end