smileidentity

package module
v0.0.0-...-6d930cc Latest Latest
Warning

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

Go to latest
Published: May 5, 2025 License: MIT Imports: 13 Imported by: 0

README

Smile Identity Go SDK (unofficial)

Simple, idiomatic Go client for Smile ID server-side products i.e Basic KYC, Enhanced KYC, Document Verification and Phone Number Verification.


Installation

To start using the SDK in your Go project, run;

go get github.com/Salaton/smile-identity

Getting Started

Setting up Environment variables

Optionally, you can supply the base URL, APIKey, PartnerID and CallbackURL via environment variables. The following environment variables are recognized

SMILE_ID_API_KEY
SMILE_ID_PARTNER_ID
SMILE_ID_BASE_URL
SMILE_ID_CALLBACK_URL

This allows you to create a client with zero arguments;

client, err := smile.NewClientFromEnvVars()
if err != nil{
    // handle error
}

If you prefer to supply the values manually;

client, err := smile.NewClient(smile.Config{
    APIKey:      os.Getenv("SMILE_API_KEY"),
    PartnerID:   os.Getenv("SMILE_PARTNER_ID"),
    BaseURL:     "https://api.smileidentity.com/v1",
    CallbackURL: "https://example.com/webhook",
})
if err != nil{
    // handle err
}

Usage Example

Below is a simple example showing how you can run a basic kyc request

package main

import (
    "context"
    "fmt"
    "log"

    smile "github.com/Salaton/smile-identity"
)

func main() {
    // 1. Configure the client once at start-up
    client, err := smile.NewClient(smile.Config{
        APIKey:      os.Getenv("SMILE_API_KEY"),
        PartnerID:   os.Getenv("SMILE_PARTNER_ID"),
        BaseURL:     "https://api.smileidentity.com/v1",
        CallbackURL: "https://example.com/webhook",
    })
    if err != nil{
        // handle err
    }

    // 2. Build your request (Basic KYC example)
    req := smile.BasicKYCRequest{
        Country:   "KE",
        IDType:    smile.NATIONAL_ID,
        IDNumber:  "12345678901",
        FirstName: "John",
        LastName:  "Doe",
        DOB:       "1994-07-13",
    }

    // 3. Send the job & handle the response
    resp, err := client.BasicKYCVerification(context.Background(), req)
    if err != nil {
        log.Fatalf("kyc failed: %v", err)
    }
}

How to Release

We use release-please to manage our releases. This tool automates the process of creating a pull request with the next semantic version, updating the CHANGELOG, and tagging a release


Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code    string `json:"code,omitempty"`
	Message string `json:"error,omitempty"`
}

func (APIError) Error

func (a APIError) Error() string

type Actions

type Actions struct {
	DOB                MatchResult            `json:"DOB,omitempty"`
	Gender             GenderMatch            `json:"Gender,omitempty"`
	IDVerification     MatchResult            `json:"ID_Verification,omitempty"`
	Names              MatchResult            `json:"Names,omitempty"`
	PhoneNumber        MatchResult            `json:"Phone_Number,omitempty"`
	ReturnPersonalInfo ReturnPersonalInfoEnum `json:"Return_Personal_Info,omitempty"`
	VerifyIDNumber     VerifyIDNumber         `json:"Verify_ID_Number,omitempty"`
}

type AsyncResponse

type AsyncResponse struct {
	Success bool `json:"success,omitempty"`
}

type Client

type Client struct {
	HTTP *http.Client
	// contains filtered or unexported fields
}

func NewClient

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

NewClient creates a new smile id api client.

func NewClientFromEnvVars

func NewClientFromEnvVars() (*Client, error)

NewClientFromEnvVars creates a new client where the needed fields are retrieved from the environment variables.

func (*Client) BasicKYCAsyncVerification

func (c *Client) BasicKYCAsyncVerification(ctx context.Context, input *KYCInput) (*AsyncResponse, error)

func (*Client) BasicKYCVerification

func (c *Client) BasicKYCVerification(ctx context.Context, input *KYCInput) (*KYCVerificationResult, error)

func (*Client) EnhancedKYCAsyncVerification

func (c *Client) EnhancedKYCAsyncVerification(ctx context.Context, input *KYCInput) (*AsyncResponse, error)

func (*Client) EnhancedKYCVerification

func (c *Client) EnhancedKYCVerification(ctx context.Context, input *KYCInput) (*KYCVerificationResult, error)

func (*Client) JobRequest

func (c *Client) JobRequest(ctx context.Context, input *RequestJobPayload) (*RequestJobResponse, error)

func (*Client) UploadJobPayload

func (c *Client) UploadJobPayload(ctx context.Context, input *RequestJobResponse) error

func (*Client) VerifyPhoneNumber

func (c *Client) VerifyPhoneNumber(
	ctx context.Context,
	input *PhoneNumberVerification,
) (*PhoneNumberVerificationResponse, error)

func (*Client) VerifyPhoneNumberAsync

func (c *Client) VerifyPhoneNumberAsync(ctx context.Context, input *PhoneNumberVerification) (*AsyncResponse, error)

type Config

type Config struct {
	APIKey      string `json:"apiKey,omitempty"`
	PartnerID   string `json:"partnerID,omitempty"`
	BaseURL     string `json:"baseURL,omitempty"`
	CallbackURL string `json:"callbackURL,omitempty"`

	HTTPClient *http.Client `json:"httpClient,omitempty"`
}

type GenderMatch

type GenderMatch string
const (
	GenderExact       GenderMatch = "Exact Match"
	GenderNoMatch     GenderMatch = "No Match"
	GenderNotProvided GenderMatch = "Not Provided"
)

type KYCInput

type KYCInput struct {
	CallbackURL      string        `json:"callback_url,omitempty"`
	Country          string        `json:"country,omitempty"`
	DOB              time.Time     `json:"dob,omitempty"`
	FirstName        string        `json:"first_name,omitempty"`
	Gender           string        `json:"gender,omitempty"`
	IDNumber         string        `json:"id_number,omitempty"`
	IDType           string        `json:"id_type,omitempty"`
	LastName         string        `json:"last_name,omitempty"`
	MiddleName       string        `json:"middle_name,omitempty"`
	PartnerID        string        `json:"partner_id,omitempty"`
	PartnerParams    PartnerParams `json:"partner_params,omitempty"`
	PhoneNumber      string        `json:"phone_number,omitempty"`
	Signature        string        `json:"signature,omitempty"`
	SourceSDKVersion string        `json:"source_sdk_version,omitempty"`
	SourceSDK        string        `json:"source_sdk,omitempty"`
	Timestamp        time.Time     `json:"timestamp,omitempty"`
}

type KYCVerificationResult

type KYCVerificationResult struct {
	Actions           Actions       `json:"Actions,omitempty"`
	Country           string        `json:"Country,omitempty"`
	DOB               string        `json:"DOB,omitempty"`
	ExpirationDate    string        `json:"ExpirationDate,omitempty"`
	IssuanceDate      string        `json:"IssuanceDate,omitempty"`
	FullName          string        `json:"FullName,omitempty"`
	IDNumber          string        `json:"IDNumber,omitempty"`
	SecondaryIDNumber string        `json:"SecondaryIDNumber,omitempty"`
	IDType            string        `json:"IDType,omitempty"`
	PartnerParams     PartnerParams `json:"PartnerParams,omitempty"`
	Photo             string        `json:"Photo,omitempty"`
	ResultCode        string        `json:"ResultCode,omitempty"`
	ResultText        ResultText    `json:"ResultText,omitempty"`
	SmileJobID        string        `json:"SmileJobID,omitempty"`
	Signature         string        `json:"signature,omitempty"`
	Timestamp         time.Time     `json:"timestamp,omitempty"`
	Source            string        `json:"Source,omitempty"`
}

type MatchFields

type MatchFields struct {
	FirstName string `json:"first_name,omitempty"`
	LastName  string `json:"last_name,omitempty"`
	OtherName string `json:"other_name,omitempty"`
	IDNumber  string `json:"id_number,omitempty"`
}

type MatchResult

type MatchResult string
const (
	MatchExact      MatchResult = "Exact Match"
	MatchPartial    MatchResult = "Partial Match"
	MatchTransposed MatchResult = "Transposed"
	MatchNoMatch    MatchResult = "No Match"
)

type ModelParameters

type ModelParameters struct{}

type PartnerParams

type PartnerParams struct {
	JobID   string `json:"job_id,omitempty"`
	UserID  string `json:"user_id,omitempty"`
	JobType int    `json:"job_type,omitempty"`
}

type PhoneNumberVerification

type PhoneNumberVerification struct {
	CallbackURL string      `json:"callback_url,omitempty"`
	Country     string      `json:"country,omitempty"`
	PhoneNumber string      `json:"phone_number,omitempty"`
	MatchFields MatchFields `json:"match_fields,omitempty"`
}

type PhoneNumberVerificationResponse

type PhoneNumberVerificationResponse struct {
	Code          string        `json:"code,omitempty"`
	CreatedAt     time.Time     `json:"created_at,omitempty"`
	JobID         string        `json:"job_id,omitempty"`
	JobType       string        `json:"job_type,omitempty"`
	MatchedFields MatchFields   `json:"matched_fields,omitempty"`
	Message       string        `json:"message,omitempty"`
	PartnerID     string        `json:"partner_id,omitempty"`
	PartnerParams PartnerParams `json:"partner_params,omitempty"`
	Signature     string        `json:"signature,omitempty"`
	Timestamp     time.Time     `json:"timestamp,omitempty"`
}

type RequestJobPayload

type RequestJobPayload struct {
	CallbackURL      string          `json:"callback_url,omitempty"`
	ModelParameters  ModelParameters `json:"model_parameters,omitempty"`
	PartnerParams    PartnerParams   `json:"partner_params,omitempty"`
	Signature        string          `json:"signature,omitempty"`
	SmileClientID    string          `json:"smile_client_id,omitempty"`
	SourceSDK        string          `json:"source_sdk,omitempty"`
	SourceSDKVersion string          `json:"source_sdk_version,omitempty"`
	Timestamp        time.Time       `json:"timestamp,omitempty"`
}

type RequestJobResponse

type RequestJobResponse struct {
	UploadURL    string `json:"upload_url,omitempty"`
	RefID        string `json:"ref_id,omitempty"`
	SmileJobID   string `json:"smile_job_id,omitempty"`
	CameraConfig string `json:"camera_config,omitempty"`
	Code         string `json:"code,omitempty"`
}

type ResultText

type ResultText string
const (
	PartialMatch ResultText = "Partial Match"
	ExactMatch   ResultText = "Exact Match"
	NoMatch      ResultText = "No Match"
)

type ReturnPersonalInfoEnum

type ReturnPersonalInfoEnum string
const (
	Returned      ReturnPersonalInfoEnum = "Returned"
	NotReturned   ReturnPersonalInfoEnum = "Not Returned"
	NotApplicable ReturnPersonalInfoEnum = "Not Applicable"
)

type VerifyIDNumber

type VerifyIDNumber string
const (
	Verified          VerifyIDNumber = "Verified"
	NotVerified       VerifyIDNumber = "Not Verified"
	NotDone           VerifyIDNumber = "Not Done"
	IssuerUnavailable VerifyIDNumber = "Issuer Unavailable"
)

Jump to

Keyboard shortcuts

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