def get_company(self, account, company_uuid): ''' Get a detail company ''' message = None if not account: company = yield self.db.companies.find_one( {'uuid':company_uuid}, {'_id':0} ) else: # change accountcode to account, because the accountcode is a uuid # and we're expecting an account name. company = yield self.db.companies.find_one( {'uuid':company_uuid, 'account':account}, {'_id':0} ) try: if company: company = companies.Company(company) company.validate() message = clean_structure(company) except Exception, e: logging.error(e) # catch some daemon here! message = str(e) # clean this or something... raise e
def get_contactx_list(self, account, checked, page_num): ''' Get contact list ''' page_num = int(page_num) page_size = self.settings.get('page_size') contact_list = [] # remove phone_2, phone_3 and contact_requests from query stuff and db. query = self.db.contacts.find({ 'account': account, 'checked': checked }, { '_id': 0, 'phone_2': 0, 'phone_3': 0, 'contact_requests': 0 }) q = query q = q.sort([('_id', -1) ]).skip(int(page_num) * page_size).limit(page_size) try: while (yield q.fetch_next): contact = contacts.Contact(q.next_object()) contact_list.append(clean_structure(contact)) except Exception, e: logging.exception(e) raise gen.Return(e)
def get_transaction_list(self, account, checked, page_num): ''' Get contact list ''' page_num = int(page_num) page_size = self.settings.get('page_size') transaction_list = [] query = self.db.transactions.find( { #'account':account, 'checked': checked }, { '_id': 0, }) q = query q = q.sort([('_id', -1) ]).skip(int(page_num) * page_size).limit(page_size) try: while (yield q.fetch_next): transaction = cuallix.Transaction(q.next_object()) transaction_list.append(clean_structure(transaction)) except Exception, e: logging.exception(e) raise gen.Return(e)
def get_transaction_list(self, account, checked, page_num): ''' Get contact list ''' page_num = int(page_num) page_size = self.settings.get('page_size') transaction_list = [] query = self.db.transactions.find( { #'account':account, 'checked':checked }, { '_id':0, } ) q = query q = q.sort([('_id', -1)]).skip(int(page_num) * page_size).limit(page_size) try: while (yield q.fetch_next): transaction = cuallix.Transaction(q.next_object()) transaction_list.append(clean_structure(transaction)) except Exception, e: logging.exception(e) raise gen.Return(e)
def get_company(self, account, company_uuid): ''' Get a detail company ''' message = None if not account: company = yield self.db.companies.find_one({'uuid': company_uuid}, {'_id': 0}) else: # change accountcode to account, because the accountcode is a uuid # and we're expecting an account name. company = yield self.db.companies.find_one( { 'uuid': company_uuid, 'account': account }, {'_id': 0}) try: if company: company = companies.Company(company) company.validate() message = clean_structure(company) except Exception, e: logging.error(e) # catch some daemon here! message = str(e) # clean this or something... raise e
def modify_transaction(self, account, transaction_uuid, struct): ''' Modify transaction ''' try: transaction = cuallix.Transaction(struct) transaction.validate() transaction = clean_structure(transaction) except Exception, e: logging.error(e) raise e
def new_payment(self, struct): ''' New payment ''' try: payment = payments.Payment(struct) payment.validate() payment = clean_structure(payment) except Exception, e: logging.error(e) raise e
def report_transactions(self, struct): ''' Report Transactions ''' uri = '{0}/CLXAPI/Services/Report/Transactions'.format(self.url) try: result = payments.ReportTransactions(struct) result.validate() result = clean_structure(result) except Exception, e: logging.error(e) raise e
def date_range_search_transactions(self, struct): ''' DateRange search transactions ''' uri = '{0}/CLXAPI/UserServices/Transactions/DateRange'.format(self.url) try: result = payments.DateRange(struct) result.validate() result = clean_structure(result) except Exception, e: logging.error(e) raise e
def settle_transaction(self, struct): ''' Settle transaction ''' uri = '{0}/CLXAPI/Services/Transactions/Settle'.format(self.url) try: settle = payments.SettleTransaction(struct) settle.validate() settle = clean_structure(settle) except Exception, e: logging.error(e) raise e
def load_funds(self, struct): ''' Account load funds ''' uri = '{0}/CLXAPI/UserServices/Account/LoadFunds'.format(self.url) try: funds = cuallix.LoadFunds(struct) funds.validate() funds = clean_structure(funds) except Exception, e: logging.error(e) raise e
def assign_account(self, struct): ''' User assign account ''' uri = '{0}/CLXAPI/UserServices/Account/Assign'.format(self.url) try: assign = cuallix.Assign(struct) assign.validate() assign = clean_structure(assign) except Exception, e: logging.error(e) raise e
def get_payment_url(self, struct): ''' Request payment URL on the CLX API ''' uri = '{0}/CLXAPI/Services/CrossBranded/RequestUrl'.format(self.url) try: payment_url = cuallix.PaymentUrl(struct) payment_url.validate() payment_url = clean_structure(payment_url) except Exception, e: logging.error(e) raise e
def customer_register(self, struct): ''' Register customer on the CLX API ''' uri = '{0}/CLXAPI/Services/Customer/Register'.format(self.url) try: register = cuallix.RegisterCustomer(struct) register.validate() register = clean_structure(register) except Exception, e: logging.error(e) raise e
def status_transaction(self, struct): ''' Status transaction ''' uri = '{0}/CLXAPI/CustomerServices/Transactions/Status'.format(self.url) try: status = payments.TransactionStatus(struct) status.validate() status = clean_structure(status) except Exception, e: logging.error(e) raise e
def send_money(self, struct): ''' Send Money on the CLX API ''' uri = '{0}/CLXAPI/CustomerServices/MoneyTransfer/SendMoney'.format(self.url) try: send_money = cuallix.SendMoney(struct) send_money.validate() send_money = clean_structure(send_money) except Exception, e: logging.error(e) raise e
def search_customer(self, struct): ''' Search customer on the CLX API ''' uri = '{0}/CLXAPI/Services/Customer/Search'.format(self.url); try: customer = cuallix.SearchCustomer(struct) customer.validate() customer = clean_structure(customer) except Exception, e: logging.error(e) raise e
def search_customer(self, struct): ''' Search customer on the CLX API ''' uri = '{0}/CLXAPI/Services/Customer/Search'.format(self.url) try: customer = cuallix.SearchCustomer(struct) customer.validate() customer = clean_structure(customer) except Exception, e: logging.error(e) raise e
def send_money(self, struct): ''' Send Money on the CLX API ''' uri = '{0}/CLXAPI/CustomerServices/MoneyTransfer/SendMoney'.format( self.url) try: send_money = cuallix.SendMoney(struct) send_money.validate() send_money = clean_structure(send_money) except Exception, e: logging.error(e) raise e
def status_transaction(self, struct): ''' Status transaction ''' uri = '{0}/CLXAPI/CustomerServices/Transactions/Status'.format( self.url) try: status = payments.TransactionStatus(struct) status.validate() status = clean_structure(status) except Exception, e: logging.error(e) raise e
def get_transaction(self, account, TransactionNum): ''' Get transaction ''' message = None logging.info('{0} get transaction {1}'.format(account, TransactionNum)) try: result = yield self.db.transactions.find_one( {'transaction': TransactionNum}, {'_id':0} # remove this stuff from db. ) logging.info('{0} this is the result'.format(str(result))) if result: transaction = cuallix.Transaction(result) transaction.validate() message = clean_structure(transaction) except Exception, e: logging.exception(e) raise e
def get_transaction(self, account, TransactionNum): ''' Get transaction ''' message = None logging.info('{0} get transaction {1}'.format(account, TransactionNum)) try: result = yield self.db.transactions.find_one( {'transaction': TransactionNum}, {'_id': 0} # remove this stuff from db. ) logging.info('{0} this is the result'.format(str(result))) if result: transaction = cuallix.Transaction(result) transaction.validate() message = clean_structure(transaction) except Exception, e: logging.exception(e) raise e
results = clean_results(results) raise gen.Return(results) @gen.coroutine def new_company(self, struct): ''' Create a new company entry ''' try: company = companies.Company(struct) company.validate() except Exception, e: logging.exception(e) raise e company = clean_structure(company) result = yield self.db.companies.insert(company) raise gen.Return(company.get('uuid')) @gen.coroutine def set_assigned_flag(self, account, company_uuid): ''' Set the company assigned flag ''' logging.info('set_assigned_flag account: %s, company: %s' % (account, company_uuid)) result = yield self.db.companies.update( {
results = clean_results(results) raise gen.Return(results) @gen.coroutine def new_company(self, struct): ''' Create a new company entry ''' try: company = companies.Company(struct) company.validate() except Exception, e: logging.exception(e) raise e company = clean_structure(company) result = yield self.db.companies.insert(company) raise gen.Return(company.get('uuid')) @gen.coroutine def set_assigned_flag(self, account, company_uuid): ''' Set the company assigned flag ''' logging.info('set_assigned_flag account: %s, company: %s' % (account, company_uuid)) result = yield self.db.companies.update( {'uuid':company_uuid, 'accountcode':account},