Skip to content

Commit

Permalink
README update
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspersorensen committed Jan 16, 2024
1 parent 390fcee commit 8d0b805
Showing 1 changed file with 41 additions and 5 deletions.
46 changes: 41 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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.

0 comments on commit 8d0b805

Please sign in to comment.