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,56 +1,56 @@
1
- require 'marketingcloudsdk'
2
- require_relative 'sample_helper'
3
-
4
- begin
5
- stubObj = MarketingCloudSDK::Client.new auth
6
-
7
- NameOfAttribute = 'RubySDKTesting'
8
-
9
- p '>>> Retrieve Profile Attribute'
10
- getProfileAttribute = ET_ProfileAttribute.new
11
- getProfileAttribute.authStub = stubObj
12
- getResponse = getProfileAttribute.get
13
- p 'Get Status: ' + getResponse.status.to_s
14
- p 'Code: ' + getResponse.code.to_s
15
- p 'Message: ' + getResponse.message.to_s
16
- p 'Result Count: ' + getResponse.results.length.to_s
17
- # p 'Results: ' + getResponse.results.inspect
18
- raise 'Failure getting Profile Attribute' unless getResponse.success?
19
-
20
- p '>>> Create ProfileAttribute'
21
- postProfileAttribute = ET_ProfileAttribute.new
22
- postProfileAttribute.authStub = stubObj
23
- postProfileAttribute.props = {"Name" => NameOfAttribute, "PropertyType"=>"string", "Description"=>"New Attribute from the SDK", "IsRequired"=>"false", "IsViewable"=>"false", "IsEditable"=>"true", "IsSendTime"=>"false"}
24
- postResponse = postProfileAttribute.post
25
- p 'Post Status: ' + postResponse.status.to_s
26
- p 'Code: ' + postResponse.code.to_s
27
- p 'Message: ' + postResponse.message.to_s
28
- p 'Result Count: ' + postResponse.results.length.to_s
29
- p 'Results: ' + postResponse.results.inspect
30
-
31
- p '>>> Update ProfileAttribute'
32
- patchProfileAttribute = ET_ProfileAttribute.new
33
- patchProfileAttribute.authStub = stubObj
34
- patchProfileAttribute.props = {"Name" => NameOfAttribute, "PropertyType"=>"string"}
35
- patchResponse = patchProfileAttribute.patch
36
- p 'Patch Status: ' + patchResponse.status.to_s
37
- p 'Code: ' + patchResponse.code.to_s
38
- p 'Message: ' + patchResponse.message.to_s
39
- p 'Result Count: ' + patchResponse.results.length.to_s
40
- p 'Results: ' + patchResponse.results.inspect
41
-
42
- p '>>> Delete ProfileAttribute'
43
- deleteProfileAttribute = ET_ProfileAttribute.new
44
- deleteProfileAttribute.authStub = stubObj
45
- deleteProfileAttribute.props = {"Name" => NameOfAttribute}
46
- deleteResponse = deleteProfileAttribute.delete
47
- p 'Delete Status: ' + deleteResponse.status.to_s
48
- p 'Code: ' + deleteResponse.code.to_s
49
- p 'Message: ' + deleteResponse.message.to_s
50
- p 'Result Count: ' + deleteResponse.results.length.to_s
51
- p 'Results: ' + deleteResponse.results.inspect
52
-
53
- rescue => e
54
- p "Caught exception: #{e.message}"
55
- p e.backtrace
56
- end
1
+ require 'marketingcloudsdk'
2
+ require_relative 'sample_helper'
3
+
4
+ begin
5
+ stubObj = MarketingCloudSDK::Client.new auth
6
+
7
+ NameOfAttribute = 'RubySDKTesting'
8
+
9
+ p '>>> Retrieve Profile Attribute'
10
+ getProfileAttribute = ET_ProfileAttribute.new
11
+ getProfileAttribute.authStub = stubObj
12
+ getResponse = getProfileAttribute.get
13
+ p 'Get Status: ' + getResponse.status.to_s
14
+ p 'Code: ' + getResponse.code.to_s
15
+ p 'Message: ' + getResponse.message.to_s
16
+ p 'Result Count: ' + getResponse.results.length.to_s
17
+ # p 'Results: ' + getResponse.results.inspect
18
+ raise 'Failure getting Profile Attribute' unless getResponse.success?
19
+
20
+ p '>>> Create ProfileAttribute'
21
+ postProfileAttribute = ET_ProfileAttribute.new
22
+ postProfileAttribute.authStub = stubObj
23
+ postProfileAttribute.props = {"Name" => NameOfAttribute, "PropertyType"=>"string", "Description"=>"New Attribute from the SDK", "IsRequired"=>"false", "IsViewable"=>"false", "IsEditable"=>"true", "IsSendTime"=>"false"}
24
+ postResponse = postProfileAttribute.post
25
+ p 'Post Status: ' + postResponse.status.to_s
26
+ p 'Code: ' + postResponse.code.to_s
27
+ p 'Message: ' + postResponse.message.to_s
28
+ p 'Result Count: ' + postResponse.results.length.to_s
29
+ p 'Results: ' + postResponse.results.inspect
30
+
31
+ p '>>> Update ProfileAttribute'
32
+ patchProfileAttribute = ET_ProfileAttribute.new
33
+ patchProfileAttribute.authStub = stubObj
34
+ patchProfileAttribute.props = {"Name" => NameOfAttribute, "PropertyType"=>"string"}
35
+ patchResponse = patchProfileAttribute.patch
36
+ p 'Patch Status: ' + patchResponse.status.to_s
37
+ p 'Code: ' + patchResponse.code.to_s
38
+ p 'Message: ' + patchResponse.message.to_s
39
+ p 'Result Count: ' + patchResponse.results.length.to_s
40
+ p 'Results: ' + patchResponse.results.inspect
41
+
42
+ p '>>> Delete ProfileAttribute'
43
+ deleteProfileAttribute = ET_ProfileAttribute.new
44
+ deleteProfileAttribute.authStub = stubObj
45
+ deleteProfileAttribute.props = {"Name" => NameOfAttribute}
46
+ deleteResponse = deleteProfileAttribute.delete
47
+ p 'Delete Status: ' + deleteResponse.status.to_s
48
+ p 'Code: ' + deleteResponse.code.to_s
49
+ p 'Message: ' + deleteResponse.message.to_s
50
+ p 'Result Count: ' + deleteResponse.results.length.to_s
51
+ p 'Results: ' + deleteResponse.results.inspect
52
+
53
+ rescue => e
54
+ p "Caught exception: #{e.message}"
55
+ p e.backtrace
56
+ end
@@ -1,70 +1,70 @@
1
- require 'marketingcloudsdk'
2
- require_relative 'sample_helper'
3
-
4
- begin
5
- stubObj = MarketingCloudSDK::Client.new auth
6
-
7
- ## Modify the date below to reduce the number of results returned from the request
8
- ## Setting this too far in the past could result in a very large response size
9
- retrieveDate = '2013-01-15T13:00:00.000'
10
-
11
- p '>>> Retrieve Filtered SentEvents with GetMoreResults'
12
- getSentEvent = MarketingCloudSDK::SentEvent.new()
13
- getSentEvent.authStub = stubObj
14
- getSentEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","ListID","PartnerKey","SubscriberID"]
15
- getSentEvent.filter = {'Property' => 'EventDate','SimpleOperator' => 'greaterThan','DateValue' => retrieveDate}
16
- getResponse = getSentEvent.get
17
- p 'Retrieve Status: ' + getResponse.status.to_s
18
- p 'Code: ' + getResponse.code.to_s
19
- p 'Message: ' + getResponse.message.to_s
20
- p 'MoreResults: ' + getResponse.more?.to_s
21
- p 'RequestID: ' + getResponse.request_id.to_s
22
- p 'Results Length: ' + getResponse.results.length.to_s
23
- # Since this could potentially return a large number of results, we do not want to print the results
24
- #p 'Results: ' + getResponse.results.to_s
25
- raise 'Failure retrieving sent events' unless getResponse.success?
26
-
27
- while getResponse.more? do
28
- p '>>> Continue Retrieve Filtered SentEvents with GetMoreResults'
29
- getResponse = getSentEvent.continue
30
- p 'Retrieve Status: ' + getResponse.status.to_s
31
- p 'Code: ' + getResponse.code.to_s
32
- p 'Message: ' + getResponse.message.to_s
33
- p 'MoreResults: ' + getResponse.more?.to_s
34
- p 'RequestID: ' + getResponse.request_id.to_s
35
- p 'Results Length: ' + getResponse.results.length.to_s
36
- end
37
-
38
- # The following request could potentially bring back large amounts of data if run against a production account
39
- =begin
40
- p '>>> Retrieve All SentEvents with GetMoreResults'
41
- getSentEvent = MarketingCloudSDK::SentEvent.new()
42
- getSentEvent.authStub = stubObj
43
- getSentEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","ListID","PartnerKey","SubscriberID"]
44
- getResponse = getSentEvent.get
45
- p 'Retrieve Status: ' + getResponse.status.to_s
46
- p 'Code: ' + getResponse.code.to_s
47
- p 'Message: ' + getResponse.message.to_s
48
- p 'MoreResults: ' + getResponse.more?.to_s
49
- p 'RequestID: ' + getResponse.request_id.to_s
50
- p 'Results Length: ' + getResponse.results.length.to_s
51
- # Since this could potentially return a large number of results, we do not want to print the results
52
- #p 'Results: ' + getResponse.results.to_s
53
-
54
- while getResponse.more? do
55
- p '>>> Continue Retrieve All SentEvents with GetMoreResults'
56
- getResponse = getSentEvent.continue
57
- p 'Retrieve Status: ' + getResponse.status.to_s
58
- p 'Code: ' + getResponse.code.to_s
59
- p 'Message: ' + getResponse.message.to_s
60
- p 'MoreResults: ' + getResponse.more?.to_s
61
- p 'RequestID: ' + getResponse.request_id.to_s
62
- p 'Results Length: ' + getResponse.results.length.to_s
63
- end
64
- =end
65
-
66
- rescue => e
67
- p "Caught exception: #{e.message}"
68
- p e.backtrace
69
- end
70
-
1
+ require 'marketingcloudsdk'
2
+ require_relative 'sample_helper'
3
+
4
+ begin
5
+ stubObj = MarketingCloudSDK::Client.new auth
6
+
7
+ ## Modify the date below to reduce the number of results returned from the request
8
+ ## Setting this too far in the past could result in a very large response size
9
+ retrieveDate = '2013-01-15T13:00:00.000'
10
+
11
+ p '>>> Retrieve Filtered SentEvents with GetMoreResults'
12
+ getSentEvent = MarketingCloudSDK::SentEvent.new()
13
+ getSentEvent.authStub = stubObj
14
+ getSentEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","ListID","PartnerKey","SubscriberID"]
15
+ getSentEvent.filter = {'Property' => 'EventDate','SimpleOperator' => 'greaterThan','DateValue' => retrieveDate}
16
+ getResponse = getSentEvent.get
17
+ p 'Retrieve Status: ' + getResponse.status.to_s
18
+ p 'Code: ' + getResponse.code.to_s
19
+ p 'Message: ' + getResponse.message.to_s
20
+ p 'MoreResults: ' + getResponse.more?.to_s
21
+ p 'RequestID: ' + getResponse.request_id.to_s
22
+ p 'Results Length: ' + getResponse.results.length.to_s
23
+ # Since this could potentially return a large number of results, we do not want to print the results
24
+ #p 'Results: ' + getResponse.results.to_s
25
+ raise 'Failure retrieving sent events' unless getResponse.success?
26
+
27
+ while getResponse.more? do
28
+ p '>>> Continue Retrieve Filtered SentEvents with GetMoreResults'
29
+ getResponse = getSentEvent.continue
30
+ p 'Retrieve Status: ' + getResponse.status.to_s
31
+ p 'Code: ' + getResponse.code.to_s
32
+ p 'Message: ' + getResponse.message.to_s
33
+ p 'MoreResults: ' + getResponse.more?.to_s
34
+ p 'RequestID: ' + getResponse.request_id.to_s
35
+ p 'Results Length: ' + getResponse.results.length.to_s
36
+ end
37
+
38
+ # The following request could potentially bring back large amounts of data if run against a production account
39
+ =begin
40
+ p '>>> Retrieve All SentEvents with GetMoreResults'
41
+ getSentEvent = MarketingCloudSDK::SentEvent.new()
42
+ getSentEvent.authStub = stubObj
43
+ getSentEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","ListID","PartnerKey","SubscriberID"]
44
+ getResponse = getSentEvent.get
45
+ p 'Retrieve Status: ' + getResponse.status.to_s
46
+ p 'Code: ' + getResponse.code.to_s
47
+ p 'Message: ' + getResponse.message.to_s
48
+ p 'MoreResults: ' + getResponse.more?.to_s
49
+ p 'RequestID: ' + getResponse.request_id.to_s
50
+ p 'Results Length: ' + getResponse.results.length.to_s
51
+ # Since this could potentially return a large number of results, we do not want to print the results
52
+ #p 'Results: ' + getResponse.results.to_s
53
+
54
+ while getResponse.more? do
55
+ p '>>> Continue Retrieve All SentEvents with GetMoreResults'
56
+ getResponse = getSentEvent.continue
57
+ p 'Retrieve Status: ' + getResponse.status.to_s
58
+ p 'Code: ' + getResponse.code.to_s
59
+ p 'Message: ' + getResponse.message.to_s
60
+ p 'MoreResults: ' + getResponse.more?.to_s
61
+ p 'RequestID: ' + getResponse.request_id.to_s
62
+ p 'Results Length: ' + getResponse.results.length.to_s
63
+ end
64
+ =end
65
+
66
+ rescue => e
67
+ p "Caught exception: #{e.message}"
68
+ p e.backtrace
69
+ end
70
+
@@ -1,135 +1,135 @@
1
- require 'marketingcloudsdk'
2
- require_relative 'sample_helper' # contains auth with credentials
3
-
4
- begin
5
- stubObj = MarketingCloudSDK::Client.new auth
6
-
7
- # NOTE: These examples only work in accounts where the SubscriberKey functionality is not enabled
8
- # SubscriberKey will need to be included in the props if that feature is enabled
9
-
10
- SubscriberTestEmail = "RubySDKExample@jb.kevy.com"
11
-
12
- # Create Subscriber
13
- p '>>> Create Subscriber'
14
- postSub = MarketingCloudSDK::Subscriber.new
15
- postSub.authStub = stubObj
16
- postSub.props = {"EmailAddress" => SubscriberTestEmail}
17
- p '>>> Posting'
18
- postResponse = postSub.post
19
- p "Post Status: #{postResponse.success? ? 'Success' : 'Failure'}"
20
- p 'Code: ' + postResponse.code.to_s
21
- p 'Message: ' + postResponse.message.to_s
22
- p 'Result Count: ' + postResponse.results.length.to_s
23
- p 'Results: ' + postResponse.results.inspect
24
-
25
- raise 'Failure creating subscriber' unless postResponse.success?
26
-
27
- # Retrieve newly created Subscriber
28
- p '>>> Retrieve newly created Subscriber'
29
- getSub = MarketingCloudSDK::Subscriber.new()
30
- getSub.authStub = stubObj
31
- getSub.props = ["SubscriberKey", "EmailAddress", "Status"]
32
- getSub.filter = {'Property' => 'SubscriberKey', 'SimpleOperator' => 'equals', 'Value' => SubscriberTestEmail}
33
- getResponse = getSub.get
34
- p "Retrieve Status: #{getResponse.success? ? 'Success' : 'Failure'}"
35
- p 'Code: ' + getResponse.code.to_s
36
- p 'Message: ' + getResponse.message.to_s
37
- p 'MoreResults: ' + getResponse.more?.to_s
38
- p 'Results Length: ' + getResponse.results.length.to_s
39
- p 'Results: ' + getResponse.results.to_s
40
-
41
- raise 'Failure retrieving subscriber' unless getResponse.success?
42
-
43
- # Update Subscriber
44
- p '>>> Update Subscriber'
45
- patchSub = MarketingCloudSDK::Subscriber.new
46
- patchSub.authStub = stubObj
47
- patchSub.props = {"EmailAddress" => SubscriberTestEmail, "Status" => "Unsubscribed"}
48
- patchResponse = patchSub.patch
49
- p 'Patch Status: ' + patchResponse.status.to_s
50
- p 'Code: ' + patchResponse.code.to_s
51
- p 'Message: ' + patchResponse.message.to_s
52
- p 'Result Count: ' + patchResponse.results.length.to_s
53
- p 'Results: ' + patchResponse.results.inspect
54
-
55
- raise 'Failure updating subscriber' unless patchResponse.success?
56
-
57
- # Retrieve Subscriber that should have status unsubscribed now
58
- p '>>> Retrieve Subscriber that should have status unsubscribed now'
59
- getSub = MarketingCloudSDK::Subscriber.new()
60
- getSub.authStub = stubObj
61
- getSub.props = ["SubscriberKey", "EmailAddress", "Status"]
62
- getSub.filter = {'Property' => 'SubscriberKey','SimpleOperator' => 'equals','Value' => SubscriberTestEmail};
63
- getResponse = getSub.get
64
- p 'Retrieve Status: ' + getResponse.status.to_s
65
- p 'Code: ' + getResponse.code.to_s
66
- p 'Message: ' + getResponse.message.to_s
67
- p 'MoreResults: ' + getResponse.more?.to_s
68
- p 'Results Length: ' + getResponse.results.length.to_s
69
- p 'Results: ' + getResponse.results.to_s
70
-
71
- raise 'Failure retrieving subscriber' unless getResponse.success?
72
-
73
- # Delete Subscriber
74
- p '>>> Delete Subscriber'
75
- deleteSub = MarketingCloudSDK::Subscriber.new()
76
- deleteSub.authStub = stubObj
77
- deleteSub.props = {"EmailAddress" => SubscriberTestEmail}
78
- deleteResponse = deleteSub.delete
79
- p 'Delete Status: ' + deleteResponse.status.to_s
80
- p 'Code: ' + deleteResponse.code.to_s
81
- p 'Message: ' + deleteResponse.message.to_s
82
- p 'Results Length: ' + deleteResponse.results.length.to_s
83
- p 'Results: ' + deleteResponse.results.to_s
84
-
85
- raise 'Failure deleting subscriber' unless deleteResponse.success?
86
-
87
- # Retrieve Subscriber to confirm deletion
88
- p '>>> Retrieve Subscriber to confirm deletion'
89
- getSub = MarketingCloudSDK::Subscriber.new()
90
- getSub.authStub = stubObj
91
- getSub.props = ["SubscriberKey", "EmailAddress", "Status"]
92
- getSub.filter = {'Property' => 'SubscriberKey','SimpleOperator' => 'equals','Value' => SubscriberTestEmail};
93
- getResponse = getSub.get
94
- p 'Retrieve Status: ' + getResponse.status.to_s
95
- p 'Code: ' + getResponse.code.to_s
96
- p 'Message: ' + getResponse.message.to_s
97
- p 'MoreResults: ' + getResponse.more?.to_s
98
- p 'Results Length: ' + getResponse.results.length.to_s
99
- p 'Results: ' + getResponse.results.to_s
100
-
101
- raise 'Failure retrieving subscriber' unless getResponse.success?
102
-
103
- =begin
104
- # Do not run the "Retrieve All Subscribers" request for testing if you have more than 100,000 records in your account as it will take a long time to complete.
105
-
106
- # Retrieve All Subcribers with GetMoreResults
107
- p '>>> Retrieve All Subcribers with GetMoreResults'
108
- getSub = MarketingCloudSDK::Subscriber.new()
109
- getSub.authStub = stubObj
110
- getSub.props = ["SubscriberKey", "EmailAddress", "Status"]
111
- getResponse = getSub.get
112
- p 'Retrieve Status: ' + getResponse.status.to_s
113
- p 'Code: ' + getResponse.code.to_s
114
- p 'Message: ' + getResponse.message.to_s
115
- p 'MoreResults: ' + getResponse.more?.to_s
116
- p 'RequestID: ' + getResponse.request_id.to_s
117
- p 'Results Length: ' + getResponse.results.length.to_s
118
- #p 'Results: ' + getResponse.results.to_s
119
-
120
- while getResponse.more? do
121
- p '>>> Continue Retrieve All Subcribers with GetMoreResults'
122
- getResponse.continue
123
- p 'Retrieve Status: ' + getResponse.status.to_s
124
- p 'Code: ' + getResponse.code.to_s
125
- p 'Message: ' + getResponse.message.to_s
126
- p 'MoreResults: ' + getResponse.more?.to_s
127
- p 'RequestID: ' + getResponse.request_id.to_s
128
- p 'Results Length: ' + getResponse.results.length.to_s
129
- end
130
- =end
131
-
132
- rescue => e
133
- p "Caught exception: #{e.message}"
134
- p e.backtrace
135
- end
1
+ require 'marketingcloudsdk'
2
+ require_relative 'sample_helper' # contains auth with credentials
3
+
4
+ begin
5
+ stubObj = MarketingCloudSDK::Client.new auth
6
+
7
+ # NOTE: These examples only work in accounts where the SubscriberKey functionality is not enabled
8
+ # SubscriberKey will need to be included in the props if that feature is enabled
9
+
10
+ SubscriberTestEmail = "RubySDKExample@jb.kevy.com"
11
+
12
+ # Create Subscriber
13
+ p '>>> Create Subscriber'
14
+ postSub = MarketingCloudSDK::Subscriber.new
15
+ postSub.authStub = stubObj
16
+ postSub.props = {"EmailAddress" => SubscriberTestEmail}
17
+ p '>>> Posting'
18
+ postResponse = postSub.post
19
+ p "Post Status: #{postResponse.success? ? 'Success' : 'Failure'}"
20
+ p 'Code: ' + postResponse.code.to_s
21
+ p 'Message: ' + postResponse.message.to_s
22
+ p 'Result Count: ' + postResponse.results.length.to_s
23
+ p 'Results: ' + postResponse.results.inspect
24
+
25
+ raise 'Failure creating subscriber' unless postResponse.success?
26
+
27
+ # Retrieve newly created Subscriber
28
+ p '>>> Retrieve newly created Subscriber'
29
+ getSub = MarketingCloudSDK::Subscriber.new()
30
+ getSub.authStub = stubObj
31
+ getSub.props = ["SubscriberKey", "EmailAddress", "Status"]
32
+ getSub.filter = {'Property' => 'SubscriberKey', 'SimpleOperator' => 'equals', 'Value' => SubscriberTestEmail}
33
+ getResponse = getSub.get
34
+ p "Retrieve Status: #{getResponse.success? ? 'Success' : 'Failure'}"
35
+ p 'Code: ' + getResponse.code.to_s
36
+ p 'Message: ' + getResponse.message.to_s
37
+ p 'MoreResults: ' + getResponse.more?.to_s
38
+ p 'Results Length: ' + getResponse.results.length.to_s
39
+ p 'Results: ' + getResponse.results.to_s
40
+
41
+ raise 'Failure retrieving subscriber' unless getResponse.success?
42
+
43
+ # Update Subscriber
44
+ p '>>> Update Subscriber'
45
+ patchSub = MarketingCloudSDK::Subscriber.new
46
+ patchSub.authStub = stubObj
47
+ patchSub.props = {"EmailAddress" => SubscriberTestEmail, "Status" => "Unsubscribed"}
48
+ patchResponse = patchSub.patch
49
+ p 'Patch Status: ' + patchResponse.status.to_s
50
+ p 'Code: ' + patchResponse.code.to_s
51
+ p 'Message: ' + patchResponse.message.to_s
52
+ p 'Result Count: ' + patchResponse.results.length.to_s
53
+ p 'Results: ' + patchResponse.results.inspect
54
+
55
+ raise 'Failure updating subscriber' unless patchResponse.success?
56
+
57
+ # Retrieve Subscriber that should have status unsubscribed now
58
+ p '>>> Retrieve Subscriber that should have status unsubscribed now'
59
+ getSub = MarketingCloudSDK::Subscriber.new()
60
+ getSub.authStub = stubObj
61
+ getSub.props = ["SubscriberKey", "EmailAddress", "Status"]
62
+ getSub.filter = {'Property' => 'SubscriberKey','SimpleOperator' => 'equals','Value' => SubscriberTestEmail};
63
+ getResponse = getSub.get
64
+ p 'Retrieve Status: ' + getResponse.status.to_s
65
+ p 'Code: ' + getResponse.code.to_s
66
+ p 'Message: ' + getResponse.message.to_s
67
+ p 'MoreResults: ' + getResponse.more?.to_s
68
+ p 'Results Length: ' + getResponse.results.length.to_s
69
+ p 'Results: ' + getResponse.results.to_s
70
+
71
+ raise 'Failure retrieving subscriber' unless getResponse.success?
72
+
73
+ # Delete Subscriber
74
+ p '>>> Delete Subscriber'
75
+ deleteSub = MarketingCloudSDK::Subscriber.new()
76
+ deleteSub.authStub = stubObj
77
+ deleteSub.props = {"EmailAddress" => SubscriberTestEmail}
78
+ deleteResponse = deleteSub.delete
79
+ p 'Delete Status: ' + deleteResponse.status.to_s
80
+ p 'Code: ' + deleteResponse.code.to_s
81
+ p 'Message: ' + deleteResponse.message.to_s
82
+ p 'Results Length: ' + deleteResponse.results.length.to_s
83
+ p 'Results: ' + deleteResponse.results.to_s
84
+
85
+ raise 'Failure deleting subscriber' unless deleteResponse.success?
86
+
87
+ # Retrieve Subscriber to confirm deletion
88
+ p '>>> Retrieve Subscriber to confirm deletion'
89
+ getSub = MarketingCloudSDK::Subscriber.new()
90
+ getSub.authStub = stubObj
91
+ getSub.props = ["SubscriberKey", "EmailAddress", "Status"]
92
+ getSub.filter = {'Property' => 'SubscriberKey','SimpleOperator' => 'equals','Value' => SubscriberTestEmail};
93
+ getResponse = getSub.get
94
+ p 'Retrieve Status: ' + getResponse.status.to_s
95
+ p 'Code: ' + getResponse.code.to_s
96
+ p 'Message: ' + getResponse.message.to_s
97
+ p 'MoreResults: ' + getResponse.more?.to_s
98
+ p 'Results Length: ' + getResponse.results.length.to_s
99
+ p 'Results: ' + getResponse.results.to_s
100
+
101
+ raise 'Failure retrieving subscriber' unless getResponse.success?
102
+
103
+ =begin
104
+ # Do not run the "Retrieve All Subscribers" request for testing if you have more than 100,000 records in your account as it will take a long time to complete.
105
+
106
+ # Retrieve All Subcribers with GetMoreResults
107
+ p '>>> Retrieve All Subcribers with GetMoreResults'
108
+ getSub = MarketingCloudSDK::Subscriber.new()
109
+ getSub.authStub = stubObj
110
+ getSub.props = ["SubscriberKey", "EmailAddress", "Status"]
111
+ getResponse = getSub.get
112
+ p 'Retrieve Status: ' + getResponse.status.to_s
113
+ p 'Code: ' + getResponse.code.to_s
114
+ p 'Message: ' + getResponse.message.to_s
115
+ p 'MoreResults: ' + getResponse.more?.to_s
116
+ p 'RequestID: ' + getResponse.request_id.to_s
117
+ p 'Results Length: ' + getResponse.results.length.to_s
118
+ #p 'Results: ' + getResponse.results.to_s
119
+
120
+ while getResponse.more? do
121
+ p '>>> Continue Retrieve All Subcribers with GetMoreResults'
122
+ getResponse.continue
123
+ p 'Retrieve Status: ' + getResponse.status.to_s
124
+ p 'Code: ' + getResponse.code.to_s
125
+ p 'Message: ' + getResponse.message.to_s
126
+ p 'MoreResults: ' + getResponse.more?.to_s
127
+ p 'RequestID: ' + getResponse.request_id.to_s
128
+ p 'Results Length: ' + getResponse.results.length.to_s
129
+ end
130
+ =end
131
+
132
+ rescue => e
133
+ p "Caught exception: #{e.message}"
134
+ p e.backtrace
135
+ end