{
  "info": {
    "name": "MagniFinance REST API - Tax Communication",
    "description": "Switch the automatic communication of documents to the Tax Authority (AT) on or off, check whether it is on, and list the communicated documents.\n\n1. Open the collection's **Variables** tab and fill in `email` and `token` (see https://developer.magnifinance.com/finance/getting-started/authentication/).\n2. To turn the service on, also fill in `atUsername` and `atPassword` with the AT user that has the WFA/WDT permissions.\n3. Send **Activation Get** first: it only reads.\n\nDocs: https://developer.magnifinance.com/finance/tax-compliance/tax-communication/",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "baseUrl", "value": "https://bo.magnifinance.com" },
    { "key": "email", "value": "", "description": "Your API user email" },
    { "key": "token", "value": "", "type": "secret", "description": "Your subscription token" },
    { "key": "atUsername", "value": "", "description": "Tax Authority (AT) user with the WFA/WDT permissions, e.g. 123456789/1" },
    { "key": "atPassword", "value": "", "type": "secret", "description": "Password of that AT user" }
  ],
  "event": [
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "exec": [
          "pm.test('HTTP 200', () => pm.response.to.have.status(200));",
          "if ((pm.response.headers.get('Content-Type') || '').includes('json')) {",
          "    const body = pm.response.json();",
          "    const error = body.ErrorValue ? `${body.ErrorValue.Name}: ${JSON.stringify(body.ValidationErrors || body.ErrorHumanReadable)}` : '';",
          "    pm.test('Type is Success', () => pm.expect(body.IsError, error).to.be.false);",
          "    // Activation Set with IsActive true succeeds even when the AT rejects the credentials, so check the result too.",
          "    const turningOn = /\"IsActive\"\\s*:\\s*true/.test((pm.request.body && pm.request.body.raw) || '');",
          "    if (turningOn) pm.test('Tax Communication is now active', () => pm.expect(body.Object && body.Object.IsActive, 'the AT rejected the credentials, so the service was switched off').to.be.true);",
          "}"
        ]
      }
    }
  ],
  "item": [
    {
      "name": "Activation Get",
      "request": {
        "method": "GET",
        "header": [
          { "key": "email", "value": "{{email}}" },
          { "key": "token", "value": "{{token}}" }
        ],
        "url": { "raw": "{{baseUrl}}/api/v2.1/taxCommunication/activationGet", "host": ["{{baseUrl}}"], "path": ["api", "v2.1", "taxCommunication", "activationGet"] },
        "description": "Is the service on? Read `Object.IsActive`.\n\nDocs: https://developer.magnifinance.com/finance/tax-compliance/tax-communication/rest/activation-get/"
      }
    },
    {
      "name": "Activation Set",
      "request": {
        "method": "POST",
        "header": [
          { "key": "email", "value": "{{email}}" },
          { "key": "token", "value": "{{token}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "url": { "raw": "{{baseUrl}}/api/v2.1/taxCommunication/activationSet", "host": ["{{baseUrl}}"], "path": ["api", "v2.1", "taxCommunication", "activationSet"] },
        "body": {
          "mode": "raw",
          "options": { "raw": { "language": "json" } },
          "raw": "{\n  \"Username\": \"{{atUsername}}\",\n  \"Password\": \"{{atPassword}}\",\n  \"IsActive\": true\n}"
        },
        "description": "Turns the service on with the AT credentials in `atUsername` / `atPassword`. The AT checks them right away: if it rejects them the request still succeeds but `Object.IsActive` is `false`. Send `\"IsActive\": false` to turn it off.\n\nDocs: https://developer.magnifinance.com/finance/tax-compliance/tax-communication/rest/activation-set/"
      }
    },
    {
      "name": "List Documents",
      "request": {
        "method": "POST",
        "header": [
          { "key": "email", "value": "{{email}}" },
          { "key": "token", "value": "{{token}}" },
          { "key": "Content-Type", "value": "application/json" }
        ],
        "url": { "raw": "{{baseUrl}}/api/v2.1/taxCommunication/communicationList", "host": ["{{baseUrl}}"], "path": ["api", "v2.1", "taxCommunication", "communicationList"] },
        "body": {
          "mode": "raw",
          "options": { "raw": { "language": "json" } },
          "raw": "{\n  \"ElementsPerPage\": 10,\n  \"CurrentPage\": 1\n}"
        },
        "description": "A page of the documents communicated to the AT and their status.\n\nDocs: https://developer.magnifinance.com/finance/tax-compliance/tax-communication/rest/communication-list/"
      }
    }
  ]
}
