Beispiel #1
0
 def get_creditcard_statement(self, account, username, password):
     """Sends an OFX request for the given user's credit card
     statement, and returns that statement if the request is
     successful.  If the OFX server returns an error, the client
     will throw an OfxException indicating the error code and
     message."""
     # See comments in get_bank_statement, above, which explain these try/catch
     # blocks.
     request = ofx.Request()
     try:
         self.request_msg = request.creditcard_stmt(account,
                                                    username,
                                                    password,
                                                    daysago=365)
         return self._send_request(account.institution.ofx_url,
                                   self.request_msg)
     except ofx.Error, detail:
         try:
             self.request_msg = request.creditcard_stmt(account,
                                                        username,
                                                        password,
                                                        daysago=90)
             return self._send_request(account.institution.ofx_url,
                                       self.request_msg)
         except ofx.Error, detail:
             self.request_msg = request.creditcard_stmt(account,
                                                        username,
                                                        password,
                                                        daysago=30)
             return self._send_request(account.institution.ofx_url,
                                       self.request_msg)
Beispiel #2
0
 def get_bank_statement(self, account, username, password):
     """Sends an OFX request for the given user's bank account
     statement, and returns that statement as an OFX document if
     the request is successful."""
     request = ofx.Request()
     # I'm breaking out these retries by statement type since I'm assuming that bank,
     # credit card, and investment OFX servers may each have different behaviors.
     try:
         # First, try to get a statement for the full year.  The USAA and American Express
         # OFX servers return a valid statement, although USAA only includes 90 days and
         # American Express seems to only include back to the first of the year.
         self.request_msg = request.bank_stmt(account,
                                              username,
                                              password,
                                              daysago=365)
         return self._send_request(account.institution.ofx_url,
                                   self.request_msg)
     except ofx.Error, detail:
         try:
             # If that didn't work, try 90 days back.
             self.request_msg = request.bank_stmt(account,
                                                  username,
                                                  password,
                                                  daysago=90)
             return self._send_request(account.institution.ofx_url,
                                       self.request_msg)
         except ofx.Error, detail:
             # If that also didn't work, try 30 days back, which has been our default and
             # which always seems to work across all OFX servers.
             self.request_msg = request.bank_stmt(account,
                                                  username,
                                                  password,
                                                  daysago=30)
             return self._send_request(account.institution.ofx_url,
                                       self.request_msg)
Beispiel #3
0
 def get_fi_profile(self,
                    institution,
                    username="******",
                    password="******"):
     request = ofx.Request()
     self.request_msg = request.fi_profile(institution, username, password)
     return self._send_request(institution.ofx_url, self.request_msg)
Beispiel #4
0
 def get_bank_closing(self, account, username, password):
     """Sends an OFX request for the given user's bank account
     statement, and returns that statement as an OFX document if
     the request is successful."""
     acct_type = account.get_ofx_accttype()
     request = ofx.Request()
     self.request_msg = request.bank_closing(account, username, password)
     return self._send_request(account.institution.ofx_url, self.request_msg)
Beispiel #5
0
 def get_creditcard_closing(self, account, username, password):
     """Sends an OFX request for the given user's credit card
     statement, and returns that statement if the request is
     successful.  If the OFX server returns an error, the client
     will throw an OfxException indicating the error code and
     message."""
     request = ofx.Request()
     self.request_msg = request.creditcard_closing(account, username, password)
     return self._send_request(account.institution.ofx_url, self.request_msg)
Beispiel #6
0
 def setUp(self):
     self.request = ofx.Request()
     self.institution = ofx.Institution(ofx_org="fi_name", ofx_fid="1000")
     self.account = ofx.Account(acct_number="00112233",
                                aba_number="12345678",
                                acct_type="Checking",
                                institution=self.institution)
     self.username = "******"
     self.password = "******"
     self.parser  = ofx.Parser()
Beispiel #7
0
 def get_account_info(self, institution, username, password):
     request = ofx.Request()
     self.request_msg = request.account_info(institution, username,
                                             password)
     return self._send_request(institution.ofx_url, self.request_msg)