Created
April 22, 2015 20:54
-
-
Save patrickisgreat/510bf10cd5ab3299cb08 to your computer and use it in GitHub Desktop.
handle method creates 4 DEs in Exact Target via Fuel-SDK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Execute the command. | |
* | |
* @return void | |
*/ | |
public function handle() | |
{ | |
//boostrap SDK | |
$slncClient = new ET_Client('slnc'); | |
$postDE = new ET_DataExtension(); | |
$postDE->authStub = $slncClient; | |
//add new columns | |
//for later -- put this on a flag | |
//Data Extension Names | |
$DeNames = [ | |
"SubPreferences", | |
"MasterPreferences", | |
"MasterPrefHistory", | |
"SubPrefHistory" | |
]; | |
//create each | |
foreach ($DeNames as $k=>$name) { | |
$DeName = $name; | |
$postDE->props = [ | |
"Name" => $DeName, | |
"CustomerKey" => $DeName | |
]; | |
$postDE->columns = array(); | |
//master acct preferences tables columns | |
if ($k == 0) { | |
//$postDE->columns[] = ["Name" => "id", "FieldType" => "Number", "IsPrimaryKey" => "true", "IsRequired" => "true"]; | |
$postDE->columns[] = ["Name" => "LINE_USER_ALIAS", "FieldType" => "Text"]; | |
$postDE->columns[] = ["Name" => "SUB_ACCOUNT", "FieldType" => "Number", "IsPrimaryKey" => "true", "IsRequired" => "true"]; | |
$postDE->columns[] = ["Name" => "LINE_STATUS", "FieldType" => "Text"]; | |
$postDE->columns[] = ["Name" => "LINE_STATUS_DATE", "FieldType" => "Date"]; | |
$postDE->columns[] = ["Name" => "PHONE_NUMBER", "FieldType" => "Phone"]; | |
$postDE->columns[] = ["Name" => "TEXT_NUMBER", "FieldType" => "Phone"]; | |
$postDE->columns[] = ["Name" => "PVT_ID", "FieldType" => "Text"]; | |
$postDE->columns[] = ["Name" => "MASTER_ACCOUNT", "FieldType" => "Number"]; | |
$postDE->columns[] = ["Name" => "SERVICE_START_DATE", "FieldType" => "Date"]; | |
$postDE->columns[] = ["Name" => "CONTRACT_START_DATE", "FieldType" => "Date"]; | |
$postDE->columns[] = ["Name" => "CONTRACT_END_DATE", "FieldType" => "Date"]; | |
$postDE->columns[] = ["Name" => "SERVICE_PLAN", "FieldType" => "Text"]; | |
//$this->info(var_dump($postDE->columns)); | |
//die(); | |
//sub account preferences tables columns | |
} else if ($k == 1) { | |
//not sure if we need this as they want to use email and and account | |
//$postDE->columns[] = ["Name" => "id", "FieldType" => "Number", "IsPrimaryKey" => "true", "IsRequired" => "true"]; | |
$postDE->columns[] = ["Name" => "CUSTOMER_ID", "FieldType" => "Number", "IsPrimaryKey" => "true", "IsRequired" => "true"]; | |
$postDE->columns[] = ["Name" => "ACCOUNT_HOLDER", "FieldType" => "Text"]; | |
$postDE->columns[] = ["Name" => "CUSTOMER_NAME", "FieldType" => "Text"]; | |
$postDE->columns[] = ["Name" => "CONNECTION_STATUS", "FieldType" => "Text"]; | |
$postDE->columns[] = ["Name" => "CURRENT_STATUS_DATE", "FieldType" => "Date"]; | |
$postDE->columns[] = ["Name" => "EMAIL_ADDRESS", "FieldType" => "EmailAddress"]; | |
$postDE->columns[] = ["Name" => "CONTACT_PHONE_NO", "FieldType" => "Phone"]; | |
$postDE->columns[] = ["Name" => "ADDRESS", "FieldType" => "Text"]; | |
$postDE->columns[] = ["Name" => "CITY", "FieldType" => "Text"]; | |
$postDE->columns[] = ["Name" => "STATE", "FieldType" => "Text"]; | |
$postDE->columns[] = ["Name" => "ZIPCODE", "FieldType" => "Number"]; | |
$postDE->columns[] = ["Name" => "MASTER_CREATE_DATE", "FieldType" => "Date"]; | |
$postDE->columns[] = ["Name" => "SMS_OPT_IN", "FieldType" => "Boolean", "DefaultValue" => "true"]; | |
$postDE->columns[] = ["Name" => "EMAIL_OPT_IN", "FieldType" => "Boolean", "DefaultValue" => "true"]; | |
$postDE->columns[] = ["Name" => "CONNECTED_SUBS", "FieldType" => "Number"]; | |
$postDE->columns[] = ["Name" => "BILL_CYCLE", "FieldType" => "Number"];*/ | |
//history tables -- fields should be identical | |
} else if ($k > 1) { | |
//is there an auto increment in ET ? | |
$postDE->columns[] = ["Name" => "id", "FieldType" => "Number", "IsPrimaryKey" => "true", "IsRequired" => "true"]; | |
$postDE->columns[] = ["Name" => "CUSOMTER_NAME", "FieldType" => "Text"]; | |
$postDE->columns[] = ["Name" => "CUSOMTER_ID", "FieldType" => "Text"]; | |
$postDE->columns[] = ["Name" => "SMS_OPT_IN", "FieldType" => "Boolean", "IsRequired" => "true", "DefaultValue" => "true"]; | |
$postDE->columns[] = ["Name" => "EMAIL_OPT_IN", "FieldType" => "Boolean", "IsRequired" => "true", "DefaultValue" => "true"]; | |
$postDE->columns[] = ["Name" => "CREATED", "FieldType" => "Date", "IsRequired" => "true"]; | |
//probably don't need this | |
//$postDE->columns[] = ["Name" => "updated", "FieldType" => "Date", "IsRequired" => "true"]; | |
} | |
$postResult = $postDE->post(); | |
if ($postResult->status == true) { | |
$this->info('Successfully Created DEs'); | |
$this->info('Code: ' . $postResult->code . ' Message: '. $postResult->message); | |
} else { | |
$this->info('Something Went Wrong'); | |
//here's the error | |
} | |
}//foreach | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment