Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Mark generated files
src/ArcadeDotnet/Models/** linguist-generated=true
src/ArcadeDotnet/Core/ModelBase.cs linguist-generated=true
src/ArcadeDotnet/Core/ModelConverter.cs linguist-generated=true
src/ArcadeDotnet/Core/ParamsBase.cs linguist-generated=true

# Line endings - preserve original for generated code
src/ArcadeDotnet/Models/** -text
src/ArcadeDotnet/Core/ModelBase.cs -text
src/ArcadeDotnet/Core/ModelConverter.cs -text
src/ArcadeDotnet/Core/ParamsBase.cs -text
src/ArcadeDotnet/Services/** -text

# New code uses LF
src/ArcadeDotnet/Extensions/** text eol=lf
src/ArcadeDotnet.Tests/Extensions/** text eol=lf
examples/** text eol=lf
docs/** text eol=lf
.github/** text eol=lf

# Binary files
*.dll binary
*.exe binary
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
15 changes: 15 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Description

## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation

## Testing
- [ ] Tests pass
- [ ] Build succeeds

## Checklist
- [ ] Code formatted (`dotnet format`)
- [ ] Documentation updated
9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-json
exclude: ^\.devcontainer/
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
# Changelog

## 0.2.0 (2025-01-XX)

### Breaking Changes

* **Client Configuration**: Constructor now requires `ArcadeClientOptions` instead of object initializer syntax
* **HttpClient**: Removed from public API. Inject via `ArcadeClientOptions.HttpClient` for dependency injection support
* **Type Names**: Renamed `HttpRequest`/`HttpResponse` → `ArcadeRequest`/`ArcadeResponse` to avoid ASP.NET naming conflicts

### Features

* **ArcadeClientOptions**: New strongly-typed configuration class with environment variable support
* **ArcadeClientFactory**: Convenient factory methods with shared HttpClient instance
* **Parameterless Constructor**: Creates client using `ARCADE_API_KEY` and `ARCADE_BASE_URL` environment variables
* **XML Documentation**: Comprehensive documentation added to all public APIs

### Improvements

* Applied modern C# 12 patterns (primary constructors, expression-bodied members, string interpolation)
* Added 69 behavior-focused unit tests covering edge cases and architectural validation
* Proper dependency injection support for `HttpClient`
* All exception types now sealed with XML documentation
* Improved separation of concerns and architectural patterns

## 0.1.0 (2025-10-29)

Full Changelog: [v0.0.1...v0.1.0](https://github.com/ArcadeAI/arcade-dotnet/compare/v0.0.1...v0.1.0)
Expand Down
97 changes: 81 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,79 @@ This library requires .NET 8 or later.

See the [`examples`](examples) directory for complete and runnable examples.

### Execute a Tool

**Simple tool (no OAuth):**
```csharp
using System;
using ArcadeDotnet;
using ArcadeDotnet.Models.Tools;

// Configured using the ARCADE_API_KEY and ARCADE_BASE_URL environment variables
ArcadeClient client = new();
var client = new ArcadeClient();

var executeParams = new ToolExecuteParams
{
ToolName = "CheckArcadeEngineHealth" // Example: simple tool
};

var result = await client.Tools.Execute(executeParams);
result.Validate();
Console.WriteLine($"Execution ID: {result.ExecutionID}");
Console.WriteLine($"Status: {result.Status}");
```

**Tool requiring OAuth (e.g., GitHub):**
```csharp
// Step 1: Authorize the tool
var authResponse = await client.Tools.Authorize(new ToolAuthorizeParams
{
ToolName = "GitHub.ListRepositories"
});

// Step 2: After OAuth completes, execute with UserID
var executeParams = new ToolExecuteParams
{
ToolName = "GitHub.ListRepositories",
UserID = authResponse.UserID // From authorization response
};

var result = await client.Tools.Execute(executeParams);
```

### List Available Tools

```csharp
using ArcadeDotnet;

ToolExecuteParams parameters = new() { ToolName = "Google.ListEmails" };
var client = new ArcadeClient();
var tools = await client.Tools.List();
tools.Validate();
Console.WriteLine($"Found {tools.Items?.Count ?? 0} tools");
```

### With Options

```csharp
using ArcadeDotnet;
using System.Net.Http;

var client = new ArcadeClient(new ArcadeClientOptions
{
ApiKey = "your-api-key",
BaseUrl = new Uri("https://api.arcade.dev"),
HttpClient = new HttpClient() // Optional: inject your own HttpClient
});
```

var executeToolResponse = await client.Tools.Execute(parameters);
### Using Factory

Console.WriteLine(executeToolResponse);
```csharp
using ArcadeDotnet;

// Factory method with shared HttpClient
var client = ArcadeClientFactory.Create("your-api-key");

// Or using environment variables
var clientFromEnv = ArcadeClientFactory.Create();
```

## Client Configuration
Expand All @@ -53,25 +113,30 @@ Configure the client using environment variables:
using ArcadeDotnet;

// Configured using the ARCADE_API_KEY and ARCADE_BASE_URL environment variables
ArcadeClient client = new();
var client = new ArcadeClient();
```

Or manually:
Or with explicit options:

```csharp
using ArcadeDotnet;

ArcadeClient client = new() { APIKey = "My API Key" };
using System.Net.Http;

var client = new ArcadeClient(new ArcadeClientOptions
{
ApiKey = "your-api-key",
BaseUrl = new Uri("https://api.arcade.dev"),
HttpClient = new HttpClient() // Optional
});
```

Or using a combination of the two approaches.

See this table for the available options:

| Property | Environment variable | Required | Default value |
| --------- | -------------------- | -------- | -------------------------- |
| `APIKey` | `ARCADE_API_KEY` | true | - |
| `BaseUrl` | `ARCADE_BASE_URL` | true | `"https://api.arcade.dev"` |
| Property | Environment variable | Required | Default value |
| ------------ | ------------------- | -------- | ------------------------- |
| `ApiKey` | `ARCADE_API_KEY` | true | - |
| `BaseUrl` | `ARCADE_BASE_URL` | false | `"https://api.arcade.dev"` |
| `HttpClient` | - | false | New instance created |

## Requests and responses

Expand Down
9 changes: 9 additions & 0 deletions examples/AspNetCoreExample/AspNetCoreExample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\ArcadeDotnet\ArcadeDotnet.csproj" />
</ItemGroup>
</Project>
27 changes: 27 additions & 0 deletions examples/AspNetCoreExample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using ArcadeDotnet;
using ArcadeDotnet.Extensions;
using Microsoft.AspNetCore.Mvc;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddArcadeClient(
builder.Configuration["Arcade:ApiKey"] ?? throw new InvalidOperationException("Arcade:ApiKey not configured")
);

var app = builder.Build();

app.MapGet("/tools", async (IArcadeClient arcade) =>
{
var tools = await arcade.Tools.List();
tools.Validate();
return Results.Ok(new { count = tools.Items?.Count ?? 0 });
});

app.MapGet("/health", async (IArcadeClient arcade) =>
{
var health = await arcade.Health.Check();
health.Validate();
return Results.Ok(new { healthy = health.Healthy });
});

app.Run();
5 changes: 5 additions & 0 deletions examples/AspNetCoreExample/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"Arcade": {
"ApiKey": "your-api-key-here"
}
}
14 changes: 14 additions & 0 deletions examples/BasicExample/BasicExample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<ProjectReference Include="..\..\src\ArcadeDotnet\ArcadeDotnet.csproj" />
</ItemGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Loading