⚠️ Support ending: Salesforce support for OpenAPI 3.0 is coming which means tools like OpenAPI Generator, NSwag, or AutoRest will become superior to this library.⚠️
Reinforce is set of Rest Interfaces for Salesforce.com! It utilizes RestEase to turn Salesforce's rest api into a dependency injection friendly C# library. Used in pair with Reinforce.HttpClientFactory
, you can get up and running within a few minutes!
The easiest way to get started is by using the Reinforce.HttpClientFactory
package that includes IServiceCollection
extensions.
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddReinforce()
.UseUsernamePasswordFlow(Configuration.GetSection(nameof(UsernamePasswordSettings)));
}
Setup your configuration.
> dotnet user-secrets set UsernamePasswordSettings:Username <Username>
> dotnet user-secrets set UsernamePasswordSettings:Password <Password>
> dotnet user-secrets set UsernamePasswordSettings:ClientId <ClientId>
> dotnet user-secrets set UsernamePasswordSettings:ClientSecret <ClientSecret>
Then in your application code, inject the api of your choice.
private readonly IQuery _query;
public AccountService(IQuery query)
{
_query = query ?? throw new ArgumentNullException(nameof(query));
}
public async Task<IEnumerable<Account>> ReadAsync(CancellationToken cancellationToken)
{
var response = await _query.GetAsync<Account>("Select Id, Name From Account", cancellationToken);
return response.Records ?? Enumerable.Empty<Account>();
}
The list of supported APIs can be found in src/Reinforce
Please create an issue for any bug you find, including sample code to re-create the issue.
See an issue open that you think you can help with? Please comment on the issue that you plan to contribute it and include unit tests for the included feature when you open a pull request. Don't see an issue for a feature you'd like? Open an issue first and have a discussion before writing any code. This library attempts to be an unopinionated set of interfaces, so many advance helper features, implementations, and/or abstractions may be rejected.