コード例 #1
0
ファイル: VerificationView.py プロジェクト: Mark-Jung/MKR
    def resend_verification(cls):
        err, status, member_id, fam_id = Auth.whoisit(request.headers)
        if err and err != 'Not a verified member':
            return json.dumps({"error_message": err}), status

        error_message, status = VerificationController.resend_verification(
            member_id)

        if error_message:
            return json.dumps({"error_message": error_message}), status
        return json.dumps({"response": "Success!"}), status
コード例 #2
0
    def get_profile(cls):
        err, status, member_id, fam_id = Auth.whoisit(request.headers)
        if err:
            return json.dumps({"error_message": err}), status

        error_message, status, response = MemberController.get_profile(
            fam_id, member_id)

        if error_message:
            return json.dumps({"error_message": error_message}), status
        return json.dumps({"response": response}), status
コード例 #3
0
ファイル: ListToCartView.py プロジェクト: Mark-Jung/MKR
    def get_cart(cls):
        err, status, member_id, fam_id = Auth.whoisit(request.headers)
        if err:
            return json.dumps({"error_message": err}), 400

        error_message, status, response = ListToCartController.get_cart(fam_id)
        if error_message:
            return json.dumps({"error_message": error_message}), status
        return json.dumps({
            "response":
            list(map(lambda x: x.json() if x else None, response))
        }), status
コード例 #4
0
    def register_family(cls):
        err, status, member_id, fam_id = Auth.whoisit(request.headers)
        if err and err != 'Not registered to family':
            return json.dumps({"error_message": err}), 400

        data = json.loads(request.data.decode('utf-8'))
        req_params = ['address_line1', 'address_line2', 'city', 'state', 'zip_code', 'name']
        if not ReqParser.check_body(data, req_params):
            return json.dumps({"error_message": "ill-formed request"}), 400

        error_message, status, response = FamilyController.register_family(data, member_id)

        if error_message:
            return json.dumps({"error_message": error_message}), status
        return json.dumps({"response": response}), status
コード例 #5
0
    def invite_by_email(cls):
        err, status, member_id, fam_id = Auth.whoisit(request.headers)
        if err:
            return json.dumps({"error_message": err}), 400
        
        data = json.loads(request.data.decode('utf-8'))
        req_params = ['admin', 'member']
        if not ReqParser.check_body(data, req_params):
            return json.dumps({"error_message": "ill-formed request"})

        error_message, status = FamilyController.invite_by_email(data['admin'], data['member'], fam_id)

        if error_message:
            return json.dumps({"error_message": error_message}), status
        return json.dumps({"response": "Success"}), status
コード例 #6
0
ファイル: VerificationView.py プロジェクト: Mark-Jung/MKR
    def verify_member(cls):
        err, status, member_id, fam_id = Auth.whoisit(request.headers)
        if err and err != 'Not a verified member':
            return json.dumps({"error_message": err}), status

        data = json.loads(request.data.decode('utf-8'))
        req_params = ["verification_code"]
        if not ReqParser.check_body(data, req_params):
            return json.dumps({"error_message": "ill-formed request"}), 400
        error_message, status = VerificationController.verify_member(
            data['verification_code'], member_id)

        if error_message:
            return json.dumps({"error_message": error_message}), status
        return json.dumps({"response": "Success!"}), status
コード例 #7
0
ファイル: ListToCartView.py プロジェクト: Mark-Jung/MKR
    def register_list_to_cart(cls):
        err, status, member_id, fam_id = Auth.whoisit(request.headers)
        if err:
            return json.dumps({"error_message": err}), 400

        data = json.loads(request.data.decode('utf-8'))
        req_params = ["alias", "in_store"]
        if not ReqParser.check_body(data, req_params):
            return json.dumps({"error_message": "ill-formed request"}), 400

        error_message, status = ListToCartController.register_list(
            member_id, fam_id, data['alias'], data['in_store'])

        if error_message:
            return json.dumps({"error_message": error_message}), status
        return json.dumps({"response": "Success!"}), status
コード例 #8
0
    def checkout(cls):
        err, status, member_id, fam_id = Auth.whoisit(request.headers)
        if err:
            return json.dumps({"error_message": err}), status

        data = json.loads(request.data.decode('utf-8'))
        req_params = ['total', 'items']
        if not ReqParser.check_body(data, req_params):
            return json.dumps({"error_message": "ill-formed request"}), 400

        error_message, status = CheckoutController.checkout(
            member_id, fam_id, data['total'], data['items'])

        if error_message:
            return json.dumps({"error_message": error_message}), status
        return json.dumps({"response": "Success!"}), 200
コード例 #9
0
    def signin_by_token(cls):
        err, status, member_id, fam_id = Auth.whoisit(request.headers)
        if err:
            if member_id == 0:
                return json.dumps({"error_message": err}), status
            else:
                return json.dumps({"response": err}), 200

        auth_header = request.headers.get('Authorization')

        error_message, status, token = MemberController.update_token(
            auth_header.split(" ")[1])

        if error_message:
            return json.dumps({"error_message": error_message}), status
        return json.dumps({"response": token, "uid": member_id}), status
コード例 #10
0
    def edit_niche(cls):
        err, status, member_id, fam_id = Auth.whoisit(request.headers)
        if err:
            return json.dumps({"error_message": err}), 400

        data = json.loads(request.data.decode('utf-8'))
        req_params = [
            'device_id', 'alert_level', 'container', 'alias',
            'auto_order_store', 'product_metadata'
        ]
        if not ReqParser.check_body(data, req_params):
            return json.dumps({"error_message": "ill-formed request"}), 400

        error_message, status = DeviceDataController.edit_niche(fam_id, data)

        if error_message:
            return json.dumps({"error_message": error_message}), status
        return json.dumps({"response": "Success"}), status
コード例 #11
0
ファイル: ListToCartView.py プロジェクト: Mark-Jung/MKR
    def delete_cart(cls):
        err, status, member_id, fam_id = Auth.whoisit(request.headers)
        if err:
            return json.dumps({"error_message": err}), 400

        data = json.loads(request.data.decode('utf-8'))
        req_params = ["victim_ids"]
        if not ReqParser.check_body(data, req_params):
            return json.dumps({"error_message": "ill-formed request"}), 400

        error_message, status, response = ListToCartController.delete_cart(
            fam_id, data['victim_ids'])
        if error_message:
            return json.dumps({"error_message": error_message}), status
        return json.dumps({
            "response":
            list(map(lambda x: x.json() if x else None, response))
        }), status
コード例 #12
0
    def change_shadow_fam(cls):
        """
        allow other users to change when this scenario becomes common
        """
        err, status, member_id, fam_id = Auth.whoisit(request.headers)
        if err:
            return json.dumps({"error_message": err}), status

        data = json.loads(request.data.decode('utf-8'))
        req_params = ['secret', 'device_id']
        if not ReqParser.check_body(data, req_params):
            return json.dumps({"error_message": "ill-formed request"}), 400

        error_message, status = DeviceDataController.change_shadow_fam(
            fam_id, data)

        if error_message:
            return json.dumps({"error_message": error_message}), status
        return json.dumps({"response": "Success"}), status
コード例 #13
0
ファイル: ListToCartView.py プロジェクト: Mark-Jung/MKR
    def edit_list_to_cart(cls):
        err, status, member_id, fam_id = Auth.whoisit(request.headers)
        if err:
            return json.dumps({"error_message": err}), 400

        data = json.loads(request.data.decode('utf-8'))

        req_params = [
            "alias", "in_cart", "in_store", "item_name", "item_image",
            "item_price", "item_quantity", "list_to_cart_id"
        ]
        if not ReqParser.check_body(data, req_params):
            return json.dumps({"error_message": "ill-formed request"}), 400

        error_message, status = ListToCartController.edit_list_to_cart(
            fam_id, data)
        if error_message:
            return json.dumps({"error_message": error_message}), status
        return json.dumps({"response": "Success"}), status