api

package
v0.0.0-...-7767d0b Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2014 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DB      *sql.DB
	DBName  = ""
	DBUser  = ""
	DBPass  = ""
	SSLMode = ""
)

Functions

func CreateNewTag

func CreateNewTag(tag string) (err error)

creates a new tag in the tags table returns an error if there is one.

func CreateNewUser

func CreateNewUser(email, first, last, hash, salt string) error

CreateNewUser is an api function for creating a new user. Given the user's form information, add a user to the database. Tjis functions does not do any validation, that should all be done by the handler.

func CreateTagMap

func CreateTagMap(taskId int, tagText string) (err error)

add a tag mapping given the task id number and the tag text string returns an error if there is one.

func CreateTask

func CreateTask(text string, owner int) (err error)

Create a new task TODO: Make this (and the database) accept a due date and possibly reminders

func DeleteTagMap

func DeleteTagMap(taskId int, tagText string) (err error)

delete a tag mapping given the task id number and the tag text string returns an error if there is one.

func DeleteTask

func DeleteTask(taskId int) (err error)

Delete a given task

func DeleteUser

func DeleteUser(userId int) error

DeleteUser is an api function for deleting a user and all associated tasks/data.

func GetTags

func GetTags(taskId int) ([]string, error)

func GetTaskById

func GetTaskById(taskId int) (err error)

func InitializeDBConnection

func InitializeDBConnection()

func UpdateTask

func UpdateTask(updatedTask TaskObject) (err error)

Takes a TaskObject. This call will replace task_text and due_date with that in the object TODO: Optimize and make not stupid

func UpdateUser

func UpdateUser(userId int, fields map[string]string) error

UpdateUser is an api function for updating parts or all of a user's information.

func VerifyTaskOwner

func VerifyTaskOwner(taskId, taskOwner int) bool

Verify that taskId is owned by taskOwner This is a general purpose api call that should be used before any alteration of an existing task

Types

type TaskObject

type TaskObject struct {
	TaskId      int
	Owner       int
	Text        string
	Tags        []string
	DateCreated time.Time
}

func GetAllUserTasks

func GetAllUserTasks(userId int) ([]TaskObject, error)

Get all a user's tasks. Default api call for a freshly logged in user

type UserObject

type UserObject struct {
	UserId    int
	FirstName string
	LastName  string
	Email     string
	Salt      string
	Hash      string
}

func GetUser

func GetUser(email string) (UserObject, error)

GetUser is a general api function for getting a user from an email. Given a user's email gets the user's information and returns it as a UserObject.

Jump to

Keyboard shortcuts

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