/nishan-go

Golang wrapper for NADRA's Nishan APIs

Primary LanguageGoMIT LicenseMIT

Nishan Pakistan

Tests Go Report Card Release License


Golang wrapper for NADRA's Nishan APIs.

Installation

go get -u github.com/IamFaizanKhalid/nishan-go

Usage Example

package main

import (
	"fmt"
	"github.com/IamFaizanKhalid/nishan-go"
	"github.com/IamFaizanKhalid/nishan-go/errors"
)

func main() {
	api, err := nishan.NewClient("your_company", "your_api_key")
	if err != nil {
		panic(err)
	}

	response := api.KnowYourCustomer(nishan.Request{
		CitizenNo:   "1234567890124",
		Fingerprint: "/9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAA...",
		FingerIndex: 6,
	})

	if response.ErrCode != errors.Nil {
		switch response.ErrCode {
		case errors.FingerprintMismatch:
			panic("fingerprint didn't match")
		case errors.FingerIndexUnavailable:
			panic(fmt.Sprintf("data available only for following finger indexes: %v", response.FingerList))
		default:
			panic(response.ErrMessage)
		}
	}

	fmt.Printf("Welcome %s %s!", response.PersonalData.Name, response.PersonalData.FatherName)
}

Reference

License

© 2023-time.Now() Faizan Khalid

Released under the MIT License