|
1 | 1 | <html>
|
2 | 2 | <body>
|
3 | 3 | <input type="text" id="subscription_id" placeholder="subscription id"></input>
|
| 4 | +<button onclick="javascript:assignSubscriptionId()" >Assign subscriptionId</button> |
4 | 5 | <button onclick="javascript:createSubscription()">Create Subscription</button>
|
5 | 6 | <button id='delete' onclick="javascript:deleteSubscription()" disabled>Delete Subscription</button>
|
6 | 7 | <button id='get' onclick="javascript:getSubscription()" disabled>Get Subscription</button>
|
@@ -39,6 +40,37 @@ <h1>Result</h1>
|
39 | 40 | }
|
40 | 41 | xhr.send('{"events":["TEXT", "MMS"],"callbackData":"test","expiresIn":3600}');
|
41 | 42 | }
|
| 43 | +function assignSubscriptionId() { |
| 44 | + var result = document.getElementById('result'); |
| 45 | + result.innerText = "Assigning subscriptionId..."; |
| 46 | + var input = document.getElementById('subscription_id'); |
| 47 | + var subscription_id = input.value; |
| 48 | + xhr = new XMLHttpRequest(); |
| 49 | + xhr.open("GET", "http://localhost:4567/att/notification/v1/subscriptions"); |
| 50 | + xhr.onreadystatechange = function () { |
| 51 | + if (xhr.readyState == 4) { |
| 52 | + var result = document.getElementById('result'); |
| 53 | + result.innerText = xhr.responseText; |
| 54 | + if (xhr.status < 300) { |
| 55 | + var deleteButton = document.getElementById('delete'); |
| 56 | + deleteButton.disabled = false; |
| 57 | + var getButton = document.getElementById('get'); |
| 58 | + getButton.disabled = false; |
| 59 | + var putButton = document.getElementById('put'); |
| 60 | + putButton.disabled = false; |
| 61 | + var gnButton = document.getElementById('get_notifications'); |
| 62 | + gnButton.disabled = false; |
| 63 | + var dnButton = document.getElementById('delete_notifications'); |
| 64 | + dnButton.disabled = false; |
| 65 | + var resultObject = JSON.parse(xhr.responseText); |
| 66 | + var subscriptionId = resultObject.subscription.subscriptionId; |
| 67 | + var input = document.getElementById('subscription_id'); |
| 68 | + input.value = subscriptionId; |
| 69 | + } |
| 70 | + } |
| 71 | + } |
| 72 | + xhr.send(); |
| 73 | +} |
42 | 74 | function getSubscription() {
|
43 | 75 | var input = document.getElementById('subscription_id');
|
44 | 76 | var subscription_id = input.value;
|
|
0 commit comments