def add_customer(token: str, name: str, phone: str, id_number: str, deposit: float = None): if deposit is not None: return do_post_request('/customer/add', headers={TOKEN_HEADER_KEY: token}, data={'name': name, 'phone': phone, 'id_number': id_number, 'deposit': deposit}) else: return do_post_request('/customer/add', headers={TOKEN_HEADER_KEY: token}, data={'name': name, 'phone': phone, 'id_number': id_number})
def customer_loan_repay(token: str, loan_record_id: int, repay: float = None): if repay is not None: return do_post_request('/loan/repay', headers={TOKEN_HEADER_KEY: token}, data={'loan_record_id': loan_record_id, 'repay': repay}) else: return do_post_request('/loan/repay', headers={TOKEN_HEADER_KEY: token}, data={'loan_record_id': loan_record_id})
def customer_deposit(token: str, customer_id: int, deposit_date: str, new_deposit: float = None): if new_deposit is not None: return do_post_request('/deposit', headers={TOKEN_HEADER_KEY: token}, data={'customer_id': customer_id, 'new_deposit': new_deposit, 'deposit_date': deposit_date}) else: return do_post_request('/deposit', headers={TOKEN_HEADER_KEY: token}, data={'customer_id': customer_id})
def issue_stock(token: str, stock_name: str, issue_date: str, issue_price: float = None): if issue_price is not None: return do_post_request('/market/issue_stock', headers={TOKEN_HEADER_KEY: token}, data={'stock_name': stock_name, 'issue_date': issue_date, 'issue_price': issue_price}) else: return do_post_request('/market/issue_stock', headers={TOKEN_HEADER_KEY: token}, data={'stock_name': stock_name, 'issue_date': issue_date})
def issue_regular_deposit(token: str, regular_deposit_name: str, issue_date: str, return_cycle: int, return_rate: float = None): if return_rate is not None: return do_post_request('/market/issue_regular_deposit', headers={TOKEN_HEADER_KEY: token}, data={'regular_deposit_name': regular_deposit_name, 'issue_date': issue_date, 'return_cycle': return_cycle, 'return_rate': return_rate}) else: return do_post_request('/market/issue_regular_deposit', headers={TOKEN_HEADER_KEY: token}, data={'regular_deposit_name': regular_deposit_name, 'issue_date': issue_date, 'return_cycle': return_cycle})
def buy_stock(token: str, customer_id: int, stock_id: int, new_position_share: float, purchase_date: str = None): if purchase_date is not None: return do_post_request('/investment/buy_stock', headers={TOKEN_HEADER_KEY: token}, data={'customer_id': customer_id, 'stock_id': stock_id, 'new_position_share': new_position_share, 'purchase_date': purchase_date}) else: return do_post_request('/investment/buy_stock', headers={TOKEN_HEADER_KEY: token}, data={'customer_id': customer_id, 'stock_id': stock_id, 'new_position_share': new_position_share})
def buy_regular_deposit(token: str, customer_id: int, regular_deposit_id: int, purchase_amount: float, purchase_date: str = None): if purchase_date is not None: return do_post_request('/investment/buy_regular_deposit', headers={TOKEN_HEADER_KEY: token}, data={'customer_id': customer_id, 'regular_deposit_id': regular_deposit_id, 'purchase_amount': purchase_amount, 'purchase_date': purchase_date}) else: return do_post_request('/investment/buy_regular_deposit', headers={TOKEN_HEADER_KEY: token}, data={'customer_id': customer_id, 'regular_deposit_id': regular_deposit_id, 'purchase_amount': purchase_amount})
def buy_fund(token: str, customer_id: int, fund_id: int, purchase_amount: float, purchase_date: str, return_cycle: int = None): if return_cycle is not None: return do_post_request('/investment/buy_fund', headers={TOKEN_HEADER_KEY: token}, data={'customer_id': customer_id, 'fund_id': fund_id, 'purchase_amount': purchase_amount, 'purchase_date': purchase_date, 'return_cycle': return_cycle}) else: return do_post_request('/investment/buy_fund', headers={TOKEN_HEADER_KEY: token}, data={'customer_id': customer_id, 'fund_id': fund_id, 'purchase_amount': purchase_amount, 'purchase_date': purchase_date})
def customer_loan(token: str, customer_id: int, payment: float, repay_cycle: int, created_time: str = None): if created_time is not None: return do_post_request('/loan/request_loan', headers={TOKEN_HEADER_KEY: token}, data={'customer_id': customer_id, 'payment': payment, 'repay_cycle': repay_cycle, 'created_time': created_time}) else: return do_post_request('/loan/request_loan', headers={TOKEN_HEADER_KEY: token}, data={'customer_id': customer_id, 'payment': payment, 'repay_cycle': repay_cycle})
def loan_auto_repay(token: str): return do_post_request('/loan/auto_repay', headers={TOKEN_HEADER_KEY: token})
def sys_register(account: str, password: str, name: str, phone: str = None): if phone is not None: return do_post_request('/system/register', data={'account': account, 'password': password, 'name': name, 'phone': phone}) else: return do_post_request('/system/register', data={'account': account, 'password': password, 'name': name})
def sys_logout(token: str): return do_post_request('/system/logout', headers={TOKEN_HEADER_KEY: token})
def sys_login(username: str, password: str = None): if password is not None: params_dict = {'account': username, 'password': password} else: params_dict = {'account': username} return do_post_request('/system/login', data=params_dict)