ravkavsdkgo

package module
v0.0.0-...-61e76d4 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: MIT Imports: 3 Imported by: 0

README

ravkav-sdk-go

github.com/derkinderfietsen/ravkav-sdk-go

MIT License Go Report Card Go Doc

Overview

The most simple ravkav card reader implemented in golang

Download

To download this package, run:

go get github.com/derkinderfietsen/ravkav-sdk-go

Example

package main

import (
    "fmt"
    ravkavSdk "github.com/derkinderfietsen/ravkav-sdk-go"
)

func main() {
    ravkavReader := ravkavSdk.NewReader()
    availableReaders, err := ravkavReader.ListReaders()
    if err != nil {
    	panic("can't find available card readers")
    }
    err = ravkavReader.Connect(availableReaders[0]) // Connect to first available reader
    if err != nil {
    	panic("error when trying to connect to reader")
    }
    
    defer func() {
    	if ravkavReader.Disconnect() != nil {
    		panic("error when trying to disconnect from reader")
    	}
    }()
    
    c := ravkavSdk.NewCard(ravkavReader) // Get new card instance
    err = c.Populate()                  // Populate the card instance with physical card records
    if err != nil {
    	panic(err)
    }
    err = c.Normalize() // Normalize card records to human readable format
    if err != nil {
    	panic(err)
    }
    jsonOutput, err := c.Output().JSON() // Get JSON string representation of the card
    if err != nil {
    	panic("error getting card output")
    }
    fmt.Println(jsonOutput)
}

License

This work is published under the MIT license.

Please see the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCard

func NewCard(reader contracts.Reader) contracts.Card

NewCard creates a new card instance, it receives a reader instance for flexibility purposes and for tests.

func NewReader

func NewReader() contracts.Reader

NewReader creates a new reader instance used for connecting to the card and transmit commands for getting card's content.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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