Skip to content

Commit fa67116

Browse files
feat: adding detailed readme (#15)
* temp commit * Refactor Cert Auth * wip: certificate auth changes * feat: adding Content encoding to MetaData add setting on compressed send, setting helpers to internal * chore: remove response logging * readme * update readme with serverSideCertificate Collection * md formatting * update check english words
1 parent 2459656 commit fa67116

3 files changed

Lines changed: 142 additions & 61 deletions

File tree

README.md

Lines changed: 137 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,183 @@
1-
# Repository Template
1+
# dotnet-mesh-client
22

33
[![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)
44
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=repository-template&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=repository-template)
55

6-
Start with an overview or a brief description of what the project is about and what it does. For example -
7-
8-
Welcome to our repository template designed to streamline your project setup! This robust template provides a reliable starting point for your new projects, covering an essential tech stack and encouraging best practices in documenting.
9-
10-
This repository template aims to foster a user-friendly development environment by ensuring that every included file is concise and adequately self-documented. By adhering to this standard, we can promote increased clarity and maintainability throughout your project's lifecycle. Bundled within this template are resources that pave the way for seamless repository creation. Currently supported technologies are:
11-
12-
- Terraform
13-
- Docker
14-
15-
Make use of this repository template to expedite your project setup and enhance your productivity right from the get-go. Enjoy the advantage of having a well-structured, self-documented project that reduces overhead and increases focus on what truly matters - coding!
6+
A 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)
167

178
## Table of Contents
189

19-
- [Repository Template](#repository-template)
10+
- [dotnet mesh client](dotnet-mesh-client)
2011
- [Table of Contents](#table-of-contents)
2112
- [Setup](#setup)
2213
- [Prerequisites](#prerequisites)
2314
- [Configuration](#configuration)
2415
- [Usage](#usage)
16+
- [Mesh Operation Service](#mesh-operation-service)
17+
- [Mesh Inbox Service](#mesh-inbox-service)
18+
- [Mesh Outbox Service](#mesh-outbox-service)
2519
- [Testing](#testing)
26-
- [Design](#design)
27-
- [Diagrams](#diagrams)
28-
- [Modularity](#modularity)
29-
- [Contributing](#contributing)
30-
- [Contacts](#contacts)
20+
3121
- [Licence](#licence)
3222

3323
## Setup
3424

35-
By including preferably a one-liner or if necessary a set of clear CLI instructions we improve user experience. This should be a frictionless installation process that works on various operating systems (macOS, Linux, Windows WSL) and handles all the dependencies.
25+
### Prerequisites
26+
27+
Currently this is not published to any nuget repository.
28+
29+
To use this package within your dotnet solution we suggest using [git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules).
30+
31+
to 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.
3632

37-
Clone the repository
33+
the `NHS.Mesh.Client.csproj` should then be added to the solution file.
34+
then the client can be added as a project reference to any project which requires it.
3835

39-
```shell
40-
git clone https://github.com/nhs-england-tools/repository-template.git
41-
cd nhs-england-tools/repository-template
36+
### Configuration
37+
38+
The client needs to be registered as a service for Dependency Injection this can be done by using the below code:
39+
40+
the parameters will need to be updated for your specific mailboxes and environments.
41+
the certificate will need to be converted or created as a `.pfx` file that stores both the certificate and the private key.
42+
the serverSideCertificateCollection should be populated with the certificates of the MESH side server, This is to ensure the host connected to is the expected host.
43+
44+
```c#
45+
services.AddMeshClient(_ => _.MeshApiBaseUrl = 'MESHURL')
46+
.AddMailbox("MYMAILBOX",new NHS.MESH.Client.Configuration.MailboxConfiguration
47+
{
48+
Password = "Password",
49+
SharedKey = "SHAREDKEY",
50+
Cert = new X509Certificate2("path to .pfx file","PFX File password"),
51+
serverSideCertCollection = new X509Certificate2Collection()
52+
})
53+
.Build();
4254
```
4355

44-
### Prerequisites
56+
Multiple 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.
4557

46-
The following software packages, or their equivalents, are expected to be installed and configured:
58+
## Usage
4759

48-
- [Docker](https://www.docker.com/) container runtime or a compatible tool, e.g. [Podman](https://podman.io/),
49-
- [asdf](https://asdf-vm.com/) version manager,
50-
- [GNU make](https://www.gnu.org/software/make/) 3.82 or later,
51-
- [GNU coreutils](https://www.gnu.org/software/coreutils/) and [GNU binutils](https://www.gnu.org/software/binutils/) may be required to build dependencies like Python, which may need to be compiled during installation. For macOS users, this has been scripted and automated by the `dotfiles` project; please see this [script](https://github.com/nhs-england-tools/dotfiles/blob/main/assets/20-install-base-packages.macos.sh) for details,
52-
- [Python](https://www.python.org/) required to run Git hooks,
53-
- [`jq`](https://jqlang.github.io/jq/) a lightweight and flexible command-line JSON processor.
60+
To use all of the functions the needed service class will need to be injected in to the class which requires them as below
61+
To use functions in the mesh Operation Service this needs to injected in the code as below:
5462

55-
> [!NOTE]<br>
56-
> The version of GNU make available by default on macOS is earlier than 3.82. You will need to upgrade it or certain `make` tasks will fail. On macOS, you will need [Homebrew](https://brew.sh/) installed, then to install `make`, like so:
57-
>
58-
> ```shell
59-
> brew install make
60-
> ```
61-
>
62-
> You will then see instructions to fix your `$PATH` variable to make the newly installed version available. If you are using [dotfiles](https://github.com/nhs-england-tools/dotfiles), this is all done for you.
63+
```c#
64+
public class ExampleService
65+
{
66+
private readonly IMeshOperationService _meshOperationService
6367

64-
### Configuration
68+
public ExampleService(IMeshOperationService meshOperationService)
69+
{
70+
_meshOperationService = meshOperationService;
71+
}
72+
73+
// methods in ExampleService that execute operation service methods.
74+
}
75+
```
76+
77+
The return type from these functions a `MeshResponse<T>` where T is the successful response data type.
78+
This response also contains an `IsSuccessful` flag which will indicate is the call to MESH returned a successful response.
79+
If the response is unsuccessful the `Error` property will contain a `APIErrorResponse` object that will have further information.
80+
Otherwise the response data will be within the `Response` property.
81+
82+
### Mesh Operation Service
6583

66-
Installation and configuration of the toolchain dependencies
84+
To use this inject `IMeshOperationService` class as shown in [Usage](#usage).
6785

68-
```shell
69-
make config
86+
#### Handshake / Validate a mailbox
87+
88+
Use 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.
89+
90+
to implement call the
91+
92+
```c#
93+
var result = await _meshOperationService.MeshHandshakeAsync(mailboxId);
7094
```
7195

72-
## Usage
96+
This will return the Mailbox Id.
7397

74-
After a successful installation, provide an informative example of how this project can be used. Additional code snippets, screenshots and demos work well in this space. You may also link to the other documentation resources, e.g. the [User Guide](./docs/user-guide.md) to demonstrate more use cases and to show more features.
98+
### Mesh Inbox Service
7599

76-
### Testing
100+
To use this inject `IMeshInboxService` class as shown in [Usage](#usage).
101+
This class contains methods used for receiving messages from MESH.
77102

78-
There 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.
103+
#### Check an Inbox
79104

80-
## Design
105+
Returns the message identifier of messages in the mailbox inbox ready for download.
106+
to implement call the below:
81107

82-
### Diagrams
108+
```c#
109+
var result = await _meshInboxService.GetMessagesAsync(mailboxId);
110+
```
111+
112+
this will return a list of MessageIds that are ready to download.
113+
114+
#### Get Message By Id
115+
116+
Retrieves a message based on the message identifier obtained from the 'GetMessagesAsync' method.
117+
Note this will not retrieve chunked messages.
118+
119+
```c#
120+
var result = await _meshInboxService.GetMessageByIdAsync(mailboxId, messageId);
121+
```
122+
123+
The response to this will return a `GetMeshResponse` Object which will contain a `FileAttachment` & `MessageMetaData`
124+
125+
#### Get Chunked Message By Id
126+
127+
Retrieves a chunked message based on the message identifier obtained from the 'GetMessagesAsync' method.
128+
129+
```c#
130+
var result = await _meshInboxService.GetChunkedMessageByIdAsync(mailboxId, messageId);
131+
```
132+
133+
The response to this will return a `GetMeshResponse` Object which will contain a `List<FileAttachment>` & `MessageMetaData`
83134

84-
The [C4 model](https://c4model.com/) is a simple and intuitive way to create software architecture diagrams that are clear, consistent, scalable and most importantly collaborative. This should result in documenting all the system interfaces, external dependencies and integration points.
135+
Note: the list of File Attachments can be passed to the helper method ReassembleChunkedFile as below which will return a File Attachment.
85136

86-
![Repository Template](./docs/diagrams/Repository_Template_GitHub_Generic.png)
137+
```c#
138+
var assembledFile = await FileHelpers.ReassembleChunkedFile(getMessageResponse.Response.FileAttachments);
139+
```
140+
141+
#### Get Head Message By Id
142+
143+
This method will retrieve a message metadata based on the message_id obtained from the 'GetMessagesAsync' method.
144+
145+
```c#
146+
var result = await _meshInboxService.GetHeadMessageByIdAsync(mailboxId, messageId);
147+
```
148+
149+
this response will return an object with a `MessageMetaData` property.
87150

88-
### Modularity
151+
#### Acknowledge Message By Id
89152

90-
Most of the projects are built with customisability and extendability in mind. At a minimum, this can be achieved by implementing service level configuration options and settings. The intention of this section is to show how this can be used. If the system processes data, you could mention here for example how the input is prepared for testing - anonymised, synthetic or live data.
153+
This method will acknowledge the successful download of a message.
91154

92-
## Contributing
155+
```c#
156+
var result = await _meshInboxService.AcknowledgeMessageByIdAsync(mailboxId, messageId);
157+
```
158+
159+
this will return the Id of the message acknowledge.
160+
161+
### Mesh Outbox Service
93162

94-
Describe or link templates on how to raise an issue, feature request or make a contribution to the codebase. Reference the other documentation files, like
163+
To use this inject `IMeshOutboxService` class as shown in [Usage](#usage).
164+
This class contains methods used for sending messages to MESH.
95165

96-
- Environment setup for contribution, i.e. `CONTRIBUTING.md`
97-
- Coding standards, branching, linting, practices for development and testing
98-
- Release process, versioning, changelog
99-
- Backlog, board, roadmap, ways of working
100-
- High-level requirements, guiding principles, decision records, etc.
166+
All of the sending methods will expect the below list of parameters
101167

102-
## Contacts
168+
| **Parameter Name** | **Data Type** | **Required** | **Description** |
169+
|--------------------|----------------|--------------|-------------------------------------------------------------------------------------------|
170+
| fromMailboxId | string | Y | Sender mailbox Id |
171+
| toMailboxId | string | Y | Recipient mailbox ID |
172+
| workFlowId | string | Y | Identifies the type of message being sent e.g. Pathology, GP Capitation. |
173+
| file | FileAttachment | Y | contains the details of the file to be sent |
174+
| localId | string | N | local identifier, your reference |
175+
| subject | string | N | additional message subject |
176+
| includeChecksum | bool | N | By default this is false, if true a header will be added with an MD5 Checksum of the file |
103177

104-
Provide a way to contact the owners of this project. It can be a team, an individual or information on the means of getting in touch via active communication channels, e.g. opening a GitHub discussion, raising an issue, etc.
178+
### Testing
179+
180+
There 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.
105181

106182
## Licence
107183

Usage.md

Whitespace-only changes.

scripts/config/vale/styles/Vocab/words/accept.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ idempotence
1515
onboarding
1616
toolchain
1717
[A-Z]+s
18+
dotnet
19+
nuget
20+
mailboxId
21+
localId
22+
bool

0 commit comments

Comments
 (0)