Example #1
0
        public string CreateCampaign(SendinBlueCampaignRequest request)
        {
            string IdCampaign = string.Empty;

            try
            {
                ApiKey = request.ApiKey;

                if (ApiKey != string.Empty)
                {
                    APISendingBlue sendinBlue             = new APISendingBlue(ApiKey);
                    var            data                   = request.GetSendinBlueCampaignRequestObject();
                    dynamic        createCampaignResponse = sendinBlue.create_campaign(data);
                    if (createCampaignResponse.code == "success")
                    {
                        IdCampaign = createCampaignResponse.data.id;
                    }
                    else
                    {
                        SendinBlueResponse wrong = new SendinBlueResponse();
                        wrong = createCampaignResponse;
                        string error = wrong.message;

                        string messageError = string.Format("Something goes wrong, detail:{0}", error);
                    }
                }
            }
            catch (Exception e)
            {
                string exceptionMessage = telemetria.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name);
                telemetria.Critical(exceptionMessage);
            }
            return(IdCampaign);
        }
Example #2
0
        private bool FolderIsValid()
        {
            bool result = false;

            try
            {
                string                   key         = GetSettingFromCosmos("Key");
                APISendingBlue           sendinBlue  = new APISendingBlue(key);
                Dictionary <string, int> foldersData = new Dictionary <string, int>();
                Dictionary <string, int> folderData  = new Dictionary <string, int>();
                foldersData.Add("page", 1);
                foldersData.Add("page_limit", 1);

                //Todo
                dynamic folders = sendinBlue.get_folders(foldersData);

                // get result
                if (folders.code == "success")
                {
                    result = true;
                }
            }
            catch (Exception e)
            {
                var messageException = telemetria.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name);
                telemetria.Critical(messageException);
            }
            return(result);
        }
Example #3
0
        public void CreateCampaignTest()
        {
            if (ApiKey != string.Empty)
            {
                APISendingBlue sendinBlue        = new APISendingBlue(ApiKey);
                Dictionary <string, Object> data = new Dictionary <string, Object>();
                List <int> listid = new List <int>();
                listid.Add(2);
                data.Add("category", "My category");
                data.Add("from_name", "[DEFAULT_FROM_NAME]");
                data.Add("name", "My Campaign 1");
                data.Add("bat", "");
                data.Add("html_content", "<html><body><pre> Corramos con el peje este 4 de julio a festejar a su depa </pre></body></html>");
                data.Add("html_url", "");
                data.Add("listid", listid);
                data.Add("scheduled_date", "2018-05-16 16:05:01");
                data.Add("subject", "My Subject");
                data.Add("from_email", "*****@*****.**");
                data.Add("reply_to", "[DEFAULT_REPLY_TO]");
                data.Add("to_field", "[PRENOM] [NOM]");
                data.Add("exclude_list", new List <int>());
                data.Add("attachment_url", "");
                data.Add("inline_image", 1);
                data.Add("mirror_active", 0);
                data.Add("send_now", 0);
                data.Add("utm_campaign", "My UTM Value1");

                Object createCampaign = sendinBlue.create_campaign(data);
                Console.WriteLine(createCampaign);
            }
        }
Example #4
0
        public List <Folder> GetAllFolders()
        {
            List <Folder> folders = new List <Folder> {
            };

            try
            {
                if (ApiKey != string.Empty)
                {
                    APISendingBlue           sendinBlue = new APISendingBlue(ApiKey);
                    Dictionary <string, int> data       = new Dictionary <string, int>();
                    data.Add("page", 1);
                    data.Add("page_limit", 10);

                    dynamic foldersResponse = sendinBlue.get_folders(data);
                    if (foldersResponse.code == "success")
                    {
                        folders = foldersResponse.data.folders.ToObject <List <Folder> >();
                        for (var i = 0; i <= (folders.Count - 1); i++)
                        {
                            folders[i].Listas = folders[i].lists.ToObject <List <Lista> >();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                string exceptionMessage = telemetria.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name);
                telemetria.Critical(exceptionMessage);
            }
            return(folders.ToList());
        }
Example #5
0
        private bool ListIsValid(string IdCampaign)
        {
            bool result = false;

            try
            {
                string                   key        = GetSetting("Key", IdCampaign);
                APISendingBlue           sendinBlue = new APISendingBlue(key);
                int                      IdList     = Convert.ToInt32(GetSetting("List", IdCampaign));
                Dictionary <string, int> listData   = new Dictionary <string, int>();
                listData.Add("id", IdList);
                dynamic list = sendinBlue.get_list(listData);
                // get result
                if (list.code == "success")
                {
                    result = true;
                }
            }
            catch (Exception e)
            {
                var messageException = telemetria.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name);
                telemetria.Critical(messageException);
            }
            return(result);
        }
Example #6
0
        private bool ApiTolenIsValid()
        {
            bool result = false;

            try
            {
                string         key        = GetSettingFromCosmos("Key");
                APISendingBlue sendinBlue = new APISendingBlue(key);
                dynamic        account    = sendinBlue.get_account();
                if (account.code == "success")
                {
                    result = true;
                }
            }
            catch (Exception e)
            {
                var messageException = telemetria.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name);
                telemetria.Critical(messageException);
            }
            return(result);
        }
Example #7
0
 public void GetAllLists(string IdCampaign, int IdFolder)
 {
     try
     {
         if (ApiKey != string.Empty)
         {
             APISendingBlue           sendinBlue = new APISendingBlue(ApiKey);
             Dictionary <string, int> data       = new Dictionary <string, int>();
             data.Add("list_parent", 1);
             data.Add("page", 1);
             data.Add("page_limit", 10);
             Object getLists = sendinBlue.get_lists(data);
             Console.WriteLine(getLists);
         }
     }
     catch (Exception e)
     {
         string exceptionMessage = telemetria.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name);
         telemetria.Critical(exceptionMessage);
     }
 }
Example #8
0
        public bool ValidateApiKey(string Key)
        {
            bool result = false;

            try
            {
                if (Key != string.Empty)
                {
                    APISendingBlue sendinBlue     = new APISendingBlue(Key);
                    dynamic        authentication = sendinBlue.get_account();
                    if (authentication.code == "success")
                    {
                        result = true;
                    }
                }
            }
            catch (Exception e)
            {
                string exceptionMessage = telemetria.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name);
                telemetria.Critical(exceptionMessage);
            }
            return(result);
        }
Example #9
0
        public string GetAccountEmail()
        {
            string email = string.Empty;

            try
            {
                if (ApiKey != string.Empty)
                {
                    APISendingBlue sendinBlue     = new APISendingBlue(ApiKey);
                    dynamic        authentication = sendinBlue.get_account();
                    if (authentication.code == "success")
                    {
                        email = authentication.data[2].email;
                    }
                }
            }
            catch (Exception e)
            {
                string exceptionMessage = telemetria.MakeMessageException(e, System.Reflection.MethodBase.GetCurrentMethod().Name);
                telemetria.Critical(exceptionMessage);
            }
            return(email);
        }