{
  "info": {
    "_postman_id": "0ba5e67a-c168-4fcf-a832-26803b5563d1",
    "name": "Synaptic Docs - Boufin Connect",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_exporter_id": "25217247"
  },
  "item": [
    {
      "name": "OTP",
      "item": [
        {
          "name": "Token OTP - Create",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "let response = pm.response.json()",
                  "pm.environment.set(\"TOKEN_OTP\", response.data.otpToken)",
                  "pm.environment.set(\"CONSENT_ID\", response.data.consentId)"
                ],
                "type": "text/javascript",
                "packages": {},
                "requests": {}
              }
            }
          ],
          "request": {
            "auth": {
              "type": "apikey",
              "apikey": [
                {
                  "key": "value",
                  "value": "{{API_KEY}}",
                  "type": "string"
                },
                {
                  "key": "key",
                  "value": "x-api-key",
                  "type": "string"
                }
              ]
            },
            "method": "POST",
            "header": [
              {
                "key": "x-boufin-client-id",
                "value": "boufin",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"products\": [\"movement\", \"product-balance\"],\n    \"user\": {\n        \"username\": \"123123123\",\n        \"email\": \"correo@synaptic.cl\"\n    },\n    \"company\": {\n      \"id\": \"123123123\"\n    },\n    \"widgetConfigId\": \"{{WIDGET_CONFIG_ID}}\",\n    \"clientId\": \"{{CLIENT_ID}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{URL_BACKEND}}/api/v1/token/otp/create",
              "host": ["{{URL_BACKEND}}"],
              "path": ["api", "v1", "token", "otp", "create"]
            }
          },
          "response": [
            {
              "name": "Token OTP - Create USER Flow",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "body": {
                  "mode": "raw",
                  "raw": "{\n    \"products\": [\"movement\", \"product-balance\"],\n    \"user\": {\n        \"username\": \"123123123\",\n        \"email\": \"correo@synaptic.cl\"\n    },\n    \"clientId\": \"1E65AE48-F9CF-49F2-8012-FB910179852F\",\n    \"widgetConfigId\": \"TeRwfeb1L05yYOhFOjJW\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": {
                  "raw": "{{URL_BACKEND}}/api/v1/token/otp/create",
                  "host": ["{{URL_BACKEND}}"],
                  "path": ["api", "v1", "token", "otp", "create"]
                }
              },
              "_postman_previewlanguage": "Text",
              "header": [],
              "cookie": [],
              "body": ""
            },
            {
              "name": "Token OTP - Create COMPANY flow",
              "originalRequest": {
                "method": "POST",
                "header": [],
                "body": {
                  "mode": "raw",
                  "raw": "{\n    \"products\": [\"movement\", \"product-balance\"],\n    \"user\": {\n        \"username\": \"123123123\",\n        \"email\": \"correo@synaptic.cl\"\n    },\n    \"company\": {\n        \"id\": \"123123123\"\n    },\n    \"filters\": {\n        \"entities\": {\n            \"include\": {\n                \"types\": [\"business-bank\"]\n            }\n        }\n    },\n    \"clientId\": \"1E65AE48-F9CF-49F2-8012-FB910179852F\",\n    \"widgetConfigId\": \"d2zQt945J2DXiNFLHNlO\"\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": {
                  "raw": "{{URL_BACKEND}}/api/v1/token/otp/create",
                  "host": ["{{URL_BACKEND}}"],
                  "path": ["api", "v1", "token", "otp", "create"]
                }
              },
              "_postman_previewlanguage": "Text",
              "header": [],
              "cookie": [],
              "body": ""
            }
          ]
        }
      ]
    },
    {
      "name": "Task token",
      "item": [
        {
          "name": "Token Tasks - Create",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "let response = pm.response.json()",
                  "pm.environment.set(\"TOKEN_TASK\", response.data.taskToken)"
                ],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "request": {
            "auth": {
              "type": "apikey",
              "apikey": [
                {
                  "key": "value",
                  "value": "{{API_KEY}}",
                  "type": "string"
                },
                {
                  "key": "key",
                  "value": "x-api-key",
                  "type": "string"
                }
              ]
            },
            "method": "POST",
            "header": [
              {
                "key": "Authorization",
                "value": "",
                "type": "text",
                "disabled": true
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"target\": \"123123123\",\n    \"clientId\": \"{{CLIENT_ID}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{URL_BACKEND}}/api/v1/token/task",
              "host": ["{{URL_BACKEND}}"],
              "path": ["api", "v1", "token", "task"]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Consents",
      "item": [
        {
          "name": "Consents - Get all",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [""],
                "type": "text/javascript",
                "packages": {}
              }
            }
          ],
          "request": {
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{TOKEN_TASK}}",
                  "type": "string"
                }
              ]
            },
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{URL_BACKEND}}/api/v1/consents",
              "host": ["{{URL_BACKEND}}"],
              "path": ["api", "v1", "consents"]
            }
          },
          "response": []
        },
        {
          "name": "Consents - Get by Id",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [""],
                "type": "text/javascript",
                "packages": {},
                "requests": {}
              }
            }
          ],
          "request": {
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{TOKEN_TASK}}",
                  "type": "string"
                }
              ]
            },
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{URL_BACKEND}}/api/v1/consents/{{CONSENT_ID}}",
              "host": ["{{URL_BACKEND}}"],
              "path": ["api", "v1", "consents", "{{CONSENT_ID}}"]
            }
          },
          "response": []
        },
        {
          "name": "Consents - Download",
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{TOKEN_TASK}}",
                  "type": "string"
                }
              ]
            },
            "method": "GET",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{URL_BACKEND}}/api/v1/consents/{{CONSENT_ID}}/download",
              "host": ["{{URL_BACKEND}}"],
              "path": ["api", "v1", "consents", "{{CONSENT_ID}}", "download"]
            }
          },
          "response": []
        }
      ]
    },
    {
      "name": "Products",
      "item": [
        {
          "name": "Retrieve Data - Start Task",
          "event": [
            {
              "listen": "test",
              "script": {
                "exec": [
                  "let response = pm.response.json()",
                  "pm.environment.set(\"TASK_ID\", response.taskId)"
                ],
                "type": "text/javascript",
                "packages": {},
                "requests": {}
              }
            }
          ],
          "request": {
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{TOKEN_TASK}}",
                  "type": "string"
                }
              ]
            },
            "method": "POST",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"product\": \"movement\",\n    \"consentId\": \"{{CONSENT_ID}}\"\n}",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{URL_BACKEND}}/api/v1/products/retrieve-data/tasks",
              "host": ["{{URL_BACKEND}}"],
              "path": ["api", "v1", "products", "retrieve-data", "tasks"]
            }
          },
          "response": []
        },
        {
          "name": "Retrieve Data - Poll Task Status",
          "protocolProfileBehavior": {
            "disableBodyPruning": true
          },
          "request": {
            "auth": {
              "type": "bearer",
              "bearer": [
                {
                  "key": "token",
                  "value": "{{TOKEN_TASK}}",
                  "type": "string"
                }
              ]
            },
            "method": "GET",
            "header": [],
            "body": {
              "mode": "raw",
              "raw": "",
              "options": {
                "raw": {
                  "language": "json"
                }
              }
            },
            "url": {
              "raw": "{{URL_BACKEND}}/api/v1/products/retrieve-data/tasks/{{TASK_ID}}",
              "host": ["{{URL_BACKEND}}"],
              "path": [
                "api",
                "v1",
                "products",
                "retrieve-data",
                "tasks",
                "{{TASK_ID}}"
              ]
            }
          },
          "response": []
        }
      ]
    }
  ]
}
