api

package
v0.0.0-...-82b861d Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GLabsTokenFetchURL    = "https://developer.globelabs.com.ph/oauth/access_token"
	GLabsAccessTokenType  = "GLABS"
	GLabsMobileNumberType = "GLOBE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Role

type Role struct {
	Name        string             `json:"name"`
	Description string             `json:"description"`
	UpdatedAt   pgtype.Timestamptz `json:"updated_at"`
	CreatedAt   pgtype.Timestamptz `json:"created_at"`

} //@name Role

type Server

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

func NewServer

func NewServer(config util.Config, store db.Store, tokenMaker token.Maker, logger *zerolog.Logger) (*Server, error)

NewServer creates a new HTTP server and setup routing

func (*Server) CreateGLabsLoad

func (s *Server) CreateGLabsLoad(ctx *gin.Context)

CreateGLabsLoad

@Summary	Create Globe Labs entry
@Tags		globelabs
@Accept		json
@Produce	json
@Param		req	query		gLabsLoadReq	true	"Globe Labs Load query"
@Success	200	{object}	gLabsLoadRes
@Router		/glabs/load [post]

func (*Server) CreateRole

func (s *Server) CreateRole(ctx *gin.Context)

CreateRole

@Summary	Create role
@Tags		roles
@Accept		json
@Produce	json
@Param		req	body	createRoleReq	true	"Create role parameters"
@Security	BearerAuth
@Success	200	{object}	Role
@Router		/roles/{id} [post]

func (*Server) CreateStation

func (s *Server) CreateStation(ctx *gin.Context)

CreateStation

@Summary	Create station
@Tags		stations
@Accept		json
@Produce	json
@Param		req	body	createStationReq	true	"Create station parameters"
@Security	BearerAuth
@Success	201	{object}	Station
@Router		/stations [post]

func (*Server) CreateStationObservation

func (s *Server) CreateStationObservation(ctx *gin.Context)

CreateStationObservation

@Summary	Create station observation
@Tags		observations
@Accept		json
@Produce	json
@Param		station_id	path	int					true	"Station ID"
@Param		stnObs		body	createStationObsReq	true	"Create station observation parameters"
@Security	BearerAuth
@Success	201	{object}	StationObservation
@Router		/stations/{station_id}/observations [post]

func (*Server) CreateUser

func (s *Server) CreateUser(ctx *gin.Context)

CreateUser

@Summary	Create user
@Tags		users
@Accept		json
@Produce	json
@Param		req	body	createUserReq	true	"Create user parameters"
@Security	BearerAuth
@Success	200	{object}	User
@Router		/users/{id} [post]

func (*Server) DeleteRole

func (s *Server) DeleteRole(ctx *gin.Context)

DeleteRole

@Summary	Delete role
@Accept		json
@Tags		roles
@Produce	json
@Param		id	path	int	true	"Role ID"
@Security	BearerAuth
@Success	204
@Router		/roles/{id} [delete]

func (*Server) DeleteStation

func (s *Server) DeleteStation(ctx *gin.Context)

DeleteStation

@Summary	Delete station
@Tags		stations
@Accept		json
@Produce	json
@Param		station_id	path	int	true	"Station ID"
@Security	BearerAuth
@Success	204
@Router		/stations/{station_id} [delete]

func (*Server) DeleteStationObservation

func (s *Server) DeleteStationObservation(ctx *gin.Context)

DeleteStationObservation

@Summary	Delete station observation
@Tags		observations
@Accept		json
@Produce	json
@Param		station_id	path	int	true	"Station ID"
@Param		id			path	int	true	"Station Observation ID"
@Security	BearerAuth
@Success	204
@Router		/stations/{station_id}/observations/{id} [delete]

func (*Server) DeleteUser

func (s *Server) DeleteUser(ctx *gin.Context)

DeleteUser

@Summary	Delete user
@Tags		users
@Accept		json
@Produce	json
@Param		id	path	int	true	"User ID"
@Security	BearerAuth
@Success	204
@Router		/users/{id} [delete]

func (*Server) GLabsOptIn

func (s *Server) GLabsOptIn(ctx *gin.Context)

GLabsOptIn

@Summary	Globe Labs opt-in
@Tags		globelabs
@Accept		json
@Produce	json
@Param		req	query		gLabsOptInReq	true	"Globe Labs Opt-in query"
@Success	200	{object}	gLabsOptInRes
@Router		/glabs [get]

func (*Server) GLabsUnsubscribe

func (s *Server) GLabsUnsubscribe(ctx *gin.Context)

GLabsUnsubscribe

@Summary	Globe Labs unsubscribe
@Tags		globelabs
@Accept		json
@Produce	json
@Param		req	query	gLabsUnsubscribeReq	true	"Globe Labs unsubscribe params"
@Success	204
@Router		/glabs [post]

func (*Server) GetAuthUser

func (s *Server) GetAuthUser(ctx *gin.Context)

GetAuthUser

@Summary	Get Auth User
@Tags		users
@Accept		json
@Produce	json
@Security	BearerAuth
@Success	200	{object}	User
@Router		/users/auth [get]

func (*Server) GetLatestStationObservation

func (s *Server) GetLatestStationObservation(ctx *gin.Context)

GetLatestStationObservation

@Summary	Get latest station observation
@Tags		observations
@Accept		json
@Produce	json
@Param		station_id	path		int	true	"Station ID"
@Success	200			{object}	latestObservationRes
@Router		/stations/{station_id}/observations/latest [get]

func (*Server) GetNearestLatestStationObservation

func (s *Server) GetNearestLatestStationObservation(ctx *gin.Context)

GetNearestLatestStationObservation

@Summary	Get nearest latest station observation
@Tags		observations
@Accept		json
@Produce	json
@Param		req	query		getNearestLatestStationObsReq	false	"Get nearest latest station observation parameters"
@Success	200	{object}	latestObservationRes
@Router		/stations/nearest/observations/latest [get]

func (*Server) GetRole

func (s *Server) GetRole(ctx *gin.Context)

GetRole

@Summary	Get role
@Tags		roles
@Accept		json
@Produce	json
@Param		id	path	int	true	"Role ID"
@Security	BearerAuth
@Success	200	{object}	Role
@Router		/roles/{id} [get]

func (*Server) GetStation

func (s *Server) GetStation(ctx *gin.Context)

GetStation

@Summary	Get station
@Tags		stations
@Accept		json
@Produce	json
@Param		station_id	path		int	true	"Station ID"
@Success	200			{object}	Station
@Router		/stations/{station_id} [get]

func (*Server) GetStationObservation

func (s *Server) GetStationObservation(ctx *gin.Context)

GetStationObservation

@Summary	Get station observation
@Tags		observations
@Accept		json
@Produce	json
@Param		station_id	path		int	true	"Station ID"
@Param		id			path		int	true	"Station Observation ID"
@Success	200			{object}	StationObservation
@Router		/stations/{station_id}/observations/{id} [get]

func (*Server) GetUser

func (s *Server) GetUser(ctx *gin.Context)

GetUser

@Summary	Get user
@Tags		users
@Accept		json
@Produce	json
@Param		id	path	int	true	"User ID"
@Security	BearerAuth
@Success	200	{object}	User
@Router		/users/{id} [get]

func (*Server) ListLatestObservations

func (s *Server) ListLatestObservations(ctx *gin.Context)

ListLatestObservations

@Summary	list latest observation
@Tags		observations
@Produce	json
@Success	200	{array}	latestObservationRes
@Router		/observations/latest [get]

func (*Server) ListObservations

func (s *Server) ListObservations(ctx *gin.Context)

ListObservations

@Summary	list station observation
@Tags		observations
@Produce	json
@Param		req	query		listObservationsReq	false	"List observations parameters"
@Success	200	{object}	paginatedStationObservations
@Router		/observations [get]

func (*Server) ListRoles

func (s *Server) ListRoles(ctx *gin.Context)

ListRoles

@Summary	List roles
@Tags		roles
@Accept		json
@Produce	json
@Param		req	query	listRolesReq	false	"List roles parameters"
@Security	BearerAuth
@Success	200	{object}	paginatedRoles
@Router		/roles [get]

func (*Server) ListStationObservations

func (s *Server) ListStationObservations(ctx *gin.Context)

ListStationObservations

@Summary	List station observations
@Tags		observations
@Accept		json
@Produce	json
@Param		station_id	path		int					true	"Station ID"
@Param		req			query		listStationObsReq	false	"List station observations parameters"
@Success	200			{object}	paginatedStationObservations
@Router		/stations/{station_id}/observations [get]

func (*Server) ListStations

func (s *Server) ListStations(ctx *gin.Context)

ListStations

@Summary	List stations
@Tags		stations
@Accept		json
@Produce	json
@Param		req	query		listStationsReq	false	"List stations parameters"
@Success	200	{object}	paginatedStations
@Router		/stations [get]

func (*Server) ListUsers

func (s *Server) ListUsers(ctx *gin.Context)

ListUsers

@Summary	List users
@Tags		users
@Accept		json
@Produce	json
@Param		req	query	listUsersReq	false	"List users parameters"
@Security	BearerAuth
@Success	200	{object}	paginatedUsers
@Router		/users [get]

func (*Server) LoginUser

func (s *Server) LoginUser(ctx *gin.Context)

LoginUser

@Summary	User login
@Tags		users
@Accept		json
@Produce	json
@Param		req	body	loginUserRequest	true	"Login user parameters"
@Success	204
@Router		/users/login [post]

func (*Server) LogoutUser

func (s *Server) LogoutUser(ctx *gin.Context)

LogoutUser

@Summary	User logout
@Tags		users
@Accept		json
@Produce	json
@Success	204
@Router		/users/logout [post]

func (*Server) LufftMsgLog

func (s *Server) LufftMsgLog(ctx *gin.Context)

LufftMsgLog

@Summary	Lufft Message Logs
@Tags		lufft
@Accept		json
@Produce	json
@Param		station_id	path		int				true	"Station ID"
@Param		req			query		lufftMsgLogReq	false	"Lufft Message log query"
@Success	200			{object}	paginatedLufftMsgLogs
@Router		/lufft/{station_id}/logs [get]

func (*Server) PromoTexterStoreLufft

func (s *Server) PromoTexterStoreLufft(ctx *gin.Context)

PromoTexterStoreLufft

@Summary	Store Lufft observation and health
@Tags		promotexter
@Accept		json
@Produce	json
@Param		req	query		pTexterStoreLufftReq	true	"Promo Texter query"
@Success	200	{object}	lufftRes
@Router		/ptexter [post]

func (*Server) RegisterUser

func (s *Server) RegisterUser(ctx *gin.Context)

RegisterUser

@Summary	Register user
@Tags		users
@Accept		json
@Produce	json
@Param		req	body	registerUserReq	true	"Register user parameters"
@Success	204
@Router		/users/register [post]

func (*Server) RenewAccessToken

func (s *Server) RenewAccessToken(ctx *gin.Context)

RenewAccessToken

@Summary	Renew access token
@Tags		users
@Accept		json
@Produce	json
@Param		req	body	renewAccessTokenRequest	true	"Renew access token parameters"
@Success	204
@Router		/tokens/renew [post]

func (*Server) Start

func (s *Server) Start(address string) error

func (*Server) UpdateRole

func (s *Server) UpdateRole(ctx *gin.Context)

UpdateRole

@Summary	Update role
@Tags		roles
@Accept		json
@Produce	json
@Param		id	path	int				true	"Role ID"
@Param		req	body	updateRoleReq	true	"Update role parameters"
@Security	BearerAuth
@Success	200	{object}	Role
@Router		/roles/{id} [put]

func (*Server) UpdateStation

func (s *Server) UpdateStation(ctx *gin.Context)

UpdateStation

@Summary	Update station
@Tags		stations
@Accept		json
@Produce	json
@Param		station_id	path	int					true	"Station ID"
@Param		req			body	updateStationReq	true	"Update station parameters"
@Security	BearerAuth
@Success	200	{object}	Station
@Router		/stations/{station_id} [put]

func (*Server) UpdateStationObservation

func (s *Server) UpdateStationObservation(ctx *gin.Context)

UpdateStationObservation

@Summary	Update station observation
@Tags		observations
@Produce	json
@Param		station_id	path	int					true	"Station ID"
@Param		id			path	int					true	"Station Observation ID"
@Param		stnObs		body	updateStationObsReq	true	"Update station observation parameters"
@Security	BearerAuth
@Success	200	{object}	StationObservation
@Router		/stations/{station_id}/observations/{id} [put]

func (*Server) UpdateUser

func (s *Server) UpdateUser(ctx *gin.Context)

UpdateUser

@Summary	Update user
@Tags		users
@Accept		json
@Produce	json
@Param		id	path	int				true	"User ID"
@Param		req	body	updateUserReq	true	"Update user parameters"
@Security	BearerAuth
@Success	200	{object}	User
@Router		/users/{id} [put]

type Station

type Station struct {
	ID            int64    `json:"id"`
	Name          string   `json:"name"`
	Lat           *float32 `json:"lat"`
	Lon           *float32 `json:"lon"`
	Elevation     *float32 `json:"elevation"`
	DateInstalled string   `json:"date_installed,omitempty"`
	MobileNumber  string   `json:"mobile_number,omitempty"`
	StationType   string   `json:"station_type,omitempty"`
	StationType2  string   `json:"station_type2,omitempty"`
	StationUrl    string   `json:"station_url,omitempty"`
	Status        string   `json:"status,omitempty"`
	Province      string   `json:"province"`
	Region        string   `json:"region"`
	Address       string   `json:"address"`

} //@name Station

type StationHealth

type StationHealth struct {
	ID         int64              `json:"id"`
	Vb1        float32            `json:"vb1"`
	Vb2        float32            `json:"vb2"`
	Curr       float32            `json:"curr"`
	Bp1        float32            `json:"bp1"`
	Bp2        float32            `json:"bp2"`
	Cm         string             `json:"cm"`
	Ss         int32              `json:"ss"`
	RhArq      float32            `json:"rh_arq"`
	TempArq    float32            `json:"temp_arq"`
	Fpm        string             `json:"fpm"`
	ErrorMsg   string             `json:"error_msg"`
	Message    string             `json:"message"`
	DataCount  int32              `json:"data_count"`
	DataStatus string             `json:"data_status"`
	Timestamp  pgtype.Timestamptz `json:"timestamp"`
	StationID  int64              `json:"station_id"`

} //@name StationHealth

type StationObservation

type StationObservation struct {
	ID        int64              `json:"id"`
	Pres      float32            `json:"pres"`
	Rr        float32            `json:"rr"`
	Rh        float32            `json:"rh"`
	Temp      float32            `json:"temp"`
	Td        float32            `json:"td"`
	Wdir      float32            `json:"wdir"`
	Wspd      float32            `json:"wspd"`
	Wspdx     float32            `json:"wspdx"`
	Srad      float32            `json:"srad"`
	Mslp      float32            `json:"mslp"`
	Hi        float32            `json:"hi"`
	StationID int64              `json:"station_id"`
	Timestamp pgtype.Timestamptz `json:"timestamp"`
	Wchill    float32            `json:"wchill"`
	QcLevel   int32              `json:"qc_level"`

} //@name StationObservation

type User

type User struct {
	Username          string             `json:"username"`
	FullName          string             `json:"full_name"`
	Email             string             `json:"email"`
	PasswordChangedAt pgtype.Timestamptz `json:"password_changed_at"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	Roles             []string           `json:"roles"`

} //@name User

Jump to

Keyboard shortcuts

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