fddb

package
v0.0.0-...-0dfd57a Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package fddb implements part of the API of http://fddb.info

Index

Constants

View Source
const ROOT_URL = "http://fddb.info/api/v13"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Apikey string

	Lang string
	// contains filtered or unexported fields
}

func New

func New(key string) *Client

func (*Client) DiaryGetDay

func (c *Client) DiaryGetDay(day time.Time) (DiaryResult, error)

func (*Client) SearchItem

func (c *Client) SearchItem(query string) (SearchResult, error)

func (*Client) SetLoginInfo

func (c *Client) SetLoginInfo(user, pass string)

type Description

type Description struct {
	Name             string `xml:"name"`
	Option           string `xml:"option"`
	Producer         string `xml:"producer"`
	Group            string `xml:"group"`
	ImageDescription string `xml:"imagedescription"`
}

func (Description) FullName

func (d Description) FullName() string

type DiaryElement

type DiaryElement struct {
	Uid  int            `xml:"diary_uid"`
	Date int64          `xml:"diary_date"`
	Type int            `xml:"diary_type"`
	Item DiaryShortItem `xml:"diaryshortitem"`
}

type DiaryItemData

type DiaryItemData struct {
	ItemData
	ServingAmount float64 `xml:"diary_serving_amount"`
}

type DiaryResult

type DiaryResult struct {
	DiaryElements []DiaryElement `xml:"diaryelement"`
}

type DiaryShortItem

type DiaryShortItem struct {
	Id          int           `xml:"itemid"`
	Data        DiaryItemData `xml:"data"`
	Description Description   `xml:"description"`
}

type Item

type Item struct {
	Id             int     `xml:"id"`
	ThumbSrc       string  `xml:"thumbsrc"`
	ThumbSrcLarge  string  `xml:"thumbsrclarge"`
	FoodRank       float64 `xml:"foodrank"`
	ProducerId     int     `xml:"producerid"`
	GroupId        int     `xml:"groupid"`
	ProductcodeEAN string  `xml:"productcode_ean"`

	Data        ItemData    `xml:"data"`
	Servings    []Serving   `xml:"servings>serving"`
	Description Description `xml:"description"`
}

type ItemData

type ItemData struct {
	Amount                float64 `xml:"amount"`
	AmountMeasuringSystem string  `xml:"amount_measuring_system"`
	AggregateState        string  `xml:"aggregate_state"`
	KJ                    float64 `xml:"kj"`
	KCal                  float64 `xml:"kcal"`
	FatGram               float64 `xml:"fat_gram"`
	FatSatGram            float64 `xml:"fat_sat_gram"`
	KhGram                float64 `xml:"kh_gram"`
	SugarGram             float64 `xml:"sugar_gram"`
	ProteinGram           float64 `xml:"protein_gram"`
	DfGram                float64 `xml:"df_gram"`
}

type SearchResult

type SearchResult struct {
	Items []Item `xml:"items>item"`
}

type Serving

type Serving struct {
	ServingId  int     `xml:"serving_id"`
	Name       string  `xml:"name"`
	WeightGram float64 `xml:"weight_gram"`
}

Jump to

Keyboard shortcuts

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