audited

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 8 Imported by: 0

README

Audited Go SDK

Go Coverage main GitHub tag Go Reference

Installation

To install the Go SDK, simply execute the following command on a terminal:

go get github.com/getaudited/audited-go/v1

Usage

package main

import (
	"context"
	"fmt"
	
	"github.com/getaudited/audited/v1"
)

func main() {
	client := audited.NewClient(audited.Config{
		BaseAPI: "https://audited.yourinstance.com",
		APIToken: "secure-api-token",
    })

	event := audited.Event{
		Action: "transfer.initiated",
		Actor: audited.Actor{
			Id: "7f1b2c3d-4e5f-6a7b-8c9d-0e1f2a3b4c5d",
			Metadata: &map[string]interface{}{
				"account_tier":       "premium",
				"compliance_status": "kyc_verified",
			},
			Name: new("Alex Rivera"),
			Type: "customer",
		},
		Context: audited.Context{
			Location:  "90.135.168.140",
			UserAgent: new("Mozilla/5.0 (Linux; Android 10; BLA-L29) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.141 Mobile Safari/537.36"),
		},
		SourceID: "01H7XRA8WWGPQX996AXWG5KXYZ",
		Targets: []audited.Target{
			{
				ID: "acc_92a1b4c3d5e6",
				Metadata: &map[string]interface{}{
					"routing_number": "123456789",
					"bank_country":   "Germany",
				},
				Name: new("Elena Rostova"),
				Type: "external_bank_account",
			},
		},
		Version: 1,
		Metadata: &map[string]interface{}{
			"service_name":    "svc-payment-routing",
			"amount":          2500.00,
			"currency":        "EUR",
			"idempotency_key": "idem-9a8b7c6d5e4f",
			"risk_score":      0.08,
		},
		OccurredAt: time.Now(),
	}

	err := client.CreateEvent(context.Background(), event)
	if err != nil {
		fmt.Printf("Error creating event: %v\n", err)
		return
	}
	
	fmt.Println("Event created successfully")
}

License

MIT

Documentation

Index

Constants

View Source
const Version = "v0.0.1"

Variables

View Source
var ErrEventTypeNotFound = errors.New("event type not found")
View Source
var ErrUnauthorized = errors.New("unauthorized")

Functions

This section is empty.

Types

type Actor

type Actor struct {
	Id       string                  `json:"id"`
	Metadata *map[string]interface{} `json:"metadata,omitempty"`
	Name     *string                 `json:"name,omitempty"`
	Type     string                  `json:"type"`
}

Actor An actor represents the person or entity that performed an action.

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(cfg Config) (*Client, error)

func (*Client) CreateEvent

func (c *Client) CreateEvent(ctx context.Context, event Event) error

type Config

type Config struct {
	BaseAPI    string
	APIToken   string
	HttpClient *http.Client
	Timeout    time.Duration
}

type Context

type Context struct {
	Location  string  `json:"location"`
	UserAgent *string `json:"user_agent,omitempty"`
}

Context The context holds details such as the IP and user agent of the person or entity that performed an action.

type Event

type Event struct {
	Action     string                  `json:"action"`
	Actor      Actor                   `json:"actor"`
	Context    Context                 `json:"context"`
	SourceID   string                  `json:"source_id"`
	Targets    []Target                `json:"targets"`
	Version    int                     `json:"version"`
	Metadata   *map[string]interface{} `json:"metadata,omitempty"`
	OccurredAt time.Time               `json:"occurred_at"`
}

Event An event represents an action perform by an actor towards a target or targets at a given time.

type Target

type Target struct {
	ID       string                  `json:"id"`
	Metadata *map[string]interface{} `json:"metadata,omitempty"`
	Name     *string                 `json:"name,omitempty"`
	Type     string                  `json:"type"`
}

Target It represents an event target.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL