Documentation ¶
Index ¶
- func MarshalList(l *List) ([]byte, error)
- type Category
- func (c *Category) DeleteItem(li *ListItem) error
- func (c *Category) Index(li *ListItem) (int, error)
- func (c *Category) Search(s string, ch chan *ListItem, wg *sync.WaitGroup)
- func (c *Category) SortItemsByChecked()
- func (c *Category) SortItemsByCost()
- func (c *Category) SortItemsByDate()
- func (c *Category) SortItemsByName()
- type List
- func (l *List) DeleteCategory(s string) error
- func (l *List) DeleteItem(c *Category, li *ListItem) error
- func (l *List) FindCategory(s string) (*Category, error)
- func (l *List) NewCategory(s string) (*Category, error)
- func (l *List) NewItem(category, name, url, description string, cost float64) error
- func (l *List) Purchase(it, m string, price float64) error
- func (l *List) RenameCategory(c *Category, s string)
- func (l *List) Search(s string) (*ListItem, error)
- func (l *List) SortByDateAdded()
- func (l *List) SortByName()
- type ListItem
- type Purchase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Category ¶
type Category struct { DateCreated time.Time `json:"created" html:"created"` DateModified time.Time `json:"modified" html:"modified"` Items []*ListItem `json:"items" html:"items"` CategoryName string `json:"name" html:"name"` Value float64 `json:"value" html:"value"` Length int `json:"length" html:"length"` NilItem *ListItem `json:"nil" html:"nil"` }
Category is a subsection of a list. They are optional
func (*Category) DeleteItem ¶
DeleteItem removes an item from a category
func (*Category) SortItemsByChecked ¶
func (c *Category) SortItemsByChecked()
SortItemsByChecked sorts items in a category by whether or not they have been marked as bought, then subsorts those sets alphabetically. At some point this hopefully will be able to work in conjunction with any of the other ones. And honestly this should probably just be handled in JS
func (*Category) SortItemsByCost ¶
func (c *Category) SortItemsByCost()
SortItemsByCost sorts items in a category by cost, from least to most expensive
func (*Category) SortItemsByDate ¶
func (c *Category) SortItemsByDate()
SortItemsByDate sorts items in a category by when they were added
func (*Category) SortItemsByName ¶
func (c *Category) SortItemsByName()
SortItemsByName sorts items in a category alphabetically by name
type List ¶
type List struct { DateCreated time.Time `json:"created" html:"created"` //I'll eventually convert these to uint64 for unix time DateModified time.Time `json:"modified" html:"modified"` ListID string `json:"id" html:"id"` Family string `json:"family" html:"family"` NilCategory *Category `json:"nil_category" html:"nil_category"` NilItem *ListItem `json:"nil" html:"nil"` ListOwner string `json:"owner" html:"owner"` //I'm thinking this can be a group ListOwnerName string `json:"owner_name" html:"owner_name"` //For a group, this will be something like "Bill and Ted's list" if they have a joined list Categories []*Category `json:"categories" html:"categories"` Value float64 `json:"value" html:"value"` Length int `json:"length" html:"length"` NumOfCategories int `json:"number_of_categories" html:"number_of_categories"` // contains filtered or unexported fields }
List holds information about a Christmas list
func UnmarshalList ¶
UnmarshalList takes a slice of bytes and marshals it to a list struct
func (*List) DeleteCategory ¶
DeleteCategory removes a category and all its items from a list The remaining categories retain their sorted order. The function returns a non-nil error if deletion is unsuccessful
func (*List) DeleteItem ¶
DeleteItem wraps the Category "delete" method for Lists
func (*List) FindCategory ¶
FindCategory takes a string input and finds the category of that name
func (*List) NewItem ¶
newItem wraps the same method from the Category type, so that the List type can benefit from the length and cost portions
func (*List) Purchase ¶
Purchase updates an item in a list so that its "checked" bool is true. It takes an string argument for the item name, a string argument for the name of the purchaser, and a price float64 value, and returns a non-nil error if the item was not found or if it was already purchased and is not a multi-purchase item
func (*List) RenameCategory ¶
RenameCategory takes a category argument and a string argument and changes the name of the given category to the given string
func (*List) SortByDateAdded ¶
func (l *List) SortByDateAdded()
SortByDateAdded sorts categories by date added
func (*List) SortByName ¶
func (l *List) SortByName()
SortByName sorts categories alphabetically by name
type ListItem ¶
type ListItem struct { DateCreated time.Time `json:"created" html:"created"` DateModified time.Time `json:"modified" html:"modified"` ItemName string `json:"name" html:"name"` Cost float64 `json:"cost" html:"cost"` URL string `json:"url" html:"url"` Description []byte `json:"description" html:"description"` Checked bool `json:"checked" html:"checked"` //true if someone has bought the item MultiPurchase bool `json:"multi_purchase" html:"multi_purchase"` //this should be true if more than one person may purchase the item, e.g. socks or coffee Purchases []*Purchase `json:"purchases" html:"purchases"` }
ListItem holds information about a list item
type Purchase ¶
type Purchase struct { PurchaseDate time.Time `json:"purchase_date" html:"purchase_date"` Purchaser string `json:"purchaser" html:"purchaser"` PricePaid float64 `json:"price_paid" html:"price_paid"` //make sure this isn't seen by other members }
Purchase holds name of purchaser, date of purchase, and price paid