Beispiel #1
0
        public OneSpanSign.Sdk.Sender GetSender(string senderId)
        {
            OneSpanSign.API.Sender apiResponse = apiClient.GetSender(senderId);
            Sender result = new SenderConverter(apiResponse).ToSDKSender();

            return(result);
        }
Beispiel #2
0
        public OneSpanSign.API.Sender ToAPISender()
        {
            if (null != sdkAccountMember)
            {
                OneSpanSign.API.Sender result = new OneSpanSign.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;
                result.TimezoneId = sdkAccountMember.TimezoneId;
                string convertedStatus = new SenderStatusConverter(sdkAccountMember.Status).ToAPISenderStatus();
                if (!String.IsNullOrEmpty(convertedStatus))
                {
                    result.Status = convertedStatus;
                }
                return(result);
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        public Sender InviteUser(AccountMember invitee)
        {
            OneSpanSign.API.Sender apiSender   = new AccountMemberConverter(invitee).ToAPISender();
            OneSpanSign.API.Sender apiResponse = apiClient.InviteUser(apiSender);
            Sender result = new SenderConverter(apiResponse).ToSDKSender();

            return(result);
        }
        public void ToSDKFromAPISender()
        {
            OneSpanSign.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);
            Assert.AreEqual(sender.TimezoneId, senderInfo.TimezoneId);
        }
        private OneSpanSign.API.Sender CreateTypicalAPISender()
        {
            OneSpanSign.API.Sender sender = new OneSpanSign.API.Sender();
            sender.Email      = EMAIL;
            sender.FirstName  = FIRST_NAME;
            sender.LastName   = LAST_NAME;
            sender.Company    = COMPANY;
            sender.Title      = TITLE;
            sender.TimezoneId = TIMEZONE_ID;

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

            return(sender);
        }
        public OneSpanSign.API.Sender InviteUser(OneSpanSign.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);
                OneSpanSign.API.Sender apiResponse = JsonConvert.DeserializeObject <OneSpanSign.API.Sender> (response, jsonSettings);
                return(apiResponse);
            }
            catch (OssServerException e) {
                throw new OssServerException("Failed to invite new account member.\t" + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e) {
                throw new OssException("Failed to invite new account member.\t" + " Exception: " + e.Message, e);
            }
        }
        public void UpdateSender(OneSpanSign.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 (OssServerException e) {
                throw new OssServerException("Could not update sender.\t" + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e) {
                throw new OssException("Could not update sender.\t" + " Exception: " + e.Message, e);
            }
        }
        public OneSpanSign.API.Sender GetSender(string senderId)
        {
            string path = template.UrlFor(UrlTemplate.ACCOUNT_MEMBER_ID_PATH)
                          .Replace("{senderUid}", senderId)
                          .Build();

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

                return(apiResponse);
            }
            catch (OssServerException e) {
                throw new OssServerException("Failed to retrieve Sender from Account.\t" + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e) {
                throw new OssException("Failed to retrieve Sender from Account.\t" + " Exception: " + e.Message, e);
            }
        }
        private OneSpanSign.API.Package CreateTypicalAPIPackage()
        {
            OneSpanSign.API.Package apiPackage = new OneSpanSign.API.Package();
            apiPackage.Id           = "1";
            apiPackage.Language     = "zh-CN";
            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;

            OneSpanSign.API.Message apiMessage = new OneSpanSign.API.Message();
            apiMessage.Content = "opt-out reason";
            apiMessage.Status  = OneSpanSign.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);

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

            return(apiPackage);
        }
        public void ToSDKSenderFromAPISender()
        {
            OneSpanSign.API.Sender apiSender = CreateTypicalAPISender();
            OneSpanSign.Sdk.Sender sdkSender = new SenderConverter(apiSender).ToSDKSender();

            Assert.AreEqual(sdkSender.Status.getApiValue(), apiSender.Status);
            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.TimezoneId, apiSender.TimezoneId);
            Assert.AreEqual(sdkSender.External.Id, apiSender.External.Id);
            Assert.AreEqual(sdkSender.External.Provider, apiSender.External.Provider);
            Assert.AreEqual(sdkSender.External.ProviderName, apiSender.External.ProviderName);
        }
 public void FromAPINull()
 {
     OneSpanSign.API.Sender sender = null;
     Assert.Throws <ArgumentNullException>(() => new SenderConverter(sender));
 }