{
	"variables": [],
	"info": {
		"name": "iKuai Open API Test Suites",
		"_postman_id": "38b6e62a-252c-3e03-22a9-567c68ad9840",
		"description": "",
		"schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
	},
	"item": [
		{
			"name": "请求AccessToken",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"var jsonData = JSON.parse( responseBody );",
							"",
							"if ( jsonData.access_token ) { // 保存认证成功后的 AccessToken，以便后面的 API 使用",
							"    postman.setEnvironmentVariable( \"access_token\", jsonData.access_token );",
							"}",
							"",
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				},
				{
					"listen": "prerequest",
					"script": {
						"type": "text/javascript",
						"exec": [
							"/////////////////////////////////////////////////",
							"// 目前 postman sandbox 无内置的 rsa 加密 js 库",
							"// 因此引入 https://github.com/travist/jsencrypt",
							"eval( postman.getEnvironmentVariable( \"external_lib_rsa\" ) );",
							"var rsaJS = new JSEncrypt();",
							"",
							"/////////////////////////////////////////////////",
							"// iKuai Open API 3.0 必要测试变量",
							"var open_id         = \"<open_id>\";         // <=====填入===== 从爱快开放平台获取的 open_id",
							"var open_rsa_pubkey = \"<open_rsa_pubkey>\"; // <=====填入===== 从爱快开放平台获取的公钥",
							"var gwid            = \"<gwid>\";            // <=====填入===== 在哪台已授权的设备上测试 API",
							"rsaJS.setPublicKey( open_rsa_pubkey );",
							"",
							"/////////////////////////////////////////////////",
							"// 请求参数定义",
							"var client_type            = \"OPEN_PARTNER\"; // 常量",
							"var client_id              = open_id; ",
							"var options_token_lifetime = 7200; // 期望 Token 存活 2 小时",
							"var request_time           = Date.parse( new Date() ) / 1000; // 发起请求的真实时间戳，不能与服务器误差太大",
							"var sign                   = rsaJS.encrypt( request_time.toString() ); // 调用者身份认证的签名",
							"",
							"/////////////////////////////////////////////////",
							"// postman 环境变量",
							"postman.setEnvironmentVariable( \"client_type\", client_type );",
							"postman.setEnvironmentVariable( \"client_id\", client_id );",
							"postman.setEnvironmentVariable( \"request_time\", request_time );",
							"postman.setEnvironmentVariable( \"options_token_lifetime\", options_token_lifetime );",
							"postman.setEnvironmentVariable( \"sign\", sign );",
							"postman.setEnvironmentVariable( \"router_gwid\", gwid );",
							""
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/access_token",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": "必填，且必须是 application/json"
					},
					{
						"key": "IK-Api-Language",
						"value": "en",
						"description": "选填，错误信息的语言，可以是 cn, en",
						"disabled": true
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"client_type\": \"{{client_type}}\",\n  \"client_id\": \"{{client_id}}\",\n  \"request_time\": {{request_time}},\n  \"options\": {\n    \"token_lifetime\": {{options_token_lifetime}}\n  },\n  \"sign\": \"{{sign}}\"\n}"
				},
				"description": "请求AccessToken"
			},
			"response": []
		},
		{
			"name": "刷新AccessToken",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"var jsonData = JSON.parse( responseBody );",
							"",
							"if ( jsonData.access_token ) {",
							"    postman.setEnvironmentVariable( \"access_token\", jsonData.access_token );",
							"}",
							"",
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/refresh_token",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": ""
					},
					{
						"key": "IK-Api-Language",
						"value": "cn",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"access_token\": \"{{access_token}}\",\n  \"client_id\": \"{{client_id}}\",\n  \"options\": {\n    \"token_lifetime\": {{options_token_lifetime}}\n  }\n}"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "获取授权设备列表",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/dev_list",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": ""
					},
					{
						"key": "IK-Api-Language",
						"value": "en",
						"description": ""
					},
					{
						"key": "IK-Access-Token",
						"value": "{{access_token}}",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": ""
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "调用API-1-获取账号列表",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/1/{{router_gwid}}",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": ""
					},
					{
						"key": "IK-Api-Language",
						"value": "en",
						"description": ""
					},
					{
						"key": "IK-Access-Token",
						"value": "{{access_token}}",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"param\": {\n    \"TYPE\": \"data\"\n  }\n}"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "调用API-3-在线用户踢下线",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/3/{{router_gwid}}",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": ""
					},
					{
						"key": "IK-Api-Language",
						"value": "en",
						"description": ""
					},
					{
						"key": "IK-Access-Token",
						"value": "{{access_token}}",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"param\": {\n    \"mac\": \"11:22:33:44:55:66\"\n  }\n}"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "调用API-4-获取在线用户列表",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/4/{{router_gwid}}",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": ""
					},
					{
						"key": "IK-Api-Language",
						"value": "en",
						"description": ""
					},
					{
						"key": "IK-Access-Token",
						"value": "{{access_token}}",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"param\": {\n    \"TYPE\": \"data\",\n    \"skip\": 0,\n    \"limit\": 2\n  }\n}"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "调用API-5-添加账号",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/5/{{router_gwid}}",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": ""
					},
					{
						"key": "IK-Api-Language",
						"value": "en",
						"description": ""
					},
					{
						"key": "IK-Access-Token",
						"value": "{{access_token}}",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"param\": {\n    \"enabled\": \"yes\",\n    \"comment\": \"comment\",\n    \"username\": \"username\",\n    \"passwd\": \"passwd\",\n    \"expires\": 1504180807,\n    \"start_time\": 1504080807,\n    \"create_time\": 1504080807,\n    \"ppptype\": \"web\",\n    \"share\": 1,\n    \"auto_mac\": 0,\n    \"upload\": 1000,\n    \"download\": 1000,\n    \"ip_addr\": \"1.2.3.4\",\n    \"mac\": \"12:34:56:78:9a:bc,11:22:33:44:55:66\",\n    \"address\": \"asdf\",\n    \"name\": \"asdf\",\n    \"phone\": \"asdf\",\n    \"cardid\": \"asdf\",\n    \"packages\": 0,\n    \"bind_vlanid\": \"0\",\n    \"bind_ifname\": \"lan1\"\n  }\n}"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "调用API-6-修改账号",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/6/{{router_gwid}}",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": ""
					},
					{
						"key": "IK-Api-Language",
						"value": "en",
						"description": ""
					},
					{
						"key": "IK-Access-Token",
						"value": "{{access_token}}",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"param\": {\n    \"id\": 1,\n    \"enabled\": \"no\",\n    \"comment\": \"comment\",\n    \"username\": \"username\",\n    \"passwd\": \"passwd\",\n    \"expires\": 1504180807,\n    \"start_time\": 1504080807,\n    \"create_time\": 1504080807,\n    \"ppptype\": \"web\",\n    \"share\": 1,\n    \"auto_mac\": 0,\n    \"upload\": 1000,\n    \"download\": 1000,\n    \"ip_addr\": \"1.2.3.4\",\n    \"mac\": \"12:34:56:78:9a:bc,11:22:33:44:55:66\",\n    \"address\": \"asdf\",\n    \"name\": \"asdf\",\n    \"phone\": \"asdf\",\n    \"cardid\": \"asdf\",\n    \"packages\": 0,\n    \"bind_vlanid\": \"0\",\n    \"bind_ifname\": \"lan1\"\n  }\n}"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "调用API-7-启用/停用账号",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/7/{{router_gwid}}",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": ""
					},
					{
						"key": "IK-Api-Language",
						"value": "en",
						"description": ""
					},
					{
						"key": "IK-Access-Token",
						"value": "{{access_token}}",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"param\": {\n    \"id\": 1,\n    \"status\": \"up\"\n  }\n}"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "调用API-8-删除账号",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/8/{{router_gwid}}",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": ""
					},
					{
						"key": "IK-Api-Language",
						"value": "en",
						"description": ""
					},
					{
						"key": "IK-Access-Token",
						"value": "{{access_token}}",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"param\": {\n    \"id\": 2\n  }\n}"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "调用API-9-获取路由器基本信息",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/9/{{router_gwid}}",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": ""
					},
					{
						"key": "IK-Api-Language",
						"value": "en",
						"description": ""
					},
					{
						"key": "IK-Access-Token",
						"value": "{{access_token}}",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": ""
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "调用API-10-设置网址白名单",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/10/{{router_gwid}}",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": ""
					},
					{
						"key": "IK-Api-Language",
						"value": "en",
						"description": ""
					},
					{
						"key": "IK-Access-Token",
						"value": "{{access_token}}",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"param\": {\n    \"whitelist\": \"baidu.com\",\n    \"whitelist_https\": \"baidu.com\",\n    \"whiteip\": \"8.8.8.8\"\n  }\n}"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "调用API-11-查询账号",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/11/{{router_gwid}}",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": ""
					},
					{
						"key": "IK-Api-Language",
						"value": "en",
						"description": ""
					},
					{
						"key": "IK-Access-Token",
						"value": "{{access_token}}",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"param\": {\n    \"username\": \"username\"\n  }\n}"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "调用API-18-添加优惠券",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/18/{{router_3.0_gwid}}",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": ""
					},
					{
						"key": "IK-Api-Language",
						"value": "en",
						"description": ""
					},
					{
						"key": "IK-Access-Token",
						"value": "{{access_token}}",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"param\": {\n    \"enabled\": \"yes\",\n    \"comment\": \"coupon_3\",\n    \"username\": \"coupon_code_3\",\n    \"timeout\": 111,\n    \"expires\": 1509444161\n  }\n}"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "调用API-19-删除优惠券",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/19/{{router_3.0_gwid}}",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": ""
					},
					{
						"key": "IK-Api-Language",
						"value": "en",
						"description": ""
					},
					{
						"key": "IK-Access-Token",
						"value": "{{access_token}}",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"param\": {\n    \"id\": 1\n  }\n}"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "调用API-20-编辑优惠券",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/20/{{router_3.0_gwid}}",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": ""
					},
					{
						"key": "IK-Api-Language",
						"value": "en",
						"description": ""
					},
					{
						"key": "IK-Access-Token",
						"value": "{{access_token}}",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"param\": {\n  \t\"id\": 1,\n    \"enabled\": \"yes\",\n    \"comment\": \"comment\",\n    \"username\": \"coupon_code\",\n    \"timeout\": 789,\n    \"expires\": 1509444161\n  }\n}"
				},
				"description": ""
			},
			"response": []
		},
		{
			"name": "调用API-21-获取优惠券列表",
			"event": [
				{
					"listen": "test",
					"script": {
						"type": "text/javascript",
						"exec": [
							"tests[\"Status code is 200\"] = responseCode.code === 200;"
						]
					}
				}
			],
			"request": {
				"url": "{{server_address}}{{api_prefix}}/open/21/{{router_3.0_gwid}}",
				"method": "POST",
				"header": [
					{
						"key": "Content-Type",
						"value": "application/json",
						"description": ""
					},
					{
						"key": "IK-Api-Language",
						"value": "en",
						"description": ""
					},
					{
						"key": "IK-Access-Token",
						"value": "{{access_token}}",
						"description": ""
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n  \"param\": {\n  \t\"TYPE\": \"data\",\n  \t\"skip\": 0,\n  \t\"limit\": 10\n  }\n}"
				},
				"description": ""
			},
			"response": []
		}
	]
}