AspireBudgetApi 2.0.1

dotnet add package AspireBudgetApi --version 2.0.1
NuGet\Install-Package AspireBudgetApi -Version 2.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AspireBudgetApi" Version="2.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AspireBudgetApi --version 2.0.1
#r "nuget: AspireBudgetApi, 2.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AspireBudgetApi as a Cake Addin
#addin nuget:?package=AspireBudgetApi&version=2.0.1

// Install AspireBudgetApi as a Cake Tool
#tool nuget:?package=AspireBudgetApi&version=2.0.1

.Net Standard Api for your Aspire Budget spreadsheet

Current version of this library supports Aspire Budget v3.3.

Nuget (with prereleases)

At first you need to turn on the Google Sheets API and obtain credentials. Follow the link and repeat steps under "Configuring Google infrastracture": (https://medium.com/@equisept/net-core-google-sheets-api-read-write-5edd919868e3).

In short 😁, you will:

  • register as a developer in Google Developer Console;
  • create your project;
  • add Google Sheets API;
  • create a service account to access your spreadsheet;
  • obtain credentials to use Google Sheets API (in form of a json file).

Don't forget to share your spreadsheet with your new service account.

Usage

Direct instantiation:
jsonCredentials variable is a content of your Google Sheets API credentials file.

using (var api = new AspireBudgetApi.AspireBudgetApi(jsonCredentials, googleSheetId))
{
	var categories = await api.GetCategoriesAsync();
}

or using DI container:

AspireApiOptions class in this example stores credentials and sheet ID.

services.AddScoped<IAspireApi, AspireApi>(x =>
{
    var options = x.GetRequiredService<IOptions<AspireApiOptions>>();
    var logger = x.GetRequiredService<ILogger<IAspireApi>>(); // optional
    var json = Encoding.UTF8.GetString(Convert.FromBase64String(options.Value.ApiCredentialsBase64));
    return new AspireApi(json, options.Value.SheetId, logger);
});

You can find a working example in TestWebApi project.

List of available methods

Accounts and categories.

List<string> categories = await api.GetCategoriesAsync();
List<string> accounts = await api.GetAccountsAsync();

Transactions: all or last n. Saving transactions.

List<Transaction> transactions = await api.GetTransactionsAsync(lastCount:100);
bool saveResult = await api.SaveTransactionAsync(transaction);

Category transfers: all or filtered by selected month. Saving transfers.

List<CategoryTransfer> categoryTranfers = await api.GetCategoryTransfersAsync(month:9);
bool result = await api.SaveCategoryTranferAsync(categoryTransfer);

Account transfers: all or last n. Saving account transfers.

List<AccountTransfer> accountTranfers = await api.GetAccountTranfersAsync();
bool saveResult = await api.SaveAccountTransferAsync(accountTransfer);

Using TestWebApi

Launch from IDE (requires .NET 5 SDK):
Update AspireApiOptions section in appsettings.json file with your Google Sheet Id and base64-encoded content of your API credentials json file.
Then run TestWebApi project. It will open up a new browser window with Swagger url.

"AspireApiOptions" : {
    "SheetId": "",
    "ApiCredentialsBase64": ""
  }

Launch from docker-compose:
Update docker-compose.yml with your your Google Sheet Id and base64-encoded content of your API credentials json file. Then run docker-compose up, API will be available at http://localhost:5010/swagger/index.html.

environment:
  - ASPNETCORE_ENVIRONMENT=Production
  - ASPIREAPIOPTIONS__SHEETID={here}
  - ASPIREAPIOPTIONS__APICREDENTIALSBASE64={here}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.0.1 457 1/23/2021
2.0.0 334 1/23/2021
1.0.0 517 5/24/2020