{
	"info": {
		"_postman_id": "0a36a487-b46c-49cd-86a7-33656366922b",
		"name": "PDMX - Mobile Identity API v2",
		"description": "_**Círculo de Crédito**_ - Mobile Identity v2 API postman collection.",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "21352240"
	},
	"item": [
		{
			"name": "Phone Carrier Data",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							"var uuidGenerator = require('uuid');",
							"var uuid = uuidGenerator.v4();",
							"pm.collectionVariables.set(\"uuid\", uuid);",
							"",
							"var dateTime = new Date().toISOString();",
							"pm.collectionVariables.set('date-time', dateTime);",
							"",
							"function doHttpSig() {",
							"    var navigator = {}; ",
							"    var window = {};",
							"",
							"    eval(pm.environment.get(\"jsrsasign-js\"));",
							"    var privateKey = pm.environment.get(\"private-key\").trim().replace(/[\\x00-\\x1F\\x7F-\\x9F]/g, \"\");",
							"    ",
							"    var body = JSON.parse(pm.request.body.toString());",
							"    body.requestId = uuid",
							"",
							"    var strBody = JSON.stringify(body)",
							"    ",
							"    console.log(\"[DEBUG ] requestId: \" + uuid);",
							"    console.log(\"[DEBUG ] private-key: \" + privateKey);",
							"    console.log(\"[DEBUG ] request-body: \" + strBody);",
							"",
							"    var sig = new KJUR.crypto.Signature({\"alg\": \"SHA256withECDSA\", \"prov\": \"cryptojs/jsrsa\"});",
							"    sig.init({d: privateKey, curve: \"secp384r1\"});",
							"    sig.updateString(strBody);",
							"",
							"    var signature = sig.sign();",
							"",
							"    console.log(\"[DEBUG] Signature ECDSA: \" + signature);",
							"    pm.collectionVariables.set(\"x-signature\", signature);",
							"    pm.request.body.update(strBody);",
							"}",
							"",
							"if (!pm.environment.has(\"jsrsasign-js\") || pm.environment.get(\"jsrsasign-js\")===\"\") {",
							"",
							"    console.log(\"La biblioteca jsrasign aún no se ha descargado. Descargando ahora.\");",
							"    pm.sendRequest({",
							"        url: \"https://cdnjs.cloudflare.com/ajax/libs/jsrsasign/8.0.12/jsrsasign-all-min.js\",",
							"        method: \"GET\",",
							"        body: {}",
							"    }, function (err, res) {",
							"        pm.environment.set(\"jsrsasign-js\", res.text());",
							"        doHttpSig();",
							"    });",
							"",
							"} else {",
							"    doHttpSig();",
							"}",
							"",
							"function generateUUIDv1() {",
							"    var time = new Date().getTime();",
							"    var uuid = 'xxxxxxxx-xxxx-1xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {",
							"        const r = (time + Math.random() * 16) % 16 | 0;",
							"        time = Math.floor(time/16);",
							"        return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);",
							"    });",
							"",
							"    var staticNode = \"a38b-00b0d068b224\";",
							"",
							"    return (uuid.slice(0, -17) + staticNode);",
							"}"
						],
						"type": "text/javascript",
						"packages": {}
					}
				}
			],
			"request": {
				"method": "POST",
				"header": [
					{
						"key": "username",
						"value": "{{username}}",
						"type": "text"
					},
					{
						"key": "password",
						"value": "{{password}}",
						"type": "text"
					},
					{
						"key": "x-api-key",
						"value": "{{x-api-key}}",
						"type": "text"
					},
					{
						"key": "x-signature",
						"value": "{{x-signature}}",
						"type": "text"
					},
					{
						"key": "Content-Type",
						"value": "application/json",
						"type": "text"
					}
				],
				"body": {
					"mode": "raw",
					"raw": "{\n    \"requestId\": \"{{uuid}}\",\n    \"customer\": {\n        \"phoneNumber\": \"\",\n        \"termsAcceptedAt\": \"\",\n        \"identity\": {\n            \"names\": \"\",\n            \"paternalSurname\": \"\",\n            \"maternalSurname\": \"\",\n            \"birthdate\": \"\",\n            \"rfc\": \"\",\n            \"curp\": \"\"\n        },\n        \"address\": {\n            \"street\": \"\",\n            \"neighborhood\": \"\",\n            \"city\": \"\",\n            \"municipality\": \"\",\n            \"state\": \"\",\n            \"postalCode\": \"\"\n        }\n    },\n    \"settings\": {\n        \"mobileCarrier\": {\n            \"creditRisk\": true,\n            \"fraudRisk\": true,\n            \"lineQuality\": true,\n            \"usageLevel\": true,\n            \"simSwapLevel\": true,\n            \"technologyLevel\": true,\n            \"spendingTrend\": true,\n            \"contactNetworkLevel\": true,\n            \"callableLevel\": true,\n            \"planSize\": true,\n            \"planCreditLimit\": true,\n            \"planAutoPay\": true,\n            \"topUpLevel\": true,\n            \"topUpCadence\": true,\n            \"lineAge\": true,\n            \"lineStatus\": true,\n            \"lineType\": true\n        }\n    }\n}",
					"options": {
						"raw": {
							"language": "json"
						}
					}
				},
				"url": {
					"raw": "{{url}}/v2/telco/phone/carrier-info",
					"host": [
						"{{url}}"
					],
					"path": [
						"v2",
						"telco",
						"phone",
						"carrier-info"
					]
				}
			},
			"response": []
		},
		{
			"name": "Get Aggregation",
			"event": [
				{
					"listen": "prerequest",
					"script": {
						"exec": [
							"",
							"function doHttpSig() {",
							"    var navigator = {};",
							"    var window = {};",
							"",
							"    eval(pm.environment.get(\"jsrsasign-js\"));",
							"    var privateKey = pm.environment.get(\"private-key\").trim().replace(/[\\x00-\\x1F\\x7F-\\x9F]/g, \"\");",
							"",
							"    var pathUrl = pm.request.url.getPath();",
							"",
							"    console.log(\"[DEBUG] private-key: \" + privateKey);",
							"    console.log(\"[DEBUG] request-url: \" + pathUrl);",
							"",
							"    var sig = new KJUR.crypto.Signature({\"alg\": \"SHA256withECDSA\", \"prov\": \"cryptojs/jsrsa\"});",
							"    sig.init({d: privateKey, curve: \"secp384r1\"});",
							"    sig.updateString(pathUrl);",
							"",
							"    var signature = sig.sign();",
							"",
							"    console.log(\"[DEBUG] Signature ECDSA: \" + signature);",
							"    pm.collectionVariables.set(\"x-signature\", signature);",
							"}",
							"",
							"if (!pm.environment.has(\"jsrsasign-js\") || pm.environment.get(\"jsrsasign-js\")===\"\") {",
							"",
							"    console.log(\"La biblioteca jsrasign aún no se ha descargado. Descargando ahora.\");",
							"    pm.sendRequest({",
							"        url: \"https://cdnjs.cloudflare.com/ajax/libs/jsrsasign/8.0.12/jsrsasign-all-min.js\",",
							"        method: \"GET\",",
							"        body: {}",
							"    }, function (err, res) {",
							"        pm.environment.set(\"jsrsasign-js\", res.text());",
							"        doHttpSig();",
							"    });",
							"",
							"} else {",
							"    doHttpSig();",
							"}"
						],
						"type": "text/javascript",
						"packages": {}
					}
				}
			],
			"request": {
				"method": "GET",
				"header": [
					{
						"key": "username",
						"value": "{{username}}",
						"type": "text"
					},
					{
						"key": "password",
						"value": "{{password}}",
						"type": "text"
					},
					{
						"key": "x-api-key",
						"value": "{{x-api-key}}",
						"type": "text"
					},
					{
						"key": "x-signature",
						"value": "{{x-signature}}",
						"type": "text"
					}
				],
				"url": {
					"raw": "{{url}}/v2/telco/aggregations/{id}",
					"host": [
						"{{url}}"
					],
					"path": [
						"v2",
						"telco",
						"aggregations",
						"{id}"
					]
				}
			},
			"response": []
		}
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		}
	],
	"variable": [
		{
			"key": "x-signature",
			"value": "",
			"type": "string"
		},
		{
			"key": "uuid",
			"value": "",
			"type": "string"
		},
		{
			"key": "date-time",
			"value": "",
			"type": "string"
		},
		{
			"key": "url",
			"value": "",
			"type": "string"
		}
	]
}