vkn

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2025 License: MIT Imports: 8 Imported by: 2

README

VKN Query Library

This library is used to query registered individuals or businesses in the Revenue Administration of Turkey.

Getting Started

Installation

To add this library to your project:

go get github.com/9ssi7/vkn
Usage
package main

import (
    "fmt"
    "github.com/9ssi7/vkn"
)

func main() {
    config := vkn.Config{
        Username: "your-username",
        Password: "your-password",
    }

    client := vkn.New(config)
    data, err := client.GetRecipient(context.Background(), "your-recipients-vkn-or-tck")
    if err != nil {
        fmt.Println("Error:", err)
        return
    }
    fmt.Println(data) // {FirstName: "John", LastName: "Doe", Title: "Company Name", TaxOffice: "Tax Office Name"}


    // close the client after use
    if err := client.Logout(context.Background()); err != nil {
        fmt.Println("Error:", err)
        return
    }
}

Important Notes

  • When querying with identity credentials (TCKN), you will receive the firstName and lastName fields, but the title (unvan) field will not be present.
  • When querying with a tax number (VKN), the title (unvan) field will be returned instead of the firstName and lastName fields.

Documentation

For detailed documentation, you can visit the here.

License

This library is licensed under the MIT license. For more information, see the LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Username is the username for the VKN service.
	Username string
	// Password is the password for the VKN service.
	Password string
}

Config holds the configuration details for the VKN service.

type GetRecipientResponse

type GetRecipientResponse struct {
	Data     *Recipient `json:"data"`
	Metadata struct {
		Optime string `json:"optime"`
	} `json:"metadata"`
}

GetRecipientResponse represents the response after querying recipient data.

type Recipient added in v1.0.0

type Recipient struct {
	// FirstName provides if the recipient is a person.
	FirstName string `json:"adi"`
	// LastName provides if the recipient is a person.
	LastName string `json:"soyadi"`
	// Title provides if the recipient is a company.
	Title string `json:"unvan"`
	// TaxOffice provides the tax office of the recipient.
	TaxOffice string `json:"vergiDairesi"`
}

type Vkn

type Vkn interface {
	// GetRecipientData fetches the recipient data for a given VKN.
	GetRecipient(ctx context.Context, vkn string) (*Recipient, error)

	// Login logs in to the VKN service.
	Login(ctx context.Context) error

	// Logout logs out from the VKN service.
	Logout(ctx context.Context) error
}

Vkn represents the main interface for querying recipient data.

func New

func New(cnf Config) Vkn

New creates a new VKN service instance.

Jump to

Keyboard shortcuts

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