From 8d0b805558a96262654d5067efe2c056b799e9f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20S=C3=B8rensen?= Date: Tue, 16 Jan 2024 15:45:21 +0100 Subject: [PATCH] README update --- README.md | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4ac1508..c97ba1d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,47 @@ This module provides a SDK for interacting with the Digiseg API. Documentation for the API can be found on https://developer.digiseg.net/ -## Code generation +## Installing and using the SDK + +Install the module in your Go project: + +```sh +go get github.com/digiseg-labs/api-client-go/openapi +``` + +Import the module and start using it: + +```go +import ( + digiseg "github.com/digiseg-labs/api-client-go/openapi" +) + +// create API client +api := digiseg.NewAPIClient(digiseg.NewConfiguration()) + +// authenticate with username+password +req := api.AuthAPI.CreateAccessToken(context.Background()).AuthTokenRequest(digiseg.AuthTokenRequest{ + Username: username, + Password: &password, +}) +authResp, _, err := req.Execute() +if err != nil { + return "", err +} + +// look up audiences +ctx := context.WithValue(context.Background(), digiseg.ContextAccessToken, *authResp.AccessToken) +req = api.AudiencesAPI.ResolveAudiencesOfSingle(ctx, ipAddress) +audiencesResponse, _, err := req.Execute() +``` + +## Examples + +More code examples for how to use this module can be found in the `examples` directory. + +## Development notes + +### Code generation The code in this repo is generated based on the OpenAPI spec of the APIs. @@ -13,7 +53,3 @@ To regenerate, run: ```sh make codegen ``` - -## Examples - -Code examples for how to use this module can be found in the `examples` directory.