|
| 1 | +# Common combinations of requests and endpoints |
| 2 | + |
| 3 | +The appropriate combination of [Request action] type and [Endpoint] type depends upon your use case. |
| 4 | +Common use cases are summarised in the table below. |
| 5 | +Information about reading this table follows. |
| 6 | + |
| 7 | +| Request payload | Response type | Endpoint type | Request action type | |
| 8 | +| --------------- | ------------- | ------------- | ---------------- | |
| 9 | +| _None_ | _None_ | [`Endpoint`] | [`SendTheHttpRequest`] | |
| 10 | +| _None_ | Deserialized with custom logic | [`Endpoint<TResult>`] | [`SendTheHttpRequestAndGetTheResponse<T>`] | |
| 11 | +| _None_ | Deserialized from JSON | [`Endpoint<TResult>`] | [`SendTheHttpRequestAndGetJsonResponse<T>`] | |
| 12 | +| Serialized with custom logic | _None_ | Derive from [`ParameterizedEndpoint<TParameters>`] | [`SendTheHttpRequest`] | |
| 13 | +| Serialized with custom logic | Deserialized with custom logic | Derive from [`ParameterizedEndpoint<TParameters,TResult>`] | [`SendTheHttpRequestAndGetTheResponse<T>`] | |
| 14 | +| Serialized with custom logic | Deserialized from JSON | Derive from [`ParameterizedEndpoint<TParameters,TResult>`] | [`SendTheHttpRequestAndGetJsonResponse<T>`] | |
| 15 | +| Serialized with JSON | _None_ | [`JsonEndpoint<TParameters>`] | [`SendTheHttpRequest`] | |
| 16 | +| Serialized with JSON | Deserialized with custom logic | [`JsonEndpoint<TParameters,TResult>`] | [`SendTheHttpRequestAndGetTheResponse<T>`] | |
| 17 | +| Serialized with JSON | Deserialized from JSON | [`JsonEndpoint<TParameters,TResult>`] | [`SendTheHttpRequestAndGetJsonResponse<T>`] | |
| 18 | + |
| 19 | +> [!TIP] |
| 20 | +> To decide which types of endpoint & performable: |
| 21 | +> _Choose the **endpoint type** based upon the needs of the **request**, adding an extra generic type parameter if the response is to be strongly-typed. |
| 22 | +> Choose the **action type** based upon the technical details of reading the **response**._ |
| 23 | +
|
| 24 | +[Request action]: Requests.md |
| 25 | +[Endpoint]: Endpoints.md |
| 26 | +[`Endpoint`]: xref:CSF.Screenplay.WebApis.Endpoint |
| 27 | +[`Endpoint<TResult>`]: xref:CSF.Screenplay.WebApis.Endpoint`1 |
| 28 | +[`ParameterizedEndpoint<TParameters>`]: xref:CSF.Screenplay.WebApis.ParameterizedEndpoint`1 |
| 29 | +[`ParameterizedEndpoint<TParameters,TResult>`]: xref:CSF.Screenplay.WebApis.ParameterizedEndpoint`2 |
| 30 | +[`JsonEndpoint<TParameters>`]: xref:CSF.Screenplay.WebApis.JsonEndpoint`1 |
| 31 | +[`JsonEndpoint<TParameters,TResult>`]: xref:CSF.Screenplay.WebApis.JsonEndpoint`2 |
| 32 | +[`SendTheHttpRequest`]: xref:CSF.Screenplay.WebApis.SendTheHttpRequest |
| 33 | +[`SendTheHttpRequestAndGetTheResponse<T>`]: xref:CSF.Screenplay.WebApis.SendTheHttpRequestAndGetTheResponse`1 |
| 34 | +[`SendTheHttpRequestAndGetJsonResponse<T>`]: xref:CSF.Screenplay.WebApis.SendTheHttpRequestAndGetJsonResponse`1 |
| 35 | + |
| 36 | +## The first two columns |
| 37 | + |
| 38 | +The first two columns indicate: |
| 39 | + |
| 40 | +1. The kind of **request payload** which will be sent<br> |
| 41 | + These are the parameters to the API function described by the endpoint |
| 42 | +1. The type of the expected **response body**<br> |
| 43 | + Where an API function returns a response, this is the .NET type which will be used to represent that response |
| 44 | + |
| 45 | +Where _None_ is listed in either column this means _"not applicable"_. |
| 46 | +For example, an API function which uses no parameters will have no request payload. |
| 47 | +In the case of responses, _None_ might mean that the response body will be ignored. |
| 48 | + |
| 49 | +## The second two columns |
| 50 | + |
| 51 | +The second two columns indicate the Endpoint type and Request action type which are recommended in this scenario. |
0 commit comments