Table of Contents

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

TResponse

The 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

response TResponse

The 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 response exposes 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

response TResponse

The batch API response from the provider.

index int

The position, within the batch, of the item to map.

sharedCustomResponseData IReadOnlyDictionary<string, object>

The value GetSharedCustomResponseData(TResponse) returned for response.

validationResult IValidationResult

The current IValidationResult, or null if none exists.

Returns

IAddressValidationResponse

An instance that implements IAddressValidationResponse.