{"id":21452367,"url":"https://github.com/vtfk/azf-archive","last_synced_at":"2025-07-14T22:31:10.479Z","repository":{"id":37709802,"uuid":"175828030","full_name":"vtfk/azf-archive","owner":"vtfk","description":"Azure function for archive operations in P360","archived":true,"fork":false,"pushed_at":"2024-12-19T13:11:37.000Z","size":2216,"stargazers_count":3,"open_issues_count":11,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-27T06:45:54.187Z","etag":null,"topics":["archive","azure","functions","p360","rpc","sif"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vtfk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-15T13:44:29.000Z","updated_at":"2025-01-16T15:31:01.000Z","dependencies_parsed_at":"2024-01-14T12:04:27.128Z","dependency_job_id":"401542a7-05cc-4b50-b75f-eaaf981b4c9d","html_url":"https://github.com/vtfk/azf-archive","commit_stats":null,"previous_names":[],"tags_count":64,"template":false,"template_full_name":null,"purl":"pkg:github/vtfk/azf-archive","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtfk%2Fazf-archive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtfk%2Fazf-archive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtfk%2Fazf-archive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtfk%2Fazf-archive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vtfk","download_url":"https://codeload.github.com/vtfk/azf-archive/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vtfk%2Fazf-archive/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265360125,"owners_count":23752631,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["archive","azure","functions","p360","rpc","sif"],"created_at":"2024-11-23T04:29:08.284Z","updated_at":"2025-07-14T22:31:10.097Z","avatar_url":"https://github.com/vtfk.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# azf-archive\n\nAzure function for archive operations in P360\n\n## API\n\nAll calls needs a valid Azure Subscription key\n\n### ```POST /archive - template```\n\nEndpoint for template calls. See [here](#templates) for a complete list of templates\n\nRequired fields:\n- `system`: Which ***system*** to use\n- `template`: Which ***template*** to use\n- `parameter`: Parameters for calling ***P360***\n\nOptional fields:\n- `parameter.attachments`: List of ***attachments*** to add to P360 Document when using templates with methods 'CreateDocument' or 'UpdateDocument'\n- `parameter.contacts`: List of ***contacts*** to add to P360 Project, Case, or Document when using templates with methods 'CreateProject', 'UpdateProject', 'CreateCase', 'UpdateCase', 'CreateDocument', or 'UpdateDocument'\n\n```json\n{\n  \"system\": \"iop\",\n  \"template\": \"document\",\n  \"parameter\": {\n    \"accessGroup\": \"Elev vgs\",\n    \"organizationNumber\": \"01234\",\n    \"ssn\": \"01010101010\",\n    \"base64\": \"JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwogIC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAvTWVkaWFCb3ggWyAwIDAgMjAwIDIwMCBdCiAgL0NvdW50IDEKICAvS2lkcyBbIDMgMCBSIF0KPj4KZW5kb2JqCgozIDAgb2JqCjw8CiAgL1R5cGUgL1BhZ2UKICAvUGFyZW50IDIgMCBSCiAgL1Jlc291cmNlcyA8PAogICAgL0ZvbnQgPDwKICAgICAgL0YxIDQgMCBSIAogICAgPj4KICA+PgogIC9Db250ZW50cyA1IDAgUgo+PgplbmRvYmoKCjQgMCBvYmoKPDwKICAvVHlwZSAvRm9udAogIC9TdWJ0eXBlIC9UeXBlMQogIC9CYXNlRm9udCAvVGltZXMtUm9tYW4KPj4KZW5kb2JqCgo1IDAgb2JqICAlIHBhZ2UgY29udGVudAo8PAogIC9MZW5ndGggNDQKPj4Kc3RyZWFtCkJUCjcwIDUwIFRECi9GMSAxMiBUZgooSGVsbG8sIHdvcmxkISkgVGoKRVQKZW5kc3RyZWFtCmVuZG9iagoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDEwIDAwMDAwIG4gCjAwMDAwMDAwNzkgMDAwMDAgbiAKMDAwMDAwMDE3MyAwMDAwMCBuIAowMDAwMDAwMzAxIDAwMDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9vdCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G\",\n    \"fileFormat\": \"pdf\",\n    \"displayName\": \"Bjarne Betjent\",\n    \"caseNumber\": \"30/99999\",\n    \"documentDate\": \"2021-09-27\",\n    \"versionNumber\": \"4.0\"\n  }\n}\n```\n#### `Sending to \"unregistered\" - for manual archiving`\nUseful for when you do not have sufficient data for automatic archiving (e.g. foreign students not registered in DSF/folkeregister)\n```json\n{\n  \"system\": \"archive\",\n  \"template\": \"unregistered\",\n  \"parameter\": {\n    \"title\": \"A title that describes the document\",\n    \"msg\": \"A message to the archivists, on why this could not be automatically be archived (keep it short)\", \n    \"base64\": \"JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwogIC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAvTWVkaWFCb3ggWyAwIDAgMjAwIDIwMCBdCiAgL0NvdW50IDEKICAvS2lkcyBbIDMgMCBSIF0KPj4KZW5kb2JqCgozIDAgb2JqCjw8CiAgL1R5cGUgL1BhZ2UKICAvUGFyZW50IDIgMCBSCiAgL1Jlc291cmNlcyA8PAogICAgL0ZvbnQgPDwKICAgICAgL0YxIDQgMCBSIAogICAgPj4KICA+PgogIC9Db250ZW50cyA1IDAgUgo+PgplbmRvYmoKCjQgMCBvYmoKPDwKICAvVHlwZSAvRm9udAogIC9TdWJ0eXBlIC9UeXBlMQogIC9CYXNlRm9udCAvVGltZXMtUm9tYW4KPj4KZW5kb2JqCgo1IDAgb2JqICAlIHBhZ2UgY29udGVudAo8PAogIC9MZW5ndGggNDQKPj4Kc3RyZWFtCkJUCjcwIDUwIFRECi9GMSAxMiBUZgooSGVsbG8sIHdvcmxkISkgVGoKRVQKZW5kc3RyZWFtCmVuZG9iagoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDEwIDAwMDAwIG4gCjAwMDAwMDAwNzkgMDAwMDAgbiAKMDAwMDAwMDE3MyAwMDAwMCBuIAowMDAwMDAwMzAxIDAwMDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9vdCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G\",\n    \"originRecno\": \"200007\" // \"200007\" is displayed as source \"Arkiveringsrobot\" for archivists - if you need something else - ask an adult\n  }\n}\n```\n\n#### `With attachments and/or contacts`\n\n```json\n{\n  \"system\": \"iop\",\n  \"template\": \"document\",\n  \"parameter\": {\n    \"accessGroup\": \"Elev vgs\",\n    \"organizationNumber\": \"01234\",\n    \"ssn\": \"01010101010\",\n    \"base64\": \"JVBERi0xLjcKCjEgMCBvYmogICUgZW50cnkgcG9pbnQKPDwKICAvVHlwZSAvQ2F0YWxvZwogIC9QYWdlcyAyIDAgUgo+PgplbmRvYmoKCjIgMCBvYmoKPDwKICAvVHlwZSAvUGFnZXMKICAvTWVkaWFCb3ggWyAwIDAgMjAwIDIwMCBdCiAgL0NvdW50IDEKICAvS2lkcyBbIDMgMCBSIF0KPj4KZW5kb2JqCgozIDAgb2JqCjw8CiAgL1R5cGUgL1BhZ2UKICAvUGFyZW50IDIgMCBSCiAgL1Jlc291cmNlcyA8PAogICAgL0ZvbnQgPDwKICAgICAgL0YxIDQgMCBSIAogICAgPj4KICA+PgogIC9Db250ZW50cyA1IDAgUgo+PgplbmRvYmoKCjQgMCBvYmoKPDwKICAvVHlwZSAvRm9udAogIC9TdWJ0eXBlIC9UeXBlMQogIC9CYXNlRm9udCAvVGltZXMtUm9tYW4KPj4KZW5kb2JqCgo1IDAgb2JqICAlIHBhZ2UgY29udGVudAo8PAogIC9MZW5ndGggNDQKPj4Kc3RyZWFtCkJUCjcwIDUwIFRECi9GMSAxMiBUZgooSGVsbG8sIHdvcmxkISkgVGoKRVQKZW5kc3RyZWFtCmVuZG9iagoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDEwIDAwMDAwIG4gCjAwMDAwMDAwNzkgMDAwMDAgbiAKMDAwMDAwMDE3MyAwMDAwMCBuIAowMDAwMDAwMzAxIDAwMDAwIG4gCjAwMDAwMDAzODAgMDAwMDAgbiAKdHJhaWxlcgo8PAogIC9TaXplIDYKICAvUm9vdCAxIDAgUgo+PgpzdGFydHhyZWYKNDkyCiUlRU9G\",\n    \"fileFormat\": \"pdf\",\n    \"displayName\": \"Bjarne Betjent\",\n    \"caseNumber\": \"30/99999\",\n    \"documentDate\": \"2021-09-27\",\n    \"versionNumber\": \"4.0\",\n    \"attachments\": [ // Optional\n      {\n        \"title\": \"Et vedlegg\",\n        \"format\": \"docx\",\n        \"base64\": \"base64-representation of the file\",\n        \"versionFormat\": \"A\" // Optional. Defaults to \"P\" (P = production format - document will be converted to pdf, if applicable)\n      },\n      {\n        \"title\": \"Enda et vedlegg\",\n        \"format\": \"msg\",\n        \"base64\": \"base64-representation of the file\"\n      }\n    ],\n    \"contacts\": [ // Optional\n      {\n        \"ssn\": \"01010101011\", // Valid property names are: \"ssn\", \"recno\", and \"externalId\"\n        \"role\": \"Mottaker\",\n        \"isUnofficial\": true // Can be true, false, or undefined (undefined =\u003e false)\n      },\n      {\n        \"recno\": \"12345\",\n        \"role\": \"Avsender\"\n      },\n      {\n        \"externalID\": \"78787\",\n        \"role\": \"Avsender\",\n        \"isUnofficial\": false\n      }\n    ]\n  }\n}\n```\n\n### ```POST /archive - raw```\n\nEndpoint for raw SIF calls\n\nRequired fields:\n- `service`: Which ***SIF service*** to use\n- `method`: Which ***method*** from ***SIF service*** to use\n- `parameter`: Parameters for calling ***service.method***\n\nOptional fields:\n- `secure`: If true, `SECURE P360` will be used; If false or undefined, `REGULAR P360` will be used\n- `options`: JSON Object for repack options\n\n#### `Secure`\n\n```json\n{\n  \"service\": \"ContactService\",\n  \"method\": \"GetPrivatePersons\",\n  \"secure\": true,\n  \"parameter\": {\n    \"PersonalIdNumber\": \"01010101010\"\n  }\n}\n```\n\n#### `Non-Secure`\n\n```json\n{\n  \"service\": \"ContactService\",\n  \"method\": \"GetPrivatePersons\",\n  \"secure\": false, // this can be undefined, removed, empty string or 0 as well\n  \"parameter\": {\n    \"PersonalIdNumber\": \"01010101010\"\n  }\n}\n```\n\n#### `With options`\n\n```json\n{\n  \"service\": \"CaseService\",\n  \"method\": \"GetCases\",\n  \"parameter\": {\n    \"ContactReferenceNumber\": \"01010101010\",\n    \"Title\": \"Elevmappe\"\n  },\n  \"options\": {\n    \"onlyOpenCases\": true // see #available-options\n  }\n}\n```\n\n#### `Get first Case`\n\n```json\n{\n  \"service\": \"CaseService\",\n  \"method\": \"GetCases\",\n  \"parameter\": {\n    \"ContactReferenceNumber\": \"01010101010\",\n    \"Title\": \"Elevmappe\"\n  },\n  \"options\": {\n    \"limit\": 1 // see #available-options\n  }\n}\n```\n\n#### Available options\n\n| Option | Type | Value | Description |\n| ------ | ---- | ----- | ----------- |\n| onlyOpenCases | `Boolean` | `true` / `false` | If true, only cases with `Status === 'Under behandling'` will be returned; If false or undefined, all cases will be returned regardless of Status |\n| excludeExpiredCases | `Boolean` | `true` / `false` | If true, only cases without `Status === 'Utgår'` will be returned; If false or undefined, all cases will be returned regardless of Status |\n| limit | `int` | `1` - `2147483647` | If set to `1`, first occurance will be returned as an `object`. If set to `2` or greater, an array with `limit` amount of items are returned. If set to `0` or not set, the original output will be returned |\n\n#### Supported **services** and their **methods**\n\n- **AccessGroupService**\n  - *GetAccessGroups*\n- **CaseService**\n  - *CreateCase*\n  - *GetCases*\n  - *UpdateCase*\n- **ContactService**\n  - *GetContactPersons*\n  - *GetEnterprises*\n  - *GetPrivatePersons*\n  - *SynchronizeContactPerson*\n  - *SynchronizeEnterprise*\n  - *SynchronizePrivatePerson*\n  - *UpdatePrivatePerson*\n- **DocumentService**\n  - *CreateDocument*\n  - *DispatchDocuments*\n  - *GetDocuments*\n  - *SignOffDocument*\n  - *UpdateDocument*\n- **EstateService**\n  - *GetEstates*\n  - *SynchronizeEstate*\n- **FileService**\n  - *CheckOutAndGetFileForExternalControl*\n  - *CreateFile*\n  - *DeleteFile*\n  - *GetFileWithMetadata*\n  - *GetFile*\n  - *Upload*\n  - *UploadAndCheckInFileFromExternalControl*\n  - *UploadFile*\n- **MyCasesService**\n  - *GetMyCases*\n- **ProjectService**\n  - *CreateProject*\n  - *GetProjects*\n  - *UpdateProject*\n- **UserService**\n  - *GetUsers*\n  - *SynchronizeUser*\n\nFull documentation for the **SIF services** can be found [here](https://github.com/vtfk/azf-archive/blob/master/docs/sif-generic-web-service.pdf)\n\n### ```POST /Changes```\n\nEndpoint for changes in IDM\n\nNo input or output. Changes will be fetched from IDM\n\n### ```POST /SyncPrivatePerson```\n- Create **PrivatePerson** on person if one doesn't exist\n- Updates name and address on **PrivatePerson** if one already exists\n- Updates ssn for **PrivatePerson** if parameter *oldSsn* is passed, or if new ssn is found in `Det sentrale folkeregister`\n\nFetches person info from [Det sentrale folkeregister](https://github.com/vtfk/azf-dsf)\n\n#### `With ssn as parameter`\n```json\n{\n  \"ssn\": \"01010101010\"\n}\n```\n\n#### `With birthdate and name as parameter (only works with one match)`\n```json\n{\n  \"birthdate\": \"010101\",\n  \"firstName\": \"Per\",\n  \"lastName\": \"Son\"\n}\n```\n\n#### `Optional: With old ssn and new ssn as parameter (for updating ssn on PrivatePerson)`\nEither updates the **PrivatePerson** with new ssn, if person exists on old ssn, or creates new **PrivatePerson** with new ssn\n```json\n{\n  \"ssn\": \"01010101011\",\n  \"oldSsn\": \"01010101010\"\n}\n```\n\n#### `Optional: Do not lookup person in DSF (det sentrale folkeregister). (Requires more info) Useful when person is not registered in DSF`\nEither updates the **PrivatePerson** with the provided data if person exists on ssn, or creates new **PrivatePerson** with the provided data\n```json\n{\n  \"ssn\": \"12345678910\",\n  \"firstName\": \"Bjarte\",\n  \"lastName\": \"Bjøstheim\",\n  \"streetAddress\": \"Gamlehjemmet 44\",\n  \"zipCode\": \"1234\",\n  \"zipPlace\": \"Jupiter\",\n  \"addressCode\": 0,\n  \"skipDSF\": true // Must be set to \"true\" if you need to skip DSF lookup\n}\n```\n\n#### `Optional: Do not lookup person in DSF (det sentrale folkeregister) AND generate a fake ssn for the preson. (Requires more info) Useful when person is not registered in DSF, and you need to generate a fake ssn`\nEither updates the **PrivatePerson** with the provided data if person exists on the fake ssn AND the lastname of the existing 360-contact and the input-lastname matches, or creates new **PrivatePerson** with the provided data. Updates or creates **elevmappe** as well. \n```json\n{\n  \"generateFakeSsn\": true, // // Must be set to \"true\" if you need want to generate a fake ssn\n  \"birthdate\": \"010188\", // Used to generate fake ssn\n  \"gender\": \"010188\", // Used to generate fake ssn\n  \"firstName\": \"Bjarte\",\n  \"lastName\": \"Bjøstheim\",\n  \"streetAddress\": \"Gamlehjemmet 44\",\n  \"zipCode\": \"1234\",\n  \"zipPlace\": \"Jupiter\",\n  \"addressCode\": 0,\n  \"skipDSF\": true, // Must be set to \"true\" if you need to skip DSF lookup\n}\n```\n\n### ```POST /SyncEnterprise```\n- Create **Enterprise** on Brreg-company if one doesn't exist\n- Updates data on **Enterprise** if one already exists\n\n#### `Payload`\n```json\n{\n  \"orgnr\": \"123456789\"\n}\n```\n\nFetches company info from [Brønnøysundregisteret]https://www.brreg.no/)\n\n\n### ```POST /SyncElevmappe```\n- Creates **PrivatePerson** on person if one doesn't exist\n- Updates name and address on **PrivatePerson** if one already exists\n- Updates ssn for **PrivatePerson** if parameter *oldSsn* is passed, or if new ssn is found in `Det sentrale folkeregister`\n- Creates **Elevmappe** on user if one doesn't exist\n- Updates case contact and name on **Elevmappe** if one already exists\n- Grants reading permissions to *newSchools* on relevant documents in **Elevmappe** if parameter *newSchools* is passed\n- Sends email alert to archive department if there is need for manual operations\nFetches person info from [Det sentrale folkeregister](https://github.com/vtfk/azf-dsf)\n\n#### `With ssn as parameter`\n```json\n{\n  \"ssn\": \"01010101010\"\n}\n```\n\n#### `With birthdate and name as parameter (only works with one match)`\n```json\n{\n  \"birthdate\": \"010101\",\n  \"firstName\": \"Per\",\n  \"lastName\": \"Son\"\n}\n```\n\n#### `Optional: With old ssn and new ssn as parameter (for updating ssn on PrivatePerson)`\nEither updates the **PrivatePerson** with new ssn, if person exists on old ssn, or creates new **PrivatePerson** with new ssn. Updates or creates **elevmappe** as well. \n```json\n{\n  \"ssn\": \"01010101011\",\n  \"oldSsn\": \"01010101010\"\n}\n```\n#### `Optional: Do not lookup person in DSF (det sentrale folkeregister). (Requires more info) Useful when person is not registered in DSF`\nEither updates the **PrivatePerson** with the provided data if person exists on ssn, or creates new **PrivatePerson** with the provided data. Updates or creates **elevmappe** as well. \n```json\n{\n  \"ssn\": \"12345678910\",\n  \"firstName\": \"Bjarte\",\n  \"lastName\": \"Bjøstheim\",\n  \"streetAddress\": \"Gamlehjemmet 44\",\n  \"zipCode\": \"1234\",\n  \"zipPlace\": \"Jupiter\",\n  \"addressCode\": 0,\n  \"skipDSF\": true // Must be set to \"true\" if you need to skip DSF lookup\n}\n```\n\n#### `Optional: Do not lookup person in DSF (det sentrale folkeregister) AND generate a fake ssn for the preson. (Requires more info) Useful when person is not registered in DSF, and you need to generate a fake ssn`\nEither updates the **PrivatePerson** with the provided data if person exists on the fake ssn AND the lastname of the existing 360-contact and the input-lastname matches, or creates new **PrivatePerson** with the provided data. Updates or creates **elevmappe** as well. \n```json\n{\n  \"generateFakeSsn\": true, // // Must be set to \"true\" if you need want to generate a fake ssn\n  \"birthdate\": \"010188\", // Used to generate fake ssn\n  \"gender\": \"010188\", // Used to generate fake ssn\n  \"firstName\": \"Bjarte\",\n  \"lastName\": \"Bjøstheim\",\n  \"streetAddress\": \"Gamlehjemmet 44\",\n  \"zipCode\": \"1234\",\n  \"zipPlace\": \"Jupiter\",\n  \"addressCode\": 0,\n  \"skipDSF\": true, // Must be set to \"true\" if you need to skip DSF lookup\n}\n```\n\n#### `Optional: With newSchools as parameter, for granting reading permissions for new school(s)`\nMust be array of school(s), where each school is the official name of the school. [See available school names here](https://github.com/vtfk/vtfk-schools-info/blob/master/lib/data/schools.json)\n```json\n{\n  \"ssn\": \"01010101011\",\n  \"newSchools\": [\"Gul videregående skole\", \"Livets videregående skole\"]\n}\n```\n\n### ```POST /SyncEmployee```\n- Creates **PrivatePerson** on person if one doesn't exist\n- Updates name and address on **PrivatePerson** if one already exists\n- Creates **Employee project** on user if one doesn't exist\n- Sends email alert to archive department if there is need for manual operations:\n  - If manager does not have user in P360\n  - If manager have several contactpersons on email-address\n  - If enterprise manager is employed in is missing enterprisenumber\n  - If several enterprises are found on the same enterprisenumber\n  - If enterprise does not have access group of type \"Lønn\" or \"Personal\"\n  - If several employee projects are found on one employee\n\nFetches person info from [Det sentrale folkeregister](https://github.com/vtfk/azf-dsf)\n\n#### `With ssn and upn as parameter`\n```json\n{\n  \"ssn\": \"01010101010\",\n  \"upn\": \"per.son@company.no\"\n}\n```\n\n#### `With birthdate and name as parameter (only works with one match)`\n```json\n{\n  \"birthdate\": \"010101\",\n  \"firstName\": \"Per\",\n  \"lastName\": \"Son\",\n  \"upn\": \"per.son@company.no\"\n}\n```\n\n#### `Optional: Do not lookup person in DSF (det sentrale folkeregister). (Requires more info) Useful when person is not registered in DSF`\nEither updates the **PrivatePerson** with the provided data if person exists on ssn, or creates new **PrivatePerson** with the provided data. Updates or creates **elevmappe** as well. \n```json\n{\n  \"ssn\": \"12345678910\",\n  \"firstName\": \"Bjarte\",\n  \"lastName\": \"Bjøstheim\",\n  \"streetAddress\": \"Gamlehjemmet 44\",\n  \"zipCode\": \"1234\",\n  \"zipPlace\": \"Jupiter\",\n  \"addressCode\": 0,\n  \"skipDSF\": true, // Must be set to \"true\" if you need to skip DSF lookup\n  \"upn\": \"bjarte.bjostheim@company.no\n}\n```\n\n#### `Optional: With parameter allowNullValues`\nSet **allowNullValues** to **true**, if you want to continue also when accessGroups and enterprise is not found. **REMARK:** Client itself must handle access groups, enterprise, and manager when this parameter is set to true\n```json\n{\n  \"ssn\": \"01010101011\",\n  \"upn\": \"per.son@company.no\",\n  \"allowNullValues\": true // Defaults to \"false\"\n}\n```\n#### `RETURNS`\n```json\n{\n\t\"dsfPerson\": {\n\t\t\"ssn\": \"010101010101\",\n\t\t\"oldSsn\": \"010101010101\", // The same as ssn if no change in DSF, or not specified by client\n\t\t\"firstName\": \"Per\",\n\t\t\"lastName\": \"Son\",\n\t\t\"streetAddress\": \"Gata 2\",\n\t\t\"zipCode\": \"1234\",\n\t\t\"zipPlace\": \"STED\",\n\t\t\"addressType\": \"VANLIG BOSATT\",\n\t\t\"addressCode\": 0,\n\t\t\"residentialAddress\": {\n\t\t\t\"ADR\": \"Gata 2\",\n\t\t\t\"POSTN\": \"1234\",\n\t\t\t\"POSTS\": \"STED\"\n\t\t}\n\t},\n\t\"privatePerson\": {\n\t\t\"ssn\": \"010101010101\",\n\t\t\"oldSsn\": \"010101010101\",\n\t\t\"firstName\": \"Per\",\n\t\t\"lastName\": \"Son\",\n\t\t\"streetAddress\": \"Gata 2\",\n\t\t\"zipCode\": \"1234\",\n\t\t\"zipPlace\": \"STED\",\n\t\t\"addressCode\": 0,\n\t\t\"recno\": 123456,\n\t\t\"updated\": false, // If the privatePerson was updated\n\t\t\"updatedSsn\": false // If the ssn of the privatePerson was updated\n\t},\n\t\"employee\": {\n    \"upn\": \"per.son@company.no\", // Employee userPrincipalName from azure ad\n\t\t\"manager\": \"herr.sjef@company.no\", // Registered manager in azure ad\n\t\t\"enterpriseNumber\": \"123456\", // NOTE: Can be null if allowNullValues is false\n\t\t\"enterpriseName\": \"Seksjon for surr og tull\", // NOTE: Can be null if allowNullValues is false\n\t\t\"accessGroups\": {\n\t\t\t\"personal\": \"Personal surr og tull\", // NOTE: Can be null if allowNullValues is false\n\t\t\t\"lonn\": \"Lønn surr og tull\" // NOTE: Can be null if allowNullValues is false\n\t\t},\n\t\t\"recno\": 12345, // Recno of employeeProject\n\t\t\"projectNumber\": \"23-12\" // ProjectNumber of employeeProject \n\t}\n}\n```\n\n### ```POST /SyncSharePointSite```\nEndpoint for connecting a Sharepoint site to a archive-project, and a list || documentLibrary || folder to a archive-case\n\nThe Sharepoint site is connected to a archive-projectNumber. The list || documentLibrary || folder is connected to a archive case through the archive-field **externalId**\n\n- Creates **Project** in archive if parameter `projectNumber` is not provided, or set to the string 'nei'.\n- Creates **Case** in archive if the Sharepoint-id of the list || documentLibrary || folder does not exist as externalId in archive - or fetches the caseNumber if it exists.\n- Does **not** update case or project metadata in archive. This is for avoiding conflicting changes if archivists change metadata directly in archive.\n- If project exists - new case will inherit responsible person from the project, even if you specify a different responsible person this in the payload. This is for avoiding conflicting changes if archivists change metadata directly in archive.\n- Returns metadata on **Project** and **Case** from archive\n\n\n#### `Example payload`\n```json\n{\n  \"siteUrl\": \"https://\u003cdomain\u003e.sharepoint.com/sites/\u003csite-name\u003e\",\n  \"projectNumber\": \"{existing project number} || ${'nei'} || ${undefined}\", // Undefined and 'nei' creates new project in archive\n  \"projectTitle\": \"Something that describes the Sharepoint site\",\n  \"responsiblePersonEmail\": \"person@domain.com\", // Must have access to archive - will throw error if user email is not found on a user in archive\n  \"caseExternalId\": \"{siteUrl}-{type}-{guid}\", // TODO: decide common structure - externalId MUST be unique\n  \"caseTitle\": \"Something that describes the list || documentLibrary || folder\",\n  \"accessGroup\": \"Elev gul skole\", // OPTIONAL. Defaults to \"Alle\"\n  \"paragraph\": \"Offntl. 13.3\" // OPTIONAL. Defaults to \"\"\n}\n```\n#### `Response`\n```json\n{\n  \"msg\": \"Succesfully synced SharePointSite\",\n  \"projectNumber\": \"24-1\",\n  \"projectTitle\": \"Bygging av nye fylkeskommuner\",\n  \"caseNumber\": \"22/00013\",\n  \"caseTitle\": \"Arkivering fra Sharepoint til P360\"\n}\n```\n\n## Templates\n[All templates](https://github.com/vtfk/azf-archive/blob/master/templates)\n\nCurrently available archive templates [All templates](https://github.com/vtfk/azf-archive/blob/master/templates)\n\n| System | Template | Languages | Description |\n|--------|----------|-----------|-------------|\n| elevmappe | create-elevmappe | nb | Create **Elevmappe** by referencing **social security number**.\u003cbr\u003e[JSON template and data format available here](https://github.com/vtfk/azf-archive/blob/master/templates/elevmappe-create-elevmappe.json)\n| elevmappe | create-private-person | nb | Create **PrivatePerson** in *P360* contact register.\u003cbr\u003e[JSON template and data format available here](https://github.com/vtfk/azf-archive/blob/master/templates/elevmappe-create-private-person.json)\n| elevmappe | get-documents | nb | Get **Documents** archived on a **caseNumber**.\u003cbr\u003e[JSON template and data format available here](https://github.com/vtfk/azf-archive/blob/master/templates/elevmappe-get-documents.json)\n| elevmappe | get-elevmappe | nb | Get **Elevmappe** archived on a **social security number**.\u003cbr\u003e[JSON template and data format available here](https://github.com/vtfk/azf-archive/blob/master/templates/elevmappe-get-elevmappe.json)\n| elevmappe | get-private-person | nb | Get **PrivatePerson** from *P360* contact register by referencing **social security number**.\u003cbr\u003e[JSON template and data format available here](https://github.com/vtfk/azf-archive/blob/master/templates/elevmappe-get-private-person.json)\n| elevmappe | update-elevmappe | nb | Update **PrivatePerson** on **Elevmappe** archived on a **caseNumber**.\u003cbr\u003e[JSON template and data format available here](https://github.com/vtfk/azf-archive/blob/master/templates/elevmappe-update-elevmappe.json)\n| elevmappe | update-private-person | nb | Update **PrivatePerson** in *P360* contact register.\u003cbr\u003e[JSON template and data format available here](https://github.com/vtfk/azf-archive/blob/master/templates/elevmappe-update-private-person.json)\n| iop | hemmelig | nb | Sends a auto generate PDF to school to distribute this manully.\u003cbr\u003e[JSON template and data format available here](https://github.com/vtfk/azf-archive/blob/master/templates/iop-hemmelig.json)\n| iop | document | nb | Archive an IOP on students elevmappe.\u003cbr\u003e[JSON template and data format available here](https://github.com/vtfk/azf-archive/blob/master/templates/iop-document.json)\n| masseutsendelse | utsendelsesdokument | nb | Upload document(s)\n\n## local.settings.json\n\n```json\n{\n  \"Values\": {\n    \"AzureWebJobsStorage\": \"\",\n    \"FUNCTIONS_WORKER_RUNTIME\": \"node\",\n    \"P360_BASE_URL\": \"http://p360server.domain.no:3001\",\n    \"P360_TOKEN\": \"bla-bla-bla-bla-123\",\n    \"P360_SECURE_BASE_URL\": \"http://p360sikkerserver.domain.no:3001\",\n    \"P360_SECURE_TOKEN\": \"bla-bla-bla-bla-123\",\n    \"P360_VTFK_ROBOT_RECNO\": \"000000\",\n    \"PAPERTRAIL_HOST\": \"https://logs.collector.solarwinds.com/v1/log\",\n    \"PAPERTRAIL_TOKEN\": \"token\",\n    \"NODE_ENV\": \"production\",\n    \"PDF_GENERATOR\": \"https://pdf.no/generate\",\n    \"DSF_JWT_SECRET\": \"Noe skikkelig hemmelig\",\n    \"DSF_URL\": \"https://dsf.no/lookup\",\n    \"DSF_SAKSREF\": \"systemref\",\n    \"DB_USER\": \"db-user\",\n    \"DB_PASSWORD\": \"db-pass\",\n    \"DB_SERVER\": \"db-server\",\n    \"DB_DATABASE\": \"db-db\",\n    \"DB_TABLE\": \"db-table\",\n    \"E18_URL\": \"https://e18url.net\", // optional\n    \"E18_KEY\": \"secret token\", // optional\n    \"E18_SYSTEM\": \"p360\", // optional\n    \"E18_EMPTY_JOB\": true // optional\n  }\n}\n```\n\n### E18\n\nTo support [E18](https://github.com/vtfk/e18-node#usage), add `E18_URL`, `E18_KEY` and `E18_SYSTEM`\n\n## Deploy\n\n### Azure\n\nYou'll need a valid subscription and to setup the following resources\n\n- resource group\n- app service plan\n- storage account\n\n#### Setup function\n\nThe easiest way to make this function run is to setup an app service, configure the app and get the function from GitHub.\n\n- add function app\n  - Runtime stack -\u003e Node\n\nConfiguration for app (Application settings)\n- add values from [local.settings.json](#local.settings.json)\n\n- add function\n  - Plattform features -\u003e deployment center\n  - github\n  - branch master\n\n# Development\n\nInstall all tools needed for [local development](https://docs.microsoft.com/en-us/azure/azure-functions/functions-develop-local).\n\nClone the repo. Install dependencies (```npm install```)\n\nCreate a [local.settings.json](#local.settings.json) file\n\nStart server\n\n```\n$ func start\n```\n\n# License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvtfk%2Fazf-archive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvtfk%2Fazf-archive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvtfk%2Fazf-archive/lists"}