def get_all_products(self): res = requests.get(self.url + "products", auth = self.auth).json() ret = [] for pr in res: pr['ir_type'] = 'order' ret.append(irconverter.convert(pr)) return ret
def get_accounts(self): res = requests.get(self.url + 'accounts', auth = self.auth).json() ret = [] for acc in res: acc['ir_type'] = 'account' ret.append(irconverter.convert(acc)) return ret
def cancel_order(self, order): res = requests.delete(self.url + f'orders/{order.id}?product_id={order.product_id}', auth=self.auth) return irconverter.convert(res)
def limit_order(self, limit_order): res = requests.post(self.url + 'orders', json=limit_order, auth=self.auth).json() res['ir_type'] = 'order' return irconverter.convert(res)
def get_product_book(self, product_id, level=1): level_str = "" if level == 1 else f"?level={str(min(3, level))}" res = requests.get(self.url + f"products/{product_id}/book{level_str}", auth = self.auth) return irconverter.convert(res)
def get_product(self, product_id): res = requests.get(self.url + f"products/{product_id}", auth = self.auth).json() res['ir_type'] = 'product' return irconverter.convert(res)
def get_account_history(self, account_id): res = requests.get(self.url + f'accounts/{account_id}/ledger', auth=self.auth) return irconverter.convert(res)
def get_account(self, account_id): res = requests.get(self.url + f'accounts/{account_id}', auth=self.auth).json() res['ir_type'] = account return irconverter.convert(res)