ovchipkaart

package
v0.0.0-...-1a5deed Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrCodeUnauthorized is returned when the user is not authorized
	ErrCodeUnauthorized = stacktrace.ErrorCode(401)
	// ErrCodeInternalServerError represents any other error
	ErrCodeInternalServerError = stacktrace.ErrorCode(500)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient struct {
	// contains filtered or unexported fields
}

APIClient is responsible for the fetching transactions using the ov-chipkaart API

func NewAPIService

func NewAPIService(config APIServiceConfig) APIClient

NewAPIService Initializes the API service.

func (APIClient) FetchTransactions

func (client APIClient) FetchTransactions(options TransactionFetchOptions) (records []RawRecord, err error)

FetchTransactions returns the transaction records based on the parameter provided.

func (APIClient) GetAuthorisationToken

func (client APIClient) GetAuthorisationToken(username string, password string) (authorisationToken string, err error)

GetAuthorisationToken fetches the auth token based on username/password combination

type APIServiceConfig

type APIServiceConfig struct {
	ClientID     string
	ClientSecret string
	Locale       string
	Client       HTTPClient
}

APIServiceConfig is the configuration for this service

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is the class used to perform http requests

type RawRecord

type RawRecord struct {
	CheckInInfo            string             `json:"checkInInfo" bson:"check_in_info"`
	CheckInText            string             `json:"checkInText" bson:"check_in_text"`
	Fare                   *float64           `json:"fare" bson:"fare"`
	FareCalculation        string             `json:"fareCalculation" bson:"fare_calculation"`
	FareText               string             `json:"fareText" bson:"fare_text"`
	ModalType              string             `json:"modalType" bson:"modal_type"`
	ProductInfo            string             `json:"productInfo" bson:"product_info"`
	ProductText            string             `json:"productText" bson:"product_text"`
	Pto                    string             `json:"pto" bson:"pto"`
	TransactionDateTime    TimeInMilliSeconds `json:"transactionDateTime" bson:"transaction_timestamp"`
	TransactionInfo        string             `json:"transactionInfo" bson:"transaction_info"`
	TransactionName        TransactionName    `json:"transactionName" bson:"transaction_name"`
	EPurseMut              *float64           `json:"ePurseMut" bson:"e_purse_mut"`
	EPurseMutInfo          string             `json:"ePurseMutInfo" bson:"e_purse_mut_info"`
	TransactionExplanation string             `json:"transactionExplanation" bson:"transaction_explanation"`
	TransactionPriority    string             `json:"transactionPriority" bson:"transaction_priority"`
}

RawRecord represents a transaction record

type TimeInMilliSeconds

type TimeInMilliSeconds int

TimeInMilliSeconds represents time in milliseconds

func (TimeInMilliSeconds) ToInt64

func (t TimeInMilliSeconds) ToInt64() int64

ToInt64 converts time in milliseconds to an int64 value

func (TimeInMilliSeconds) ToTime

func (t TimeInMilliSeconds) ToTime() time.Time

ToTime converts time in milliseconds to a time object

type TransactionFetchOptions

type TransactionFetchOptions struct {
	Username   string
	Password   string
	CardNumber string
	StartDate  time.Time
	EndDate    time.Time
}

TransactionFetchOptions are the options needed when fetching a list of transactions

type TransactionName

type TransactionName string

TransactionName represents the various transaction names

func (TransactionName) IsTheSameAs

func (name TransactionName) IsTheSameAs(comp TransactionName) bool

IsTheSameAs is used to compare 2 transaction names

func (TransactionName) String

func (name TransactionName) String() string

String returns the transaction name as a string

Jump to

Keyboard shortcuts

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