def otp_check(self): self.reqmsg = messages.phone_check_req.copy() self.reqmsg['header'].update(self.msg_hdr['header']) self.reqmsg['sender']['username'] = self.username self.reqmsg['sender']['target'] = self.target self.reqmsg['sender']['response_mode'] = 'sms' send_request(self.conn, self.reqmsg) # Parse and dump the JSON response from server objs = handle_response(self.conn, self.reqmsg['header']['msg_type']) self.response_key = objs['data'].get('challenge_key', 1234) # send challenge response self.reqmsg = messages.phone_check_resp.copy() self.reqmsg['header'].update(self.msg_hdr['header']) self.reqmsg['sender']['username'] = self.username self.reqmsg['sender']['response_key'] = self.response_key send_request(self.conn, self.reqmsg) objs = handle_response(self.conn, self.reqmsg['header']['msg_type']) self.uid = objs['data']['user_id'] self.key = str(self.global_index) global_user_list.append({self.key: dict(uid=self.uid)})
def get_cards(self): self.reqmsg = messages.get_cards.copy() self.reqmsg['header'].update(self.msg_hdr['header']) self.reqmsg['sender']['user_id'] = self.uid self.reqmsg['sender']['wizuser_id'] = self.wuid send_request(self.conn, self.reqmsg) objs = handle_response(self.conn, self.reqmsg['header']['msg_type'])
def entity_access(self, entity_id, entity_type='EVT', state=1): self.reqmsg = messages.entity_access.copy() self.reqmsg['header'].update(self.msg_hdr['header']) self.reqmsg['sender']['user_id'] = self.uid self.reqmsg['sender']['wizuser_id'] = self.wuid self.reqmsg['sender']['entity_id'] = entity_id self.reqmsg['sender']['entity_type'] = entity_type self.reqmsg['sender']['state'] = state send_request(self.conn, self.reqmsg) objs = handle_response(self.conn, self.reqmsg['header']['msg_type'])
def add_wizcard(self): self.reqmsg = messages.edit_card.copy() self.reqmsg['header'].update(self.msg_hdr['header']) self.reqmsg['sender']['user_id'] = self.uid self.reqmsg['sender']['wizuser_id'] = self.wuid self.reqmsg['sender']['first_name'] = names.get_first_name() self.reqmsg['sender']['last_name'] = names.get_last_name() send_request(self.conn, self.reqmsg) objs = handle_response(self.conn, self.reqmsg['header']['msg_type']) self.wc_id = objs['data']['wizcard']['wizcard_id'] global_user_list[self.global_index][self.key].update(wc_id=self.wc_id)
def login(self): self.reqmsg = messages.login.copy() self.reqmsg['header'].update(self.msg_hdr['header']) self.reqmsg['sender']['user_id'] = self.uid self.reqmsg['sender']['username'] = self.username self.reqmsg['sender']['password'] = self.password(self.uid) send_request(self.conn, self.reqmsg) objs = handle_response(self.conn, self.reqmsg['header']['msg_type']) self.wuid = objs['data']['wizuser_id'] global_user_list[self.global_index][self.key].update(wuid=self.wuid)
#!/usr/bin/python # Test WizCard client (the real one resides on a smartphone - iphone, android) # Standard imports import httplib import messages import libtest import pdb from libtest import send_request, handle_response, APP_VERSION server_url = "localhost" server_port = 8000 # Open the connection to Wiz server conn = httplib.HTTPConnection(server_url, server_port) f = open(libtest.ocr_image_path, 'rb') ocr_out = f.read().encode('base64') reqmsg = messages.ocr_req_self reqmsg['header']['version'] = APP_VERSION reqmsg['sender']['user_id'] = '6595f5d1-b194-4649-9b32-e69e61052c12' reqmsg['sender']['wizuser_id'] = 8 reqmsg['sender']['f_ocr_card_image'] = ocr_out send_request(conn, reqmsg) # Parse and dump the JSON response from server objs = handle_response(conn, reqmsg['header']['msg_type']) contact_container = objs['data']['ocr_result']['contact_container']
def send(self, err_skip=False): self.reqmsg['header'].update(self.msg_hdr['header']) send_request(self.conn, self.reqmsg) objs = handle_response(self.conn, self.reqmsg['header']['msg_type']) return objs