nishan

package module
v0.0.0-...-efa7592 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 7 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {

	// Access token to be used for further APIs calls
	AccessToken string `json:"access_token"`
	// contains filtered or unexported fields
}

type BioKYC

type BioKYC struct {

	// Array of available finger indexes
	FingerList []int `json:"fingerList"`

	// Transaction id
	TransactionId string `json:"transactionId"`

	// Citizen's personal info
	PersonalData PersonalData `json:"personalData"`
	// contains filtered or unexported fields
}

type Bioverisys

type Bioverisys struct {

	// Array of available finger indexes
	FingerList []int `json:"fingerList"`

	// Transaction id
	TransactionId string `json:"transactionId"`
	// contains filtered or unexported fields
}

type Client

type Client interface {
	VerifyFingerprint(Request) Bioverisys

	VerifyFingerprintFromMobile(MobileRequest) Bioverisys

	KnowYourCustomer(Request) BioKYC

	KnowYourCustomerFromMobile(MobileRequest) BioKYC

	UpdateAccessToken() Auth
	// contains filtered or unexported methods
}

func NewClient

func NewClient(subdomain, apiKey string) (Client, error)

type MobileRequest

type MobileRequest struct {
	// 13 digit citizen number
	CitizenNo string `json:"citizenNo"`

	// Base64 encoded string of fingerprint
	Fingerprint string `json:"fingerprint"`

	// Finger index from 1 to 10
	FingerIndex int `json:"fingerIndex"`

	// A pakistani mobile number
	MobileNumber string `json:"mobileNumber"`

	Longitude float64 `json:"longitude"`
	Latitude  float64 `json:"latitude"`

	// IMEI of device
	IMEI string `json:"imei"`
}

func (*MobileRequest) Validate

func (r *MobileRequest) Validate() errors.ErrorCode

type PersonalData

type PersonalData struct {
	Name       string `json:"name"`
	FatherName string `json:"father_name"`
}

type Request

type Request struct {
	// 13 digit citizen number
	CitizenNo string `json:"citizenNo"`

	// Base64 encoded string of fingerprint
	Fingerprint string `json:"fingerprint"`

	// Finger index from 1 to 10
	FingerIndex int `json:"fingerIndex"`
}

func (*Request) Validate

func (r *Request) Validate() errors.ErrorCode

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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