Ejemplo n.º 1
0
        public Silanis.ESL.SDK.Sender GetSender(string senderId)
        {
            Silanis.ESL.API.Sender apiResponse = apiClient.GetSender(senderId);
            Sender result = new SenderConverter(apiResponse).ToSDKSender();

            return(result);
        }
        public Silanis.ESL.API.Sender ToAPISender()
        {
            if (sdkAccountMember != null)
            {
                Silanis.ESL.API.Sender result = new Silanis.ESL.API.Sender();

                result.Address   = new AddressConverter(sdkAccountMember.Address).ToAPIAddress();
                result.FirstName = sdkAccountMember.FirstName;
                result.LastName  = sdkAccountMember.LastName;
                result.Title     = sdkAccountMember.Title;
                result.Company   = sdkAccountMember.Company;
                result.Email     = sdkAccountMember.Email;
                result.Phone     = sdkAccountMember.PhoneNumber;
                result.Language  = sdkAccountMember.Language;
                Silanis.ESL.API.SenderStatus?convertedStatus = new SenderStatusConverter(sdkAccountMember.Status).ToAPISenderStatus();
                if (convertedStatus.HasValue)
                {
                    result.Status = convertedStatus.Value;
                }
                return(result);
            }
            else
            {
                return(null);
            }
        }
        public Silanis.ESL.API.Sender ToAPISender()
        {
            if (null != sdkAccountMember)
            {
                Silanis.ESL.API.Sender result = new Silanis.ESL.API.Sender();

                result.Address   = new AddressConverter(sdkAccountMember.Address).ToAPIAddress();
                result.FirstName = sdkAccountMember.FirstName;
                result.LastName  = sdkAccountMember.LastName;
                result.Title     = sdkAccountMember.Title;
                result.Company   = sdkAccountMember.Company;
                result.Email     = sdkAccountMember.Email;
                result.Phone     = sdkAccountMember.PhoneNumber;
                result.Language  = sdkAccountMember.Language;
                string convertedStatus = new SenderStatusConverter(sdkAccountMember.Status).ToAPISenderStatus();
                if (!String.IsNullOrEmpty(convertedStatus))
                {
                    result.Status = convertedStatus;
                }
                return(result);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 4
0
        public Sender InviteUser(AccountMember invitee)
        {
            Silanis.ESL.API.Sender apiSender   = new AccountMemberConverter(invitee).ToAPISender();
            Silanis.ESL.API.Sender apiResponse = apiClient.InviteUser(apiSender);
            Sender result = new SenderConverter(apiResponse).ToSDKSender();

            return(result);
        }
Ejemplo n.º 5
0
        public void ToSDKFromAPISender()
        {
            Silanis.ESL.API.Sender sender = CreateTypicalAPISender();

            SenderInfo senderInfo = new SenderConverter(sender).ToSDKSenderInfo();

            Assert.IsNotNull(senderInfo);
            Assert.AreEqual(sender.Email, senderInfo.Email);
            Assert.AreEqual(sender.FirstName, senderInfo.FirstName);
            Assert.AreEqual(sender.LastName, senderInfo.LastName);
            Assert.AreEqual(sender.Company, senderInfo.Company);
            Assert.AreEqual(sender.Title, senderInfo.Title);
        }
Ejemplo n.º 6
0
        private Silanis.ESL.API.Sender CreateTypicalAPISender()
        {
            Silanis.ESL.API.Sender sender = new Silanis.ESL.API.Sender();
            sender.Email     = EMAIL;
            sender.FirstName = FIRST_NAME;
            sender.LastName  = LAST_NAME;
            sender.Company   = COMPANY;
            sender.Title     = TITLE;

            sender.External              = new Silanis.ESL.API.External();
            sender.External.Id           = EXTERNAL_ID;
            sender.External.Provider     = EXTERNAL_PROVIDER;
            sender.External.ProviderName = EXTERNAL_PROVIDER_NAME;

            return(sender);
        }
Ejemplo n.º 7
0
        public Silanis.ESL.API.Sender InviteUser(Silanis.ESL.API.Sender invitee)
        {
            string path = template.UrlFor(UrlTemplate.ACCOUNT_MEMBER_PATH).Build();

            try {
                string json     = JsonConvert.SerializeObject(invitee, jsonSettings);
                string response = restClient.Post(path, json);
                Silanis.ESL.API.Sender apiResponse = JsonConvert.DeserializeObject <Silanis.ESL.API.Sender> (response, jsonSettings);
                return(apiResponse);
            }
            catch (EslServerException e) {
                throw new EslServerException("Failed to invite new account member.\t" + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e) {
                throw new EslException("Failed to invite new account member.\t" + " Exception: " + e.Message, e);
            }
        }
Ejemplo n.º 8
0
        public void UpdateSender(Silanis.ESL.API.Sender apiSender, string senderId)
        {
            string path = template.UrlFor(UrlTemplate.ACCOUNT_MEMBER_ID_PATH)
                          .Replace("{senderUid}", senderId)
                          .Build();

            try {
                string json = JsonConvert.SerializeObject(apiSender, jsonSettings);
                apiSender.Id = senderId;
                restClient.Post(path, json);
            }
            catch (EslServerException e) {
                throw new EslServerException("Could not update sender.\t" + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e) {
                throw new EslException("Could not update sender.\t" + " Exception: " + e.Message, e);
            }
        }
Ejemplo n.º 9
0
        public void ToSDKFromAPISender()
        {
            Silanis.ESL.API.Sender sender = new Silanis.ESL.API.Sender();
            sender.Email     = EMAIL;
            sender.FirstName = FIRST_NAME;
            sender.LastName  = LAST_NAME;
            sender.Company   = COMPANY;
            sender.Title     = TITLE;

            SenderInfo senderInfo = new SenderConverter(sender).ToSDKSenderInfo();

            Assert.IsNotNull(senderInfo);
            Assert.AreEqual(sender.Email, senderInfo.Email);
            Assert.AreEqual(sender.FirstName, senderInfo.FirstName);
            Assert.AreEqual(sender.LastName, senderInfo.LastName);
            Assert.AreEqual(sender.Company, senderInfo.Company);
            Assert.AreEqual(sender.Title, senderInfo.Title);
        }
Ejemplo n.º 10
0
		public void ToSDKFromAPISender()
		{

			Silanis.ESL.API.Sender sender = new Silanis.ESL.API.Sender();
			sender.Email = EMAIL;
			sender.FirstName = FIRST_NAME;
			sender.LastName = LAST_NAME;
			sender.Company = COMPANY;
			sender.Title = TITLE;

			SenderInfo senderInfo = new SenderConverter(sender).ToSDKSenderInfo();

			Assert.IsNotNull(senderInfo);
			Assert.AreEqual(sender.Email, senderInfo.Email);
			Assert.AreEqual(sender.FirstName, senderInfo.FirstName);
			Assert.AreEqual(sender.LastName, senderInfo.LastName);
			Assert.AreEqual(sender.Company, senderInfo.Company);
			Assert.AreEqual(sender.Title, senderInfo.Title);
		}
Ejemplo n.º 11
0
        public Silanis.ESL.API.Sender GetSender(string senderId)
        {
            string path = template.UrlFor(UrlTemplate.ACCOUNT_MEMBER_ID_PATH)
                          .Replace("{senderUid}", senderId)
                          .Build();

            try {
                string response = restClient.Get(path);
                Silanis.ESL.API.Sender apiResponse = JsonConvert.DeserializeObject <Silanis.ESL.API.Sender> (response, jsonSettings);

                return(apiResponse);
            }
            catch (EslServerException e) {
                throw new EslServerException("Failed to retrieve Sender from Account.\t" + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e) {
                throw new EslException("Failed to retrieve Sender from Account.\t" + " Exception: " + e.Message, e);
            }
        }
Ejemplo n.º 12
0
 public Silanis.ESL.API.Sender ToAPISender() {
     if (sdkAccountMember != null ) {
         Silanis.ESL.API.Sender result = new Silanis.ESL.API.Sender();
         
         result.Address = new AddressConverter(sdkAccountMember.Address).ToAPIAddress();
         result.FirstName = sdkAccountMember.FirstName;
         result.LastName = sdkAccountMember.LastName;
         result.Title = sdkAccountMember.Title;
         result.Company = sdkAccountMember.Company;
         result.Email = sdkAccountMember.Email;
         result.Phone = sdkAccountMember.PhoneNumber;
         result.Language = sdkAccountMember.Language;
         Silanis.ESL.API.SenderStatus? convertedStatus = new SenderStatusConverter(sdkAccountMember.Status).ToAPISenderStatus();
         if ( convertedStatus.HasValue ) result.Status = convertedStatus.Value;
         return result;
     }
     else {
         return null;
     }
 }
Ejemplo n.º 13
0
        public void ToSDKSenderFromAPISender()
        {
            Silanis.ESL.API.Sender apiSender = CreateTypicalAPISender();
            Silanis.ESL.SDK.Sender sdkSender = new SenderConverter(apiSender).ToSDKSender();

            Assert.AreEqual(sdkSender.Status.ToString(), apiSender.Status.ToString());
            Assert.AreEqual(sdkSender.LastName, apiSender.LastName);
            Assert.AreEqual(sdkSender.FirstName, apiSender.FirstName);
            Assert.AreEqual(sdkSender.Company, apiSender.Company);
            Assert.AreEqual(sdkSender.Created, apiSender.Created);
            Assert.AreEqual(sdkSender.Email, apiSender.Email);
            Assert.AreEqual(sdkSender.Language, apiSender.Language);
            Assert.AreEqual(sdkSender.Phone, apiSender.Phone);
            Assert.AreEqual(sdkSender.Name, apiSender.Name);
            Assert.AreEqual(sdkSender.Title, apiSender.Title);
            Assert.AreEqual(sdkSender.Type.ToString(), apiSender.Type.ToString());
            Assert.AreEqual(sdkSender.Updated, apiSender.Updated);
            Assert.AreEqual(sdkSender.Id, apiSender.Id);
            Assert.AreEqual(sdkSender.External.Id, apiSender.External.Id);
            Assert.AreEqual(sdkSender.External.Provider, apiSender.External.Provider);
            Assert.AreEqual(sdkSender.External.ProviderName, apiSender.External.ProviderName);
        }
        private Silanis.ESL.API.Package CreateTypicalAPIPackage()
        {
            Silanis.ESL.API.Package apiPackage = new Silanis.ESL.API.Package();
            apiPackage.Id           = "1";
            apiPackage.Language     = "en";
            apiPackage.Autocomplete = true;
            apiPackage.Consent      = "Consent";
            apiPackage.Completed    = new DateTime?();
            apiPackage.Description  = "API document package description";
            apiPackage.Due          = new DateTime?();
            apiPackage.Name         = "API package name";
            apiPackage.Status       = DocumentPackageStatus.DRAFT.getApiValue();
            apiPackage.Created      = DateTime.Now;

            Silanis.ESL.API.Message apiMessage = new Silanis.ESL.API.Message();
            apiMessage.Content = "opt-out reason";
            apiMessage.Status  = Silanis.ESL.SDK.MessageStatus.NEW.getApiValue();
            apiMessage.Created = DateTime.Now;
            User fromUser = new User();

            fromUser.FirstName = "John";
            fromUser.LastName  = "Smith";
            fromUser.Email     = "*****@*****.**";
            apiMessage.From    = fromUser;
            apiPackage.AddMessage(apiMessage);
            User toUser = new User();

            toUser.FirstName = "Patty";
            toUser.LastName  = "Galant";
            toUser.Email     = "*****@*****.**";
            apiMessage.AddTo(toUser);

            Silanis.ESL.API.Sender sender = new Silanis.ESL.API.Sender();
            sender.Email      = "*****@*****.**";
            apiPackage.Sender = sender;

            return(apiPackage);
        }
 public void FromAPINull()
 {
     Silanis.ESL.API.Sender sender = null;
     Assert.Throws <ArgumentNullException>(() => new SenderConverter(sender));
 }
Ejemplo n.º 16
0
 public void FromAPINull()
 {
     Silanis.ESL.API.Sender sender = null;
     new SenderConverter(sender);
 }
Ejemplo n.º 17
0
		private Silanis.ESL.API.Sender CreateTypicalAPISender()
		{
			Silanis.ESL.API.Sender sender = new Silanis.ESL.API.Sender();
			sender.Email = EMAIL;
			sender.FirstName = FIRST_NAME;
			sender.LastName = LAST_NAME;
			sender.Company = COMPANY;
			sender.Title = TITLE;

            sender.External = new Silanis.ESL.API.External();
            sender.External.Id = EXTERNAL_ID;
            sender.External.Provider = EXTERNAL_PROVIDER;
            sender.External.ProviderName = EXTERNAL_PROVIDER_NAME;

			return sender;
		}