Sha256: 78873dc72d19d89bc1ea27512b08fd3f1b9e1d876f5a8f9a524301cb5f085519

Contents?: true

Size: 1.89 KB

Versions: 16

Compression:

Stored size: 1.89 KB

Contents

require 'fuelsdk'
require_relative 'sample_helper'

begin
	stubObj = ET_Client.new auth

	NewListName = "RubySDKList"

	## Example using AddSubscriberToList() method
	## Typically this method will be used with a pre-existing list but for testing purposes one is being created.

	# Create List
	p '>>> Create List'
	postList = ET_List.new
	postList.authStub = stubObj
	postList.props = {"ListName" => NewListName, "Description" => "This list was created with the RubySDK", "Type" => "Private" }
	postResponse = postList.post
	p 'Post Status: ' + postResponse.status.to_s
	p 'Code: ' + postResponse.code.to_s
	p 'Message: ' + postResponse.message.to_s
	p 'Result Count: ' + postResponse.results.length.to_s
	p 'Results: ' + postResponse.results.inspect
  raise 'Failure creating list' unless postResponse.success?

	if postResponse.status then

		newListID = postResponse.results[0][:new_id]
		# Adding Subscriber To a List
		p '>>> Add Subscriber To a List'
		AddSubResponse = stubObj.AddSubscriberToList("AddSubTesting@bh.exacttarget.com", [newListID])
		p 'AddSubResponse Status: ' + AddSubResponse.status.to_s
		p 'Code: ' + AddSubResponse.code.to_s
		p 'Message: ' + AddSubResponse.message.to_s
		p 'Result Count: ' + AddSubResponse.results.length.to_s
		p 'Results: ' + AddSubResponse.results.inspect
    raise 'Failure adding user to list' unless AddSubResponse.success?

		# Delete List
		p '>>> Delete List'
		deleteSub = ET_List.new()
		deleteSub.authStub = stubObj
		deleteSub.props = {"ID" => newListID}
		deleteResponse = deleteSub.delete
		p 'Delete Status: ' + deleteResponse.status.to_s
		p 'Code: ' + deleteResponse.code.to_s
		p 'Message: ' + deleteResponse.message.to_s
		p 'Results Length: ' + deleteResponse.results.length.to_s
		p 'Results: ' + deleteResponse.results.to_s
    raise 'Failure deleting list' unless deleteResponse.success?
	end

rescue => e
	p "Caught exception: #{e.message}"
	p e.backtrace
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
fuelsdk-0.1.11 samples/sample-AddSubscriberToList.rb
fuelsdk-0.1.9 samples/sample-AddSubscriberToList.rb
fuelsdk-0.1.8 samples/sample-AddSubscriberToList.rb
fuelsdk-0.1.7 samples/sample-AddSubscriberToList.rb
fuelsdk-0.1.6 samples/sample-AddSubscriberToList.rb
fuelsdk-0.1.5 samples/sample-AddSubscriberToList.rb
fuelsdk-0.1.4 samples/sample-AddSubscriberToList.rb
fuelsdk-0.1.3 samples/sample-AddSubscriberToList.rb
fuelsdk-0.1.2 samples/sample-AddSubscriberToList.rb
fuelsdk-0.1.1 samples/sample-AddSubscriberToList.rb
fuelsdk-0.1.0 samples/sample-AddSubscriberToList.rb
fuelsdk-0.0.9 samples/sample-AddSubscriberToList.rb
fuelsdk-0.0.8 samples/sample-AddSubscriberToList.rb
fuelsdk-0.0.7 samples/sample-AddSubscriberToList.rb
fuelsdk-0.0.6 samples/sample-AddSubscriberToList.rb
fuelsdk-0.0.5 samples/sample-AddSubscriberToList.rb