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
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
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
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
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
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
def images_upsert(item_id, image_id=None):
    data = json.loads(request.data)

    response = spcall('images_upsert', (
        image_id,
        data['item_id'],
        data['image_url'],
        data['caption'],), True)

    json_dict = build_json(response)

    status_code = 200
    if not image_id:
        status_code = 201

    return jsonify(json_dict), status_code
def items_upsert(item_id=None):
    data = json.loads(request.data)

    response = spcall('items_upsert', (
        item_id,
        data['name'],
        data['description'],
        str(data['date_added']),
        str(data['date_updated']),
        data['is_active'],), True)

    json_dict = build_json(response)

    status_code = 200
    if not item_id:
        status_code = 201

    return jsonify(json_dict), status_code
def item_variations_upsert(item_id, option_id=None):
    data = json.loads(request.data)

    response = spcall('item_variations_upsert', (
        data['item_id'],
        data['option_id'],
        data['stock_on_hand'],
        data['unit_cost'],
        data['re_order_level'],
        data['re_order_quantity'],
        data['is_active'],), True)

    json_dict = build_json(response)

    status_code = 200
    if not option_id:
        status_code = 201

    return jsonify(json_dict), status_code
def options_get(option_group_id, option_id=None):
    response = spcall('options_get', (option_id, option_group_id,))

    json_dict = build_json(response)

    return jsonify(json_dict)
def locations_get(location_id=None):
    response = spcall('locations_get', (location_id,))

    json_dict = build_json(response)

    return jsonify(json_dict)
def attributes_get(attribute_id=None):
    response = spcall('attributes_get', (attribute_id,))

    json_dict = build_json(response)

    return jsonify(json_dict)
def item_variations_get(item_id, option_id=None):
    response = spcall('item_variations_get', (item_id, option_id,), )

    json_dict = build_json(response)

    return jsonify(json_dict)
def images_get(item_id, image_id=None):
    response = spcall('images_get', (image_id, item_id,), )

    json_dict = build_json(response)

    return jsonify(json_dict)
def item_attributes_get(item_id, attribute_id=None):
    response = spcall('item_attributes_get', (attribute_id, item_id,), )

    json_dict = build_json(response)

    return jsonify(json_dict)
def wishlist_items_get(wishlist_id, item_id=None):
    response = spcall("wishlist_items_get", (wishlist_id, item_id))

    json_dict = build_json(response)

    return jsonify(json_dict)