from flask import Blueprint, request

from functions.Response import sendResponse
from functions.Square import Orders, Products
from functions.Square.Auth import squareAuthToken, squareAuthUrl

squareBlueprint = Blueprint("square", __name__)

@squareBlueprint.get("/auth_url")
def auth_url():
    return sendResponse(squareAuthUrl, request)

@squareBlueprint.post("/callback")
def token():
    return sendResponse(squareAuthToken, request)

@squareBlueprint.route("/products")
def products():
    return sendResponse(Products.updateAllProducts, request, authRequired=False)

@squareBlueprint.route("/orders")
def orders():
    return sendResponse(Orders.updateAllOrders, request, authRequired=False)