""" import requests

token_url = "https://auth.smartpos.cz/auth/realms/sdc/protocol/openid-connect/token"
client_id = "sdc"
client_secret = "6db26b7e-48a7-46c7-ac2f-4467993fd1b3"
username = "student"
password = "T5msT6k1"

payload = {
    'grant_type': 'password',
    'client_id': client_id,
    'client_secret': client_secret,
    'username': username,
    'password': password,
    'scope': 'roles'
}

response = requests.post(token_url, data=payload)

if response.status_code == 200:
    token_data = response.json()
    access_token = token_data['access_token']
    print("Success Token received. "+access_token)
else:
    print("Error getting token: {response.text}")
    exit()


api_base = "https://orders.smartpos.cz/"
remote_code = "SMARTPOS"
 """



import requests

token_url = "https://auth.smartpos.cz/auth/realms/sdc/protocol/openid-connect/token"
client_id = "sdc"
client_secret = "6db26b7e-48a7-46c7-ac2f-4467993fd1b3"
username = "student"
password = "T5msT6k1"


payload = {
    'grant_type': 'password',
    'client_id': client_id,
    'client_secret': client_secret,
    'username': username,
    'password': password,
    'scope': 'roles'
}

response = requests.post(token_url, data=payload)

if response.status_code == 200:
    token_data = response.json()
    access_token = token_data['access_token']
    print("Success! Token received.")
else:
    print("Error getting token: {response.text}")
    exit()

api_base = "https://orders.smartpos.cz/"
remote_code = "SMARTPOS"


order_endpoint = f"{api_base}/api/v2/external-order/v1/remoteId/{remote_code}"

headers = {
    'Authorization': f'Bearer {access_token}',
    'Content-Type': 'application/json'
}


response = requests.get(f"{api_base}/api/v2/external-order/v1/shops/remoteCode/{remote_code}")

print(response)



""" order_payload = {
    "remoteCode": remote_code,
    "items": [
        {"productId": "7175841", "quantity": 1}
    ],
    "customer": {
        "name": "Test Student" # Optional, depending on docs
    }
}

order_response = requests.post(order_endpoint, json=order_payload, headers=headers)

if order_response.status_code in [200, 201]:
    print("Order Placed Successfully!")
    print(order_response.json())
else:
    print(f"Order Failed: {order_response.status_code}")
    print(order_response.text) """