Exemple #1
0
        public async Task <(string Error, BceidAccount account)> GetBceidAccountAsync(string username, string userType)
        {
            var typeCode = userType.IsIdirUser() ? BCeIDAccountTypeCode.Internal : BCeIDAccountTypeCode.Business;

            var request = new AccountDetailRequest();

            request.requesterAccountTypeCode = typeCode;
            request.requesterUserId          = _client.ClientCredentials.UserName.UserName;
            request.accountTypeCode          = BCeIDAccountTypeCode.Business;
            request.userId          = username;
            request.onlineServiceId = _client.Osid;

            var response = await _client.getAccountDetailAsync(request);

            if (response.code != ResponseCode.Success)
            {
                return(response.message, null);
            }
            else if (response.failureCode == FailureCode.NoResults)
            {
                return("", null);
            }

            var account = new BceidAccount();

            account.Username = response.account.userId.value;
            account.UserGuid = new Guid(response.account.guid.value);
            account.UserType = userType;

            if (!account.UserType.IsBusinessUser())
            {
                account.BusinessGuid      = new Guid(response.account.business.guid.value);
                account.BusinessLegalName = response.account.business.legalName.value;
                account.BusinessNumber    = Convert.ToDecimal(response.account.business.businessNumber.value);
                account.DisplayName       = response.account.business.doingBusinessAs.value;
            }
            else
            {
                account.DisplayName = response.account.displayName.value;
            }

            account.FirstName = response.account.individualIdentity.name.firstname.value;
            account.LastName  = response.account.individualIdentity.name.surname.value;
            account.Email     = response.account.contact.email.value;

            return("", account);
        }
Exemple #2
0
        public async Task <BCeIDBusiness> ProcessBusinessQuery(string guid)
        {
            if (String.IsNullOrEmpty(url))
            {
                return(null);
            }

            // create the SOAP client
            //var binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
            BasicHttpsBinding binding = new BasicHttpsBinding {
                MaxReceivedMessageSize = int.MaxValue
            };

            binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
            binding.CloseTimeout = new TimeSpan(0, 10, 0);
            EndpointAddress address = new EndpointAddress(url);
            var             client  = new BCeIDServiceSoapClient(binding, address);

            client.ClientCredentials.UserName.UserName = user;
            client.ClientCredentials.UserName.Password = password;

            var n_guid = NormalizeGuid(guid);

            // SOAP request and parameters
            var myparams = new AccountDetailRequest();

            myparams.onlineServiceId          = svcid;
            myparams.requesterUserGuid        = n_guid;
            myparams.requesterAccountTypeCode = BCeIDAccountTypeCode.Business;
            myparams.userGuid        = n_guid;
            myparams.accountTypeCode = BCeIDAccountTypeCode.Business;

            try
            {
                var response = await client.getAccountDetailAsync(myparams);

                if (response.code == ResponseCode.Success)
                {
                    var          business = new BCeIDBusiness();
                    BCeIDAccount account  = response.account;

                    business.contactEmail = account.contact.email.value;
                    business.contactPhone = account.contact.telephone.value;

                    business.individualFirstname       = account.individualIdentity.name.firstname.value;
                    business.individualMiddlename      = account.individualIdentity.name.middleName.value;
                    business.individualOtherMiddlename = account.individualIdentity.name.otherMiddleName.value;
                    business.individualSurname         = account.individualIdentity.name.surname.value;

                    business.businessTypeName        = account.business.type.name;
                    business.businessTypeDescription = account.business.type.description;
                    business.businessTypeCode        = account.business.type.code.ToString();
                    business.businessTypeOther       = account.business.businessTypeOther.value;
                    business.legalName                   = account.business.legalName.value;
                    business.businessNumber              = account.business.businessNumber.value;
                    business.incorporationNumber         = account.business.incorporationNumber.value;
                    business.jurisdictionOfIncorporation = account.business.jurisdictionOfIncorporation.value;
                    business.addressLine1                = account.business.address.addressLine1.value;
                    business.addressLine2                = account.business.address.addressLine2.value;
                    business.addressCity                 = account.business.address.city.value;
                    business.addressProv                 = account.business.address.province.value;
                    business.addressPostal               = account.business.address.postal.value;
                    business.addressCountry              = account.business.address.country.value;
                    business.userId = account.userId.value;

                    return(business);
                }
            }
            catch (Exception)
            {
                // ignore errors and just return null
            }

            return(null);
        }
Exemple #3
0
        private async Task <(string error, BceidAccount account)> GetBceidAccountAsync(Guid?userGuid, string username, string userType, string requestorGuid, string requestorType)
        {
            var targetTypeCode    = userType.IsIdirUser() ? BCeIDAccountTypeCode.Internal : BCeIDAccountTypeCode.Business;
            var requesterTypeCode = requestorType.IsIdirUser() ? BCeIDAccountTypeCode.Internal : BCeIDAccountTypeCode.Business;

            var request = new AccountDetailRequest();

            request.requesterAccountTypeCode = requesterTypeCode;
            request.requesterUserGuid        = requestorGuid;
            request.accountTypeCode          = targetTypeCode;

            //ISA - for IDIR, only IDIR search is allowed
            if (userType.IsIdirUser())
            {
                request.userId = username;
            }
            else if (userGuid != null)
            {
                request.userGuid = userGuid?.ToString("N");
            }
            else
            {
                request.userId = username;
            }

            request.onlineServiceId = _client.Osid;

            var response = await _client.getAccountDetailAsync(request);

            if (response.code != ResponseCode.Success)
            {
                return(response.message, null);
            }
            else if (response.failureCode == FailureCode.NoResults)
            {
                return("", null);
            }

            var account = new BceidAccount();

            account.Username = response.account.userId.value;
            account.UserGuid = userGuid ?? new Guid(response.account.guid.value);
            account.UserType = userType;

            if (account.UserType.IsBusinessUser())
            {
                account.BusinessGuid      = new Guid(response.account.business.guid.value);
                account.BusinessLegalName = response.account.business.legalName.value;

                var doingBusinessAs = response.account.business.doingBusinessAs.value;
                account.DoingBusinessAs = doingBusinessAs.IsEmpty() ? account.BusinessLegalName : doingBusinessAs;

                var businessNumber = response.account.business.businessNumber.value;
                account.BusinessNumber = businessNumber.IsEmpty() ? 0 : Convert.ToDecimal(businessNumber);
            }

            account.DisplayName = response.account.displayName.value;
            account.FirstName   = response.account.individualIdentity.name.firstname.value;
            account.LastName    = response.account.individualIdentity.name.surname.value;
            account.Email       = response.account.contact.email.value;

            return("", account);
        }