Esempio n. 1
0
        public void Setup()
        {
            emailCustKey        = emailName = System.Guid.NewGuid().ToString();
            emailContent        = "<b>This is a content generated by Fuel SDK C#";
            emailUpdatedContent = "<b>This is an updated content generated by Fuel SDK C#";

            var emailObj = new ETEmail
            {
                AuthStub    = client,
                Name        = emailName,
                CustomerKey = emailCustKey,
                Subject     = "This email is created using C# SDK",
                HTMLBody    = emailContent
            };
            var response = emailObj.Post();

            Assert.AreEqual(response.Code, 200);
            Assert.AreEqual(response.Status, true);
            email = (ETEmail)response.Results[0].Object;
        }
        public void Setup()
        {
            tsdName = Guid.NewGuid().ToString();
            desc    = "Triggered Send Definition created by C# SDK";
            var emailName    = string.Empty;
            var emailCustKey = emailName = System.Guid.NewGuid().ToString();
            var emailContent = "<b>This is a content generated by Fuel SDK C#";

            var emailObj = new ETEmail
            {
                AuthStub    = client,
                Name        = emailName,
                CustomerKey = emailCustKey,
                Subject     = "This email is created using C# SDK",
                HTMLBody    = emailContent
            };
            var emailResponse = emailObj.Post();

            Assert.AreEqual(emailResponse.Code, 200);
            Assert.AreEqual(emailResponse.Status, true);
            email = (ETEmail)emailResponse.Results[0].Object;

            var tsdObj = new ETTriggeredSendDefinition
            {
                AuthStub           = client,
                Name               = tsdName,
                Description        = desc,
                CustomerKey        = tsdName,
                Email              = email,
                SendClassification = new ETSendClassification {
                    CustomerKey = "Default Commercial"
                },
            };

            var response = tsdObj.Post();

            Assert.AreEqual(response.Code, 200);
            Assert.AreEqual(response.Status, true);
            Assert.AreEqual(response.Results[0].StatusMessage, "TriggeredSendDefinition created");
            tsd = (ETTriggeredSendDefinition)response.Results[0].Object;
        }
        public void Setup()
        {
            //To create a email send definition we need: Email, SendableList, SendClassification
            //we will create email ,sendable data extension for SendableList

            var dataExtensionName = Guid.NewGuid().ToString();
            var deObj             = new ETDataExtension
            {
                AuthStub    = client,
                Name        = dataExtensionName,
                CustomerKey = dataExtensionName,
                IsSendable  = true,
                SendableDataExtensionField = new ETDataExtensionColumn {
                    Name = "SubscriberID", FieldType = DataExtensionFieldType.Number
                },
                SendableSubscriberField = new ETProfileAttribute {
                    Name = "Subscriber ID", Value = "Subscriber ID"
                },
                Columns = new[] {
                    new ETDataExtensionColumn {
                        Name = "SubscriberID", FieldType = DataExtensionFieldType.Number, IsPrimaryKey = true, IsRequired = true
                    },
                    new ETDataExtensionColumn {
                        Name = "FirstName", FieldType = DataExtensionFieldType.Text
                    },
                    new ETDataExtensionColumn {
                        Name = "LastName", FieldType = DataExtensionFieldType.Text
                    }
                }
            };

            var result = deObj.Post();

            dataExtension = (ETDataExtension)result.Results[0].Object;
            var dataExtensionId = result.Results[0].NewObjectID;
            //create Email
            var emailName    = string.Empty;
            var emailCustKey = emailName = System.Guid.NewGuid().ToString();
            var emailContent = "<b>This is a content generated by Fuel SDK C#";

            var emailObj = new ETEmail
            {
                AuthStub    = client,
                Name        = emailName,
                CustomerKey = emailCustKey,
                Subject     = "This email is created using C# SDK",
                HTMLBody    = emailContent
            };
            var emailResponse = emailObj.Post();

            Assert.AreEqual(emailResponse.Code, 200);
            Assert.AreEqual(emailResponse.Status, true);
            email = (ETEmail)emailResponse.Results[0].Object;



            //create the send def
            var sendDefName = Guid.NewGuid().ToString();
            var sendDefList = new ETSendDefinitionList
            {
                Name                   = "SendDefintion List CSharp",
                CustomerKey            = dataExtension.CustomerKey,
                SendDefinitionListType = SendDefinitionListTypeEnum.SourceList,
                CustomObjectID         = dataExtension.ObjectID,
                DataSourceTypeID       = DataSourceTypeEnum.CustomObject
            };
            var postESDDE = new ETEmailSendDefinition
            {
                AuthStub           = client,
                Name               = sendDefName,
                CustomerKey        = sendDefName,
                Description        = desc,
                SendClassification = new ETSendClassification {
                    CustomerKey = "Default Commercial"
                },
                SendDefinitionList = new[] { sendDefList },
                Email = new ETEmail {
                    ID = emailResponse.Results[0].NewID
                },
            };
            var postResponse = postESDDE.Post();

            Assert.AreEqual(postResponse.Code, 200);
            Assert.AreEqual(postResponse.Status, true);

            emailSendDef = (ETEmailSendDefinition)postResponse.Results[0].Object;
        }