{
  "info": {
    "_postman_id": "83dd533d-5cf0-4041-ac4f-f188aa874cce",
    "name": "External iBinder postman",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_exporter_id": "2890793"
  },
  "item": [
    {
      "name": "iBinder api",
      "item": [
        {
          "name": "Documents",
          "item": [
            {
              "name": "drive",
              "item": [
                {
                  "name": "List folders in binder",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "pm.test(\"Status code is 200\", function () {",
                          "    pm.response.to.have.status(200);",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "GET",
                    "header": [
                      {
                        "key": "x-ibinder-tenantid",
                        "value": "{{tenant_id}}",
                        "type": "text"
                      }
                    ],
                    "url": {
                      "raw": "{{api_url}}/documents/drives/:domain/:id",
                      "host": [
                        "{{api_url}}"
                      ],
                      "path": [
                        "documents",
                        "drives",
                        ":domain",
                        ":id"
                      ],
                      "variable": [
                        {
                          "key": "domain",
                          "value": "",
                          "description": "The domain of the drive. For example, \"binders\"."
                        },
                        {
                          "key": "id",
                          "value": "",
                          "description": "The drive id, corresponding to an object of the domain. For example, a 9 char NanoId for binderId."
                        }
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "List folders in folder",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "pm.test(\"Status code is 200\", function () {",
                          "    pm.response.to.have.status(200);",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "GET",
                    "header": [
                      {
                        "key": "x-ibinder-tenantid",
                        "value": "{{tenant_id}}",
                        "type": "text"
                      }
                    ],
                    "url": {
                      "raw": "{{api_url}}/documents/drives/:domain/:id/:folderid",
                      "host": [
                        "{{api_url}}"
                      ],
                      "path": [
                        "documents",
                        "drives",
                        ":domain",
                        ":id",
                        ":folderid"
                      ],
                      "variable": [
                        {
                          "key": "domain",
                          "value": "",
                          "description": "The domain of the drive. For example, \"binders\"."
                        },
                        {
                          "key": "id",
                          "value": "",
                          "description": "The drive id, corresponding to an object of the domain. For example, a 9 char NanoId for binderId."
                        },
                        {
                          "key": "folderid",
                          "value": "",
                          "description": "The folder id to upload to. For example a Guid corresponding to a TabId in a Binder."
                        }
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "List documents in folder",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "pm.test(\"Status code is 200\", function () {",
                          "    pm.response.to.have.status(200);",
                          "});"
                        ],
                        "type": "text/javascript",
                        "packages": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "GET",
                    "header": [
                      {
                        "key": "x-ibinder-tenantid",
                        "value": "{{tenant_id}}",
                        "type": "text"
                      }
                    ],
                    "url": {
                      "raw": "{{api_url}}/documents/drives/:domain/:id/:folderid/documents",
                      "host": [
                        "{{api_url}}"
                      ],
                      "path": [
                        "documents",
                        "drives",
                        ":domain",
                        ":id",
                        ":folderid",
                        "documents"
                      ],
                      "variable": [
                        {
                          "key": "domain",
                          "value": "",
                          "description": "The domain of the drive. For example, \"binders\"."
                        },
                        {
                          "key": "id",
                          "value": "",
                          "description": "The drive id, corresponding to an object of the domain. For example, a 9 char NanoId for binderId."
                        },
                        {
                          "key": "folderid",
                          "value": "",
                          "description": "The folder id to upload to. For example a Guid corresponding to a TabId in a Binder."
                        }
                      ]
                    }
                  },
                  "response": []
                }
              ],
              "description": "simplified api for accessing ibinder domains as document folder trees"
            },
            {
              "name": "Upload",
              "item": [
                {
                  "name": "Get New Presigned Url for Upload",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "var jsonData = pm.response.json();\r",
                          "pm.collectionVariables.set(\"Upload:PersonalStorageSasToken\", jsonData.presignedUrl);\r",
                          "pm.collectionVariables.set(\"Upload:UploadId\", jsonData.uploadId);\r",
                          "pm.collectionVariables.set(\"Upload:RawQuery\", jsonData.presignedUrl.split('?')[1]);\r",
                          "pm.collectionVariables.set(\"Upload:RawUrl\", jsonData.presignedUrl.split('?')[0]);\r",
                          "pm.expect(pm.response.code).to.be.oneOf([200]);\r",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {}
                      }
                    },
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "pm.environment.set(\"Documents:UploadId\", createUUID());\r",
                          "\r",
                          "function createUUID() {\r",
                          "   return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {\r",
                          "      var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);\r",
                          "      return v.toString(16);\r",
                          "   });\r",
                          "}"
                        ],
                        "type": "text/javascript",
                        "packages": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "GET",
                    "header": [],
                    "url": {
                      "raw": "{{api_url}}/documents/uploads/personalstorage/presignedupload",
                      "host": [
                        "{{api_url}}"
                      ],
                      "path": [
                        "documents",
                        "uploads",
                        "personalstorage",
                        "presignedupload"
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "Upload File To Presigned Url (use only once per presigned url)",
                  "event": [
                    {
                      "listen": "prerequest",
                      "script": {
                        "exec": [
                          "console.log(\"{{Documents:RawUrl}}/{{Documents:UploadId}}?{{Documents:RawQuery}}\");\r",
                          "\r",
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {}
                      }
                    },
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          ""
                        ],
                        "type": "text/javascript",
                        "packages": {}
                      }
                    }
                  ],
                  "protocolProfileBehavior": {
                    "disabledSystemHeaders": {}
                  },
                  "request": {
                    "auth": {
                      "type": "noauth"
                    },
                    "method": "PUT",
                    "header": [
                      {
                        "key": "x-ms-blob-type",
                        "value": "BlockBlob",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "file",
                      "file": {
                        "src": "/C:/Users/AlexanderSkarehag/OneDrive - iBinder AB/Documents/blob11.jpg"
                      }
                    },
                    "url": {
                      "raw": "{{Upload:RawUrl}}?{{Upload:RawQuery}}",
                      "host": [
                        "{{Upload:RawUrl}}"
                      ],
                      "query": [
                        {
                          "key": "{{Upload:RawQuery}}",
                          "value": null
                        }
                      ]
                    }
                  },
                  "response": []
                },
                {
                  "name": "Commit Uploaded File as DocumentVersion",
                  "event": [
                    {
                      "listen": "test",
                      "script": {
                        "exec": [
                          "pm.test(\"Status code is 200\", function () {",
                          "    pm.response.to.have.status(200);",
                          "});",
                          "",
                          "if (pm.response.status == 200) {",
                          "    pm.collectionVariables.unset(\"Upload:PersonalStorageSasToken\");",
                          "    pm.collectionVariables.unset(\"Upload:UploadId\");",
                          "    pm.collectionVariables.unset(\"Upload:RawQuery\");",
                          "    pm.collectionVariables.unset(\"Upload:RawUrl\");",
                          "}"
                        ],
                        "type": "text/javascript",
                        "packages": {}
                      }
                    }
                  ],
                  "request": {
                    "method": "POST",
                    "header": [
                      {
                        "key": "x-ibinder-tenantid",
                        "value": "{{tenant_id}}",
                        "type": "text"
                      }
                    ],
                    "body": {
                      "mode": "raw",
                      "raw": "{\r\n    \"fileName\": \"FILENAME-HERE.EXTENSION\",\r\n    \"version\": \"b\",\r\n    \"uploadId\": \"{{Upload:UploadId}}\",\r\n    \"additionalMetadata\": [\r\n        {\r\n            \"metadataElementId\": \"GLOBAL_Category\",\r\n            \"value\": \"Some category\"\r\n        },\r\n        {\r\n            \"metadataElementId\": \"HANDLING\",\r\n            \"value\": \"PROGRAMHANDLING\"\r\n        }\r\n    ]\r\n}",
                      "options": {
                        "raw": {
                          "language": "json"
                        }
                      }
                    },
                    "url": {
                      "raw": "{{api_url}}/documents/drives/:domain/:id/:folderid/upload",
                      "host": [
                        "{{api_url}}"
                      ],
                      "path": [
                        "documents",
                        "drives",
                        ":domain",
                        ":id",
                        ":folderid",
                        "upload"
                      ],
                      "variable": [
                        {
                          "key": "domain",
                          "value": "",
                          "description": "The domain of the drive. For example, \"binders\"."
                        },
                        {
                          "key": "id",
                          "value": "",
                          "description": "The drive id, corresponding to an object of the domain. For example, a 9 char NanoId for binderId."
                        },
                        {
                          "key": "folderid",
                          "value": "",
                          "description": "The folder id to upload to. For example a Guid corresponding to a TabId in a Binder."
                        }
                      ]
                    }
                  },
                  "response": []
                }
              ]
            },
            {
              "name": "List documentversions for document",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "pm.test(\"Status code is 200\", function () {",
                      "    pm.response.to.have.status(200);",
                      "});"
                    ],
                    "type": "text/javascript",
                    "packages": {}
                  }
                }
              ],
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "x-ibinder-tenantid",
                    "value": "{{tenant_id}}",
                    "type": "text"
                  }
                ],
                "url": {
                  "raw": "{{api_url}}/documents/:documentId/versions",
                  "host": [
                    "{{api_url}}"
                  ],
                  "path": [
                    "documents",
                    ":documentId",
                    "versions"
                  ],
                  "variable": [
                    {
                      "key": "documentId",
                      "value": "",
                      "description": "The document Id of the document to list versions for. Expects a Guid."
                    }
                  ]
                }
              },
              "response": []
            },
            {
              "name": "Get documentversion",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "pm.test(\"Status code is 200\", function () {",
                      "    pm.response.to.have.status(200);",
                      "});"
                    ],
                    "type": "text/javascript",
                    "packages": {}
                  }
                }
              ],
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "x-ibinder-tenantid",
                    "value": "{{tenant_id}}",
                    "type": "text"
                  }
                ],
                "url": {
                  "raw": "{{api_url}}/documents/:documentId/versions/:versionId",
                  "host": [
                    "{{api_url}}"
                  ],
                  "path": [
                    "documents",
                    ":documentId",
                    "versions",
                    ":versionId"
                  ],
                  "variable": [
                    {
                      "key": "documentId",
                      "value": "",
                      "description": "The document Id of the documentVersion. Expects a Guid."
                    },
                    {
                      "key": "versionId",
                      "value": "",
                      "description": "The document version Id of the documentVersion. Expects a Guid."
                    }
                  ]
                }
              },
              "response": []
            },
            {
              "name": "Get document",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "pm.test(\"Status code is 200\", function () {",
                      "    pm.response.to.have.status(200);",
                      "});"
                    ],
                    "type": "text/javascript",
                    "packages": {}
                  }
                }
              ],
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "x-ibinder-tenantid",
                    "value": "{{tenant_id}}",
                    "type": "text"
                  }
                ],
                "url": {
                  "raw": "{{api_url}}/documents/:documentId",
                  "host": [
                    "{{api_url}}"
                  ],
                  "path": [
                    "documents",
                    ":documentId"
                  ],
                  "variable": [
                    {
                      "key": "documentId",
                      "value": "",
                      "description": "The document Id of the documentVersion. Expects a Guid."
                    }
                  ]
                }
              },
              "response": []
            },
            {
              "name": "Get documentversion download link",
              "event": [
                {
                  "listen": "test",
                  "script": {
                    "exec": [
                      "pm.test(\"Status code is 200\", function () {",
                      "    pm.response.to.have.status(200);",
                      "});"
                    ],
                    "type": "text/javascript",
                    "packages": {}
                  }
                }
              ],
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "x-ibinder-tenantid",
                    "value": "{{tenant_id}}",
                    "type": "text"
                  }
                ],
                "url": {
                  "raw": "{{api_url}}/documents/:documentId/versions/:versionId/raw",
                  "host": [
                    "{{api_url}}"
                  ],
                  "path": [
                    "documents",
                    ":documentId",
                    "versions",
                    ":versionId",
                    "raw"
                  ],
                  "variable": [
                    {
                      "key": "documentId",
                      "value": "",
                      "description": "The document Id of the documentVersion. Expects a Guid."
                    },
                    {
                      "key": "versionId",
                      "value": "",
                      "description": "The document version Id of the documentVersion. Expects a Guid."
                    }
                  ]
                }
              },
              "response": []
            },
            {
              "name": "Search/filter documents",
              "protocolProfileBehavior": {
                "disabledSystemHeaders": {}
              },
              "request": {
                "method": "POST",
                "header": [
                  {
                    "key": "x-ibinder-tenantid",
                    "value": "{{tenant_id}}",
                    "type": "text"
                  }
                ],
                "body": {
                  "mode": "raw",
                  "raw": "{\r\n    \"metadataFilters\": [\r\n        {\r\n            \"metadataElementId\": \"GLOBAL_BinderId\",\r\n            \"valueId\": \"MNWI5YR89\"\r\n        },\r\n        {\r\n            \"metadataElementId\": \"GLOBAL_TabType\",\r\n            \"value\": \"Ritningar ÖrebroPorten\"\r\n        }\r\n    ],\r\n    \"sortBy\": [\r\n        {\r\n            \"metadataElementId\": \"GLOBAL_Category\",\r\n            \"direction\": \"asc\"\r\n        }\r\n    ]\r\n}",
                  "options": {
                    "raw": {
                      "language": "json"
                    }
                  }
                },
                "url": {
                  "raw": "{{api_url}}/documents?pageSize=1000",
                  "host": [
                    "{{api_url}}"
                  ],
                  "path": [
                    "documents"
                  ],
                  "query": [
                    {
                      "key": "pageSize",
                      "value": "1000"
                    }
                  ]
                }
              },
              "response": []
            }
          ]
        },
        {
          "name": "Binders",
          "item": [
            {
              "name": "List binders",
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "x-ibinder-tenantid",
                    "value": "{{tenant_id}}",
                    "type": "text"
                  }
                ],
                "url": {
                  "raw": "{{api_url}}/binders",
                  "host": [
                    "{{api_url}}"
                  ],
                  "path": [
                    "binders"
                  ]
                }
              },
              "response": []
            },
            {
              "name": "Get definitions of metadata in binder",
              "request": {
                "method": "GET",
                "header": [
                  {
                    "key": "x-ibinder-tenantid",
                    "value": "{{tenant_id}}",
                    "type": "text"
                  }
                ],
                "url": {
                  "raw": "{{api_url}}/binders/:id/metadataelements",
                  "host": [
                    "{{api_url}}"
                  ],
                  "path": [
                    "binders",
                    ":id",
                    "metadataelements"
                  ],
                  "variable": [
                    {
                      "key": "id",
                      "value": "",
                      "description": "The id of the binder. Expects a 9 char NanoId. "
                    }
                  ]
                }
              },
              "response": []
            }
          ]
        }
      ]
    }
  ],
  "auth": {
    "type": "oauth2",
    "oauth2": [
      {
        "key": "clientSecret",
        "value": "{{ibinder_client_secret}}",
        "type": "string"
      },
      {
        "key": "clientId",
        "value": "{{ibinder_client_id}}",
        "type": "string"
      },
      {
        "key": "tokenName",
        "value": "ibinder_client_credentials",
        "type": "string"
      },
      {
        "key": "accessTokenUrl",
        "value": "{{signin_authority}}/connect/token",
        "type": "string"
      },
      {
        "key": "refreshRequestParams",
        "value": [],
        "type": "any"
      },
      {
        "key": "tokenRequestParams",
        "value": [],
        "type": "any"
      },
      {
        "key": "authRequestParams",
        "value": [],
        "type": "any"
      },
      {
        "key": "challengeAlgorithm",
        "value": "S256",
        "type": "string"
      },
      {
        "key": "scope",
        "value": "ibinder_public",
        "type": "string"
      },
      {
        "key": "grant_type",
        "value": "client_credentials",
        "type": "string"
      },
      {
        "key": "addTokenTo",
        "value": "header",
        "type": "string"
      },
      {
        "key": "client_authentication",
        "value": "body",
        "type": "string"
      }
    ]
  },
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "packages": {},
        "exec": [
          ""
        ]
      }
    },
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "packages": {},
        "exec": [
          ""
        ]
      }
    }
  ],
  "variable": [
    {
      "key": "tenant_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "ibinder_client_id",
      "value": "",
      "type": "string"
    },
    {
      "key": "ibinder_client_secret",
      "value": "",
      "type": "string"
    },
    {
      "key": "signin_authority",
      "value": "https://signin.ibinder.com",
      "type": "string"
    },
    {
      "key": "api_url",
      "value": "https://api.ibinder.com/api",
      "type": "string"
    }
  ]
}