models

package
v0.0.0-...-45c4399 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2023 License: MIT Imports: 2 Imported by: 0

README

Models

This directory contains structs that represent requrest and response objects for our rest api.

Documentation

Index

Constants

View Source
const (
	ActiveStatus    = "ACTIVE"
	CanceledStatus  = "CANCELLED"
	SuspendedStatus = "SUSPENDED"
)

Variables

View Source
var MemberLevelFromAmount = map[int64]MemberLevel{
	0:  Inactive,
	1:  Credited,
	30: Classic,
	35: Standard,
	50: Premium,
}

MemberLevelFromAmount convert amount to MemberLevel

View Source
var MemberLevelToAmount = map[MemberLevel]int64{
	Inactive: 0,
	Credited: 1,
	Classic:  30,
	Standard: 35,
	Premium:  50,
}

MemberLeveltoAmount convert MemberLevel to amount

View Source
var MemberLevelToStr = map[MemberLevel]string{
	Inactive: "Inactive",
	Credited: "Credited",
	Classic:  "Classic",
	Standard: "Standard",
	Premium:  "Premium",
}

MemberLevelToStr convert MemberLevel to string

Functions

This section is empty.

Types

type ACLResponse

type ACLResponse struct {
	Hash string `json:"acl"`
	// Name of the resource - this should match what we have in the database
	//  so we know which acl to compare it with
	Name string `json:"name"`
}

ACLResponse Response from a resource that is a hash of the ACL that the

resource has stored

type ACLUpdateRequest

type ACLUpdateRequest struct {
	ACL []string `json:"acl"`
}

ACLUpdateRequest is the json object we send to a resource when pushing an update

type AccessStats

type AccessStats struct {
	Date         time.Time `json:"date"`
	AccessCount  int       `json:"accessCount"`
	ResourceName string    `json:"resourceName"`
}

type AssignRFIDRequest

type AssignRFIDRequest struct {
	Email string `json:"email"`
	RFID  string `json:"rfid"`
}

AssignRFIDRequest -- request to associate an rfid to a member

type ChartCol

type ChartCol struct {
	Label string `json:"label"`
	Type  string `json:"type"`
}

ChartCol -- chart col info

type ChartOptions

type ChartOptions struct {
	Title     string  `json:"title"`
	CurveType string  `json:"curveType"`
	PieHole   float64 `json:"pieHole"`
	Legend    string  `json:"legend"`
}

ChartOptions -- config option for the chart

type ChartRow

type ChartRow struct {
	MemberLevel, MemberCount interface{}
}

ChartRow -- chart row info

type Claims

type Claims struct {
	Email string `json:"email"`
	jwt.StandardClaims
}

Claims -- auth claims

type Communication

type Communication struct {
	ID                int    `json:"id"`
	Name              string `json:"name"`
	Subject           string `json:"subject"`
	FrequencyThrottle int    `json:"frequencyThrottle"`
	Template          string `json:"template"`
}

Communication defines an email communication

type Credentials

type Credentials struct {
	// Password - the user's password
	// required: true
	// example: string
	Password string `json:"password"`
	// Email - the users email
	// required: true
	// example: string
	Email string `json:"email"`
}

Credentials Create a struct that models the structure of a user, both in the request body, and in the DB

type DeleteMemberRequest

type DeleteMemberRequest struct {
	ResourceAddress string `json:"doorip"`
	Command         string `json:"cmd"`
}

type EndpointSuccess

type EndpointSuccess struct {
	Ack bool `json:"ack"`
}

EndpointSuccess -- success response

type InfoResponse

type InfoResponse struct {
	// Info Message
	//
	// Example: hello, world!
	Message string `json:"message"`
}

InfoResponse -- response of info request

type LogMessage

type LogMessage struct {
	Type      string `json:"type"`
	EventTime int64  `json:"time"`
	IsKnown   string `json:"isKnown"`
	Username  string `json:"username"`
	RFID      string `json:"uid"`
	Door      string `json:"door"`
}

type MQTTRequest

type MQTTRequest struct {
	Door    string `json:"door"`
	Command string `json:"cmd"`
	Address string `json:"doorip"`
}

type Member

type Member struct {
	ID             string           `json:"id"`
	Name           string           `json:"name"`
	Email          string           `json:"email"`
	RFID           string           `json:"rfid"`
	Level          uint8            `json:"memberLevel"`
	Resources      []MemberResource `json:"resources"`
	SubscriptionID string           `json:"subscriptionID"`
}

Member -- a member of the makerspace

type MemberAccess

type MemberAccess struct {
	Email           string
	ResourceAddress string
	ResourceName    string
	Name            string
	RFID            string
}

MemberAccess represents that a member has access to a certain resource.

this will get pushed to a device.

type MemberChurn

type MemberChurn struct {
	Churn int `json:"churn"`
}

type MemberCount

type MemberCount struct {
	Month    time.Time `json:"month"`
	Classic  int       `json:"classic"`
	Standard int       `json:"standard"`
	Premium  int       `json:"premium"`
	Credited int       `json:"credited"`
}

type MemberLevel

type MemberLevel int

MemberLevel enum

const (
	// Inactive $0
	Inactive MemberLevel = iota + 1
	// Credited $1
	Credited
	// Classic $30
	Classic
	// Standard $35
	Standard
	// Premium $50
	Premium
)

type MemberRequest

type MemberRequest struct {
	ResourceAddress string `json:"doorip"`
	Command         string `json:"cmd"`
	UserName        string `json:"user"`
	RFID            string `json:"uid"`
	AccessType      int    `json:"acctype"`
	ValidUntil      int    `json:"validuntil"`
}

type MemberResource

type MemberResource struct {
	ResourceID string `json:"resourceID"`
	Name       string `json:"name"`
}

MemberResource a resource that a member belongs to

type MemberResourceRelation

type MemberResourceRelation struct {
	ID         string `json:"id"`
	MemberID   string `json:"memberID"`
	ResourceID string `json:"resourceID"`
}

MemberResourceRelation - a relationship between resources and members

type MemberResourceRelationUpdateRequest

type MemberResourceRelationUpdateRequest struct {
	// ID of the Resource
	// required: true
	// example: string
	ID string `json:"resourceID"`
	// Email - this will be the member's email address
	// Name of the Resource
	// required: true
	// example: email
	Email string `json:"email"`
}

MemberResourceRelationUpdateRequest -- update or delete a resource for a member

type MembersResourceRelation

type MembersResourceRelation struct {
	// ID of the Resource
	// required: true
	// example: string
	ID string `json:"resourceID"`
	// Emails - list of member's email address
	// required: true
	// example: []
	Emails []string `json:"emails"`
}

MembersResourceRelation -- update or delete a resource for multiple members

type NewMember

type NewMember struct {
	Email string `json:"email"`
	RFID  string `json:"rfid"`
}

NewMember - add a new member

type OpenResourceRequest

type OpenResourceRequest struct {
	// Name of the Resource
	// required: true
	// example: string
	Name string `json:"name"`
}

OpenResourceRequest -- request to associate an rfid to a member

type Payment

type Payment struct {
	Amount string    `json:"amount"`
	Time   time.Time `json:"time"`
}

type RegisterResourceRequest

type RegisterResourceRequest struct {
	// Name of the Resource
	// required: true
	// example: string
	Name string `json:"name"`
	// Address of the Resource. i.e. where it can be found on the network
	// required: true
	// example: string
	Address string `json:"address"`
	// Default state of the Resource
	// required: false
	// example: true
	IsDefault bool `json:"isDefault"`
}

RegisterResourceRequest a resource that can accept an access control list

type ReportChart

type ReportChart struct {
	Options ChartOptions    `json:"options"`
	Type    string          `json:"type"`
	Rows    [][]interface{} `json:"rows"`
	Cols    []ChartCol      `json:"cols"`
}

ReportChart - deliver information to the frontend so that

we can display a monthly payment chart

type Resource

type Resource struct {
	// UniqueID of the Resource
	// required: true
	// example: string
	ID string `json:"id"`
	// Name of the Resource
	// required: true
	// example: string
	Name string `json:"name"`
	// Address of the Resource. i.e. where it can be found on the network
	// required: true
	// example: string
	Address string `json:"address"`
	// Default state of the Resource
	// required: true
	// example: true
	IsDefault     bool      `json:"isDefault"`
	LastHeartBeat time.Time `json:"lastHeartBeat"`
}

Resource a resource that can accept an access control list

type ResourceDeleteRequest

type ResourceDeleteRequest struct {
	// UniqueID of the Resource
	// required: true
	// example: string
	ID string `json:"id"`
}

ResourceDeleteRequest - request for deleting a resource

type ResourceRequest

type ResourceRequest struct {
	// UniqueID of the Resource
	// required: true
	// example: string
	ID string `json:"id"`
	// Name of the Resource
	// required: true
	// example: string
	Name string `json:"name"`
	// Address of the Resource. i.e. where it can be found on the network
	// required: true
	// example: string
	Address string `json:"address"`
	// Default state of the Resource
	// required: true
	// example: true
	IsDefault bool `json:"isDefault"`
}

ResourceRequest a resource that can accept an access control list

type Tier

type Tier struct {
	ID   uint8  `json:"id"`
	Name string `json:"level"`
}

Tier - level of membership

type TokenResponse

type TokenResponse struct {
	// login response to send token string
	//
	// Example: <TOKEN_STRING>
	Token string `json:"token"`
}

TokenResponse -- for json response of signin

type UpdateMemberRequest

type UpdateMemberRequest struct {
	FullName       string `json:"fullName"`
	SubscriptionID string `json:"subscriptionID"`
}

UpdateMemberRequest -- request to update a member

type UserResponse

type UserResponse struct {
	// Email - user's Email
	// example: string
	Email     string     `json:"email"`
	Resources []Resource `json:"resources"`
}

UserResponse - a user object that we can send as json

type VersionResponse

type VersionResponse struct {
	Major string `json:"major"`
	Build string `json:"build"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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