Class AuthorizerServiceClient
Concrete class that implement HTTP calls on Authorizer Microservice.
Implements
Inherited Members
Namespace: StoneCo.TransRep.Authorizer.Host.Client
Assembly: cs.temp.dll.dll
Syntax
public class AuthorizerServiceClient : AuthorizerServiceClientBase, IAuthorizerServiceClient
Constructors
AuthorizerServiceClient(IOptionsSnapshot<AuthorizerServiceClientOptions>, IHttpRestServiceClient)
Default constructor to set options and HttpRestServiceClient.
Declaration
public AuthorizerServiceClient(IOptionsSnapshot<AuthorizerServiceClientOptions> options, IHttpRestServiceClient httpRestServiceClient)
Parameters
Type | Name | Description |
---|---|---|
IOptionsSnapshot<AuthorizerServiceClientOptions> | options | The options design pattern used in AuthorizerServiceClient. |
IHttpRestServiceClient | httpRestServiceClient | Interface with the default methods and properties to be used for all HTTP Rest calls. |
Examples
Create a options configuration on class with name AppSettingsOptionsConfigurations on folder Configurations.
public static class AppSettingsOptionsConfigurations
{
private static string AppSettingsAuthorizerServiceClient => "Clients:AuthorizerServiceClient";
public static void ConfigureAppSettingsOptions(this IServiceCollection services, IConfiguration configuration)
{
services.AddOptions();
services.Configure<AuthorizerServiceClientOptions>(options =>
configuration.GetSection(AppSettingsAuthorizerServiceClient).Bind(options));
}
}
Representation on appsettings.json file.
{
"Clients": {
"AuthorizerServiceClient": {
"Name": "AuthorizerServiceClient",
"AuthorizationToken": "a07f5aa4d2654c0e91412ee7025de133",
"BaseAddress": "https://domain-of-api.com/"
}
}
}
Dependency injection on application.
public class DIFactory
{
public static void ConfigureDI(IServiceCollection services, IConfiguration configuration)
{
services.AddScoped<IAuthorizerServiceClient, AuthorizerServiceClient>(configuration.GetValue<string>("Clients:AuthorizerServiceClient:Name"), configuration.GetValue<string>("Clients:AuthorizerServiceClient:BaseAddress"));
}
}
Finally, follow the example of how to use the client.
public class Bar
{
private IAuthorizerServiceClient AuthorizerServiceClient { get; }
public Bar(IAuthorizerServiceClient authorizerServiceClient) => AuthorizerServiceClient = authorizerServiceClient;
public async Task NewImport(string cardAcceptorCode, string cardAcceptorTerminalCode, ...)
{
var traceKey = Guid.NewGuid().ToString("N");
var request = new NewRequestMessage();
request.AuthorizerMessage = new AuthorizerMessage
{
CardAcceptorCode = cardAcceptorCode,
CardAcceptorTerminalCode = cardAcceptorTerminalCode,
...
};
request.AddHeader(Headers.TraceKey, traceKey);
var result = await AuthorizerServiceClient.NewAsync(request);
}
Methods
ClearEnqueuedTransactionsAsync(RequestMessage)
Asynchronous call to clear all queued transactions.
Declaration
public Task<ResultResponseMessage> ClearEnqueuedTransactionsAsync(RequestMessage request)
Parameters
Type | Name | Description |
---|---|---|
RequestMessage | request | Default request. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ResultResponseMessage> | Result of operations. |
NewAsync(NewAuthorizationRequestMessage)
Asynchronous call to import one transaction of Authorization type.
Declaration
public Task<ResultResponseMessage<ResponseMessage>> NewAsync(NewAuthorizationRequestMessage request)
Parameters
Type | Name | Description |
---|---|---|
NewAuthorizationRequestMessage | request | Request whit values to import. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ResultResponseMessage<ResponseMessage>> | Result of operations. |
NewAsync(NewCancellationRequestMessage)
Asynchronous call to import one transaction of Cancellation type.
Declaration
public Task<ResultResponseMessage<ResponseMessage>> NewAsync(NewCancellationRequestMessage request)
Parameters
Type | Name | Description |
---|---|---|
NewCancellationRequestMessage | request | Request whit values to import. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ResultResponseMessage<ResponseMessage>> | Result of operations. |
NewAsync(NewCaptureRequestMessage)
Asynchronous call to import one transaction of Capture type.
Declaration
public Task<ResultResponseMessage<ResponseMessage>> NewAsync(NewCaptureRequestMessage request)
Parameters
Type | Name | Description |
---|---|---|
NewCaptureRequestMessage | request | Request whit values to import. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ResultResponseMessage<ResponseMessage>> | Result of operations. |
NewAsync(NewFullAuthorizationRequestMessage)
Asynchronous call to import one transaction of Full Authorization type.
Declaration
public Task<ResultResponseMessage<ResponseMessage>> NewAsync(NewFullAuthorizationRequestMessage request)
Parameters
Type | Name | Description |
---|---|---|
NewFullAuthorizationRequestMessage | request | Request whit values to import. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ResultResponseMessage<ResponseMessage>> | Result of operations. |
NewBatchAsync(NewBatchAuthorizationRequestMessage)
Asynchronous call to import in batch many transactions of Authorization type.
Declaration
public Task<ResultResponseMessage<ResponseMessage>> NewBatchAsync(NewBatchAuthorizationRequestMessage request)
Parameters
Type | Name | Description |
---|---|---|
NewBatchAuthorizationRequestMessage | request | Request whit array of values to import. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ResultResponseMessage<ResponseMessage>> | Result of operations. |
NewBatchAsync(NewBatchCancellationRequestMessage)
Asynchronous call to import in batch many transactions of Cancellation type.
Declaration
public Task<ResultResponseMessage<ResponseMessage>> NewBatchAsync(NewBatchCancellationRequestMessage request)
Parameters
Type | Name | Description |
---|---|---|
NewBatchCancellationRequestMessage | request | Request whit array of values to import. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ResultResponseMessage<ResponseMessage>> | Result of operations. |
NewBatchAsync(NewBatchCaptureRequestMessage)
Asynchronous call to import in batch many transactions of Capture type.
Declaration
public Task<ResultResponseMessage<ResponseMessage>> NewBatchAsync(NewBatchCaptureRequestMessage request)
Parameters
Type | Name | Description |
---|---|---|
NewBatchCaptureRequestMessage | request | Request whit array of values to import. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ResultResponseMessage<ResponseMessage>> | Result of operations. |
NewBatchAsync(NewBatchFullAuthorizationRequestMessage)
Asynchronous call to import in batch many transactions of Full Authorization type.
Declaration
public Task<ResultResponseMessage<ResponseMessage>> NewBatchAsync(NewBatchFullAuthorizationRequestMessage request)
Parameters
Type | Name | Description |
---|---|---|
NewBatchFullAuthorizationRequestMessage | request | Request whit array of values to import. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ResultResponseMessage<ResponseMessage>> | Result of operations. |
QueuesAsync(RequestMessage)
Asynchronous call to consolidate and send to queue all transactions.
Declaration
public Task<ResultResponseMessage<ResponseMessage>> QueuesAsync(RequestMessage request)
Parameters
Type | Name | Description |
---|---|---|
RequestMessage | request | Default request. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<ResultResponseMessage<ResponseMessage>> | Result of operations with total queued on header. |