.NET Core wrappers for the HubSpot API.
Package | Version | Type |
---|---|---|
Devpro.Hubspot.Abstractions |
.NET Standard 2.1 | |
Devpro.Hubspot.Client |
.NET Standard 2.1 |
- Have an HubSpot developer account (create one)
- Have the NuGet package in your csproj file (can be done manually, with Visual Studio or through nuget command)
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Devpro.Hubspot.Client" Version="X.Y.Z" />
</ItemGroup>
</Project>
- Make the code changes to be able to use the library (config & service provider)
// implement the configuration interface (for instance in a configuration class in your app project) or use DefaultHubspotClientConfiguration
using Devpro.Hubspot.Client;
public class AppConfiguration : IHubspotClientConfiguration
{
// explicitely choose where to take the configuration for Hubspot REST API (this is the responibility of the app, not the library)
}
// configure your service provider (for instance in your app Startup class)
using Devpro.Hubspot.Client.DependencyInjection;
var services = new ServiceCollection()
.AddHubspotClient(Configuration);
- Use the repositories (enjoy a simple, yet optimized, HTTP client)
using Devpro.Hubspot.Abstractions;
private readonly IContactRepository _contactRepository;
public MyService(IContactRepository contactRepository)
{
_contactRepository = contactRepository;
}
public async Task GetContacts()
{
var contacts = await _contactRepository.FindAllAsync();
}
Once the git repository has been cloned, execute the following commands from the root directory:
dotnet restore
dotnet build
For integration tests, to manage the configuration (secrets) you can create a file at the root directory called Local.runsettings
or define them as environment variables:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<EnvironmentVariables>
<Hubspot__Sandbox__BaseUrl>xxx</Hubspot__Sandbox__BaseUrl>
<Hubspot__Sandbox__ApiKey>xxx</Hubspot__Sandbox__ApiKey>
<Hubspot__Sandbox__ApplicationId>xxx</Hubspot__Sandbox__ApplicationId>
<Hubspot__Sandbox__ClientId>xxx</Hubspot__Sandbox__ClientId>
<Hubspot__Sandbox__ClientSecret>xxx</Hubspot__Sandbox__ClientSecret>
<Hubspot__Sandbox__RedirectUrl>xxx</Hubspot__Sandbox__RedirectUrl>
</EnvironmentVariables>
</RunConfiguration>
</RunSettings>
And execute all tests (unit and integration ones):
dotnet test --settings Local.runsettings
- HubSpot API Overview
- adimichele/hubspot-ruby
- HubSpot/hubspot-php
- hubspot-net/HubSpot.NET: outdated .NET client, no recent CI with code coverage, not compatible with dependency injection and not using .NET best practices (HTTP client, naming convention, clean code, editorconfig)