camparchimedes commited on
Commit
daf2ab5
ยท
verified ยท
1 Parent(s): 1c84663

Create api_docs_mck.py

Browse files
Files changed (1) hide show
  1. api_docs_mck.py +55 -0
api_docs_mck.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### api_docs_mck.py
2
+
3
+ import json
4
+
5
+ daysoff_api_docs = {
6
+ "base_url": "https://670dccd0073307b4ee447f2f.mockapi.io/daysoff/api/V1/booking",
7
+ "endpoints": {
8
+ "method": "POST",
9
+ "description": "Retrieve booking information for a given booking ID.",
10
+ "parameters": {
11
+ "booking_id": {
12
+ "type": "string",
13
+ "description": "The unique identifier of the booking to retrieve ('bestillingsnummer')"
14
+ }
15
+ },
16
+ "headers": {
17
+ "Content-Type": "application/json"
18
+ },
19
+ "response": {
20
+ "description": "A decoded JSON object containing booking details ('Informasjon om bestillingen)",
21
+ "content_type": "application/json",
22
+ "booking_info": {
23
+ "booking_id": "response.get('booking_id', 'N/A')",
24
+ "full_name": "response.get('full_name', 'N/A')",
25
+ "amount": "response.get('amount', 'N/A')",
26
+ "date": "response.get('date', 'N/A')",
27
+ "address": "response.get('address', 'N/A')",
28
+ "user_id": "response.get('user_id', 'N/A')"
29
+ }
30
+ }
31
+ }
32
+ }
33
+
34
+ # --json decode fu.
35
+ def decode_booking_info(response):
36
+ booking_info = {
37
+ "booking_id": response.get("booking_id", "N/A"),
38
+ "full_name": response.get("full_name", "N/A"),
39
+ "amount": response.get("amount", "N/A"),
40
+ "date": response.get("date", "N/A"),
41
+ "address": response.get("address", "N/A"),
42
+ "user_id": response.get("user_id", "N/A")
43
+ }
44
+
45
+ json_decode = (
46
+ f"Booking ID: {booking_info['booking_id']}\n"
47
+ f"Full Name: {booking_info['full_name']}\n"
48
+ f"Amount: {booking_info['amount']}\n"
49
+ f"Date: {booking_info['date']}\n"
50
+ f"Address: {booking_info['address']}\n"
51
+ f"User ID: {booking_info['user_id']}"
52
+ )
53
+
54
+ return json_decode
55
+