fuelsdk 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -4,7 +4,7 @@ FuelSDK-Ruby
4
4
  ExactTarget Fuel SDK for Ruby
5
5
 
6
6
  ## Overview ##
7
- The Fuel SDK for Ruby provides easy access to ExactTarget's Fuel API Family services, including a collection of REST APIs and a SOAP API. These APIs provide access to ExactTarget functionality via common collection types such as array/hash.
7
+ The Fuel SDK for Ruby provides easy access to ExactTarget's Fuel API Family services, including a collection of REST APIs and a SOAP API. These APIs provide access to ExactTarget functionality via common collection types such as array/hash.
8
8
 
9
9
  ## Requirements ##
10
10
  Ruby Version 1.9.3
@@ -17,7 +17,7 @@ Gems:
17
17
 
18
18
 
19
19
  ## Getting Started ##
20
- After downloading the project, rename the config.yaml.template file to config.yaml.
20
+ After downloading the project, rename the config.yaml.template file to config.yaml.
21
21
 
22
22
  Edit config.yaml so you can input the ClientID and Client Secret values provided when you registered your application. If you are building a HubExchange application for the Interactive Marketing Hub then, you must also provide the Application Signature (appsignature). Only change the value for the defaultwsdl configuration item if instructed by ExactTarget.
23
23
 
@@ -30,7 +30,7 @@ Add a require statement to reference the Fuel SDK's functionality:
30
30
  > require 'fuelsdk'
31
31
 
32
32
  Next, create an instance of the ET_Client class:
33
- > myClient = FuelSDK::ET_Client.new
33
+ > myClient = FuelSDK::ET_Client.new {'client' => { 'id' => CLIENTID, 'secret' => SECRET }}
34
34
 
35
35
  Create an instance of the object type we want to work with:
36
36
  > list = FuelSDK::ET_List.new
@@ -47,71 +47,71 @@ Print out the results for viewing
47
47
  **Example Output:**
48
48
 
49
49
  <pre>
50
- #&lt;ET_Get:0x355bc48
50
+ #&lt;ET_Get:0x355bc48
51
51
  @results=[
52
52
  {
53
53
  :client=>{
54
- :id=>"1000001",
54
+ :id=>"1000001",
55
55
  :partner_client_key=>nil
56
- },
57
- :partner_key=>nil,
58
- :created_date=>#&lt;DateTime: 2009-06-12T14:42:06+00:00 ((2454995j,52926s,100000000n),+0s,2299161j)&gt;,
59
- :modified_date=>#&lt;DateTime: 2011-08-17T14:50:30+00:00 ((2455791j,53430s,697000000n),+0s,2299161j)&gt;,
60
- :id=>"1718921",
61
- :object_id=>"f41c7d1b-8957-de11-92ee-001cc494ae9e",
62
- :customer_key=>"All Subscribers - 578623",
63
- :list_name=>"All Subscribers",
64
- :category=>"578623",
65
- :type=>"Private",
66
- :description=>"Contains all subscribers",
67
- :list_classification=>"ExactTargetList",
56
+ },
57
+ :partner_key=>nil,
58
+ :created_date=>#&lt;DateTime: 2009-06-12T14:42:06+00:00 ((2454995j,52926s,100000000n),+0s,2299161j)&gt;,
59
+ :modified_date=>#&lt;DateTime: 2011-08-17T14:50:30+00:00 ((2455791j,53430s,697000000n),+0s,2299161j)&gt;,
60
+ :id=>"1718921",
61
+ :object_id=>"f41c7d1b-8957-de11-92ee-001cc494ae9e",
62
+ :customer_key=>"All Subscribers - 578623",
63
+ :list_name=>"All Subscribers",
64
+ :category=>"578623",
65
+ :type=>"Private",
66
+ :description=>"Contains all subscribers",
67
+ :list_classification=>"ExactTargetList",
68
68
  :"@xsi:type"=>"List"}
69
- ],
70
- @code=200,
71
- @status=true,
72
- @moreResults=false,
69
+ ],
70
+ @code=200,
71
+ @status=true,
72
+ @moreResults=false,
73
73
  @request_id="41f0f293-954f-4ac7-8e7a-0a5756022218"
74
74
  >
75
75
  </pre>
76
76
 
77
77
  ## ET\_Client Class ##
78
78
 
79
- The ET\_Client class takes care of many of the required steps when accessing ExactTarget's API, including retrieving appropriate access tokens, handling token state for managing refresh, and determining the appropriate endpoints for API requests. In order to leverage the advantages this class provides, use a single instance of this class for an entire session. Do not instantiate a new ET_Client object for each request made.
79
+ The ET\_Client class takes care of many of the required steps when accessing ExactTarget's API, including retrieving appropriate access tokens, handling token state for managing refresh, and determining the appropriate endpoints for API requests. In order to leverage the advantages this class provides, use a single instance of this class for an entire session. Do not instantiate a new ET_Client object for each request made.
80
80
 
81
81
  ## Responses ##
82
82
  All methods on Fuel SDK objects return a generic object that follows the same structure, regardless of the type of call. This object contains a common set of properties used to display details about the request.
83
83
 
84
- - status: Boolean value that indicates if the call was successful
84
+ - success?: Boolean value that indicates if the call was successful
85
85
  - code: HTTP Error Code (will always be 200 for SOAP requests)
86
86
  - message: Text values containing more details in the event of an error
87
- - results: Collection containing the details unique to the method called.
87
+ - results: Collection containing the details unique to the method called.
88
88
 
89
89
  Get Methods also return an addition value to indicate if more information is available (that information can be retrieved using the getMoreResults method):
90
90
 
91
- - moreResults - Boolean value that indicates on Get requests if more data is available.
91
+ - more? - Boolean value that indicates on Get requests if more data is available.
92
92
 
93
93
 
94
94
  ## Samples ##
95
- Find more sample files that illustrate using all of the available functions for ExactTarget objects exposed through the API in the objsamples directory.
95
+ Find more sample files that illustrate using all of the available functions for ExactTarget objects exposed through the API in the samples directory.
96
96
 
97
97
  Sample List:
98
98
 
99
- - [BounceEvent](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/objsamples/sample-bounceevent.rb)
100
- - [Campaign](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/objsamples/sample-campaign.rb)
101
- - [ClickEvent](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/objsamples/sample-clickevent.rb)
102
- - [ContentArea](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/objsamples/sample-contentarea.rb)
103
- - [DataExtension](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/objsamples/sample-dataextension.rb)
104
- - [Email](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/objsamples/sample-email.rb)
105
- - [List](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/objsamples/sample-list.rb)
106
- - [List > Subscriber](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/objsamples/sample-list.subscriber.rb)
107
- - [OpenEvent](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/objsamples/sample-openevent.rb)
108
- - [SentEvent](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/objsamples/sample-sentevent.rb)
109
- - [Subscriber](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/objsamples/sample-subscriber.rb)
110
- - [TriggeredSend](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/objsamples/sample-triggeredsend.rb)
111
- - [UnsubEvent](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/objsamples/sample-unsubevent.rb)
112
-
113
-
114
-
99
+ - [BounceEvent](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/samples/sample-bounceevent.rb)
100
+ - [Campaign](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/samples/sample-campaign.rb)
101
+ - [ClickEvent](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/samples/sample-clickevent.rb)
102
+ - [ContentArea](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/samples/sample-contentarea.rb)
103
+ - [DataExtension](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/samples/sample-dataextension.rb)
104
+ - [Email](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/samples/sample-email.rb)
105
+ - [List](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/samples/sample-list.rb)
106
+ - [List > Subscriber](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/samples/sample-list.subscriber.rb)
107
+ - [OpenEvent](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/samples/sample-openevent.rb)
108
+ - [SentEvent](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/samples/sample-sentevent.rb)
109
+ - [Subscriber](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/samples/sample-subscriber.rb)
110
+ - [TriggeredSend](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/samples/sample-triggeredsend.rb)
111
+ - [UnsubEvent](https://github.com/ExactTarget/FuelSDK-Ruby/blob/master/samples/sample-unsubevent.rb)
112
+
113
+
114
+
115
115
 
116
116
 
117
117
 
@@ -110,6 +110,18 @@ module FuelSDK
110
110
  include ET_SoapGet
111
111
  end
112
112
 
113
+ class ET_TriggeredSend < ET_Base
114
+ attr_accessor :subscribers
115
+ include ET_SoapGet
116
+ include ET_SoapCUD
117
+ def id
118
+ 'TriggeredSendDefinition'
119
+ end
120
+ def send
121
+ client.soap_post 'TriggeredSend', 'TriggeredSendDefinition' => properties, 'Subscribers' => subscribers
122
+ end
123
+ end
124
+
113
125
  class ET_Campaign < ET_Base
114
126
  include ET_RestGet
115
127
  include ET_RestCUD
data/lib/fuelsdk/soap.rb CHANGED
@@ -171,6 +171,7 @@ module FuelSDK
171
171
  end
172
172
  SoapResponse.new rsp, self
173
173
  rescue
174
+ raise if rsp.nil?
174
175
  SoapResponse.new rsp, self
175
176
  end
176
177
  end
@@ -1,3 +1,3 @@
1
1
  module FuelSDK
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,14 +1,15 @@
1
- require '../ET_Client.rb'
1
+ require 'fuelsdk'
2
+ require_relative 'sample_helper'
2
3
 
3
4
  begin
4
- stubObj = ET_Client.new(false, false)
5
+ stubObj = FuelSDK::ET_Client.new auth
5
6
 
6
7
  ## Modify the date below to reduce the number of results returned from the request
7
8
  ## Setting this too far in the past could result in a very large response size
8
9
  retrieveDate = '2011-01-15T13:00:00.000'
9
10
 
10
11
  p '>>> Retrieve Filtered BounceEvents with GetMoreResults'
11
- getBounceEvent = ET_BounceEvent.new()
12
+ getBounceEvent = FuelSDK::ET_BounceEvent.new()
12
13
  getBounceEvent.authStub = stubObj
13
14
  getBounceEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
14
15
  getBounceEvent.filter = {'Property' => 'EventDate','SimpleOperator' => 'greaterThan','DateValue' => retrieveDate}
@@ -16,19 +17,20 @@ begin
16
17
  p 'Retrieve Status: ' + getResponse.status.to_s
17
18
  p 'Code: ' + getResponse.code.to_s
18
19
  p 'Message: ' + getResponse.message.to_s
19
- p 'MoreResults: ' + getResponse.moreResults.to_s
20
+ p 'MoreResults: ' + getResponse.more?.to_s
20
21
  p 'RequestID: ' + getResponse.request_id.to_s
21
22
  p 'Results Length: ' + getResponse.results.length.to_s
22
23
  # Since this could potentially return a large number of results, we do not want to print the results
23
24
  p 'Results: ' + getResponse.results.to_s
25
+ raise 'Failure retrieving bounce events' unless getResponse.success?
24
26
 
25
- while getResponse.moreResults do
27
+ while getResponse.more? do
26
28
  p '>>> Continue Retrieve Filtered BounceEvents with GetMoreResults'
27
- getResponse = getBounceEvent.getMoreResults
29
+ getResponse = getBounceEvent.continue
28
30
  p 'Retrieve Status: ' + getResponse.status.to_s
29
31
  p 'Code: ' + getResponse.code.to_s
30
32
  p 'Message: ' + getResponse.message.to_s
31
- p 'MoreResults: ' + getResponse.moreResults.to_s
33
+ p 'MoreResults: ' + getResponse.more?.to_s
32
34
  p 'RequestID: ' + getResponse.request_id.to_s
33
35
  p 'Results Length: ' + getResponse.results.length.to_s
34
36
  end
@@ -36,26 +38,26 @@ begin
36
38
  # The following request could potentially bring back large amounts of data if run against a production account
37
39
  =begin
38
40
  p '>>> Retrieve All BounceEvents with GetMoreResults'
39
- getBounceEvent = ET_BounceEvent.new()
41
+ getBounceEvent = FuelSDK::ET_BounceEvent.new()
40
42
  getBounceEvent.authStub = stubObj
41
43
  getBounceEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
42
44
  getResponse = getBounceEvent.get
43
45
  p 'Retrieve Status: ' + getResponse.status.to_s
44
46
  p 'Code: ' + getResponse.code.to_s
45
47
  p 'Message: ' + getResponse.message.to_s
46
- p 'MoreResults: ' + getResponse.moreResults.to_s
48
+ p 'MoreResults: ' + getResponse.more?.to_s
47
49
  p 'RequestID: ' + getResponse.request_id.to_s
48
50
  p 'Results Length: ' + getResponse.results.length.to_s
49
51
  # Since this could potentially return a large number of results, we do not want to print the results
50
52
  #p 'Results: ' + getResponse.results.to_s
51
53
 
52
- while getResponse.moreResults do
54
+ while getResponse.more? do
53
55
  p '>>> Continue Retrieve All BounceEvents with GetMoreResults'
54
- getResponse = getBounceEvent.getMoreResults
56
+ getResponse = getBounceEvent.continue
55
57
  p 'Retrieve Status: ' + getResponse.status.to_s
56
58
  p 'Code: ' + getResponse.code.to_s
57
59
  p 'Message: ' + getResponse.message.to_s
58
- p 'MoreResults: ' + getResponse.moreResults.to_s
60
+ p 'MoreResults: ' + getResponse.more?.to_s
59
61
  p 'RequestID: ' + getResponse.request_id.to_s
60
62
  p 'Results Length: ' + getResponse.results.length.to_s
61
63
  end
@@ -1,6 +1,5 @@
1
1
  require 'fuelsdk'
2
2
  require_relative 'sample_helper'
3
- require 'pry'
4
3
 
5
4
 
6
5
  begin
@@ -1,14 +1,15 @@
1
- require '../ET_Client.rb'
1
+ require 'fuelsdk'
2
+ require_relative 'sample_helper'
2
3
 
3
4
  begin
4
- stubObj = ET_Client.new(false, false)
5
+ stubObj = FuelSDK::ET_Client.new auth
5
6
 
6
7
  ## Modify the date below to reduce the number of results returned from the request
7
8
  ## Setting this too far in the past could result in a very large response size
8
9
  retrieveDate = '2013-01-15T13:00:00.000'
9
10
 
10
11
  p '>>> Retrieve Filtered ClickEvents with GetMoreResults'
11
- getClickEvent = ET_ClickEvent.new()
12
+ getClickEvent = FuelSDK::ET_ClickEvent.new()
12
13
  getClickEvent.authStub = stubObj
13
14
  getClickEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
14
15
  getClickEvent.filter = {'Property' => 'EventDate','SimpleOperator' => 'greaterThan','DateValue' => retrieveDate}
@@ -16,19 +17,21 @@ begin
16
17
  p 'Retrieve Status: ' + getResponse.status.to_s
17
18
  p 'Code: ' + getResponse.code.to_s
18
19
  p 'Message: ' + getResponse.message.to_s
19
- p 'MoreResults: ' + getResponse.moreResults.to_s
20
+ p 'MoreResults: ' + getResponse.more?.to_s
20
21
  p 'RequestID: ' + getResponse.request_id.to_s
21
22
  p 'Results Length: ' + getResponse.results.length.to_s
22
23
  # Since this could potentially return a large number of results, we do not want to print the results
23
24
  #p 'Results: ' + getResponse.results.to_s
25
+ #
26
+ raise 'Failure retrieving click events' unless getResponse.success?
24
27
 
25
- while getResponse.moreResults do
28
+ while getResponse.more? do
26
29
  p '>>> Continue Retrieve Filtered ClickEvents with GetMoreResults'
27
- getResponse = getClickEvent.getMoreResults
30
+ getResponse = getClickEvent.continue
28
31
  p 'Retrieve Status: ' + getResponse.status.to_s
29
32
  p 'Code: ' + getResponse.code.to_s
30
33
  p 'Message: ' + getResponse.message.to_s
31
- p 'MoreResults: ' + getResponse.moreResults.to_s
34
+ p 'MoreResults: ' + getResponse.more?.to_s
32
35
  p 'RequestID: ' + getResponse.request_id.to_s
33
36
  p 'Results Length: ' + getResponse.results.length.to_s
34
37
  end
@@ -36,26 +39,26 @@ begin
36
39
  # The following request could potentially bring back large amounts of data if run against a production account
37
40
  =begin
38
41
  p '>>> Retrieve All ClickEvents with GetMoreResults'
39
- getClickEvent = ET_ClickEvent.new()
42
+ getClickEvent = FuelSDK::ET_ClickEvent.new()
40
43
  getClickEvent.authStub = stubObj
41
44
  getClickEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
42
45
  getResponse = getClickEvent.get
43
46
  p 'Retrieve Status: ' + getResponse.status.to_s
44
47
  p 'Code: ' + getResponse.code.to_s
45
48
  p 'Message: ' + getResponse.message.to_s
46
- p 'MoreResults: ' + getResponse.moreResults.to_s
49
+ p 'MoreResults: ' + getResponse.more?.to_s
47
50
  p 'RequestID: ' + getResponse.request_id.to_s
48
51
  p 'Results Length: ' + getResponse.results.length.to_s
49
52
  # Since this could potentially return a large number of results, we do not want to print the results
50
53
  #p 'Results: ' + getResponse.results.to_s
51
54
 
52
- while getResponse.moreResults do
55
+ while getResponse.more? do
53
56
  p '>>> Continue Retrieve All ClickEvents with GetMoreResults'
54
- getResponse = getClickEvent.getMoreResults
57
+ getResponse = getClickEvent.continue
55
58
  p 'Retrieve Status: ' + getResponse.status.to_s
56
59
  p 'Code: ' + getResponse.code.to_s
57
60
  p 'Message: ' + getResponse.message.to_s
58
- p 'MoreResults: ' + getResponse.moreResults.to_s
61
+ p 'MoreResults: ' + getResponse.more?.to_s
59
62
  p 'RequestID: ' + getResponse.request_id.to_s
60
63
  p 'Results Length: ' + getResponse.results.length.to_s
61
64
  end
@@ -1,28 +1,30 @@
1
- require '../ET_Client.rb'
1
+ require 'fuelsdk'
2
+ require_relative 'sample_helper'
2
3
 
3
4
  begin
4
- stubObj = ET_Client.new(false, false)
5
+ stubObj = FuelSDK::ET_Client.new auth
5
6
 
6
7
  # Retrieve All ContentArea with GetMoreResults
7
8
  p '>>> Retrieve All ContentArea with GetMoreResults'
8
- getContent = ET_ContentArea.new()
9
+ getContent = FuelSDK::ET_ContentArea.new()
9
10
  getContent.authStub = stubObj
10
11
  getContent.props = ["RowObjectID","ObjectID","ID","CustomerKey","Client.ID","ModifiedDate","CreatedDate","CategoryID","Name","Layout","IsDynamicContent","Content","IsSurvey","IsBlank","Key"]
11
12
  getResponse = getContent.get
12
13
  p 'Retrieve Status: ' + getResponse.status.to_s
13
14
  p 'Code: ' + getResponse.code.to_s
14
15
  p 'Message: ' + getResponse.message.to_s
15
- p 'MoreResults: ' + getResponse.moreResults.to_s
16
+ p 'MoreResults: ' + getResponse.more?.to_s
16
17
  p 'Results Length: ' + getResponse.results.length.to_s
17
18
  #p 'Results: ' + getResponse.results.to_s
19
+ raise 'Failure retrieving contentarea' unless getResponse.success?
18
20
 
19
- while getResponse.moreResults do
21
+ while getResponse.more? do
20
22
  p '>>> Continue Retrieve All ContentArea with GetMoreResults'
21
- getResponse = getContent.getMoreResults
23
+ getResponse = getContent.continue
22
24
  p 'Retrieve Status: ' + getResponse.status.to_s
23
25
  p 'Code: ' + getResponse.code.to_s
24
26
  p 'Message: ' + getResponse.message.to_s
25
- p 'MoreResults: ' + getResponse.moreResults.to_s
27
+ p 'MoreResults: ' + getResponse.more?.to_s
26
28
  p 'RequestID: ' + getResponse.request_id.to_s
27
29
  p 'Results Length: ' + getResponse.results.length.to_s
28
30
  end
@@ -31,7 +33,7 @@ begin
31
33
 
32
34
  # Create ContentArea
33
35
  p '>>> Create ContentArea'
34
- postContent = ET_ContentArea.new
36
+ postContent = FuelSDK::ET_ContentArea.new
35
37
  postContent.authStub = stubObj
36
38
  postContent.props = {"CustomerKey" => NameOfTestContentArea, "Name"=>NameOfTestContentArea, "Content"=> "<b>Some HTML Content Goes here</b>"}
37
39
  postResponse = postContent.post
@@ -40,10 +42,11 @@ begin
40
42
  p 'Message: ' + postResponse.message.to_s
41
43
  p 'Result Count: ' + postResponse.results.length.to_s
42
44
  p 'Results: ' + postResponse.results.inspect
45
+ raise 'Failure creating contentarea' unless postResponse.success?
43
46
 
44
47
  # Retrieve newly created ContentArea
45
48
  p '>>> Retrieve newly created ContentArea'
46
- getContent = ET_ContentArea.new()
49
+ getContent = FuelSDK::ET_ContentArea.new()
47
50
  getContent.authStub = stubObj
48
51
  getContent.props = ["RowObjectID","ObjectID","ID","CustomerKey","Client.ID","ModifiedDate","CreatedDate","CategoryID","Name","Layout","IsDynamicContent","Content","IsSurvey","IsBlank","Key"]
49
52
  getContent.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestContentArea}
@@ -51,13 +54,14 @@ begin
51
54
  p 'Retrieve Status: ' + getResponse.status.to_s
52
55
  p 'Code: ' + getResponse.code.to_s
53
56
  p 'Message: ' + getResponse.message.to_s
54
- p 'MoreResults: ' + getResponse.moreResults.to_s
57
+ p 'MoreResults: ' + getResponse.more?.to_s
55
58
  p 'Results Length: ' + getResponse.results.length.to_s
56
59
  p 'Results: ' + getResponse.results.to_s
60
+ raise 'Failure retrieving contentarea' unless getResponse.success?
57
61
 
58
62
  # Update ContentArea
59
63
  p '>>> Update ContentArea'
60
- patchContent = ET_ContentArea.new
64
+ patchContent = FuelSDK::ET_ContentArea.new
61
65
  patchContent.authStub = stubObj
62
66
  patchContent.props = {"CustomerKey" => NameOfTestContentArea, "Name"=>NameOfTestContentArea, "Content"=> "<b>Some HTML Content Goes here. NOW WITH NEW CONTENT</b>"}
63
67
  patchResponse = patchContent.patch
@@ -66,10 +70,11 @@ begin
66
70
  p 'Message: ' + patchResponse.message.to_s
67
71
  p 'Result Count: ' + patchResponse.results.length.to_s
68
72
  p 'Results: ' + patchResponse.results.inspect
73
+ raise 'Failure updating contentarea' unless patchResponse.success?
69
74
 
70
75
  # Retrieve updated ContentArea
71
76
  p '>>> Retrieve updated ContentArea'
72
- getContent = ET_ContentArea.new()
77
+ getContent = FuelSDK::ET_ContentArea.new()
73
78
  getContent.authStub = stubObj
74
79
  getContent.props = ["RowObjectID","ObjectID","ID","CustomerKey","Client.ID","ModifiedDate","CreatedDate","CategoryID","Name","Layout","IsDynamicContent","Content","IsSurvey","IsBlank","Key"]
75
80
  getContent.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestContentArea}
@@ -77,13 +82,14 @@ begin
77
82
  p 'Retrieve Status: ' + getResponse.status.to_s
78
83
  p 'Code: ' + getResponse.code.to_s
79
84
  p 'Message: ' + getResponse.message.to_s
80
- p 'MoreResults: ' + getResponse.moreResults.to_s
85
+ p 'MoreResults: ' + getResponse.more?.to_s
81
86
  p 'Results Length: ' + getResponse.results.length.to_s
82
87
  p 'Results: ' + getResponse.results.to_s
88
+ raise 'Failure retrieving contentarea' unless getResponse.success?
83
89
 
84
90
  # Delete ContentArea
85
91
  p '>>> Delete ContentArea'
86
- deleteContent = ET_ContentArea.new
92
+ deleteContent = FuelSDK::ET_ContentArea.new
87
93
  deleteContent.authStub = stubObj
88
94
  deleteContent.props = {"CustomerKey" => NameOfTestContentArea, "Name"=>NameOfTestContentArea, "Content"=> "<b>Some HTML Content Goes here. NOW WITH NEW CONTENT</b>"}
89
95
  deleteResponse = deleteContent.delete
@@ -92,6 +98,7 @@ begin
92
98
  p 'Message: ' + deleteResponse.message.to_s
93
99
  p 'Result Count: ' + deleteResponse.results.length.to_s
94
100
  p 'Results: ' + deleteResponse.results.inspect
101
+ raise 'Failure deleting contentarea' unless deleteResponse.success?
95
102
 
96
103
  # Retrieve ContentArea to confirm deletion
97
104
  p '>>> Retrieve ContentArea to confirm deletion'
@@ -103,9 +110,10 @@ begin
103
110
  p 'Retrieve Status: ' + getResponse.status.to_s
104
111
  p 'Code: ' + getResponse.code.to_s
105
112
  p 'Message: ' + getResponse.message.to_s
106
- p 'MoreResults: ' + getResponse.moreResults.to_s
113
+ p 'MoreResults: ' + getResponse.more?.to_s
107
114
  p 'Results Length: ' + getResponse.results.length.to_s
108
115
  p 'Results: ' + getResponse.results.to_s
116
+ raise 'Failure retrieving contentarea' unless getResponse.success?
109
117
 
110
118
  rescue => e
111
119
  p "Caught exception: #{e.message}"
@@ -1,28 +1,30 @@
1
- require '../ET_Client.rb'
1
+ require 'fuelsdk'
2
+ require_relative 'sample_helper'
2
3
 
3
4
  begin
4
- stubObj = ET_Client.new(false, false)
5
+ stubObj = FuelSDK::ET_Client.new auth
5
6
 
6
7
  # Retrieve All Email with GetMoreResults
7
8
  p '>>> Retrieve All Email with GetMoreResults'
8
- getHTMLBody = ET_Email.new()
9
+ getHTMLBody = FuelSDK::ET_Email.new()
9
10
  getHTMLBody.authStub = stubObj
10
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"]
11
12
  getResponse = getHTMLBody.get
12
13
  p 'Retrieve Status: ' + getResponse.status.to_s
13
14
  p 'Code: ' + getResponse.code.to_s
14
15
  p 'Message: ' + getResponse.message.to_s
15
- p 'MoreResults: ' + getResponse.moreResults.to_s
16
+ p 'MoreResults: ' + getResponse.more?.to_s
16
17
  p 'Results Length: ' + getResponse.results.length.to_s
17
18
  #p 'Results: ' + getResponse.results.to_s
19
+ raise 'Failure retrieving email' unless getResponse.success?
18
20
 
19
- while getResponse.moreResults do
21
+ while getResponse.more? do
20
22
  p '>>> Continue Retrieve All Email with GetMoreResults'
21
- getResponse = getHTMLBody.getMoreResults
23
+ getResponse = getHTMLBody.continue
22
24
  p 'Retrieve Status: ' + getResponse.status.to_s
23
25
  p 'Code: ' + getResponse.code.to_s
24
26
  p 'Message: ' + getResponse.message.to_s
25
- p 'MoreResults: ' + getResponse.moreResults.to_s
27
+ p 'MoreResults: ' + getResponse.more?.to_s
26
28
  p 'RequestID: ' + getResponse.request_id.to_s
27
29
  p 'Results Length: ' + getResponse.results.length.to_s
28
30
  end
@@ -31,7 +33,7 @@ begin
31
33
 
32
34
  # Create Email
33
35
  p '>>> Create Email'
34
- postHTMLBody = ET_Email.new
36
+ postHTMLBody = FuelSDK::ET_Email.new
35
37
  postHTMLBody.authStub = stubObj
36
38
  postHTMLBody.props = {"CustomerKey" => NameOfTestEmail, "Name"=>NameOfTestEmail, "Subject" => "Created Using the RubySDK", "HTMLBody"=> "<b>Some HTML Goes here</b>"}
37
39
  postResponse = postHTMLBody.post
@@ -40,10 +42,11 @@ begin
40
42
  p 'Message: ' + postResponse.message.to_s
41
43
  p 'Result Count: ' + postResponse.results.length.to_s
42
44
  p 'Results: ' + postResponse.results.inspect
45
+ raise 'Failure creating email' unless postResponse.success?
43
46
 
44
47
  # Retrieve newly created Email
45
48
  p '>>> Retrieve newly created Email'
46
- getHTMLBody = ET_Email.new()
49
+ getHTMLBody = FuelSDK::ET_Email.new()
47
50
  getHTMLBody.authStub = stubObj
48
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"]
49
52
  getHTMLBody.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestEmail}
@@ -51,13 +54,14 @@ begin
51
54
  p 'Retrieve Status: ' + getResponse.status.to_s
52
55
  p 'Code: ' + getResponse.code.to_s
53
56
  p 'Message: ' + getResponse.message.to_s
54
- p 'MoreResults: ' + getResponse.moreResults.to_s
57
+ p 'MoreResults: ' + getResponse.more?.to_s
55
58
  p 'Results Length: ' + getResponse.results.length.to_s
56
59
  p 'Results: ' + getResponse.results.to_s
60
+ raise 'Failure retrieving email' unless getResponse.success?
57
61
 
58
62
  # Update Email
59
63
  p '>>> Update Email'
60
- patchHTMLBody = ET_Email.new
64
+ patchHTMLBody = FuelSDK::ET_Email.new
61
65
  patchHTMLBody.authStub = stubObj
62
66
  patchHTMLBody.props = {"CustomerKey" => NameOfTestEmail, "Name"=>NameOfTestEmail, "HTMLBody"=> "<b>Some HTML HTMLBody Goes here. NOW WITH NEW HTMLBody</b>"}
63
67
  patchResponse = patchHTMLBody.patch
@@ -66,10 +70,11 @@ begin
66
70
  p 'Message: ' + patchResponse.message.to_s
67
71
  p 'Result Count: ' + patchResponse.results.length.to_s
68
72
  p 'Results: ' + patchResponse.results.inspect
73
+ raise 'Failure updating email' unless patchResponse.success?
69
74
 
70
75
  # Retrieve updated Email
71
76
  p '>>> Retrieve updated Email'
72
- getHTMLBody = ET_Email.new()
77
+ getHTMLBody = FuelSDK::ET_Email.new()
73
78
  getHTMLBody.authStub = stubObj
74
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"]
75
80
  getHTMLBody.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestEmail}
@@ -77,13 +82,14 @@ begin
77
82
  p 'Retrieve Status: ' + getResponse.status.to_s
78
83
  p 'Code: ' + getResponse.code.to_s
79
84
  p 'Message: ' + getResponse.message.to_s
80
- p 'MoreResults: ' + getResponse.moreResults.to_s
85
+ p 'MoreResults: ' + getResponse.more?.to_s
81
86
  p 'Results Length: ' + getResponse.results.length.to_s
82
87
  p 'Results: ' + getResponse.results.to_s
88
+ raise 'Failure retrieving email' unless getResponse.success?
83
89
 
84
90
  # Delete Email
85
91
  p '>>> Delete Email'
86
- deleteHTMLBody = ET_Email.new
92
+ deleteHTMLBody = FuelSDK::ET_Email.new
87
93
  deleteHTMLBody.authStub = stubObj
88
94
  deleteHTMLBody.props = {"CustomerKey" => NameOfTestEmail, "Name"=>NameOfTestEmail, "HTMLBody"=> "<b>Some HTML HTMLBody Goes here. NOW WITH NEW HTMLBody</b>"}
89
95
  deleteResponse = deleteHTMLBody.delete
@@ -92,10 +98,11 @@ begin
92
98
  p 'Message: ' + deleteResponse.message.to_s
93
99
  p 'Result Count: ' + deleteResponse.results.length.to_s
94
100
  p 'Results: ' + deleteResponse.results.inspect
101
+ raise 'Failure deleteing email' unless deleteResponse.success?
95
102
 
96
103
  # Retrieve Email to confirm deletion
97
104
  p '>>> Retrieve Email to confirm deletion'
98
- getHTMLBody = ET_Email.new()
105
+ getHTMLBody = FuelSDK::ET_Email.new()
99
106
  getHTMLBody.authStub = stubObj
100
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"]
101
108
  getHTMLBody.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestEmail}
@@ -103,9 +110,10 @@ begin
103
110
  p 'Retrieve Status: ' + getResponse.status.to_s
104
111
  p 'Code: ' + getResponse.code.to_s
105
112
  p 'Message: ' + getResponse.message.to_s
106
- p 'MoreResults: ' + getResponse.moreResults.to_s
113
+ p 'MoreResults: ' + getResponse.more?.to_s
107
114
  p 'Results Length: ' + getResponse.results.length.to_s
108
115
  p 'Results: ' + getResponse.results.to_s
116
+ raise 'Failure retrieving email' unless getResponse.success?
109
117
 
110
118
  rescue => e
111
119
  p "Caught exception: #{e.message}"
@@ -1,14 +1,15 @@
1
- require '../ET_Client.rb'
1
+ require 'fuelsdk'
2
+ require_relative 'sample_helper'
2
3
 
3
4
  begin
4
- stubObj = ET_Client.new(false, false)
5
+ stubObj = FuelSDK::ET_Client.new auth
5
6
 
6
7
  ## Modify the date below to reduce the number of results returned from the request
7
8
  ## Setting this too far in the past could result in a very large response size
8
9
  retrieveDate = '2013-01-15T13:00:00.000'
9
10
 
10
11
  p '>>> Retrieve Filtered OpenEvents with GetMoreResults'
11
- getOpenEvent = ET_OpenEvent.new()
12
+ getOpenEvent = FuelSDK::ET_OpenEvent.new()
12
13
  getOpenEvent.authStub = stubObj
13
14
  getOpenEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
14
15
  getOpenEvent.filter = {'Property' => 'EventDate','SimpleOperator' => 'greaterThan','DateValue' => retrieveDate}
@@ -16,19 +17,20 @@ begin
16
17
  p 'Retrieve Status: ' + getResponse.status.to_s
17
18
  p 'Code: ' + getResponse.code.to_s
18
19
  p 'Message: ' + getResponse.message.to_s
19
- p 'MoreResults: ' + getResponse.moreResults.to_s
20
+ p 'MoreResults: ' + getResponse.more?.to_s
20
21
  p 'RequestID: ' + getResponse.request_id.to_s
21
22
  p 'Results Length: ' + getResponse.results.length.to_s
22
23
  # Since this could potentially return a large number of results, we do not want to print the results
23
24
  #p 'Results: ' + getResponse.results.to_s
25
+ raise 'Failure retrieving open events' unless getResponse.success?
24
26
 
25
- while getResponse.moreResults do
27
+ while getResponse.more? do
26
28
  p '>>> Continue Retrieve Filtered OpenEvents with GetMoreResults'
27
- getResponse = getOpenEvent.getMoreResults
29
+ getResponse = getOpenEvent.contine
28
30
  p 'Retrieve Status: ' + getResponse.status.to_s
29
31
  p 'Code: ' + getResponse.code.to_s
30
32
  p 'Message: ' + getResponse.message.to_s
31
- p 'MoreResults: ' + getResponse.moreResults.to_s
33
+ p 'MoreResults: ' + getResponse.more?.to_s
32
34
  p 'RequestID: ' + getResponse.request_id.to_s
33
35
  p 'Results Length: ' + getResponse.results.length.to_s
34
36
  end
@@ -36,26 +38,26 @@ begin
36
38
  # The following request could potentially bring back large amounts of data if run against a production account
37
39
  =begin
38
40
  p '>>> Retrieve All OpenEvents with GetMoreResults'
39
- getOpenEvent = ET_OpenEvent.new()
41
+ getOpenEvent = FuelSDK::ET_OpenEvent.new()
40
42
  getOpenEvent.authStub = stubObj
41
43
  getOpenEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
42
44
  getResponse = getOpenEvent.get
43
45
  p 'Retrieve Status: ' + getResponse.status.to_s
44
46
  p 'Code: ' + getResponse.code.to_s
45
47
  p 'Message: ' + getResponse.message.to_s
46
- p 'MoreResults: ' + getResponse.moreResults.to_s
48
+ p 'MoreResults: ' + getResponse.more?.to_s
47
49
  p 'RequestID: ' + getResponse.request_id.to_s
48
50
  p 'Results Length: ' + getResponse.results.length.to_s
49
51
  # Since this could potentially return a large number of results, we do not want to print the results
50
52
  #p 'Results: ' + getResponse.results.to_s
51
53
 
52
- while getResponse.moreResults do
54
+ while getResponse.more? do
53
55
  p '>>> Continue Retrieve All OpenEvents with GetMoreResults'
54
- getResponse = getOpenEvent.getMoreResults
56
+ getResponse = getOpenEvent.contine
55
57
  p 'Retrieve Status: ' + getResponse.status.to_s
56
58
  p 'Code: ' + getResponse.code.to_s
57
59
  p 'Message: ' + getResponse.message.to_s
58
- p 'MoreResults: ' + getResponse.moreResults.to_s
60
+ p 'MoreResults: ' + getResponse.more?.to_s
59
61
  p 'RequestID: ' + getResponse.request_id.to_s
60
62
  p 'Results Length: ' + getResponse.results.length.to_s
61
63
  end
@@ -1,15 +1,15 @@
1
- require '../ET_Client.rb'
2
- require 'securerandom'
1
+ require 'fuelsdk'
2
+ require_relative 'sample_helper'
3
3
 
4
4
  begin
5
- stubObj = ET_Client.new(false, false)
5
+ stubObj = FuelSDK::ET_Client.new auth
6
6
 
7
7
  ## Modify the date below to reduce the number of results returned from the request
8
8
  ## Setting this too far in the past could result in a very large response size
9
9
  retrieveDate = '2013-01-15T13:00:00.000'
10
10
 
11
11
  p '>>> Retrieve Filtered SentEvents with GetMoreResults'
12
- getSentEvent = ET_SentEvent.new()
12
+ getSentEvent = FuelSDK::ET_SentEvent.new()
13
13
  getSentEvent.authStub = stubObj
14
14
  getSentEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","ListID","PartnerKey","SubscriberID"]
15
15
  getSentEvent.filter = {'Property' => 'EventDate','SimpleOperator' => 'greaterThan','DateValue' => retrieveDate}
@@ -17,19 +17,20 @@ begin
17
17
  p 'Retrieve Status: ' + getResponse.status.to_s
18
18
  p 'Code: ' + getResponse.code.to_s
19
19
  p 'Message: ' + getResponse.message.to_s
20
- p 'MoreResults: ' + getResponse.moreResults.to_s
20
+ p 'MoreResults: ' + getResponse.more?.to_s
21
21
  p 'RequestID: ' + getResponse.request_id.to_s
22
22
  p 'Results Length: ' + getResponse.results.length.to_s
23
23
  # Since this could potentially return a large number of results, we do not want to print the results
24
24
  #p 'Results: ' + getResponse.results.to_s
25
+ raise 'Failure retrieving sent events' unless getResponse.success?
25
26
 
26
- while getResponse.moreResults do
27
+ while getResponse.more? do
27
28
  p '>>> Continue Retrieve Filtered SentEvents with GetMoreResults'
28
- getResponse = getSentEvent.getMoreResults
29
+ getResponse = getSentEvent.continue
29
30
  p 'Retrieve Status: ' + getResponse.status.to_s
30
31
  p 'Code: ' + getResponse.code.to_s
31
32
  p 'Message: ' + getResponse.message.to_s
32
- p 'MoreResults: ' + getResponse.moreResults.to_s
33
+ p 'MoreResults: ' + getResponse.more?.to_s
33
34
  p 'RequestID: ' + getResponse.request_id.to_s
34
35
  p 'Results Length: ' + getResponse.results.length.to_s
35
36
  end
@@ -37,26 +38,26 @@ begin
37
38
  # The following request could potentially bring back large amounts of data if run against a production account
38
39
  =begin
39
40
  p '>>> Retrieve All SentEvents with GetMoreResults'
40
- getSentEvent = ET_SentEvent.new()
41
+ getSentEvent = FuelSDK::ET_SentEvent.new()
41
42
  getSentEvent.authStub = stubObj
42
43
  getSentEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","ListID","PartnerKey","SubscriberID"]
43
44
  getResponse = getSentEvent.get
44
45
  p 'Retrieve Status: ' + getResponse.status.to_s
45
46
  p 'Code: ' + getResponse.code.to_s
46
47
  p 'Message: ' + getResponse.message.to_s
47
- p 'MoreResults: ' + getResponse.moreResults.to_s
48
+ p 'MoreResults: ' + getResponse.more?.to_s
48
49
  p 'RequestID: ' + getResponse.request_id.to_s
49
50
  p 'Results Length: ' + getResponse.results.length.to_s
50
51
  # Since this could potentially return a large number of results, we do not want to print the results
51
52
  #p 'Results: ' + getResponse.results.to_s
52
53
 
53
- while getResponse.moreResults do
54
+ while getResponse.more? do
54
55
  p '>>> Continue Retrieve All SentEvents with GetMoreResults'
55
- getResponse = getSentEvent.getMoreResults
56
+ getResponse = getSentEvent.continue
56
57
  p 'Retrieve Status: ' + getResponse.status.to_s
57
58
  p 'Code: ' + getResponse.code.to_s
58
59
  p 'Message: ' + getResponse.message.to_s
59
- p 'MoreResults: ' + getResponse.moreResults.to_s
60
+ p 'MoreResults: ' + getResponse.more?.to_s
60
61
  p 'RequestID: ' + getResponse.request_id.to_s
61
62
  p 'Results Length: ' + getResponse.results.length.to_s
62
63
  end
@@ -1,30 +1,48 @@
1
- require '../ET_Client.rb'
1
+ require 'fuelsdk'
2
2
  require 'securerandom'
3
+ require_relative 'sample_helper'
3
4
 
4
5
  begin
5
- stubObj = ET_Client.new(false, false)
6
+ stubObj = FuelSDK::ET_Client.new auth
6
7
 
7
8
  # Get all TriggeredSendDefinitions
8
9
  p '>>> Get all TriggeredSendDefinitions'
9
- getTS = ET_TriggeredSend.new
10
+ getTS = FuelSDK::ET_TriggeredSend.new
10
11
  getTS.authStub = stubObj
11
12
  getTS.props = ["CustomerKey", "Name", "TriggeredSendStatus"]
12
13
  getResponse = getTS.get
13
14
  p 'Retrieve Status: ' + getResponse.status.to_s
14
15
  p 'Code: ' + getResponse.code.to_s
15
16
  p 'Message: ' + getResponse.message.to_s
16
- p 'MoreResults: ' + getResponse.moreResults.to_s
17
+ p 'MoreResults: ' + getResponse.more?.to_s
17
18
  p 'Results Count: ' + getResponse.results.length.to_s
18
19
  #p 'Results: ' + getResponse.results.to_s
20
+ raise 'Failure retrieving triggersend' unless getResponse.success?
21
+
22
+ # Generate a unique identifier for the TriggeredSend customer key since they cannot be re-used even after deleted
23
+ TSNameForCreateThenDelete = SecureRandom.uuid
24
+
25
+ # Create a TriggeredSend Definition
26
+ p '>>> Create a TriggeredSend Definition'
27
+ postTrig = FuelSDK::ET_TriggeredSend.new
28
+ postTrig.authStub = stubObj
29
+ postTrig.props = {'CustomerKey' => TSNameForCreateThenDelete,'Name' => TSNameForCreateThenDelete, 'Email' => {"ID"=>"3113962"}, "SendClassification"=> {"CustomerKey"=> "2240"}}
30
+ postResponse = postTrig.post
31
+ p 'Post Status: ' + postResponse.status.to_s
32
+ p 'Code: ' + postResponse.code.to_s
33
+ p 'Message: ' + postResponse.message.to_s
34
+ p 'Result Count: ' + postResponse.results.length.to_s
35
+ p 'Results: ' + postResponse.results.inspect
36
+ raise 'Failure creating triggersend' unless postResponse.success?
19
37
 
20
38
  # Specify the name of a TriggeredSend that was setup for testing
21
39
  # Do not use a production Triggered Send Definition
22
40
 
23
- NameOfTestTS = "TEXTEXT"
41
+ NameOfTestTS = TSNameForCreateThenDelete
24
42
 
25
43
  # Pause a TriggeredSend
26
44
  p '>>> Pause a TriggeredSend'
27
- patchTrig = ET_TriggeredSend.new
45
+ patchTrig = FuelSDK::ET_TriggeredSend.new
28
46
  patchTrig.authStub = stubObj
29
47
  patchTrig.props = {"CustomerKey" => NameOfTestTS, "TriggeredSendStatus" =>"Inactive"}
30
48
  patchResponse = patchTrig.patch
@@ -33,10 +51,11 @@ begin
33
51
  p 'Message: ' + patchResponse.message.to_s
34
52
  p 'Result Count: ' + patchResponse.results.length.to_s
35
53
  p 'Results: ' + patchResponse.results.inspect
54
+ raise 'Failure updating triggersend' unless patchResponse.success?
36
55
 
37
56
  # Retrieve Single TriggeredSend
38
57
  p '>>> Retrieve Single TriggeredSend'
39
- getTS = ET_TriggeredSend.new
58
+ getTS = FuelSDK::ET_TriggeredSend.new
40
59
  getTS.authStub = stubObj
41
60
  getTS.props = ["CustomerKey", "Name", "TriggeredSendStatus"]
42
61
  getTS.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestTS}
@@ -44,13 +63,14 @@ begin
44
63
  p 'Retrieve Status: ' + getResponse.status.to_s
45
64
  p 'Code: ' + getResponse.code.to_s
46
65
  p 'Message: ' + getResponse.message.to_s
47
- p 'MoreResults: ' + getResponse.moreResults.to_s
66
+ p 'MoreResults: ' + getResponse.more?.to_s
48
67
  p 'Results Count: ' + getResponse.results.length.to_s
49
68
  p 'Results: ' + getResponse.results.to_s
69
+ raise 'Failure retrieving triggersend' unless getResponse.success?
50
70
 
51
71
  # Start a TriggeredSend by setting to Active
52
72
  p '>>> Start a TriggeredSend by setting to Active'
53
- patchTrig = ET_TriggeredSend.new
73
+ patchTrig = FuelSDK::ET_TriggeredSend.new
54
74
  patchTrig.authStub = stubObj
55
75
  patchTrig.props = {"CustomerKey" => NameOfTestTS, "TriggeredSendStatus" =>"Active"}
56
76
  patchResponse = patchTrig.patch
@@ -59,10 +79,11 @@ begin
59
79
  p 'Message: ' + patchResponse.message.to_s
60
80
  p 'Result Count: ' + patchResponse.results.length.to_s
61
81
  p 'Results: ' + patchResponse.results.inspect
82
+ raise 'Failure updating triggersend' unless patchResponse.success?
62
83
 
63
84
  # Retrieve Single TriggeredSend After setting back to active
64
85
  p '>>> Retrieve Single TriggeredSend After setting back to active'
65
- getTS = ET_TriggeredSend.new
86
+ getTS = FuelSDK::ET_TriggeredSend.new
66
87
  getTS.authStub = stubObj
67
88
  getTS.props = ["CustomerKey", "Name", "TriggeredSendStatus"]
68
89
  getTS.filter = {'Property' => 'CustomerKey','SimpleOperator' => 'equals','Value' => NameOfTestTS}
@@ -70,14 +91,14 @@ begin
70
91
  p 'Retrieve Status: ' + getResponse.status.to_s
71
92
  p 'Code: ' + getResponse.code.to_s
72
93
  p 'Message: ' + getResponse.message.to_s
73
- p 'MoreResults: ' + getResponse.moreResults.to_s
94
+ p 'MoreResults: ' + getResponse.more?.to_s
74
95
  p 'Results Count: ' + getResponse.results.length.to_s
75
96
  p 'Results: ' + getResponse.results.to_s
76
-
97
+ raise 'Failure retrieving triggersend' unless getResponse.success?
77
98
 
78
99
  # Send an email with TriggeredSend
79
100
  p '>>> Send an email with TriggeredSend'
80
- sendTrig = ET_TriggeredSend.new
101
+ sendTrig = FuelSDK::ET_TriggeredSend.new
81
102
  sendTrig.authStub = stubObj
82
103
  sendTrig.props = {"CustomerKey" => NameOfTestTS}
83
104
  sendTrig.subscribers = [{"EmailAddress"=>"testing@bh.exacttarget.com", "SubscriberKey" => "testing@bh.exacttarget.com"}]
@@ -87,25 +108,12 @@ begin
87
108
  p 'Message: ' + sendResponse.message.to_s
88
109
  p 'Result Count: ' + sendResponse.results.length.to_s
89
110
  p 'Results: ' + sendResponse.results.inspect
111
+ raise 'Failure sending triggersend' unless sendResponse.success?
90
112
 
91
- # Generate a unique identifier for the TriggeredSend customer key since they cannot be re-used even after deleted
92
- TSNameForCreateThenDelete = SecureRandom.uuid
93
-
94
- # Create a TriggeredSend Definition
95
- p '>>> Create a TriggeredSend Definition'
96
- postTrig = ET_TriggeredSend.new
97
- postTrig.authStub = stubObj
98
- postTrig.props = {'CustomerKey' => TSNameForCreateThenDelete,'Name' => TSNameForCreateThenDelete, 'Email' => {"ID"=>"3113962"}, "SendClassification"=> {"CustomerKey"=> "2240"}}
99
- postResponse = postTrig.post
100
- p 'Post Status: ' + postResponse.status.to_s
101
- p 'Code: ' + postResponse.code.to_s
102
- p 'Message: ' + postResponse.message.to_s
103
- p 'Result Count: ' + postResponse.results.length.to_s
104
- p 'Results: ' + postResponse.results.inspect
105
113
 
106
114
  # Delete a TriggeredSend Definition
107
115
  p '>>> Delete a TriggeredSend Definition '
108
- deleteTrig = ET_TriggeredSend.new
116
+ deleteTrig = FuelSDK::ET_TriggeredSend.new
109
117
  deleteTrig.authStub = stubObj
110
118
  deleteTrig.props = {'CustomerKey' => TSNameForCreateThenDelete}
111
119
  deleteResponse = deleteTrig.delete
@@ -114,6 +122,7 @@ begin
114
122
  p 'Message: ' + deleteResponse.message.to_s
115
123
  p 'Result Count: ' + deleteResponse.results.length.to_s
116
124
  p 'Results: ' + deleteResponse.results.inspect
125
+ raise 'Failure deleting triggersend' unless deleteResponse.success?
117
126
 
118
127
  rescue => e
119
128
  p "Caught exception: #{e.message}"
@@ -1,34 +1,38 @@
1
- require '../ET_Client.rb'
1
+ require 'fuelsdk'
2
+ require_relative 'sample_helper'
2
3
 
3
4
  begin
4
- stubObj = ET_Client.new(false, false)
5
+ stubObj = FuelSDK::ET_Client.new auth
5
6
 
6
7
  ## Modify the date below to reduce the number of results returned from the request
7
8
  ## Setting this too far in the past could result in a very large response size
8
9
  retrieveDate = '2013-01-15T13:00:00.000'
9
10
 
10
11
  p '>>> Retrieve Filtered UnsubEvents with GetMoreResults'
11
- getUnsubEvent = ET_UnsubEvent.new()
12
+ getUnsubEvent = FuelSDK::ET_UnsubEvent.new()
12
13
  getUnsubEvent.authStub = stubObj
13
- getUnsubEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
14
- getUnsubEvent.filter = {'Property' => 'EventDate','SimpleOperator' => 'greaterThan','DateValue' => retrieveDate}
14
+ getUnsubEvent.props = ["SendID","SubscriberKey","EventDate",
15
+ "Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
16
+ getUnsubEvent.filter = {'Property' => 'EventDate',
17
+ 'SimpleOperator' => 'greaterThan','DateValue' => retrieveDate}
15
18
  getResponse = getUnsubEvent.get
16
19
  p 'Retrieve Status: ' + getResponse.status.to_s
17
20
  p 'Code: ' + getResponse.code.to_s
18
21
  p 'Message: ' + getResponse.message.to_s
19
- p 'MoreResults: ' + getResponse.moreResults.to_s
22
+ p 'MoreResults: ' + getResponse.more?.to_s
20
23
  p 'RequestID: ' + getResponse.request_id.to_s
21
24
  p 'Results Length: ' + getResponse.results.length.to_s
22
25
  # Since this could potentially return a large number of results, we do not want to print the results
23
26
  #p 'Results: ' + getResponse.results.to_s
27
+ raise 'Failure retrieving unsub events' unless getResponse.success?
24
28
 
25
- while getResponse.moreResults do
29
+ while getResponse.more? do
26
30
  p '>>> Continue Retrieve Filtered UnsubEvents with GetMoreResults'
27
- getResponse = getUnsubEvent.getMoreResults
31
+ getResponse = getUnsubEvent.continue
28
32
  p 'Retrieve Status: ' + getResponse.status.to_s
29
33
  p 'Code: ' + getResponse.code.to_s
30
34
  p 'Message: ' + getResponse.message.to_s
31
- p 'MoreResults: ' + getResponse.moreResults.to_s
35
+ p 'MoreResults: ' + getResponse.more?.to_s
32
36
  p 'RequestID: ' + getResponse.request_id.to_s
33
37
  p 'Results Length: ' + getResponse.results.length.to_s
34
38
  end
@@ -36,26 +40,26 @@ begin
36
40
  # The following request could potentially bring back large amounts of data if run against a production account
37
41
  =begin
38
42
  p '>>> Retrieve All UnsubEvents with GetMoreResults'
39
- getUnsubEvent = ET_UnsubEvent.new()
43
+ getUnsubEvent = FuelSDK::ET_UnsubEvent.new()
40
44
  getUnsubEvent.authStub = stubObj
41
45
  getUnsubEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
42
46
  getResponse = getUnsubEvent.get
43
47
  p 'Retrieve Status: ' + getResponse.status.to_s
44
48
  p 'Code: ' + getResponse.code.to_s
45
49
  p 'Message: ' + getResponse.message.to_s
46
- p 'MoreResults: ' + getResponse.moreResults.to_s
50
+ p 'MoreResults: ' + getResponse.more?.to_s
47
51
  p 'RequestID: ' + getResponse.request_id.to_s
48
52
  p 'Results Length: ' + getResponse.results.length.to_s
49
53
  # Since this could potentially return a large number of results, we do not want to print the results
50
54
  #p 'Results: ' + getResponse.results.to_s
51
55
 
52
- while getResponse.moreResults do
56
+ while getResponse.more? do
53
57
  p '>>> Continue Retrieve All UnsubEvents with GetMoreResults'
54
- getResponse = getUnsubEvent.getMoreResults
58
+ getResponse = getUnsubEvent.continue
55
59
  p 'Retrieve Status: ' + getResponse.status.to_s
56
60
  p 'Code: ' + getResponse.code.to_s
57
61
  p 'Message: ' + getResponse.message.to_s
58
- p 'MoreResults: ' + getResponse.moreResults.to_s
62
+ p 'MoreResults: ' + getResponse.more?.to_s
59
63
  p 'RequestID: ' + getResponse.request_id.to_s
60
64
  p 'Results Length: ' + getResponse.results.length.to_s
61
65
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fuelsdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-06-17 00:00:00.000000000 Z
13
+ date: 2013-06-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler