Code Monkey home page Code Monkey logo

hubspot-dotnet's Introduction

HubSpot .NET

Build Status Quality Gate Status Coverage

.NET Core wrappers for the HubSpot API.

Package Version Type
Devpro.Hubspot.Abstractions Version .NET Standard 2.1
Devpro.Hubspot.Client Version .NET Standard 2.1

Requirements

How to use

  • 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();
}

How to build

Once the git repository has been cloned, execute the following commands from the root directory:

dotnet restore
dotnet build

How to test

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

References

hubspot-dotnet's People

Contributors

devpro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.