infinias

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidAuthorization = errors.New("invalid authorization")
View Source
var ErrInvalidID = errors.New("invalid id")

Functions

func HTTPErrorCode

func HTTPErrorCode(err error) int

Types

type Credential added in v1.2.0

type Credential struct {
	ID       int  `json:"id,omitempty"`
	Active   bool `json:"active"`
	SiteCode int  `json:"site_code"`
	CardCode int  `json:"card_code"`
}

type Group

type Group struct {
	ID   int    `json:"id"`
	Name string `json:"name"`
}

type HTTPError

type HTTPError struct {
	StatusCode int
	Err        error
}

func (*HTTPError) Error

func (h *HTTPError) Error() string

func (*HTTPError) Unwrap

func (h *HTTPError) Unwrap() error

type Person

type Person struct {
	ID          int           `json:"id"`
	FirstName   string        `json:"first_name"`
	LastName    string        `json:"last_name"`
	EmployeeID  string        `json:"employee_id"`
	Department  string        `json:"department"`
	SiteCode    int           `json:"site_code"`
	CardCode    int           `json:"card_code"`
	Image       []byte        `json:"image,omitempty"`
	HasImage    bool          `json:"has_image"`
	GroupsToAdd []int         `json:"groups_to_add,omitempty"`
	Credentials []*Credential `json:"credentials,omitempty"`
}

type Service

type Service struct {
	APIConn *api.Conn
	DBConn  *db.Conn
	Log     func(string)
	APIKey  string
}

func (*Service) CreateCredential added in v1.2.0

func (s *Service) CreateCredential(id int, cred *Credential) (int, error)

func (*Service) CreateCredentialHandler added in v1.2.0

func (s *Service) CreateCredentialHandler(r *http.Request) (interface{}, error)

func (*Service) CreatePerson

func (s *Service) CreatePerson(p *Person) (int, error)

func (*Service) CreatePersonHandler

func (s *Service) CreatePersonHandler(r *http.Request) (interface{}, error)

func (*Service) DeleteCredential added in v1.2.0

func (s *Service) DeleteCredential(id, credID int) error

func (*Service) DeleteCredentialHandler added in v1.2.0

func (s *Service) DeleteCredentialHandler(r *http.Request) error

func (*Service) DeletePerson

func (s *Service) DeletePerson(id int) error

func (*Service) DeletePersonHandler

func (s *Service) DeletePersonHandler(r *http.Request) error

func (*Service) HandleJSON

func (s *Service) HandleJSON(next func(r *http.Request) (interface{}, error)) http.Handler

func (*Service) Handler

func (s *Service) Handler() http.Handler

func (*Service) ListCredentials added in v1.2.0

func (s *Service) ListCredentials(id int) ([]*Credential, error)

func (*Service) ListCredentialsHandler added in v1.2.0

func (s *Service) ListCredentialsHandler(r *http.Request) (interface{}, error)

func (*Service) ListGroups

func (s *Service) ListGroups() ([]*Group, error)

func (*Service) ListGroupsHandler

func (s *Service) ListGroupsHandler(r *http.Request) (interface{}, error)

func (*Service) ListPeople

func (s *Service) ListPeople() ([]*Person, error)

func (*Service) ListPeopleHandler added in v1.2.0

func (s *Service) ListPeopleHandler(r *http.Request) (interface{}, error)

func (*Service) ReadPerson

func (s *Service) ReadPerson(id int) (*Person, error)

func (*Service) ReadPersonHandler

func (s *Service) ReadPersonHandler(r *http.Request) (interface{}, error)

func (*Service) UpdatePerson

func (s *Service) UpdatePerson(p *Person) error

func (*Service) UpdatePersonHandler

func (s *Service) UpdatePersonHandler(r *http.Request) (interface{}, error)

func (*Service) WithAuth

func (s *Service) WithAuth(next http.Handler) http.Handler

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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