예제 #1
0
        private OneSpanSign.API.Plan CreateTypicalAPIPlan()
        {
            OneSpanSign.API.Plan plan = new OneSpanSign.API.Plan();
            plan.Contract    = PLAN_CONTRACT;
            plan.Group       = PLAN_GRP;
            plan.Original    = PLAN_ORI;
            plan.Description = PLAN_DES;
            plan.Data        = PLAN_DATA;
            plan.Cycle       = PLAN_CYC;
            plan.Id          = PLAN_ID;
            plan.Features    = PLAN_FEAT;
            plan.Name        = PLAN_NAME;
            OneSpanSign.API.CycleCount cycleCount = new OneSpanSign.API.CycleCount();
            cycleCount.Cycle = PLAN_CYC_CYCLE;
            cycleCount.Count = PLAN_CYC_COUNT;
            plan.FreeCycles  = cycleCount;
            OneSpanSign.API.Quota quota = new OneSpanSign.API.Quota();
            quota.Target = PLAN_QUOTA_TARGET;
            quota.Limit  = PLAN_QUOTA_LIMIT;
            quota.Cycle  = PLAN_QUOTA_CYCLE;
            quota.Scope  = PLAN_QUOTA_SCOPE;
            plan.AddQuota(quota);
            OneSpanSign.API.Price price1 = new OneSpanSign.API.Price();
            price1.Amount = PLAN_PRICE_AMOUNT;
            OneSpanSign.API.Currency currency1 = new OneSpanSign.API.Currency();
            currency1.Id    = PLAN_PRICE_CURR_ID;
            currency1.Name  = PLAN_PRICE_CURR_NAME;
            currency1.Data  = PLAN_PRICE_CURR_DATA;
            price1.Currency = currency1;
            plan.Price      = price1;

            return(plan);
        }
예제 #2
0
        public void ConvertNullAPIToAPI()
        {
            apiPlan   = null;
            converter = new PlanConverter(apiPlan);

            Assert.IsNull(converter.ToAPIPlan());
        }
예제 #3
0
        private OneSpanSign.API.License CreateTypicalAPILicense()
        {
            OneSpanSign.API.License license = new OneSpanSign.API.License();
            license.Created   = LIC_CREATED;
            license.Status    = LIC_STATUS;
            license.PaidUntil = LIC_PAIDUNTIL;
            OneSpanSign.API.Transaction transaction = new OneSpanSign.API.Transaction();
            transaction.Created = LIC_TRANS_CREATED;
            OneSpanSign.API.CreditCard creditCard = new OneSpanSign.API.CreditCard();
            creditCard.Cvv    = LIC_TRANS_CC_CVV;
            creditCard.Type   = LIC_TRANS_CC_TYPE;
            creditCard.Name   = LIC_TRANS_CC_NAME;
            creditCard.Number = LIC_TRANS_CC_NUM;
            OneSpanSign.API.CcExpiration ccExpiration = new OneSpanSign.API.CcExpiration();
            ccExpiration.Month     = LIC_TRANS_CC_EXP_MONTH;
            ccExpiration.Year      = LIC_TRANS_CC_EXP_YEAR;
            creditCard.Expiration  = ccExpiration;
            transaction.CreditCard = creditCard;
            OneSpanSign.API.Price price = new OneSpanSign.API.Price();
            price.Amount = LIC_TRANS_PRICE_AMOUNT;
            OneSpanSign.API.Currency currency = new OneSpanSign.API.Currency();
            currency.Data     = LIC_TRANS_PRICE_CURR_DATA;
            currency.Name     = LIC_TRANS_PRICE_CURR_NAME;
            currency.Id       = LIC_TRANS_PRICE_CURR_ID;
            price.Currency    = currency;
            transaction.Price = price;
            license.AddTransaction(transaction);
            OneSpanSign.API.Plan plan = new OneSpanSign.API.Plan();
            plan.Contract    = LIC_PLAN_CONTRACT;
            plan.Group       = LIC_PLAN_GRP;
            plan.Original    = LIC_PLAN_ORI;
            plan.Description = LIC_PLAN_DES;
            plan.Data        = LIC_PLAN_DATA;
            plan.Cycle       = LIC_PLAN_CYC;
            plan.Id          = LIC_PLAN_ID;
            plan.Features    = LIC_PLAN_FEAT;
            plan.Name        = LIC_PLAN_NAME;
            OneSpanSign.API.CycleCount cycleCount = new OneSpanSign.API.CycleCount();
            cycleCount.Cycle = LIC_PLAN_CYC_CYCLE;
            cycleCount.Count = LIC_PLAN_CYC_COUNT;
            plan.FreeCycles  = cycleCount;
            OneSpanSign.API.Quota quota = new OneSpanSign.API.Quota();
            quota.Target = LIC_PLAN_QUOTA_TARGET;
            quota.Limit  = LIC_PLAN_QUOTA_LIMIT;
            quota.Cycle  = LIC_PLAN_QUOTA_CYCLE;
            quota.Scope  = LIC_PLAN_QUOTA_SCOPE;
            plan.AddQuota(quota);
            OneSpanSign.API.Price price1 = new OneSpanSign.API.Price();
            price1.Amount = LIC_PLAN_PRICE_AMOUNT;
            OneSpanSign.API.Currency currency1 = new OneSpanSign.API.Currency();
            currency1.Id    = LIC_PLAN_PRICE_CURR_ID;
            currency1.Name  = LIC_PLAN_PRICE_CURR_NAME;
            currency1.Data  = LIC_PLAN_PRICE_CURR_DATA;
            price1.Currency = currency1;
            plan.Price      = price1;
            license.Plan    = plan;

            return(license);
        }
예제 #4
0
        public void ConvertAPIToAPI()
        {
            apiPlan   = CreateTypicalAPIPlan();
            converter = new PlanConverter(apiPlan);

            OneSpanSign.API.Plan plan = converter.ToAPIPlan();

            Assert.IsNotNull(plan);
            Assert.AreEqual(apiPlan, plan);
        }
예제 #5
0
        public void ConvertAPIToSDK()
        {
            apiPlan   = CreateTypicalAPIPlan();
            converter = new PlanConverter(apiPlan);
            Plan plan = converter.ToSDKPlan();

            Assert.IsNotNull(plan);
            Assert.AreEqual(PLAN_CONTRACT, plan.Contract);
            Assert.AreEqual(PLAN_PRICE_AMOUNT, plan.Price.Amount);
            Assert.AreEqual(PLAN_CYC_COUNT, plan.FreeCycles.Count);
            Assert.AreEqual(1, plan.Quotas.Count);
            Assert.AreEqual(PLAN_QUOTA_SCOPE, plan.Quotas[0].Scope);
        }
예제 #6
0
        public void ConvertSDKToAPI()
        {
            sdkPlan   = CreateTypicalSDKPlan();
            converter = new PlanConverter(sdkPlan);

            OneSpanSign.API.Plan plan = converter.ToAPIPlan();

            Assert.IsNotNull(plan);
            Assert.AreEqual(PLAN_CONTRACT, plan.Contract);
            Assert.AreEqual(PLAN_PRICE_AMOUNT, plan.Price.Amount);
            Assert.AreEqual(PLAN_CYC_COUNT, plan.FreeCycles.Count);
            Assert.AreEqual(1, plan.Quotas.Count);
            Assert.AreEqual(PLAN_QUOTA_SCOPE, plan.Quotas[0].Scope);
        }
예제 #7
0
        public OneSpanSign.API.Plan ToAPIPlan()
        {
            if (apiPlan != null)
            {
                return(apiPlan);
            }
            else if (sdkPlan != null)
            {
                OneSpanSign.API.Plan result = new OneSpanSign.API.Plan();
                result.Name             = sdkPlan.Name;
                result.Id               = sdkPlan.Id;
                result.Contract         = sdkPlan.Contract;
                result.Cycle            = sdkPlan.Cycle;
                result.Data             = sdkPlan.Data;
                result.Features         = sdkPlan.Features;
                result.Description      = sdkPlan.Description;
                result.Group            = sdkPlan.Group;
                result.Original         = sdkPlan.Original;
                result.Price            = new PriceConverter(sdkPlan.Price).ToAPIPrice();
                result.FreeCycles       = new API.CycleCount();
                result.FreeCycles.Count = sdkPlan.FreeCycles.Count;
                result.FreeCycles.Cycle = sdkPlan.FreeCycles.Cycle;
                foreach (Quota quota in sdkPlan.Quotas)
                {
                    API.Quota apiQuota = new API.Quota();
                    apiQuota.Cycle  = quota.Cycle;
                    apiQuota.Limit  = quota.Limit;
                    apiQuota.Scope  = quota.Scope;
                    apiQuota.Target = quota.Target;
                    result.Quotas.Add(apiQuota);
                }

                return(result);
            }
            else
            {
                return(null);
            }
        }
예제 #8
0
 public PlanConverter(OneSpanSign.API.Plan apiPlan)
 {
     this.apiPlan = apiPlan;
 }
예제 #9
0
        private OneSpanSign.API.Account CreateTypicalAPIAccount()
        {
            OneSpanSign.API.Account account = new OneSpanSign.API.Account();

            account.Name    = ACC_NAME;
            account.Id      = ACC_ID;
            account.Owner   = ACC_OWNER;
            account.LogoUrl = ACC_LOGOURL;
            account.Data    = ACC_DATA;
            account.Created = ACC_CREATED;
            account.Updated = ACC_UPDATED;

            OneSpanSign.API.Company company = new OneSpanSign.API.Company();
            company.Id   = ACC_CO_ID;
            company.Name = ACC_CO_NAME;
            company.Data = ACC_CO_DATA;
            OneSpanSign.API.Address address = new OneSpanSign.API.Address();
            address.Address1 = ACC_CO_ADDR_ADDR1;
            address.Address2 = ACC_CO_ADDR_ADDR2;
            address.City     = ACC_CO_ADDR_CITY;
            address.Country  = ACC_CO_ADDR_COUNTRY;
            address.State    = ACC_CO_ADDR_STATE;
            address.Zipcode  = ACC_CO_ADDR_ZIP;
            company.Address  = address;
            account.Company  = company;

            OneSpanSign.API.CustomField customField = new OneSpanSign.API.CustomField();
            customField.Id       = ACC_FIELD_ID;
            customField.Required = ACC_FIELD_IS_REQUIRED;
            customField.Value    = ACC_FIELD_DEF_VLE;
            OneSpanSign.API.Translation translation = new OneSpanSign.API.Translation();
            translation.Language = ACC_FIELD_TRANSL_LANG;
            customField.AddTranslation(translation);
            account.AddCustomField(customField);

            OneSpanSign.API.License license = new OneSpanSign.API.License();
            license.Created   = ACC_LIC_CREATED;
            license.Status    = ACC_LIC_STATUS;
            license.PaidUntil = ACC_LIC_PAIDUNTIL;
            OneSpanSign.API.Transaction transaction = new OneSpanSign.API.Transaction();
            transaction.Created = ACC_LIC_TRANS_CREATED;
            OneSpanSign.API.CreditCard creditCard = new OneSpanSign.API.CreditCard();
            creditCard.Cvv    = ACC_LIC_TRANS_CC_CVV;
            creditCard.Type   = ACC_LIC_TRANS_CC_TYPE;
            creditCard.Name   = ACC_LIC_TRANS_CC_NAME;
            creditCard.Number = ACC_LIC_TRANS_CC_NUM;
            OneSpanSign.API.CcExpiration ccExpiration = new OneSpanSign.API.CcExpiration();
            ccExpiration.Month     = ACC_LIC_TRANS_CC_EXP_MONTH;
            ccExpiration.Year      = ACC_LIC_TRANS_CC_EXP_YEAR;
            creditCard.Expiration  = ccExpiration;
            transaction.CreditCard = creditCard;
            OneSpanSign.API.Price price = new OneSpanSign.API.Price();
            price.Amount = ACC_LIC_TRANS_PRICE_AMOUNT;
            OneSpanSign.API.Currency currency = new OneSpanSign.API.Currency();
            currency.Data     = ACC_LIC_TRANS_PRICE_CURR_DATA;
            currency.Name     = ACC_LIC_TRANS_PRICE_CURR_NAME;
            currency.Id       = ACC_LIC_TRANS_PRICE_CURR_ID;
            price.Currency    = currency;
            transaction.Price = price;
            license.AddTransaction(transaction);
            OneSpanSign.API.Plan plan = new OneSpanSign.API.Plan();
            plan.Contract    = ACC_LIC_PLAN_CONTRACT;
            plan.Group       = ACC_LIC_PLAN_GRP;
            plan.Original    = ACC_LIC_PLAN_ORI;
            plan.Description = ACC_LIC_PLAN_DES;
            plan.Data        = ACC_LIC_PLAN_DATA;
            plan.Cycle       = ACC_LIC_PLAN_CYC;
            plan.Id          = ACC_LIC_PLAN_ID;
            plan.Features    = ACC_LIC_PLAN_FEAT;
            plan.Name        = ACC_LIC_PLAN_NAME;
            OneSpanSign.API.CycleCount cycleCount = new OneSpanSign.API.CycleCount();
            cycleCount.Cycle = ACC_LIC_PLAN_CYC_CYCLE;
            cycleCount.Count = ACC_LIC_PLAN_CYC_COUNT;
            plan.FreeCycles  = cycleCount;
            OneSpanSign.API.Quota quota = new OneSpanSign.API.Quota();
            quota.Target = ACC_LIC_PLAN_QUOTA_TARGET;
            quota.Limit  = ACC_LIC_PLAN_QUOTA_LIMIT;
            quota.Cycle  = ACC_LIC_PLAN_QUOTA_CYCLE;
            quota.Scope  = ACC_LIC_PLAN_QUOTA_SCOPE;
            plan.AddQuota(quota);
            OneSpanSign.API.Price price1 = new OneSpanSign.API.Price();
            price1.Amount = ACC_LIC_PLAN_PRICE_AMOUNT;
            OneSpanSign.API.Currency currency1 = new OneSpanSign.API.Currency();
            currency1.Id    = ACC_LIC_PLAN_PRICE_CURR_ID;
            currency1.Name  = ACC_LIC_PLAN_PRICE_CURR_NAME;
            currency1.Data  = ACC_LIC_PLAN_PRICE_CURR_DATA;
            price1.Currency = currency1;
            plan.Price      = price1;
            license.Plan    = plan;
            account.AddLicense(license);

            OneSpanSign.API.AccountProviders accountProviders = new OneSpanSign.API.AccountProviders();
            OneSpanSign.API.Provider         provider         = new OneSpanSign.API.Provider();
            provider.Id       = ACC_PROV_DOC_ID;
            provider.Name     = ACC_PROV_DOC_NAME;
            provider.Data     = ACC_PROV_DOC_DATA;
            provider.Provides = ACC_PROV_DOC_PROVIDES;
            accountProviders.AddDocument(provider);
            OneSpanSign.API.Provider provider1 = new OneSpanSign.API.Provider();
            provider1.Id       = ACC_PROV_USR_ID;
            provider1.Name     = ACC_PROV_USR_NAME;
            provider1.Data     = ACC_PROV_USR_DATA;
            provider1.Provides = ACC_PROV_USR_PROVIDES;
            accountProviders.AddUser(provider1);
            account.Providers = accountProviders;

            return(account);
        }