Ejemplo n.º 1
0
 public Guid Create(CampaignParams campaignParams)
 {
     return _Manager.MakeRequest<Guid>(HttpMethod.POST, "/campaigns/create", campaignParams);
 }
Ejemplo n.º 2
0
        public void Save(Campaign campaign)
        {
            if (campaign.ID == Guid.Empty)
            {
                var data = new CampaignParams()
                {
                    ConfirmationToEmail = campaign.ConfirmationTo,
                    Name = campaign.Name,
                    Subject = campaign.Subject,
                    WebLocation = campaign.WebLocation
                };

                if (campaign.MailingList != null) data.MailingListID = campaign.MailingList.ID;
                if (campaign.Segment != null) data.SegmentID = campaign.Segment.ID;
                if (campaign.Sender != null) data.SenderEmail = campaign.Sender.Email;
                if (campaign.ReplyToEmail != null) data.ReplyToEmail = campaign.ReplyToEmail.Email;
                else campaign.ReplyToEmail = campaign.Sender;

                if (campaign.ABCampaignData != null)
                {
                    data.ABCampaignType = campaign.ABCampaignData.ABCampaignType;
                    data.ABWinnerSelectionType = campaign.ABCampaignData.ABWinnerSelectionType;
                    data.HoursToTest = campaign.ABCampaignData.HoursToTest;
                    data.ListPercentage = campaign.ABCampaignData.ListPercentage;
                    if (campaign.ABCampaignData.SenderB != null) data.SenderEmailB = campaign.ABCampaignData.SenderB.Email;
                    data.SubjectB = campaign.ABCampaignData.SubjectB;
                    data.WebLocationB = campaign.ABCampaignData.WebLocationB;
                }
                campaign.ID = Create(data);
            }
            else
            {
                Update(campaign);
            }
            Campaign reloaded = FindByID(campaign.ID);
            Utilities.CopyProperties<Campaign>(reloaded, campaign);
        }
Ejemplo n.º 3
0
        public void Update(Campaign campaign)
        {
            CampaignParams cp = new CampaignParams()
            {
                Name = campaign.Name,
                Subject = campaign.Subject,
                WebLocation = campaign.WebLocation,
                ConfirmationToEmail = campaign.ConfirmationTo
            };

            if (campaign.Sender != null) cp.SenderEmail = campaign.Sender.Email;
            else cp.SenderEmail = null;

            if (campaign.ReplyToEmail != null) cp.ReplyToEmail = campaign.ReplyToEmail.Email;
            else cp.ReplyToEmail = null;

            if (campaign.MailingList != null) cp.MailingListID = campaign.MailingList.ID;
            else cp.MailingListID = Guid.Empty;

            if (campaign.Segment != null) cp.SegmentID = campaign.Segment.ID;
            else cp.SegmentID = 0;

            if (campaign.ABCampaignData != null)
            {
                cp.ABCampaignType = campaign.ABCampaignData.ABCampaignType;
                cp.ABWinnerSelectionType = campaign.ABCampaignData.ABWinnerSelectionType;
                cp.HoursToTest = campaign.ABCampaignData.HoursToTest;
                cp.ListPercentage = campaign.ABCampaignData.ListPercentage;
                cp.SubjectB = campaign.ABCampaignData.SubjectB;
                cp.WebLocationB = campaign.ABCampaignData.WebLocationB;

                if (campaign.ABCampaignData.SenderB != null) cp.SenderEmailB = campaign.ABCampaignData.SenderB.Email;
                else cp.SenderEmailB = null;
            }
            _Manager.MakeRequest(HttpMethod.POST, String.Format("/campaigns/{0}/update", campaign.ID), cp);
        }