{
	"info": {
		"_postman_id": "6fa023b1-29ed-4471-b4ca-dd15627af267",
		"name": "service_log_api_samples_futurae",
		"description": "This endpoint streams service events in njson format.\n\n`service_id` and a `service_log_api_key` is required for authentication. `service_id` in the path variable is required and must be the same used to generate the authentication header.\n\nThe `start` and end `date` is optional. Where these values are not provided, the system return events within the period of 1 minute. You can stream events at max period of an hour. You cannot stream events over 30days.\n\nFor further information on the Log API, please visit the [Auth API Documentation](https://futurae.com/docs/api/log/).",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "29181996"
	},
	"item": [
		{
			"name": "/logs/v1/service/:service_id",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							""
						],
						"type": "text/javascript"
					}
				}
			],
			"protocolProfileBehavior": {
				"disableBodyPruning": true
			},
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "FT-Date",
						"value": "{{dateHeader}}",
						"type": "text"
					},
					{
						"key": "Authorization",
						"value": "{{authorizationHeader}}",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": ""
				},
				"url": {
					"raw": "https://{{hostname}}/logs/v1/service/:service_id",
					"protocol": "https",
					"host": [
						"{{hostname}}"
					],
					"path": [
						"logs",
						"v1",
						"service",
						":service_id"
					],
					"query": [
						{
							"key": "start",
							"value": null,
							"description": "optional start datetime",
							"disabled": true
						},
						{
							"key": "end",
							"value": null,
							"description": "optional end time",
							"disabled": true
						}
					],
					"variable": [
						{
							"key": "service_id",
							"value": ""
						}
					]
				},
				"description": ""
			},
			"response": []
		}
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"exec": [
					"var hostname = pm.variables.get(\"hostname\");",
					"var service_id = pm.variables.get(\"service_id\");",
					"var secret_key = pm.variables.get(\"service_log_api_key\");",
					"",
					"",
					"var date = new Date().toUTCString().slice(0,26) + \"-0000\";",
					"var method = request.method;",
					"var url = request.url.split(\"://\")[1];",
					"var sepIdx = url.indexOf(\"/\");",
					"var path = url.slice(sepIdx);",
					"var body = '';",
					"if (request.data.length > 0) body = request.data;",
					"",
					"var toSign = date + '\\n' + method + '\\n' + hostname + '\\n' + path + '\\n' + body + '\\n';",
					"",
					"// Generate HMAC SHA256 signature",
					"var hash = CryptoJS.HmacSHA256(toSign, secret_key);",
					"var signature = CryptoJS.enc.Hex.stringify(hash)",
					"var wordArray = CryptoJS.enc.Utf8.parse(service_id + \":\" + signature);",
					"var base64 = CryptoJS.enc.Base64.stringify(wordArray);",
					"",
					"postman.setEnvironmentVariable('authorizationHeader', 'Basic ' + base64);",
					"postman.setEnvironmentVariable('dateHeader', date);"
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		}
	],
	"variable": [
		{
			"key": "hostname",
			"value": "YOUR_FUTURAE_SERVICE_HOSTNAME",
			"type": "string"
		},
		{
			"key": "service_id",
			"value": "YOUR_FUTURAE_SERVICE_ID",
			"type": "string"
		},
		{
			"key": "service_log_api_key",
			"value": "YOUR_FUTURAE_SERVICE_LOG_API_KEY",
			"type": "string"
		}
	]
}