Skip to content

aviationexam/Aviationexam.MoneyErp

Repository files navigation

Build Status Build Status - DevOps

Aviationexam.MoneyErp.Common

NuGet feedz.io

Aviationexam.MoneyErp.Graphql

NuGet feedz.io

Aviationexam.MoneyErp.RestApi

NuGet feedz.io

Aviationexam.MoneyErp Clients

This repository contains .NET clients for interacting with the Money ERP system, a popular accounting and business management software in the Czech Republic and Slovakia. The clients provide convenient access to both the GraphQL and REST APIs of Money ERP.

Getting Started

To get started, you need to add the desired client library to your project and configure the necessary services in your dependency injection container.

First, add the core package to your project:

dotnet add package Aviationexam.MoneyErp.Common

Then, in your Program.cs or Startup.cs, configure the Money ERP services:

using Aviationexam.MoneyErp.Common.Extensions;

// ...

builder.Services.AddMoneyErp(
    options => options.Configure(builder.Configuration.GetSection("MoneyErp"))
);

This will configure the basic services required for authentication and communication with the Money ERP API. The configuration section in your appsettings.json should look like this:

{
  "MoneyErp": {
    "Endpoint": "https://your-money-erp-endpoint",
    "ClientId": "your-client-id",
    "ClientSecret": "your-client-secret"
  }
}

GraphQL Client

To use the GraphQL client, you need to add the Aviationexam.MoneyErp.Graphql package to your project:

dotnet add package Aviationexam.MoneyErp.Graphql

Then, chain the AddGraphQlClient method to the AddMoneyErp call:

using Aviationexam.MoneyErp.Graphql.Extensions;

// ...

builder.Services.AddMoneyErp(
    options => options.Configure(builder.Configuration.GetSection("MoneyErp"))
)
.AddGraphQlClient(
    options => options.Configure(builder.Configuration.GetSection("MoneyErp"))
);

Now you can inject MoneyErpGraphqlClient into your services and use it to make GraphQL queries:

public class MyService(MoneyErpGraphqlClient graphqlClient)
{
    public async Task<string> GetMoneyErpVersion()
    {
        var version = await graphqlClient.Query(x => x.Version);
        return version.Data;
    }
}

REST API Client

To use the REST API client, you need to add the Aviationexam.MoneyErp.RestApi package to your project:

dotnet add package Aviationexam.MoneyErp.RestApi

Then, chain the AddRestApiClient method to the AddMoneyErp call:

using Aviationexam.MoneyErp.RestApi.Extensions;

// ...

builder.Services.AddMoneyErp(
    options => options.Configure(builder.Configuration.GetSection("MoneyErp"))
)
.AddRestApiClient(
    options => options.Configure(builder.Configuration.GetSection("MoneyErp"))
);

You can then inject MoneyErpApiV1Client or MoneyErpApiV2Client into your services to interact with the v1 and v2 REST APIs respectively.

V1 Client Example

public class MyService(MoneyErpApiV1Client client)
{
    public async Task<ArticleResponse?> GetArticles()
    {
        var articles = await client.V10.Article.GetAsync();
        return articles;
    }
}

V2 Client Example

public class MyService(MoneyErpApiV2Client client)
{
    public async Task<SomeV2Response?> GetSomething()
    {
        // Example usage of V2 client
        // var result = await client.SomeEndpoint.GetAsync();
        // return result;
        return null;
    }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 5

Languages