Sha256: 5b613d600bee37474a934bf8fdd73d8befe86958f8c824b1b17a2109ca13ccfa

Contents?: true

Size: 1.96 KB

Versions: 3

Compression:

Stored size: 1.96 KB

Contents

require 'marketingcloudsdk'
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], "Test")
		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

3 entries across 3 versions & 2 rubygems

Version Path
sfmc-fuelsdk-ruby-1.3.0 samples/sample-AddSubscriberToList.rb
sfmc-fuelsdk-ruby-1.2.0 samples/sample-AddSubscriberToList.rb
MyPreciousRuby1-1.1.0 samples/sample-AddSubscriberToList.rb