ClickTime.NET 1.1.1

dotnet add package ClickTime.NET --version 1.1.1
NuGet\Install-Package ClickTime.NET -Version 1.1.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="ClickTime.NET" Version="1.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ClickTime.NET --version 1.1.1
#r "nuget: ClickTime.NET, 1.1.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 ClickTime.NET as a Cake Addin
#addin nuget:?package=ClickTime.NET&version=1.1.1

// Install ClickTime.NET as a Cake Tool
#tool nuget:?package=ClickTime.NET&version=1.1.1

ClickTime.NET

.NET wrapper for Web API @ https://developer.clicktime.com/docs/api/

Why do this?

Because I wanted to experiment with creating some sort of SDK for some public API using their openapi/swagger spec.

What was done

Using Kiota (https://learn.microsoft.com/en-us/openapi/kiota/) to generate a CSharp interface for the API. Then adding a light wrapper around that to make a few things nicer. As I use more endpoints I will try to add more unit tests.

How to use

Direct Access

I have left the generated code public, so you can directly call it like so:

Direct Access Example
using Microsoft.Kiota.Abstractions.Authentication;
using Microsoft.Kiota.Http.HttpClientLibrary;
using static Microsoft.Kiota.Abstractions.Authentication.ApiKeyAuthenticationProvider;

var token = "402880824ff933a4014ff9345d7c0002";

ApiKeyAuthenticationProvider auth = new(
    $"Token {token}"
    , "Authorization"
    , KeyLocation.Header
    , "api.clicktime.com");

HttpClientRequestAdapter adapter = new(auth);

ClickTimeClient client = new(adapter);

try
{
    var me = await client.Me.GetAsync();

    Console.WriteLine(me.Data.Email);
}
catch(Exception e)
{
    Console.WriteLine(e.Message);
}

Using Helper Methods

However, I have also added some wrapper methods in ClickTimeClientHelper under namespace ClickTime.NET.HelperMethods.

Helper Method Example
var client = ClickTimeClientHelper.CreateWithToken("402880824ff933a4014ff9345d7c0002");

try
{
    var me = await client.Me.GetAsync();
    Console.WriteLine(me.Data.Email);
}
catch(Exception e)
{
    Console.WriteLine(e.Message);
}
Environment Variables

The wrapper methods can also use environment variables when not provided engough information directly via method calling.

Description Environment Variable Key Default if not present Example
Email ClickTimeClient:Email ClickTimeClient:Email=example@gmail.com
Password ClickTimeClient:Password ClickTimeClient:Password=123Password!
API AuthToken ClickTimeClient:AuthToken Uses (Basic email:password[Base64]) ClickTimeClient:AuthToken=1kj2k3j2923i1k2j3l1k2j31k2j3
AllowedHosts ClickTimeClient:AllowedHosts api.clicktime.com ClickTimeClient:AllowedHosts=api.clicktime.com,google.com,otherHostName.com
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
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
1.1.1 279 1/21/2024
0.1.1 191 1/21/2024
0.1.0 195 1/21/2024

Updating API documentation, adding readme, change API for creating email:password clients