samples/sample-campaign.rb in fuelsdk-0.0.3 vs samples/sample-campaign.rb in fuelsdk-0.0.4
- old
+ new
@@ -1,15 +1,15 @@
require 'fuelsdk'
require_relative 'sample_helper'
begin
- stubObj = FuelSDK::ET_Client.new auth
+ stubObj = FuelSDK::Client.new auth
# Create List
p '>>> Create List'
- postList = FuelSDK::ET_List.new
+ postList = FuelSDK::List.new
postList.authStub = stubObj
postList.props = {"ListName" => 'RubyAssetList', "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
@@ -23,11 +23,11 @@
ExampleAssetType = "LIST"
ExampleAssetItemID = postResponse.results[0][:new_id]
# Retrieve all Campaigns
p '>>> Retrieve all Campaigns'
- getCamp = FuelSDK::ET_Campaign.new
+ getCamp = FuelSDK::Campaign.new
getCamp.authStub = stubObj
getResponse = getCamp.get
p 'Retrieve Status: ' + getResponse.status.to_s
p 'Code: ' + getResponse.code.to_s
p 'Message: ' + getResponse.message.to_s
@@ -48,11 +48,11 @@
p 'Results(Items) Length: ' + getResponse.results['items'].length.to_s
end
# Create a new Campaign
p '>>> Create a new Campaign'
- postCamp = FuelSDK::ET_Campaign.new
+ postCamp = FuelSDK::Campaign.new
postCamp.authStub = stubObj
postCamp.props = {"name" => "RubySDKCreatedForTest1", "description"=> "RubySDKCreatedForTest", "color"=>"FF9933", "favorite"=>"false"}
postResponse = postCamp.post
p 'Post Status: ' + postResponse.status.to_s
p 'Code: ' + postResponse.code.to_s
@@ -64,11 +64,11 @@
IDOfpostCampaign = postResponse.results['id']
# Retrieve the new Campaign
p '>>> Retrieve the new Campaign'
- getCamp = FuelSDK::ET_Campaign.new
+ getCamp = FuelSDK::Campaign.new
getCamp.authStub = stubObj
getCamp.props = {"id" => IDOfpostCampaign}
getResponse = getCamp.get
p 'Retrieve Status: ' + getResponse.status.to_s
p 'Code: ' + getResponse.code.to_s
@@ -78,11 +78,11 @@
raise 'Failure retrieving campaign' unless getResponse.success?
# Update the new Campaign
p '>>> Update the new Campaign'
- patchCamp = FuelSDK::ET_Campaign.new
+ patchCamp = FuelSDK::Campaign.new
patchCamp.authStub = stubObj
patchCamp.props = {"id"=> IDOfpostCampaign, "name" => "RubySDKCreated-Updated!"}
patchResponse = patchCamp.patch
p 'Patch Status: ' + patchResponse.status.to_s
p 'Code: ' + patchResponse.code.to_s
@@ -92,11 +92,11 @@
raise 'Failure updating campaign' unless patchResponse.success?
# Retrieve the updated Campaign
p '>>> Retrieve the updated Campaign'
- getCamp = FuelSDK::ET_Campaign.new
+ getCamp = FuelSDK::Campaign.new
getCamp.authStub = stubObj
getCamp.props = {"id" => IDOfpostCampaign}
getResponse = getCamp.get
p 'Retrieve Status: ' + getResponse.status.to_s
p 'Code: ' + getResponse.code.to_s
@@ -106,11 +106,11 @@
raise 'Failure retrieving campaign' unless getResponse.success?
# Create a new Campaign Asset
p '>>> Create a new Campaign Asset'
- postCampAsset = FuelSDK::ET_Campaign::Asset.new
+ postCampAsset = FuelSDK::Campaign::Asset.new
postCampAsset.authStub = stubObj
postCampAsset.props = {"id" => IDOfpostCampaign, "ids"=> [ExampleAssetItemID], "type"=> ExampleAssetType}
postResponse = postCampAsset.post
p 'Post Status: ' + postResponse.status.to_s
p 'Code: ' + postResponse.code.to_s
@@ -122,11 +122,11 @@
IDOfpostCampaignAsset = postResponse.results[0]['id']
# Retrieve all Campaign Asset for a campaign
p '>>> Retrieve all Campaign Asset for a Campaign'
- getCampAsset = FuelSDK::ET_Campaign::Asset.new
+ getCampAsset = FuelSDK::Campaign::Asset.new
getCampAsset.authStub = stubObj
getCampAsset.props = {"id" => IDOfpostCampaign}
getResponse = getCampAsset.get
p 'Retrieve Status: ' + getResponse.status.to_s
p 'Code: ' + getResponse.code.to_s
@@ -136,11 +136,11 @@
raise 'Failure retrieving campaign assets' unless getResponse.success?
# Retrieve a single new Campaign Asset
p '>>> Retrieve a single new Campaign Asset'
- getCampAsset = FuelSDK::ET_Campaign::Asset.new
+ getCampAsset = FuelSDK::Campaign::Asset.new
getCampAsset.authStub = stubObj
getCampAsset.props = {"id" => IDOfpostCampaign, "assetId" => IDOfpostCampaignAsset}
getResponse = getCampAsset.get
p 'Retrieve Status: ' + getResponse.status.to_s
p 'Code: ' + getResponse.code.to_s
@@ -150,11 +150,11 @@
raise 'Failure retrieving campaign asset' unless getResponse.success?
# Delete the new Campaign Asset
p '>>> Delete the new Campaign Asset'
- deleteCampAsset = FuelSDK::ET_Campaign::Asset.new
+ deleteCampAsset = FuelSDK::Campaign::Asset.new
deleteCampAsset.authStub = stubObj
deleteCampAsset.props = {"id" => IDOfpostCampaign, "assetId"=> IDOfpostCampaignAsset}
deleteResponse = deleteCampAsset.delete
p 'Delete Status: ' + deleteResponse.status.to_s
p 'Code: ' + deleteResponse.code.to_s
@@ -164,11 +164,11 @@
raise 'Failure deleting campaign asset' unless deleteResponse.success?
# Get a single a new Campaign Asset to confirm deletion
p '>>> Get a single a new Campaign Asset to confirm deletion'
- getCampAsset = FuelSDK::ET_Campaign::Asset.new
+ getCampAsset = FuelSDK::Campaign::Asset.new
getCampAsset.authStub = stubObj
getCampAsset.props = {"id" => IDOfpostCampaign}
getResponse = getCampAsset.get
p 'Retrieve Status: ' + getResponse.status.to_s
p 'Code: ' + getResponse.code.to_s
@@ -184,11 +184,11 @@
p e.backtrace
ensure
# Delete the new Campaign
p '>>> Delete the new Campaign'
- deleteCamp = FuelSDK::ET_Campaign.new
+ deleteCamp = FuelSDK::Campaign.new
deleteCamp.authStub = stubObj
deleteCamp.props = {"id"=> IDOfpostCampaign}
deleteResponse = deleteCamp.delete
p 'Delete Status: ' + deleteResponse.status.to_s
p 'Code: ' + deleteResponse.code.to_s
@@ -197,10 +197,10 @@
p '-----------------------------'
raise 'Failure deleting campaign asset' unless deleteResponse.success?
p '>>> Delete List'
- deleteSub = FuelSDK::ET_List.new()
+ deleteSub = FuelSDK::List.new()
deleteSub.authStub = stubObj
deleteSub.props = {"ID" => ExampleAssetItemID}
deleteResponse = deleteSub.delete
p 'Delete Status: ' + deleteResponse.status.to_s
p 'Code: ' + deleteResponse.code.to_s