dijnet

package module
v0.0.0-...-9927e7f Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2023 License: MIT Imports: 15 Imported by: 0

README

Díjnet

(Unofficial) Díjnet API client for Go

Download it using

go get github.com/ProZsolt/dijnet

Usage

package main

import (
  "fmt"
  "path/filepath"
  "time"

  "github.com/ProZsolt/dijnet"
)

func main() {
  // Authentication
  srv := dijnet.NewService()
  err := srv.Login("username", "password")
  if err != nil {
    // handle error
  }
  
  //List available providers
  providers, err := srv.Providers()
  if err != nil {
    // handle error
  }
  for _, provider := range providers {
    fmt.Println(provider)
  }

  // Download the last 3 months of Invoices from NKM Főldgáz
  query := dijnet.InvoicesQuery{
    Provider: dijnet.NKMFoldgaz,
    From:     time.Now().AddDate(0, -3, 0),
  }
  invoices, err := srv.Invoices(query)
  if err != nil {
    // handle error
  }

  for _, invoice := range invoices {
    basePath := "invoices"
    PDF := filepath.Join(basePath, invoice.InvoiceID+".pdf")
    XML := filepath.Join(basePath, invoice.InvoiceID+".xml")
    err = srv.DownloadInvoice(invoice, PDF, XML)
    if err != nil {
      // handle error
    }
  }
}

Limitation

Due to Díjnet don't let you navigate easily via URLs, you have to call Providers, Invoices, DownloadInvoice in this order otherwise it won't work.

Documentation

Index

Constants

View Source
const FCSM = "FCSM Zrt."
View Source
const FovarosiVizmuvek = "FV Zrt."
View Source
const NKMFoldgaz = "NKM Energia - földgáz"
View Source
const Vodafone = "Vodafone Cégcsoport"

Variables

This section is empty.

Functions

This section is empty.

Types

type Invoice

type Invoice struct {
	ID              string
	Provider        string
	IssuerID        string
	InvoiceID       string
	DateOfIssue     time.Time
	Total           int
	PaymentDeadline time.Time
	Payable         int
	Status          string
}

type InvoicesQuery

type InvoicesQuery struct {
	Provider string
	IssuerID string
	From     time.Time
	To       time.Time
}

type Service

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

func NewService

func NewService() Service

func (Service) DownloadInvoice

func (s Service) DownloadInvoice(i Invoice, pdf string, xml string) error

func (Service) Invoices

func (s Service) Invoices(query InvoicesQuery) ([]Invoice, error)

func (Service) Login

func (s Service) Login(username string, password string) error

func (Service) Providers

func (s Service) Providers() ([]string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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