vvn

package module
v0.0.0-...-85be4bb Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 2 Imported by: 0

README

vvn-go

Unofficial client for VVN AI EKYC

This package uses ogen to generate the client from the VVN AI APIs specification.

Install:

go get -u giautm.dev/vvn@main

See the example from test:

package vvn_test

import (
	"context"
	"os"
	"testing"

	"giautm.dev/vvn"
	"giautm.dev/vvn/api"
	"github.com/google/uuid"
	"github.com/ogen-go/ogen/http"
	"github.com/stretchr/testify/require"
)

func TestNewOCRRecognition_integration(t *testing.T) {
	apiKey := os.Getenv("VVN_API_KEY")
	if apiKey == "" {
		t.Skip("VVN_API_KEY is not set")
	}
	documentFile := os.Getenv("VVN_DOCUMENT_FILE")
	if documentFile == "" {
		t.Skip("VVN_DOCUMENT_FILE is not set")
	}

	r := require.New(t)
	c, err := api.NewClient(vvn.ServerProduction, vvn.StaticKey(apiKey))
	r.NoError(err)

	f, err := os.OpenFile(documentFile, os.O_RDONLY, 0666)
	r.NoError(err)

	res, err := c.NewOCRRecognition(context.Background(), api.OCRInputForm{
		RequestID: uuid.NewString(),
		Image: http.MultipartFile{
			Name: "random_name_abc.jpeg",
			File: f,
		},
		IDFullThr: api.NewOptFloat32(0.8),
	})
	r.NoError(err)

	result, ok := res.(*api.OCRResult)
	r.Equal(ok, true)
	r.NotEmpty(result.ID.Value)
	r.Equal(result.IDCheck.Value, api.OCRResultIDCheckREAL)
}

Documentation

Index

Constants

View Source
const (
	// ServerProduction is the base URL for the production server.
	ServerProduction = "https://api.cloudekyc.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type StaticKey

type StaticKey string

StaticKey is a static API key.

func (StaticKey) APIKey

func (s StaticKey) APIKey(context.Context, string) (api.APIKey, error)

APIKey implement api.SecuritySource.

Directories

Path Synopsis
Code generated by ogen, DO NOT EDIT.
Code generated by ogen, DO NOT EDIT.

Jump to

Keyboard shortcuts

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