· 6 years ago · Dec 31, 2019, 12:28 PM
1{
2 "info": {
3 "_postman_id": "88a0f7ed-8643-45c8-99bd-82aa609aaeed",
4 "name": "HKNYCD",
5 "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
6 },
7 "item": [
8 {
9 "name": "redeem",
10 "event": [
11 {
12 "listen": "prerequest",
13 "script": {
14 "id": "7dbe4fe6-22b5-46e9-8f4f-07f3f342e012",
15 "exec": [
16 "const echoPostRequest = {",
17 " url: 'https://www.hknycd.com/api/v1/login',",
18 " method: 'POST',",
19 " header: 'Content-Type:application/json',",
20 " body: {",
21 " mode: 'application/json',",
22 " raw: JSON.stringify(",
23 " {",
24 " \"lang\": 1,",
25 " \"is_citizen\": 2,",
26 " \"username\": pm.environment.get('email'),",
27 " \"password\": pm.environment.get('hkid'),",
28 " \"token\": \"88recaptcha\"",
29 " })",
30 " }",
31 "};",
32 "",
33 "var getToken = true;",
34 "",
35 "if (!pm.environment.get('currentAccessToken')) {",
36 " console.log('Token is missing')",
37 "} else {",
38 " getToken = false;",
39 " console.log('Token is all good');",
40 "}",
41 "",
42 "if (getToken === true) {",
43 " pm.sendRequest(echoPostRequest, function (err, res) {",
44 " console.log(err ? err : res.json());",
45 " if (res.code !== 200) {",
46 " throw new Error('Login Error - not returning 200');",
47 " }",
48 " if (err === null) {",
49 " console.log('Saving the token')",
50 " var responseJson = res.json();",
51 " pm.environment.set('currentAccessToken', responseJson.detail)",
52 " }",
53 " });",
54 "}"
55 ],
56 "type": "text/javascript"
57 }
58 }
59 ],
60 "request": {
61 "auth": {
62 "type": "bearer",
63 "bearer": [
64 {
65 "key": "token",
66 "value": "{{currentAccessToken}}",
67 "type": "string"
68 }
69 ]
70 },
71 "method": "POST",
72 "header": [
73 {
74 "key": "Content-Type",
75 "name": "Content-Type",
76 "value": "application/json",
77 "type": "text"
78 }
79 ],
80 "body": {
81 "mode": "raw",
82 "raw": "{\n\t\"lang\": 1,\n \"token\": \"88recaptcha\"\n}",
83 "options": {
84 "raw": {
85 "language": "json"
86 }
87 }
88 },
89 "url": {
90 "raw": "https://www.hknycd.com/api/v1/card-game-redeem",
91 "protocol": "https",
92 "host": [
93 "www",
94 "hknycd",
95 "com"
96 ],
97 "path": [
98 "api",
99 "v1",
100 "card-game-redeem"
101 ]
102 }
103 },
104 "response": []
105 }
106 ],
107 "protocolProfileBehavior": {}
108}