Interface IBatchApiResponseMapper<TResponse>
- Namespace
- Visus.AddressValidation.Mappers
- Assembly
- Visus.AddressValidation.dll
Abstraction for mapping a single item within a batch API response to an IAddressValidationResponse.
public interface IBatchApiResponseMapper<in TResponse> where TResponse : class
Type Parameters
TResponseThe type of API response the provider returns.
Methods
GetSharedCustomResponseData(TResponse)
Computes the response-level custom data shared by every item mapped from response.
IReadOnlyDictionary<string, object?> GetSharedCustomResponseData(TResponse response)
Parameters
responseTResponseThe batch API response from the provider.
Returns
- IReadOnlyDictionary<string, object>
The response-level custom data to merge into every mapped item. Return an empty dictionary when
responseexposes no shared data. Never return null.
Remarks
Call this once per batch, not once per item. response is the same instance for
every item in the batch, so any response-level data it exposes is invariant across the whole call.
The batch service does not call this method when every item in the batch has validation errors.
Map(TResponse, int, IReadOnlyDictionary<string, object?>, IValidationResult?)
Maps the item at index within response to an instance that
implements IAddressValidationResponse.
IAddressValidationResponse Map(TResponse response, int index, IReadOnlyDictionary<string, object?> sharedCustomResponseData, IValidationResult? validationResult = null)
Parameters
responseTResponseThe batch API response from the provider.
indexintThe position, within the batch, of the item to map.
sharedCustomResponseDataIReadOnlyDictionary<string, object>The value GetSharedCustomResponseData(TResponse) returned for
response.validationResultIValidationResultThe current IValidationResult, or null if none exists.
Returns
- IAddressValidationResponse
An instance that implements IAddressValidationResponse.