Ejemplo n.º 1
0
def get_customer(customer_id):
    res = spcall('get_single_customer', (customer_id))

    if len(res) == 0:
        return jsonify({'status': 'ok', 'message': 'No entries found', 'entries': [], 'count': '0'})
    else:
        recs = []
        for r in res:
            recs.append({
                "id": customer_id,
                "first_name": r[0],
                "last_name": r[1],
                "address": r[2],
                "city": r[3],
                "state": r[4],
                "postal_code": r[5],
                "country": r[6],
                "phone": r[7],
                "email": r[8],
                "user_id": r[9],
                "billing_address": r[10],
                "shipping_address": r[11],
                "date_created": r[12]
            })
            return jsonify({'status': 'ok', 'entries': recs, 'count': len(recs)})
Ejemplo n.º 2
0
def get_all_customers():
    res = spcall('get_all_customers', ())

    if 'Error' in str(res[0][0]):
        return jsonify({'status': 'error', 'message': res[0][0]})

    recs = []
    for r in res:
        recs.append({
            "id": r[0],
            "first_name": r[1],
            "last_name": r[2],
            "address": r[3],
            "city": r[4],
            "state": r[5],
            "postal_code": r[6],
            "country": r[7],
            "phone": r[8],
            "email": r[9],
            "user_id": r[10],
            "billing_address": r[11],
            "shipping_address": r[12],
            "date_created": r[13]
        })
        return jsonify({'status': 'ok', 'entries': recs, 'count': len(recs)})
Ejemplo n.º 3
0
def delete_product_category(id):
    res = spcall("delete_product_category", (id,), True)
    if 'Error' in res[0][0]:
        return jsonify({'status': 'error', 'message': res[0][0]})

    return jsonify({'status': 'ok', 'message': res[0][0]})

    """ Todo: This route should be protected """
Ejemplo n.º 4
0
def get_wishlist_items():
    res = spcall('get_wishlist_items', ())

    if 'Error' in str(res[0][0]):
        return jsonify({'status': 'error', 'message': res[0][0]})

    recs = []
    for r in res:
        recs.append({"wishlist_item_id": r[0], "wishlist_id": r[1], "item_id": r[2], "time_stamp": r[3]})
    return jsonify({'status': 'ok', 'entries': recs, 'count': len(recs)})
Ejemplo n.º 5
0
def get_wishlist_item(wishlist_item_id):
    res = spcall('get_wishlist_item', (wishlist_item_id,))

    entries = []
    if len(res) == 0:
        return jsonify({"status": "ok", "message": "No entries found", "entries": [], "count": "0"})
    else:
        row = res[0]
        entries.append({"wishlist_item_id": r[0], "wishlist_id": r[1], "item_id": r[2], "time_stamp": r[3]})
        return jsonify({"status": "ok", "message": "ok", "entries": entries, "count": len(entries)})
Ejemplo n.º 6
0
def new_wishlist():
    data = json.loads(request.data)

    response = spcall('new_wishlist', (
        data['wishlist_id'],data['wishlist_name']), True)

    if 'Error' in response[0][0]:
        return jsonify({'status': 'error', 'message': response[0][0]})

    return jsonify({'status': 'ok', 'status_code': '200', 'message': response[0][0]}), 200
Ejemplo n.º 7
0
def get_all_wishlists():
    res = spcall('get_wishlists', ())

    if 'Error' in str(res[0][0]):
        return jsonify({'status': 'error', 'message': res[0][0]})

    recs = []
    for r in res:
        recs.append({"wishlist_id": (r[0]), "wishlist_name": (r[1])})
    return jsonify({'status': 'ok', 'entries': recs, 'count': len(recs)}), 200
Ejemplo n.º 8
0
def get_wishlist(wishlist_id):
    res = spcall('get_wishlist', (wishlist_id,))

    entries = []
    if len(res) == 0:
        return jsonify({"status": "ok", "message": "No entries found", "entries": [], "count": "0"})
    else:
        row = res[0]
        entries.append({"wishlist_id": row[0], "wishlist_name": row[1]})
        return jsonify({"status": "ok", "message": "ok", "entries": entries, "count": len(entries)})
Ejemplo n.º 9
0
def get_product_category(product_category_id):
    res = spcall('get_product_category_id', (product_category_id))

    if 'Error' in res[0][0]:
        return jsonify({'status': 'error', 'message': res[0][0]})

    r = res[0]
    return jsonify(
        {"id": str(product_category_id), "name": str(r[0]), "description": str(r[1]), "main_image": str(r[2]),
         "parent_category_id": str(r[3]), "is_active": str(r[4])})
Ejemplo n.º 10
0
def new_wishlist_item():
    json = request.json
    wishlist_item_id = json['wishlist_item_id']
    wishlist_id = json['wishlist_id']
    item_id = json['item_id']
    time_stamp = json['time_stamp']
    res = spcall('new_wishlist_item', (wishlist_item_id, wishlist_id, product_id, time_stamp), True)

    if 'Error' in res[0][0]:
        return jsonify({'status': 'error', 'message': res[0][0]})
    return jsonify({'status': 'ok', 'message': res[0][0]})
Ejemplo n.º 11
0
def get_all_suppliers():
    res = spcall('get_suppliers', ())

    if 'Error' in str(res[0][0]):
        return jsonify({'status': 'error', 'message': res[0][0]})

    recs = []
    for r in res:
        recs.append(
            {"supplier_id": str(r[0]), "name": str(r[1]), "address": str(r[2]), "phone": str(r[3]), "fax": str(r[4]),
             "email": str(r[5]), "is_active": str(r[6])})
    return jsonify({'status': 'ok', 'entries': recs, 'count': len(recs)})
Ejemplo n.º 12
0
def wishlists_upsert(wishlist_id=None):
    data = json.loads(request.data)

    response = spcall("wishlists_upsert", (wishlist_id, data["wishlist_name"]), True)

    json_dict = build_json(response)

    status_code = 200
    if not wishlist_id:
        status_code = 201

    return jsonify(json_dict), status_code
Ejemplo n.º 13
0
def wishlist_items_upsert(wishlist_id, item_id=None):
    data = json.loads(request.data)

    response = spcall("wishlist_items_upsert", (data["wishlist_id"], data["item_id"], data["time_stamp"]), True)

    json_dict = build_json(response)

    status_code = 200
    if not item_id:
        status_code = 201

    return jsonify(json_dict), status_code
Ejemplo n.º 14
0
def options_upsert(option_group_id, option_id=None):
    data = json.loads(request.data)
    response = spcall('options_upsert', (
        option_id,
        option_group_id,
        data['option_value'],), True)
    json_dict = build_json(response)

    status_code = 200
    if not option_id:
        status_code = 201

    return jsonify(json_dict), status_code
Ejemplo n.º 15
0
def new_user():
    data = json.loads(request.data)
    response = spcall('new_user', (
        data['username'],
        data['email'],
        data['password'],
        data['date_created'],
        data['is_admin'],), True)

    if 'Error' in response[0][0]:
        return jsonify({'status': 'error', 'message': response[0][0]})

    return jsonify({'status': 'ok', 'message': response[0][0]}), 201
Ejemplo n.º 16
0
def get_cart(cart_id):
    res = spcall('get_cart', (cart_id,))

    if len(res) == 0:
        return jsonify({"status": "ok", "message": "No entries found", "entries": [], "count": "0"})
    else:
        recs = []
        for r in res:
            recs.append({"session_id": r[0],
                         "date_created": str(r[1]),
                         "customer_id": r[2],
                         "is_active": r[3]})

            return jsonify({'status': 'ok', 'entries': recs, 'count': len(recs)})
Ejemplo n.º 17
0
def locations_upsert(location_id=None):
    data = json.loads(request.data)

    response = spcall('locations_upsert', (
        location_id,
        data['location_name'],), True)

    json_dict = build_json(response)

    status_code = 200
    if not location_id:
        status_code = 201

    return jsonify(json_dict), status_code
Ejemplo n.º 18
0
def get_supplier(supplier_id):
    response = spcall('get_supplier', (supplier_id,))
    entries = []
    if len(response) == 0:
        return jsonify({"status": "ok", "message": "No entries found", "entries": [], "count": "0"})
    else:
        row = response[0]
        entries.append({"supplier_id": row[0],
                        "name": row[1],
                        "address": row[2],
                        "phone": row[3],
                        "fax": row[4],
                        "email": row[5]})
        return jsonify({"status": "ok", "message": "ok", "entries": entries, "count": len(entries)})
Ejemplo n.º 19
0
def new_cart_item(cart_id):
    data = json.loads(request.data)

    response = spcall('new_cart_item', (
        data['id'],
        cart_id,
        data['product_id'],
        data['quantity'],
        data['time_stamp'],), True)

    if 'Error' in response[0][0]:
        return jsonify({'status': 'error', 'message': response[0][0]})

    return jsonify({'status': 'ok', 'message': response[0][0]}), 200
Ejemplo n.º 20
0
def get_cart_item(cart_id, cart_item_id):
    res = spcall('get_cart_item', (cart_item_id, cart_id,))

    if len(res) == 0:
        return jsonify({"status": "ok", "message": "No entries found", "entries": [], "count": "0"})
    else:
        recs = []
        for r in res:
            recs.append({"cart_id": r[0],
                         "product_id": r[1],
                         "quantity": r[2],
                         "time_stamp": str(r[3])})

            return jsonify({'status': 'ok', 'entries': recs, 'count': len(recs)})
Ejemplo n.º 21
0
def new_cart():
    data = json.loads(request.data)

    response = spcall('new_cart', (
        data['id'],
        data['session_id'],
        data['date_created'],
        data['customer_id'],
        data['is_active'],), True)

    if 'Error' in response[0][0]:
        return jsonify({'status': 'error', 'message': response[0][0]})

    return jsonify({'status': 'ok', 'message': response[0][0]}), 200
Ejemplo n.º 22
0
def attributes_upsert(attribute_id=None):
    data = json.loads(request.data)

    response = spcall('attributes_upsert', (
        attribute_id,
        data['attribute_name'],
        data['validation'],), True)

    json_dict = build_json(response)

    status_code = 200
    if not attribute_id:
        status_code = 201

    return jsonify(json_dict), status_code
Ejemplo n.º 23
0
def item_attributes_upsert(item_id, attribute_id=None):
    data = json.loads(request.data)

    response = spcall('item_attributes_upsert', (
        data['attribute_id'],
        data['item_id'],
        data['attribute_value'],), True)

    json_dict = build_json(response)

    status_code = 200
    if not attribute_id:
        status_code = 201

    return jsonify(json_dict), status_code
Ejemplo n.º 24
0
def new_order_item(order_id):
    data = json.loads(request.data)

    response = spcall('new_order_item', (
        data['id'],
        order_id,
        data['item_id'],
        data['unit_price'],
        data['discount'],
        data['quantity'],), True)

    if 'Error' in response[0][0]:
        return jsonify({'status': 'error', 'message': response[0][0]})

    return jsonify({'status': 'ok', 'message': response[0][0]}), 200
Ejemplo n.º 25
0
def get_cart_items(cart_id):
    res = spcall('get_cart_items', (cart_id,))

    if 'Error' in str(res[0][0]):
        return jsonify({'status': 'error', 'message': res[0][0]})

    recs = []
    for r in res:
        recs.append({"id": r[0],
                     "cart_id": r[1],
                     "product_id": r[2],
                     "quantity": r[3],
                     "time_stamp": r[4]})

        return jsonify({'status': 'ok', 'entries': recs, 'count': len(recs)})
Ejemplo n.º 26
0
def get_order(order_id):
    response = spcall('get_order_id', (order_id,))
    entries = []
    if len(response) == 0:
        return jsonify({"status": "ok", "message": "No entries found", "entries": [], "count": "0"})
    else:
        r = response[0]
        entries.append({"customer_id": r[0],
                        "payment_id": r[1],
                        "transaction_date": str(r[2]),
                        "shipping_date": str(r[3]),
                        "time_stamp": str(r[4]),
                        "transaction_status": str(r[5]),
                        "total": r[6]})
        return jsonify({"status": "ok", "message": "ok", "entries": entries, "count": len(entries)})
Ejemplo n.º 27
0
def get_all_users():
    res = spcall('get_users', ())

    if 'Error' in str(res[0][0]):
        return jsonify({'status': 'error', 'message': res[0][0]})

    recs = []
    for r in res:
        recs.append({"id": r[0],
                     "username": r[1],
                     "password": r[2],
                     "email": r[3],
                     "is_admin": r[4]})

        return jsonify({'status': 'ok', 'entries': recs, 'count': len(recs)})
Ejemplo n.º 28
0
def new_product_category():
    id = request.form['inputID']
    name = request.form['inputName']
    description = request.form['inputDescription']
    main_image = request.form['inputMainImage']
    parent_category_id = request.form['inputParentCategoryId']
    is_active = False

    res = spcall('new_product_category', (
        id, name, description, main_image, parent_category_id, is_active), True)

    if 'Error' in res[0][0]:
        return jsonify({'status': 'error', 'message': res[0][0]})

    return jsonify({'status': 'ok', 'message': res[0][0]})
Ejemplo n.º 29
0
def get_all_orders():
    """
    Retrieve All Orders
    """

    res = spcall('get_orders', ())

    if 'Error' in str(res[0][0]):
        return jsonify({'status': 'error', 'message': res[0][0]})

    recs = []
    for r in res:
        recs.append({"id": str(r[0]), "customer_id": str(r[1]), "payment_id": str(r[2]), "transaction_date": str(r[3]),
                     "shipping_date": str(r[4]),
                     "time_stamp": str(r[5]), "transaction_status": str(r[6]), "total": str(r[7])})
    return jsonify({'status': 'ok', 'entries': recs, 'count': len(recs)})
Ejemplo n.º 30
0
def get_order_items(order_id):
    """
    Retrieve All Order_Details
    """

    res = spcall('get_order_items', ())

    if 'Error' in str(res[0][0]):
        return jsonify({'status': 'error', 'message': res[0][0]})

    recs = []
    for r in res:
        recs.append({"id": str(r[0]), order_id: str(r[1]), "item_id": str(r[2]), "unit_price": str(r[3]),
                     "discount": str(r[4]),
                     "quantity": str(r[5])})
    return jsonify({'status': 'ok', 'entries': recs, 'count': len(recs)})