{"id":23421190,"url":"https://github.com/nhsdigital/dotnet-mesh-client","last_synced_at":"2025-04-09T09:40:29.115Z","repository":{"id":250738838,"uuid":"830963713","full_name":"NHSDigital/dotnet-mesh-client","owner":"NHSDigital","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-01T09:54:47.000Z","size":1212,"stargazers_count":1,"open_issues_count":6,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-01T10:26:30.378Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NHSDigital.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":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-19T10:58:24.000Z","updated_at":"2025-04-01T09:54:51.000Z","dependencies_parsed_at":"2024-08-12T10:51:43.132Z","dependency_job_id":"8c0589ab-b0ce-4199-83c5-1ad20e6ce355","html_url":"https://github.com/NHSDigital/dotnet-mesh-client","commit_stats":null,"previous_names":["nhsdigital/dotnet-mesh-client"],"tags_count":1,"template":false,"template_full_name":"NHSDigital/repository-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fdotnet-mesh-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fdotnet-mesh-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fdotnet-mesh-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NHSDigital%2Fdotnet-mesh-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NHSDigital","download_url":"https://codeload.github.com/NHSDigital/dotnet-mesh-client/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248016415,"owners_count":21033974,"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":[],"created_at":"2024-12-23T02:14:22.330Z","updated_at":"2025-04-09T09:40:29.098Z","avatar_url":"https://github.com/NHSDigital.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dotnet-mesh-client\n\n[![CI/CD Pull Request](https://github.com/nhs-england-tools/repository-template/actions/workflows/cicd-1-pull-request.yaml/badge.svg)](https://github.com/nhs-england-tools/repository-template/actions/workflows/cicd-1-pull-request.yaml)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=repository-template\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=repository-template)\n\nA dotnet client for accessing the [NHS MESH API](https://digital.nhs.uk/developer/api-catalogue/message-exchange-for-social-care-and-health-api#api-description__end-to-end-process-to-integrate-with-mesh-api)\n\n## Table of Contents\n\n- [dotnet mesh client](dotnet-mesh-client)\n  - [Table of Contents](#table-of-contents)\n  - [Setup](#setup)\n    - [Prerequisites](#prerequisites)\n    - [Configuration](#configuration)\n  - [Usage](#usage)\n    - [Mesh Operation Service](#mesh-operation-service)\n    - [Mesh Inbox Service](#mesh-inbox-service)\n    - [Mesh Outbox Service](#mesh-outbox-service)\n    - [Testing](#testing)\n\n  - [Licence](#licence)\n\n## Setup\n\n### Prerequisites\n\nCurrently this is not published to any nuget repository.\n\nTo use this package within your dotnet solution we suggest using [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules).\n\nto pull down the repository using git submodules the below command `git submodule add https://github.com/NHSDigital/dotnet-mesh-client` in the directory you wish to pull down the solution into.\n\nthe `NHS.Mesh.Client.csproj` should then be added to the solution file.\nthen the client can be added as a project reference to any project which requires it.\n\n### Configuration\n\nThe client needs to be registered as a service for Dependency Injection this can be done by using the below code:\n\nthe parameters will need to be updated for your specific mailboxes and environments.\nthe certificate will need to be converted or created as a `.pfx` file that stores both the certificate and the private key.\nthe serverSideCertificateCollection should be populated with the certificates of the MESH side server, This is to ensure the host connected to is the expected host.\n\n```c#\n        services.AddMeshClient(_ =\u003e _.MeshApiBaseUrl = 'MESHURL')\n            .AddMailbox(\"MYMAILBOX\",new NHS.MESH.Client.Configuration.MailboxConfiguration\n            {\n                Password = \"Password\",\n                SharedKey = \"SHAREDKEY\",\n                Cert = new X509Certificate2(\"path to .pfx file\",\"PFX File password\"),\n                serverSideCertCollection = new X509Certificate2Collection()\n            })\n            .Build();\n```\n\nMultiple mailboxes can be added by including more `.AddMailbox` methods to the builder and will be resolved when calling the various functions depending on the mailboxId passed to the function.\n\n## Usage\n\nTo use all of the functions the needed service class will need to be injected in to the class which requires them as below\nTo use functions in the mesh Operation Service this needs to injected in the code as below:\n\n```c#\n  public class ExampleService\n  {\n      private readonly IMeshOperationService _meshOperationService\n\n      public ExampleService(IMeshOperationService meshOperationService)\n      {\n          _meshOperationService = meshOperationService;\n      }\n\n      // methods in ExampleService that execute operation service methods.\n  }\n```\n\nThe return type from these functions a `MeshResponse\u003cT\u003e` where T is the successful response data type.\nThis response also contains an `IsSuccessful` flag which will indicate is the call to MESH returned a successful response.\nIf the response is unsuccessful the `Error` property will contain a `APIErrorResponse` object that will have further information.\nOtherwise the response data will be within the `Response` property.\n\n### Mesh Operation Service\n\nTo use this inject `IMeshOperationService` class as shown in [Usage](#usage).\n\n#### Handshake / Validate a mailbox\n\nUse this endpoint to check that MESH can be reached and that the authentication you are using is correct. This endpoint only needs to be called once every 24 hours. This endpoint updates the details of the connection history held for your mailbox and is similar to a keep-alive or ping message, in that it allows monitoring on the Spine to be aware of the active use of a mailbox despite a lack of traffic.\n\nto implement call the\n\n```c#\n    var result = await _meshOperationService.MeshHandshakeAsync(mailboxId);\n```\n\nThis will return the Mailbox Id.\n\n### Mesh Inbox Service\n\nTo use this inject `IMeshInboxService` class as shown in [Usage](#usage).\nThis class contains methods used for receiving messages from MESH.\n\n#### Check an Inbox\n\nReturns the message identifier of messages in the mailbox inbox ready for download.\nto implement call the below:\n\n```c#\n    var result = await _meshInboxService.GetMessagesAsync(mailboxId);\n```\n\nthis will return a list of MessageIds that are ready to download.\n\n#### Get Message By Id\n\nRetrieves a message based on the message identifier obtained from the 'GetMessagesAsync' method.\nNote this will not retrieve chunked messages.\n\n```c#\n    var result = await _meshInboxService.GetMessageByIdAsync(mailboxId, messageId);\n```\n\nThe response to this will return a `GetMeshResponse` Object which will contain a `FileAttachment` \u0026 `MessageMetaData`\n\n#### Get Chunked Message By Id\n\nRetrieves a chunked message based on the message identifier obtained from the 'GetMessagesAsync' method.\n\n```c#\n    var result = await _meshInboxService.GetChunkedMessageByIdAsync(mailboxId, messageId);\n```\n\nThe response to this will return a `GetMeshResponse` Object which will contain a `List\u003cFileAttachment\u003e` \u0026 `MessageMetaData`\n\nNote: the list of File Attachments can be passed to the helper method ReassembleChunkedFile as below which will return a File Attachment.\n\n```c#\n    var assembledFile = await FileHelpers.ReassembleChunkedFile(getMessageResponse.Response.FileAttachments);\n```\n\n#### Get Head Message By Id\n\nThis method will retrieve a message metadata based on the message_id obtained from the 'GetMessagesAsync' method.\n\n```c#\n    var result = await _meshInboxService.GetHeadMessageByIdAsync(mailboxId, messageId);\n```\n\nthis response will return an object with a `MessageMetaData` property.\n\n#### Acknowledge Message By Id\n\nThis method will acknowledge the successful download of a message.\n\n```c#\n    var result = await _meshInboxService.AcknowledgeMessageByIdAsync(mailboxId, messageId);\n```\n\nthis will return the Id of the message acknowledge.\n\n### Mesh Outbox Service\n\nTo use this inject `IMeshOutboxService` class as shown in [Usage](#usage).\nThis class contains methods used for sending messages to MESH.\n\nAll of the sending methods will expect the below list of parameters\n\n| **Parameter Name** | **Data Type**  | **Required** | **Description**                                                                           |\n|--------------------|----------------|--------------|-------------------------------------------------------------------------------------------|\n| fromMailboxId      | string         | Y            | Sender mailbox Id                                                                         |\n| toMailboxId        | string         | Y            | Recipient mailbox ID                                                                      |\n| workFlowId         | string         | Y            | Identifies the type of message being sent e.g. Pathology, GP Capitation.                  |\n| file               | FileAttachment | Y            | contains the details of the file to be sent                                               |\n| localId            | string         | N            | local identifier, your reference                                                          |\n| subject            | string         | N            | additional message subject                                                                |\n| includeChecksum    | bool           | N            | By default this is false, if true a header will be added with an MD5 Checksum of the file |\n\n### Testing\n\nThere are `make` tasks for you to configure to run your tests.  Run `make test` to see how they work.  You should be able to use the same entry points for local development as in your CI pipeline.\n\n## Licence\n\n\u003e The [LICENCE.md](./LICENCE.md) file will need to be updated with the correct year and owner\n\nUnless stated otherwise, the codebase is released under the MIT License. This covers both the codebase and any sample code in the documentation.\n\nAny HTML or Markdown documentation is [© Crown Copyright](https://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/uk-government-licensing-framework/crown-copyright/) and available under the terms of the [Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhsdigital%2Fdotnet-mesh-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnhsdigital%2Fdotnet-mesh-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnhsdigital%2Fdotnet-mesh-client/lists"}