def _ccreq(self, acctid, dtstart): req = tag('CCSTMTRQ', tag('CCACCTFROM',field('ACCTID',acctid)), tag('INCTRAN', field('DTSTART',dtstart), field('INCLUDE','Y'))) return self._message('CREDITCARD','CCSTMT',req)
def _bareq(self, acctid, routing_number, dtstart, accttype): config = self.config req = tag( 'STMTRQ', tag('BANKACCTFROM', field('BANKID', str(routing_number)), field('ACCTID', acctid), field('ACCTTYPE', accttype)), tag('INCTRAN', field('DTSTART', dtstart), field('INCLUDE', 'Y'))) return self._message('BANK', 'STMT', req)
def _message(self, msgType, trnType, request): return tag( msgType + 'MSGSRQV1', tag( trnType + 'TRNRQ', field('TRNUID', _genuuid()), field('CLTCOOKIE', self._cookie()), # what is cookie used for? request))
def _invstreq(self, brokerid, acctid, dtstart): dtnow = time.strftime('%Y%m%d%H%M%S', time.localtime()) req = tag( 'INVSTMTRQ', tag('INVACCTFROM', field('BROKERID', brokerid), field('ACCTID', acctid)), tag('INCTRAN', field('DTSTART', dtstart), field('INCLUDE', 'Y')), field('INCOO', 'Y'), tag('INCPOS', field('DTASOF', dtnow), field('INCLUDE', 'Y')), field('INCBAL', 'Y')) return self._message('INVSTMT', 'INVSTMT', req)
def _bareq(self, acctid,routing_number, dtstart, accttype): config=self.config req = tag('STMTRQ', tag('BANKACCTFROM', field('BANKID', str(routing_number)), field('ACCTID',acctid), field('ACCTTYPE',accttype)), tag('INCTRAN', field('DTSTART',dtstart), field('INCLUDE','Y'))) return self._message('BANK','STMT',req)
def _invstreq(self, brokerid, acctid, dtstart): dtnow = time.strftime('%Y%m%d%H%M%S',time.localtime()) req = tag('INVSTMTRQ', tag('INVACCTFROM', field('BROKERID', brokerid), field('ACCTID',acctid)), tag('INCTRAN', field('DTSTART',dtstart), field('INCLUDE','Y')), field('INCOO','Y'), tag('INCPOS', field('DTASOF', dtnow), field('INCLUDE','Y')), field('INCBAL','Y')) return self._message('INVSTMT','INVSTMT',req)
def _signOn(self): config = self.config fidata = [ field('ORG',config['fiorg']) ] if config.has_key('fid'): fidata += [ field('FID',config['fid']) ] return tag('SIGNONMSGSRQV1', tag('SONRQ', field('DTCLIENT',_date()), field('USERID',config['user']), field('USERPASS',config['password']), field('LANGUAGE','ENG'), tag('FI', *fidata), field('APPID',config['appid']), field('APPVER',config['appver']), ))
def _bankQuery(self, acctid, routing_number, dtstart, accttype): '''Bank account statement request''' return join('\r\n', [ self._header(), tag('OFX', self._signOn(), self._bareq(acctid, routing_number, dtstart, accttype)) ])
def _signOn(self): config = self.config fidata = [field('ORG', config['fiorg'])] if config.has_key('fid'): fidata += [field('FID', config['fid'])] return tag( 'SIGNONMSGSRQV1', tag( 'SONRQ', field('DTCLIENT', _date()), field('USERID', config['user']), field('USERPASS', config['password']), field('LANGUAGE', 'ENG'), tag('FI', *fidata), field('APPID', config['appid']), field('APPVER', config['appver']), ))
def _message(self,msgType,trnType,request): return tag(msgType+'MSGSRQV1', tag(trnType+'TRNRQ', field('TRNUID',_genuuid()), field('CLTCOOKIE',self._cookie()), # what is cookie used for? request))
def _ccQuery(self, acctid, dtstart): '''CC Statement request''' return join('\r\n', [ self._header(), tag('OFX', self._signOn(), self._ccreq(acctid, dtstart)) ])
def _acctQuery(self, dtstart): return join('\r\n', [ self._header(), tag('OFX', self._signOn(), self._acctreq(dtstart)) ])
def _acctreq(self, dtstart): req = tag('ACCTINFORQ',field('DTACCTUP',dtstart)) return self._message('SIGNUP','ACCTINFO',req)
def _invstQuery(self, brokerid, acctid, dtstart): return join('\r\n',[self._header(), tag('OFX', self._signOn(), self._invstreq(brokerid, acctid,dtstart))])
def _acctQuery(self,dtstart): return join('\r\n',[self._header(), tag('OFX', self._signOn(), self._acctreq(dtstart))])
def _ccQuery(self, acctid, dtstart): '''CC Statement request''' return join('\r\n',[self._header(), tag('OFX', self._signOn(), self._ccreq(acctid, dtstart))])
def _bankQuery(self, acctid, routing_number, dtstart, accttype): '''Bank account statement request''' return join('\r\n',[self._header(), tag('OFX', self._signOn(), self._bareq(acctid, routing_number, dtstart, accttype))])
def _invstQuery(self, brokerid, acctid, dtstart): return join('\r\n', [ self._header(), tag('OFX', self._signOn(), self._invstreq(brokerid, acctid, dtstart)) ])
def _ccreq(self, acctid, dtstart): req = tag( 'CCSTMTRQ', tag('CCACCTFROM', field('ACCTID', acctid)), tag('INCTRAN', field('DTSTART', dtstart), field('INCLUDE', 'Y'))) return self._message('CREDITCARD', 'CCSTMT', req)
def _acctreq(self, dtstart): req = tag('ACCTINFORQ', field('DTACCTUP', dtstart)) return self._message('SIGNUP', 'ACCTINFO', req)