firebase

package
v0.0.0-...-f6dc39f Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	// Instance is the instance of the Firebase app.
	Instance *firebase.App
	// Client is the authentication instance used by the controller.
	Client *auth.Client
	// Database is the database instance used by the controller.
	Database *db.Client
}

Controller contains app and client instances for Firebase related requests.

func New

func New() Controller

New creates a new Firebase controller. Requires that GOOGLE_APPLICATION_CREDENTIALS environment variable be set.

func (*Controller) AuthMiddleware

func (c *Controller) AuthMiddleware(next http.Handler) http.Handler

AuthMiddleware creates an HTTP authentication middleware handler for authenticating HTTP requests against Firebase authentication.

func (*Controller) CreateNewEvent

func (c *Controller) CreateNewEvent(uid string, request *EventRequest) (EventResponse, error)

CreateNewEvent creates a new event and returns the JSON request.

func (*Controller) GetAllResponses

func (c *Controller) GetAllResponses(id string) (EventUserResponses, error)

GetAllResponses returns the stored the responses for the given event.

func (*Controller) GetUserSelection

func (c *Controller) GetUserSelection(size int, eventID string) (MatchList, error)

GetUserSelection gets a number of ordered users from the database.

func (*Controller) GetUsersFromUIDs

func (c *Controller) GetUsersFromUIDs(uids []string, color string) (MatchList, error)

GetUsersFromUIDs creates a payload with user information a given list of UIDs.

type EventRequest

type EventRequest struct {
	// Expires is the expiry time. Not required, but defaults to 10 days from now.
	Expires uint `json:"expires,omitempty"`
	// Questionnaire is the ID of the questionnaire for the event.
	Questionnaire string `json:"questionnaire"`
}

EventRequest represents the content of a valid event creation request.

type EventResponse

type EventResponse struct {
	// EventID is the code and identifier for an event.
	EventID string `json:"eventId"`
}

EventResponse contains the response values for an event creation.

type EventUserResponses

type EventUserResponses struct {
	// ID is the ID of the current event.
	ID string
	// Results is a list of all responses from all users in the event.
	Results []struct {
		// UID is the ID of the user.
		UID string
		// Responses is list of all responses to the current event.
		Responses []int
	}
}

EventUserResponses contains the list of user responses for the current event.

func (EventUserResponses) GetRawResponses

func (e EventUserResponses) GetRawResponses() [][]float64

GetRawResponses returns a 2D slice containing the ordered responses from each user in integer form. This is to extract the relevant data for training.

func (*EventUserResponses) UnmarshalJSON

func (e *EventUserResponses) UnmarshalJSON(data []byte) error

UnmarshalJSON is the custom implementation of json.Unmarshal for the EventUserResponses type.

type MatchList

type MatchList struct {
	// Color is the color for the given group of matches.
	Color string `json:"color"`
	// Matches is the list of matches for the current user.
	Matches []*MatchedUser `json:"matches"`
}

MatchList is a struct containing the fields for the list of matches for the current user and the color associated with their group.

type MatchedUser

type MatchedUser struct {
	// UID is the UID of the matched user.
	UID string `json:"uid"`
	// Name is the display name for the user.
	Name string `json:"name"`
	// Company is the company name that the user works for.
	Company string `json:"company"`
	// Phone is the phone number for the current user.
	Phone string `json:"phone"`
}

MatchedUser is a struct containing information for a matching user.

Jump to

Keyboard shortcuts

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