예제 #1
0
        public OFX2Service(Types.FinancialInstitution financialInstitution, Credentials userCredentials)
        {
            this.financialInstitution = financialInstitution;
            this.userCredentials = userCredentials;

            // Setup default MessageSetData  - used in requests that do not have more specific data
            defaultMessageSetProfile = new DefaultMessageSetRequestProfile(financialInstitution.ServiceEndpoint,
                "Realm1");
        }
예제 #2
0
        public async Task TestListFiProfiles()
        {
            // Retrieve financial institutions
            var financialInstitutions = OFX2Service.ListFinancialInstitutions();

            // Default empty credentials
            var emptyCredentials = new Credentials("","");

            // Step through each, count success and failure
            int successCount = 0;
            int failureCount = 0;
            foreach (var fi in financialInstitutions)
            {
                var ofxService = new OFX2Service(fi, emptyCredentials);

                // Only test a few entries during a normal run. Each entry can take a significant amount of time to test.
                if (successCount + failureCount > 5)
                    continue;

                try
                {
                    var profiles = await ofxService.ListProfiles();

                    // At least 1 profile should come back
                    if (profiles.Items.Length == 0)
                    {
                        // Manual diagnostics assistance
                        Trace.WriteLine("No profiles returned for " + fi.Name + " at " + fi.ServiceEndpoint);
                        failureCount++;
                    }
                    else
                    {
                        successCount++;
                    }
                }
                catch (Exception)
                {
                    // Any exception is a failure
                    failureCount++;

                    // Manual diagnostics assistance
                    Trace.WriteLine("Failed to list profiles for " + fi.Name + " at " + fi.ServiceEndpoint);
                }
            }

            // At least 1 of the profiles should succed
            Assert.IsTrue(successCount >= 1);

        }
예제 #3
0
        /// <summary>
        /// Populates a signon request for this service using the provided user credentials.
        /// Some OFX calls can use special credentials different than a FI account holder, so this method
        ///   allows the caller to specify credentials
        /// </summary>
        /// <param name="credentials">Authentication credentials to use for this request. If no credentials are specified, the default user credentials for the service are used.</param>
        /// <param name="requestProfile">Request profile specifying communication parameters for this request</param>
        /// <returns></returns>
        protected SignonRequestMessageSetV1 CreateSignonRequest(Credentials credentials=null, MessageSetRequestProfile requestProfile=null)
        {
            // If no credentials are specified, use the default user credentials assigned when the service was constructed
            if (credentials == null)
                credentials = userCredentials;
            // If no request profile is specified, use the default
            if (requestProfile == null)
                requestProfile = defaultMessageSetProfile;

            // Populate the FinancialInstitution data
            var fi = new FinancialInstitution
            {
                ORG = financialInstitution.OrganizationId,
                FID = financialInstitution.FinancialId
            };

            // Populate a signon request with the current date and provided user credentials
            var signonRequest = new SignonRequest
            {
                DTCLIENT = OFXUtils.DateToOFX(new DateTimeOffset(DateTime.Now)),
                ItemsElementName = new ItemsChoiceType[2] {ItemsChoiceType.USERID, ItemsChoiceType.USERPASS},
                Items = new string[2] {credentials.UserId, credentials.Password},
                FI = fi,
                LANGUAGE = LanguageEnum.ENG,
                APPID = appId,
                APPVER = appVer
            };

            // Wrap the signon request in a signon message set, per protocol
            var signonMessageSet = new SignonRequestMessageSetV1 {SONRQ = signonRequest};

            // Return the fully populated request
            return signonMessageSet;
        }