-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathrunning_code_example.py
38 lines (30 loc) · 1.1 KB
/
running_code_example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import os
import voucherify
from dotenv import load_dotenv
load_dotenv()
HOST = os.getenv('VOUCHERIFY_HOST', 'https://api.voucherify.io')
X_APP_ID = os.getenv('X_APP_ID')
X_APP_TOKEN = os.getenv('X_APP_TOKEN')
if not X_APP_ID or not X_APP_TOKEN:
raise ValueError("X_APP_ID and X_APP_TOKEN must be set in the .env file.")
configuration = voucherify.Configuration(
host=HOST,
api_key={
"X-App-Id": X_APP_ID,
"X-App-Token": X_APP_TOKEN
}
)
# Debugging line
api_key_id = configuration.get_api_key_with_prefix('X-App-Id')
api_key_token = configuration.get_api_key_with_prefix('X-App-Token')
# Print whether both API keys are present and valid
are_keys_present = bool(api_key_id) and bool(api_key_token)
print(f"Configuration loaded: {are_keys_present}")
if(are_keys_present):
with voucherify.ApiClient(configuration) as api_client:
customers_api_instance = voucherify.CustomersApi(api_client)
try:
result = customers_api_instance.list_customers()
print(result)
except voucherifyClient.ApiException as e:
self.fail(e)