-
Notifications
You must be signed in to change notification settings - Fork 2
/
tester.html
64 lines (64 loc) · 2.04 KB
/
tester.html
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Test POST</title>
<style media="screen">
.hidden {
display: none;
}
textarea#curl {
width: 90%;
height: 14em;
}
</style>
</head>
<body>
Test POST to <code>${TEST_URL}</code> mimics values from <code>${PIPE_URL}</code>
<h3>POST</h3>
<code><pre id="post"></pre></code>
<h3>RESPONSE</h3>
<code><pre id="response"></pre></code>
<h3>cURL</h3>
<code><textarea id="curl" class="hidden"></textarea></code>
<script
src="https://code.jquery.com/jquery-3.5.1.js"
integrity="sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc="
crossorigin="anonymous"></script>
<script>
const randStr = () => Math.random().toString(36).substring(2, 15);
let vals = {
'id_participant': prompt('id_participant*'),
'meta/instanceID': randStr() + randStr(),
};
vals['RECRUITMENT/CARRIER'] = prompt('carrier?') || `${vals.id_participant} carrier`;
vals['RECRUITMENT/PHONE_INCENTIVE'] = prompt('ref phone?') || `${vals.id_participant} phone num`;
for (let n = 1; n <= 3; n++) {
let baseVar = 'RECRUITMENT/RECRUIT' + n;
let phoneVar = baseVar + '_PHONE';
let nameVar = baseVar + '_NAME';
let phonePrompt = prompt(phoneVar);
if (!phonePrompt) {
break;
}
let namePrompt = prompt(nameVar) || '';
vals[phoneVar] = phonePrompt;
vals[nameVar] = namePrompt;
}
$('#post').text(JSON.stringify(vals, null, 2));
$.ajax({
type: "POST",
url: '${PIPE_URL}/test',
data: JSON.stringify(vals),
contentType: 'application/json; charset=utf-8',
dataType: 'JSON'
}).then(function (response, status, req){
if (response.curl) {
$('#curl').text(response.curl).removeClass('hidden');
delete response.curl;
}
$('#response').text(JSON.stringify(response, null, 2))
});
</script>
</body>
</html>