Show / Hide Table of Contents

Class MovementServiceClient

Concrete class that implement HTTP calls on Movement Microservice.

Inheritance
System.Object
InterchangeServiceVisaServiceClientBase
MovementServiceClient
Implements
IMovementServiceClient
Inherited Members
InterchangeServiceVisaServiceClientBase.HttpRestServiceClient
InterchangeServiceVisaServiceClientBase.AuthorizationToken
InterchangeServiceVisaServiceClientBase.Options
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ToString()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: StoneCo.IC.Service.Visa.Host.Client
Assembly: cs.temp.dll.dll
Syntax
public class MovementServiceClient : InterchangeServiceVisaServiceClientBase, IMovementServiceClient

Constructors

MovementServiceClient(IOptionsSnapshot<InterchangeServiceVisaServiceClientOptions>, IHttpRestServiceClient)

Default constructor to set options and HttpRestServiceClient.

Declaration
public MovementServiceClient(IOptionsSnapshot<InterchangeServiceVisaServiceClientOptions> options, IHttpRestServiceClient httpRestServiceClient)
Parameters
Type Name Description
IOptionsSnapshot<InterchangeServiceVisaServiceClientOptions> options

The options design pattern used in InterchangeServiceVisaServiceClient.

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 AppSettingsInterchangeServiceVisaServiceClient => "Clients:InterchangeServiceVisaServiceClient";

    public static void ConfigureAppSettingsOptions(this IServiceCollection services, IConfiguration configuration)
    {
        services.AddOptions();
        services.Configure<InterchangeServiceVisaServiceClientOptions>(options => 
            configuration.GetSection(AppSettingsInterchangeServiceVisaServiceClient).Bind(options));
    }

}

Representation on appsettings.json file.

{
  "Clients": {
    "InterchangeServiceVisaServiceClient": {
      "Name": "InterchangeServiceVisaServiceClient",
      "AuthorizationToken": "50953e76f47d4be8b0c0072b1b876ab7",
      "BaseAddress": "https://domain-of-api.com/"
    }
  }
}

Dependency injection on application.

public class DIFactory
{
    public static void ConfigureDI(IServiceCollection services, IConfiguration configuration)
    {
        services.AddScoped<IMovementServiceClient, MovementServiceClient>(configuration.GetValue<string>("Clients:InterchangeServiceVisaServiceClient:Name"), configuration.GetValue<string>("Clients:InterchangeServiceVisaServiceClient:BaseAddress"));
    }
}

Finally, follow the example of how to use the client.

public class Bar
{
    private IMovementServiceClient MovementServiceClient { get; }

    public Bar(IMovementServiceClient movementServiceClient) => MovementServiceClient = movementServiceClient;

    public async Task InsertMovements(...)
    {
        var request = new MovementRequestMessage();

        //(...)

        ResultResponseMessage result = await MovementServiceClient.InsertMovementsAsync(request);

        //(...)
    }
}

Methods

InsertMovementsAsync(MovementRequestMessage)

Asynchronous call to insert movement data.

Declaration
public Task<ResultResponseMessage> InsertMovementsAsync(MovementRequestMessage request)
Parameters
Type Name Description
MovementRequestMessage request

Request whit values to insert movement data.

Returns
Type Description
System.Threading.Tasks.Task<ResultResponseMessage>

Result of operations.

Implements

IMovementServiceClient
Back to top Generated by DocFX