add JSON template examples
This commit is contained in:
parent
1ce6c26d84
commit
e3817980ec
@ -1,38 +0,0 @@
|
|||||||
# Types: App, s2s_msg
|
|
||||||
# Auth: public, private
|
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
|
|
||||||
msg_xfer = {
|
|
||||||
'mode':'msg_xfer',
|
|
||||||
'system_name':'ABC',
|
|
||||||
'response_url':'http://localhost:8093/api/',
|
|
||||||
'auth_type':'private',
|
|
||||||
'credentials': {
|
|
||||||
'user':'test_name',
|
|
||||||
'password':'passw0rd',
|
|
||||||
},
|
|
||||||
'data':{
|
|
||||||
1:{'source_id':1234,
|
|
||||||
'destination_id':3153591,
|
|
||||||
'slot':2,
|
|
||||||
'msg_type':'unit',
|
|
||||||
'msg_format':'motorola',
|
|
||||||
'message':'text of the message'
|
|
||||||
},
|
|
||||||
2:{'source_id':1234,
|
|
||||||
'destination_id':3153591,
|
|
||||||
'slot':2,
|
|
||||||
'msg_type':'unit',
|
|
||||||
'msg_format':'motorola',
|
|
||||||
'message':'text of the 2nd message'
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
json_object = json.dumps(msg_xfer, indent = 4)
|
|
||||||
print(json_object)
|
|
||||||
|
|
81
dev/json_templates.py
Normal file
81
dev/json_templates.py
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
# Types: App, msg_xfer, raw
|
||||||
|
# Auth: public, private
|
||||||
|
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
msg_xfer = {
|
||||||
|
'mode':'msg_xfer',
|
||||||
|
'system_name':'ABC',
|
||||||
|
'response_url':'http://localhost:8093/api/',
|
||||||
|
'auth_type':'private',
|
||||||
|
'credentials': {
|
||||||
|
'user':'test_name',
|
||||||
|
'password':'passw0rd',
|
||||||
|
},
|
||||||
|
'data':{
|
||||||
|
1:{'source_id':1234,
|
||||||
|
'destination_id':3153591,
|
||||||
|
'slot':2,
|
||||||
|
'msg_type':'unit',
|
||||||
|
'msg_format':'motorola',
|
||||||
|
'message':'text of the message'
|
||||||
|
},
|
||||||
|
2:{'source_id':1234,
|
||||||
|
'destination_id':3153591,
|
||||||
|
'slot':2,
|
||||||
|
'msg_type':'unit',
|
||||||
|
'msg_format':'motorola',
|
||||||
|
'message':'text of the 2nd message'
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
json_object = json.dumps(msg_xfer, indent = 4)
|
||||||
|
print('App')
|
||||||
|
print(json_object)
|
||||||
|
|
||||||
|
app_request = {
|
||||||
|
'mode':'app',
|
||||||
|
'system_name':'ABC',
|
||||||
|
'response_url':'http://localhost:8093/api/',
|
||||||
|
'auth_token':'1234567899',
|
||||||
|
'data':{
|
||||||
|
'source_id':1234,
|
||||||
|
'destination_id':3153591,
|
||||||
|
'slot':2,
|
||||||
|
'msg_type':'unit',
|
||||||
|
'msg_format':'motorola',
|
||||||
|
'message':'text of the message'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
json_object = json.dumps(app_request, indent = 4)
|
||||||
|
print(json_object)
|
||||||
|
|
||||||
|
app_response = {
|
||||||
|
'mode':'app',
|
||||||
|
'system_name':'APP',
|
||||||
|
'auth_token':'1234567899',
|
||||||
|
'data':{
|
||||||
|
1:{'source_id':1234,
|
||||||
|
'destination_id':3153591,
|
||||||
|
'slot':2,
|
||||||
|
'msg_type':'unit',
|
||||||
|
'msg_format':'motorola',
|
||||||
|
'message':'text of the message'
|
||||||
|
},
|
||||||
|
2:{'source_id':1234,
|
||||||
|
'destination_id':3153591,
|
||||||
|
'slot':2,
|
||||||
|
'msg_type':'unit',
|
||||||
|
'msg_format':'motorola',
|
||||||
|
'message':'text of the 2nd message'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
json_object = json.dumps(app_response, indent = 4)
|
||||||
|
print(json_object)
|
@ -772,6 +772,8 @@ def api(api_mode=None):
|
|||||||
mode=api_data['mode'],
|
mode=api_data['mode'],
|
||||||
status='Not an authorization method',
|
status='Not an authorization method',
|
||||||
)
|
)
|
||||||
|
if api_data['mode'] == 'app':
|
||||||
|
print('implement')
|
||||||
else:
|
else:
|
||||||
message = jsonify(message='Mode not found')
|
message = jsonify(message='Mode not found')
|
||||||
return make_response(message, 400)
|
return make_response(message, 400)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user