koyc

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

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

Go to latest
Published: Feb 19, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

README

Getting Started

import (
	koyc "github.com/koyctechnologies/gokoyc"
)

keys := koyc.Keys {
	CustomerKey: "REPLACE_HERE",
	ApiKey: "REPLACE_HERE",
	AccessKey: "REPLACE_HERE",
	SecretKey: "REPLACE_HERE",
}
	
var jsonBytes = []byte(`{"id_number":"` + PAN_NUMBER + `"}`)

resp, err := koyc.NewRequest(keys, "POST", "/pan/pan-only", jsonBytes)
if err != nil {
	t.Error("Error in making the request, error: ", err)
}

defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
t.Log("resp.Body:", string(body)) // {"success":true|false, ...

You can also unmarshal the response to koyc.DefaultPanVerifyResponse

Complete Test

Here is a complete test, where you need to find and replace REPLACE_HERE

package koyc_test

import (
	koyc "github.com/koyctechnologies/gokoyc"
	"io/ioutil"
	"testing"
)

const (
	PAN_NUMBER = "REPLACE_HERE"
)

func TestKoycPan(t *testing.T) {

	keys := koyc.Keys {
		CustomerKey: "REPLACE_HERE",
		ApiKey: "REPLACE_HERE",
		AccessKey: "REPLACE_HERE",
		SecretKey: "REPLACE_HERE",
	}
	
	var jsonBytes = []byte(`{"id_number":"` + PAN_NUMBER+ `","dob":"REPLACE_HERE(YYYY-MM-DD)"}`)

	resp, err := koyc.NewRequest(keys, "POST", "/pan/pan-only", jsonBytes)
	if err != nil {
		t.Error("Error in making the request, error: ", err)
	}
	defer resp.Body.Close()
	body, _ := ioutil.ReadAll(resp.Body)
	t.Log("resp.Body:", string(body))   // {"success":true|false, ...
}

Documentation

Index

Constants

View Source
const (
	VERSION  = "1"
	PROTOCOL = "https"
	DOMAIN   = "api.koyc.in"
)

Variables

View Source
var Client = &http.Client{Timeout: 30 * time.Second}

Functions

func KoycAwsSignHttpRequest

func KoycAwsSignHttpRequest(r *http.Request, keys Keys) (*http.Request, error)

func NewRequest

func NewRequest(keys Keys, method string, path string, jsonBytes []byte) (*http.Response, error)

func RequestWith

func RequestWith(r *http.Request, keys Keys) (*http.Response, error)

Types

type DefaultPanVerifyDataResponse

type DefaultPanVerifyDataResponse struct {
	FatherName string `json:"father_name"`
	PanNumber  string `json:"pan_number"`
	FullName   string `json:"full_name"`
}

type DefaultPanVerifyResponse

type DefaultPanVerifyResponse struct {
	MessageCode string                       `json:"message_code"`
	StatusCode  int                          `json:"status_code"`
	Message     string                       `json:"message"`
	Success     bool                         `json:"success"`
	Data        DefaultPanVerifyDataResponse `json:"data"`
}

type Keys

type Keys struct {
	CustomerKey string
	ApiKey      string
	AccessKey   string
	SecretKey   string
}

Jump to

Keyboard shortcuts

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