client

package
v0.0.0-...-6be9b1d Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AmountClient

type AmountClient interface {
	GetAmounts(api.AmountQuery) ([]api.Amount, error)
	CreateAmount(api.Amount) error
	UpdateAmount(api.Amount) error
	DeleteAmount(api.Amount) error
}

AmountClient is the interface to the amounts API

type ReportClient

type ReportClient interface {
	TicketTotals(api.TotalsQuery) ([]api.TotalReport, error)
}

ReportClient is the interface to the reports API

type Session

type Session struct {
	Conn      *grpc.ClientConn
	TokenFile string
}

Session represents a session with the API endpoint

func NewSession

func NewSession(baseURL string, port int, tokenFile string) (*Session, error)

NewSession opens a connection to the API and returns a populated session

func (*Session) CloseConn

func (s *Session) CloseConn() error

CloseConn closes the client connection to the API

func (*Session) CreateAmount

func (s *Session) CreateAmount(a api.Amount) error

CreateAmount calls the API to create an amount

func (*Session) CreateTicket

func (s *Session) CreateTicket(t api.Ticket) error

CreateTicket calls the API to create an amount

func (*Session) CreateTime

func (s *Session) CreateTime(t api.Time) error

CreateTime calls the API to create a time

func (*Session) DeleteAmount

func (s *Session) DeleteAmount(api.Amount) error

DeleteAmount calls the API to delete an amount

func (*Session) DeleteTicket

func (s *Session) DeleteTicket(api.Ticket) error

DeleteTicket calls the API to delete an amount

func (*Session) DeleteTime

func (s *Session) DeleteTime(t api.Time) error

DeleteTime calls the API to delete a time

func (*Session) GetAmounts

func (s *Session) GetAmounts(api.AmountQuery) ([]api.Amount, error)

GetAmounts calls the API to get amounts according to query params

func (*Session) GetTickets

func (s *Session) GetTickets() ([]api.Ticket, error)

GetTickets calls the API to get tickets for the current user

func (*Session) GetTimes

func (s *Session) GetTimes(q api.TimeQuery) ([]api.Time, error)

GetTimes calls the API to get times according to query results

func (*Session) GetTokenFile

func (s *Session) GetTokenFile() string

GetTokenFile returns the token filename

func (*Session) Login

func (s *Session) Login(l *api.Login) (*api.Session, error)

Login calls the login method on the API

func (*Session) SetToken

func (s *Session) SetToken(ctx context.Context) (context.Context, error)

SetToken sets the auth token in a context

func (*Session) Signup

func (s *Session) Signup(u *api.User) (*api.User, error)

Signup calls the signup method on the API

func (*Session) StreamInterceptor

func (s *Session) StreamInterceptor(
	ctx context.Context,
	desc *grpc.StreamDesc,
	cc *grpc.ClientConn,
	method string,
	streamer grpc.Streamer,
	opts ...grpc.CallOption,
) (grpc.ClientStream, error)

StreamInterceptor adds the authentication token to the streaming request

func (*Session) TicketTotals

func (s *Session) TicketTotals(q api.TotalsQuery) ([]api.TotalReport, error)

TicketTotals calls the API and returns a slice of tickets

func (*Session) UnaryInterceptor

func (s *Session) UnaryInterceptor(
	ctx context.Context,
	method string,
	req interface{},
	reply interface{},
	cc *grpc.ClientConn,
	invoker grpc.UnaryInvoker,
	opts ...grpc.CallOption,
) error

UnaryInterceptor adds the authentication token to the unary request

func (*Session) UpdateAmount

func (s *Session) UpdateAmount(api.Amount) error

UpdateAmount calls the API to update an amount

func (*Session) UpdateTicket

func (s *Session) UpdateTicket(api.Ticket) error

UpdateTicket calls the API to update an amount

func (*Session) UpdateTime

func (s *Session) UpdateTime(t api.Time) error

UpdateTime calls the API to update a time

type SessionClient

type SessionClient interface {
	Login(l *api.Login) (*api.Session, error)
	GetTokenFile() string
}

SessionClient is the interface to the session api

type TicketClient

type TicketClient interface {
	GetTickets() ([]api.Ticket, error)
	CreateTicket(api.Ticket) error
	UpdateTicket(api.Ticket) error
	DeleteTicket(api.Ticket) error
}

TicketClient is the interface to the tickets api

type TimeClient

type TimeClient interface {
	GetTimes(api.TimeQuery) ([]api.Time, error)
	CreateTime(api.Time) error
	UpdateTime(api.Time) error
	DeleteTime(api.Time) error
}

TimeClient is the interfacee to the time API

type UserClient

type UserClient interface {
	Signup(u *api.User) (*api.User, error)
}

UserClient is the interface to the user api

Jump to

Keyboard shortcuts

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