tgtg

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2022 License: MIT Imports: 9 Imported by: 0

README

Too Good To Go API client (tgt-go)

Coverage Build Status GoDoc Go Report Card

tgt-go is an unofficial Go client library for accessing the Too Good To Go API.

No official Too Good To Go API documentation is available.

Install

go get github.com/filippalach/tgt-go@vX.Y.Z

where X.Y.Z is the version you need.

or

go get github.com/filippalach/tgt-go

for non Go modules usage or latest version.

Usage

Create a new Too Good To Go client, then use the exposed services (Auth, Items, Orders) to access different parts of the API.

Capabilities

This package provides following functionalities through exposed services:

  • Auth Service
    • Login - initiate auth process - /auth/vX/authByEmail
    • Poll - finish auth process - /auth/vX/authByRequestPollingId
    • Refresh - refresh tokens - /auth/vX/token/refresh
    • Signup - create account - /auth/vX/signUpByEmail
  • Items Service
    • List - fetch items - /items/vX/
    • Get - fetch specific item - /items/vX/{item_id}
    • Favorite - un/set specific item as favorite - /items/vX/{item_id}/setFavorite
  • Orders Service
    • Active - fetch active orders - /order/vX/active
    • Inactive - fetch past/inactive orders - /order/vX/inactive

Apart from that, exported methods such as: SetAuthContext, NewRequest, Do, CheckResponseForErrors can be used to form request from scratch, if service capabilites would happen to be insufficient in any case.

Authentication

Too Good To Go application uses custom authentication process. It consists of 3 steps:

  • Initiating Login process with email (Login method of Auth service)
  • Clicking link in email received (requires manual intervention)
  • Obtaining tokens (Poll method of Auth service)

After successful authentication process with client's Auth service, Too Good To Go auth context will be set and used in every subsequent request, consisting of

  • access_token (needed for subsequent requests using Items, Orders service)
  • refresh_token (needed for refreshing tokens)
  • user_id (needed for subsequent requests using Items, Orders service)

Usage example

package main

import (
	"context"
	"log"
	"os"
	"time"

	tgtg "github.com/filippalach/tgt-go"
)

func main() {
	// Create client with custom user agent and headers. Pass no ClentOpts to get default client.
	client, err := tgtg.New(
		nil,
		tgtg.SetUserAgent("<your custom user agent>"),
		tgtg.SetRequestHeaders(map[string]string{"<header>": "<value>"}))
	if err != nil {
		log.Fatal(err)
		os.Exit(1)
	}

	// Initiate login process with login request.
	loginReq := &tgtg.LoginRequest{
		DeviceType: "<IOS|ANDROID>",
		Email:      "<your_email>",
	}
	loginResp, _, err := client.Auth.Login(context.TODO(), loginReq)
	if err != nil {
		log.Fatal(err)
		os.Exit(1)
	}

	// Poll to obtain Too Good To Go tokens.
	pollReq := &tgtg.PollRequest{
		DeviceType: "<IOS|ANDROID>",
		Email:      "<your_email>",

		// Polling ID is returned by Login request.
		PollingID: loginResp.PollingID,
	}

	// Give client time for you to finish authentication process via received email.
	log.Println("Check your mailbox, finish login process and wait 2 minutes...")
	time.Sleep(2 * time.Minute)
	pollResp, _, err := client.Auth.Poll(context.TODO(), pollReq)
	if err != nil {
		log.Fatal(err)
		os.Exit(1)
	}

	// Refresh tokens - nil body - client's refresh token will be used by default
	// since they already got set earlier with sucessful Poll method.
	refreshResp, _, err := client.Auth.Refresh(context.TODO(), nil)
	if err != nil {
		log.Fatal(err)
		os.Exit(1)
	}

	// Refresh tokens - with body - specific refresh token will be used.
	refreshReq := &tgtg.RefreshTokensRequest{
		RefreshToken: refreshResp.RefreshToken,
	}
	_, _, err = client.Auth.Refresh(context.TODO(), refreshReq)
	if err != nil {
		log.Fatal(err)
		os.Exit(1)
	}

	// List items.
	listItemsReq := &tgtg.ListItemsRequest{
		// UserID has to be specified if no SetAuthContext was called
		// either manually, or through the Auth service usage.
		UserID:   pollResp.StartupData.User.UserID,
		Radius:   10,
		PageSize: 100,
		Page:     1,
		Origin: &tgtg.Origin{
			Latitude:  50.000,
			Longitude: 20.000,
		},
	}
	listItemsResp, _, err := client.Items.List(context.TODO(), listItemsReq)
	if err != nil {
		log.Fatal(err)
		os.Exit(1)
	}

	// Get speicifc's item ID.
	itemID := listItemsResp.Items[0].Item.ItemID

	// Get specific item
	itemReq := &tgtg.GetItemRequest{
		// UserID has to be specified if no SetAuthContext was called either
		// manually, or through the Auth service usage.
		UserID: pollResp.StartupData.User.UserID,
	}
	_, _, err = client.Items.Get(context.TODO(), itemReq, itemID)
	if err != nil {
		log.Fatal(err)
		os.Exit(1)
	}
	// ...process received item.

	// Un/Set specific item as favorite.
	favItemReq := &tgtg.FavoriteItemRequest{
		IsFavorite: true,
	}
	_, err = client.Items.Favorite(context.TODO(), favItemReq, itemID)
	if err != nil {
		log.Fatal(err)
		os.Exit(1)
	}
	// ...process received response.

	// Check active orders.
	activeOrdersReq := &tgtg.ActiveOrdersRequest{
		// UserID has to be specified if no SetAuthContext was called either
		// manually, or through the Auth service usage.
		UserID: pollResp.StartupData.User.UserID,
	}
	_, _, err = client.Orders.Active(context.TODO(), activeOrdersReq)
	if err != nil {
		log.Fatal(err)
		os.Exit(1)
	}
	// ...process received response.

	// Check all inactive/past orders.
	inactiveOrdersReq := &tgtg.InactiveOrdersRequest{
		// UserID has to be specified if no SetAuthContext was called either
		// manually, or through the Auth service usage.
		UserID: pollResp.StartupData.User.UserID,
		Paging: tgtg.Paging{
			// 0 for all - this API endpoint works really weirdly.
			Page: 0,
			Size: 200,
		},
	}
	_, _, err = client.Orders.Inactive(context.TODO(), inactiveOrdersReq)
	if err != nil {
		log.Fatal(err)
		os.Exit(1)
	}
	// ...process received response.

	// Signup request.
	signupReq := &tgtg.SignupRequest{
		CountryID:             "<ISO 3166-1 APLHA-2 country code - e.x. GB, IT>",
		DeviceType:            "<ANDROID|IOS>",
		Email:                 "<your_email>",
		Name:                  "<your_name>",
		NewsletterOptIn:       false,
		PushNotificationOptIn: true,
	}
	_, _, err = client.Auth.Signup(context.TODO(), signupReq)
	if err != nil {
		log.Fatal(err)
		os.Exit(1)
	}
	// ...process received response.
}

Versioning

Each version of the client is tagged and the version is updated accordingly.

To see the list of past versions, run git tag.

Documentation

For details on all the functionality in this library, see the GoDoc documentation.

Contributions

Too Good To Go App is subject of constant changes - some might be tricky to track - that's why we love pull requests!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponseForErrors

func CheckResponseForErrors(r *http.Response) error

CheckResponseForErrors checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 2xx range. Error response is expected to have either no response body, or a JSON response body that maps to ErrorResponse or plain text. Either way Client will log out the message.

Types

type ActiveOrdersRequest

type ActiveOrdersRequest struct {
	UserID string `json:"user_id"`
}

ActiveOrdersRequest represents a request body to obtain user's active orders.

type Address

type Address struct {
	AddressLine string  `json:"address_line"`
	City        string  `json:"city"`
	Country     Country `json:"country"`
	PostalCode  string  `json:"postal_code"`
}

Address represents a Too Good To Go Address details.

type ArgumentError

type ArgumentError struct {
	// contains filtered or unexported fields
}

ArgumentError is an error that represents an issue with an input to Too Good To Go API client. Identifies input parameter and the cause.

func NewArgumentError

func NewArgumentError(argument, reason string) *ArgumentError

NewArgumentError creates an ArgumentError.

func (*ArgumentError) Error

func (e *ArgumentError) Error() string

Error implements error interface's method.

type AuthService

AuthService is an interface for interfacing with the Auth related endpoints of the Too Good To Go API.

type AuthServiceOp

type AuthServiceOp struct {
	// contains filtered or unexported fields
}

AuthServiceOp handles communication with the Auth related methods of the Too Good To Go API.

func (*AuthServiceOp) Login

func (s *AuthServiceOp) Login(ctx context.Context, loginRequest *LoginRequest) (*LoginResponse, *http.Response, error)

Login handles initiating authentication process. It does not return tokens. After Login user have to manually finish logging process using received mail.

Calling this endpoint frequently will cause 429 TOO_MANY_REQUESTS HTTP error, which will decay after ~15mins.

func (*AuthServiceOp) Poll

func (s *AuthServiceOp) Poll(ctx context.Context, pollRequest *PollRequest) (*PollResponse, *http.Response, error)

Poll handles checking current authentication status.

If the login was finished using email, it return tokens, otherwise it errors out with EOF, empty body HTTP 202 ACCEPTED response.

func (*AuthServiceOp) Refresh

Refresh handles refreshing tokens.

If refreshRequest does not specify refresh token to use, client will attempt to use one already stored. For that to work authenticate client first using Login and Poll, or use SetAuthContext manually.

func (*AuthServiceOp) Signup

func (s *AuthServiceOp) Signup(ctx context.Context, signupRequest *SignupRequest) (*SignupResponse, *http.Response, error)

Signup handles signing up a new account.

type AverageOverallRating

type AverageOverallRating struct {
	AverageOverallRating float64 `json:"average_overall_rating"`
	MonthCount           int     `json:"month_count"`
	RatingCount          int     `json:"rating_count"`
}

AverageOverallRating represents a Too Good To Go AverageOverallRating details.

type Badges

type Badges struct {
	BadgeType   string `json:"badge_type"`
	MonthCount  int    `json:"month_count"`
	Percentage  int    `json:"percentage"`
	RatingGroup string `json:"rating_group"`
	UserCount   int    `json:"user_count"`
}

Badges represents a Too Good To Go Badges details.

type Client

type Client struct {

	// AccessToken used in subsequent API requests, if set.
	AccessToken string

	// RefreshToken used in refresh API request, if set.
	RefreshToken string

	// UserID is set at the end on successful logging attempt ending with Poll.
	// It is required in multiple Too Good To Go API calls.
	UserID string

	// Base URL for API requests, has to end with "/".
	BaseURL *url.URL

	// User agent for client.
	UserAgent string

	// Services used for communicating with the Too Good To Go API.
	Auth   AuthService
	Items  ItemsService
	Orders OrdersService
	// contains filtered or unexported fields
}

Client represents Too Good To Go client.

func New

func New(httpClient *http.Client, options ...ClientOption) (*Client, error)

New returns a new Too Good To Go API client.

Multiple ClientOptions can be passed to configure client.

func NewClient

func NewClient(httpClient *http.Client) *Client

NewClient returns a new Too Good To Go API client.

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *http.Request, v interface{}) (*http.Response, error)

Do sends Too Good To Go API request and returns response. The response is JSON decoded and stored in the value pointed to by v, or returned as an error if occurred.

func (*Client) NewRequest

func (c *Client) NewRequest(method, url string, body interface{}) (*http.Request, error)

NewRequest creates Too Good To Go API request. Relative URL has to be provided in url, which will be merged with BaseURL of the Client. URL has to start with no "/" prefix, only relative URL is handled. If specified, the value pointing at body would be JSON encoded and included in as the request body.

func (*Client) SetAuthContext

func (c *Client) SetAuthContext(accessToken, refreshToken, userID string)

SetAuthContext sets Too Good To Go API auth context: access token, refresh token and user id.

type ClientOption

type ClientOption func(*Client) error

ClientOption are options for New.

func SetRequestHeaders

func SetRequestHeaders(headers map[string]string) ClientOption

SetRequestHeaders sets optional HTTP headers on the client that are sent on each HTTP request.

func SetUserAgent

func SetUserAgent(userAgent string) ClientOption

SetUserAgent is a ClientOption for setting the user agent.

type Country

type Country struct {
	IsoCode string `json:"iso_code"`
	Name    string `json:"name"`
}

Country represents a Too Good To Go Country details.

type Error

type Error struct {
	// Code field is always set by Too Good To Go API.
	Code string `json:"code"`

	// Message is optional and not always returned.
	Message string `json:"message"`
}

An Error represent the error returned from Too Good to Go API.

type ErrorResponse

type ErrorResponse struct {
	// HTTP response that caused this error.
	Response *http.Response

	// Error body from Too Good To Go API.
	Errors []Error `json:"errors"`
}

ErrorResponse represents error response returned from Too Good To Go API.

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

type FavoriteItemRequest

type FavoriteItemRequest struct {
	IsFavorite bool `json:"is_favorite"`
}

FavoriteItemRequest represents a request body to un/set favorite item.

type GetItemRequest

type GetItemRequest struct {
	UserID string  `json:"user_id"`
	Origin *Origin `json:"origin"`
}

GetItemRequest represents a request body to get item details.

type GetItemResponse

type GetItemResponse struct {
	Item  Item  `json:"item"`
	Store Store `json:"store"`

	DisplayName    string         `json:"display_name"`
	Distance       float64        `json:"distance"`
	Favorite       bool           `json:"favorite"`
	InSalesWindow  bool           `json:"in_sales_window"`
	ItemsAvailable int            `json:"items_available"`
	NewItem        bool           `json:"new_item"`
	PickupInterval PickupInterval `json:"pickup_interval"`
	PickupLocation PickupLocation `json:"pickup_location"`
	PurchaseEnd    string         `json:"purchase_end"`
	SharingURL     string         `json:"sharing_url"`
}

GetItemResponse represents a response body with detailed item info.

type InactiveOrdersRequest

type InactiveOrdersRequest struct {
	UserID string `json:"user_id"`
	Paging Paging `json:"paging"`
}

InactiveOrdersRequest represents a request body to obtain user's inactive orders.

type Item

type Item struct {
	AverageOverallRating   AverageOverallRating `json:"average_overall_rating"`
	Badges                 []Badges             `json:"badges"`
	Buffet                 bool                 `json:"buffet"`
	CanUserSupplyPackaging bool                 `json:"can_user_supply_packaging"`
	CollectionInfo         string               `json:"collection_info"`
	CoverPicture           Picture              `json:"cover_picture"`
	Description            string               `json:"description"`
	DietCategories         []string             `json:"diet_categories"`
	FavoriteCount          int                  `json:"favorite_count"`
	ItemCategory           string               `json:"item_category"`
	ItemID                 string               `json:"item_id"`
	LogoPicture            Picture              `json:"logo_picture"`
	Name                   string               `json:"name"`
	PackagingOption        string               `json:"packaging_option"`
	PositiveRatingReasons  []string             `json:"positive_rating_reasons"`
	Price                  Price                `json:"price"`
	PriceExcludingTaxes    Price                `json:"price_excluding_taxes"`
	PriceIncludingTaxes    Price                `json:"price_including_taxes"`
	SalesTaxes             []SalesTaxes         `json:"sales_taxes"`
	ShowSalesTaxes         bool                 `json:"show_sales_taxes"`
	TaxAmount              Price                `json:"tax_amount"`
	TaxationPolicy         string               `json:"taxation_policy"`
	ValueExcludingTaxes    Price                `json:"value_excluding_taxes"`
	ValueIncludingTaxes    Price                `json:"value_including_taxes"`
}

Item represents a Too Good To Go Item details.

type ItemCoverImage

type ItemCoverImage struct {
	PictureID              string `json:"picture_id"`
	CurrentURL             string `json:"current_url"`
	IsAutomaticallyCreated bool   `json:"is_automatically_created"`
}

ItemCoverImage represents Too Good To Go Cover Image.

type Items

type Items struct {
	Item  Item  `json:"item"`
	Store Store `json:"store"`

	DisplayName    string         `json:"display_name"`
	PickupInterval PickupInterval `json:"pickup_interval"`
	PickupLocation Location       `json:"pickup_location"`
	PurchaseEnd    time.Time      `json:"purchase_end"`
	ItemsAvailable int            `json:"items_available"`
	SoldOutAt      time.Time      `json:"sold_out_at"`
	Distance       float64        `json:"distance"`
	Favorite       bool           `json:"favorite"`
	InSalesWindow  bool           `json:"in_sales_window"`
	NewItem        bool           `json:"new_item"`
}

Items represents a Too Good To Go Items details.

type ItemsService

ItemsService is an interface for interfacing with the Items endpoints of the Too Good To Go API.

type ItemsServiceOp

type ItemsServiceOp struct {
	// contains filtered or unexported fields
}

ItemsServiceOp handles communication with the Items related methods of the Too Good To Go API.

func (*ItemsServiceOp) Favorite

func (s *ItemsServiceOp) Favorite(ctx context.Context, favoriteItemRequest *FavoriteItemRequest, itemID string) (*http.Response, error)

Favorite handles setting particular item entry as favorite.

func (*ItemsServiceOp) Get

func (s *ItemsServiceOp) Get(ctx context.Context, getItemRequest *GetItemRequest, itemID string) (*GetItemResponse, *http.Response, error)

Get handles getting specific information about particular item entry.

func (*ItemsServiceOp) List

func (s *ItemsServiceOp) List(ctx context.Context, listItemsRequest *ListItemsRequest) (*ListItemsResponse, *http.Response, error)

List handles listing all items.

type ListItemsRequest

type ListItemsRequest struct {
	PageSize int `json:"page_size"`
	Page     int `json:"page"`

	UserID string `json:"user_id"`

	Radius int     `json:"radius"`
	Origin *Origin `json:"origin"`

	ItemCategories []string `json:"item_categories"`
	DietCategories []string `json:"diet_categories"`
	PickupEarliest string   `json:"pickup_earliest"`
	PickupLatest   string   `json:"pickup_latest"`
	SearchPhrase   string   `json:"search_phrase"`

	Discover      bool `json:"discover"`
	FavoritesOnly bool `json:"favorites_only"`
	WithStockOnly bool `json:"with_stock_only"`
	HiddenOnly    bool `json:"hidden_only"`
	WeCareOnly    bool `json:"we_care_only"`
}

ListItemsRequest represents a request body to list all items.

type ListItemsResponse

type ListItemsResponse struct {
	Items []Items `json:"items"`
}

ListItemsResponse represents a response body with detailed items list.

type Location

type Location Origin

Location represents a Too Good To Go Location details which has same structure as Origin.

type Login

type Login struct {
	AccessToken    string      `json:"access_token"`
	RefreshToken   string      `json:"refresh_token"`
	AccessTokenTTL int         `json:"access_token_ttl_seconds"`
	StartupData    StartupData `json:"startup_data"`
}

Login is a part of SignupResponse and represents a response body in sucessful signup process.

type LoginRequest

type LoginRequest struct {
	DeviceType string `json:"device_type"`
	Email      string `json:"email"`
}

LoginRequest represents a request body to initiate authentication process.

type LoginResponse

type LoginResponse struct {
	PollingID string `json:"polling_id"`
	State     string `json:"state"`
}

LoginResponse represents a response body in authentication process.

type Milestones

type Milestones struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

Milestones represents a Too Good To Go Milestones details.

type Order

type Order struct {
	OrderID                    string         `json:"order_id"`
	State                      string         `json:"state"`
	CancelUntil                time.Time      `json:"cancel_until"`
	RedeemInterval             PickupInterval `json:"redeem_interval"`
	PickupInterval             PickupInterval `json:"pickup_interval"`
	Quantity                   int            `json:"quantity"`
	PriceIncludingTaxes        Price          `json:"price_including_taxes"`
	PriceExcludingTaxes        Price          `json:"price_excluding_taxes"`
	TotalAppliedTaxes          Price          `json:"total_applied_taxes"`
	SalesTaxes                 []SalesTaxes   `json:"sales_taxes"`
	PickupLocation             PickupLocation `json:"pickup_location"`
	IsRated                    bool           `json:"is_rated"`
	TimeOfPurchase             time.Time      `json:"time_of_purchase"`
	StoreID                    string         `json:"store_id"`
	StoreName                  string         `json:"store_name"`
	StoreBranch                string         `json:"store_branch"`
	ItemID                     string         `json:"item_id"`
	ItemName                   string         `json:"item_name"`
	ItemCoverImage             ItemCoverImage `json:"item_cover_image"`
	IsBuffet                   bool           `json:"is_buffet"`
	CanUserSupplyPackaging     bool           `json:"can_user_supply_packaging"`
	PackagingOption            string         `json:"packaging_option"`
	IsStoreWeCare              bool           `json:"is_store_we_care"`
	CanShowBestBeforeExplainer bool           `json:"can_show_best_before_explainer"`
	ShowSalesTaxes             bool           `json:"show_sales_taxes"`
}

Order represents Too Good To Go Order.

type OrdersResponse

type OrdersResponse struct {
	CurrentTime time.Time `json:"current_time"`
	HasMore     bool      `json:"has_more"`
	Orders      []Order   `json:"orders"`
}

OrdersResponse represents a response body containing Orders details.

type OrdersService

OrdersService is an interface for interfacing with the Orders endpoints of the Too Good To Go API.

type OrdersServiceOp

type OrdersServiceOp struct {
	// contains filtered or unexported fields
}

OrdersServiceOp handles communication with the Orders related methods of the Too Good To Go API.

func (*OrdersServiceOp) Active

func (s *OrdersServiceOp) Active(ctx context.Context, activeOrdersRequest *ActiveOrdersRequest) (*OrdersResponse, *http.Response, error)

Active handles getting active orders for given user.

func (*OrdersServiceOp) Inactive

func (s *OrdersServiceOp) Inactive(ctx context.Context, inactiveOrdersRequest *InactiveOrdersRequest) (*OrdersResponse, *http.Response, error)

Inactive handles getting inactive/past orders for given user.

type Origin

type Origin struct {
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

Origin represents a Too Good To Go Origin details.

type Paging

type Paging struct {
	Page int `json:"page"`
	Size int `json:"size"`
}

Paging specifies paging options in Order requests.

type PickupInterval

type PickupInterval struct {
	End   time.Time `json:"end"`
	Start time.Time `json:"start"`
}

PickupInterval represents a Too Good To Go Pickup Interval details.

type PickupLocation

type PickupLocation struct {
	Address  Address  `json:"address"`
	Location Location `json:"location"`
}

PickupLocation represents a Too Good To Go Pickup Location details.

type Picture

type Picture struct {
	CurrentURL string `json:"current_url"`
	PictureID  string `json:"picture_id"`
}

Picture represents a Too Good To Go Picture details.

type PollRequest

type PollRequest struct {
	DeviceType string `json:"device_type"`
	Email      string `json:"email"`
	PollingID  string `json:"request_polling_id"`
}

PollRequest represents a request to check current authentication status.

type PollResponse

type PollResponse struct {
	AccessToken    string      `json:"access_token"`
	RefreshToken   string      `json:"refresh_token"`
	AccessTokenTTL int         `json:"access_token_ttl_seconds"`
	StartupData    StartupData `json:"startup_data"`
}

PollResponse represents a response body in polling process.

type Price

type Price struct {
	Code       string `json:"code"`
	Decimals   int    `json:"decimals"`
	MinorUnits int    `json:"minor_units"`
}

Price represents a Too Good To Go Price details.

type RefreshTokensRequest

type RefreshTokensRequest struct {
	RefreshToken string `json:"refresh_token"`
}

RefreshTokensRequest represents a request body to refresh Too Good To Go tokens.

type RefreshTokensResponse

type RefreshTokensResponse struct {
	AccessToken    string `json:"access_token"`
	RefreshToken   string `json:"refresh_token"`
	AccessTokenTTL int    `json:"access_token_ttl_seconds"`
}

RefreshTokensResponse represents Too Good To Go Tokens returned in authentication process.

type SalesTaxes

type SalesTaxes struct {
	TaxDescription string  `json:"tax_description"`
	TaxPercentage  float64 `json:"tax_percentage"`
	TaxAmount      Price   `json:"tax_amount"`
}

SalesTaxes represents Too Good To Go Sales Taxes.

type SignupRequest

type SignupRequest struct {
	CountryID             string `json:"country_id"`
	DeviceType            string `json:"device_type"`
	Email                 string `json:"email"`
	Name                  string `json:"name"`
	NewsletterOptIn       bool   `json:"newsletter_opt_in"`
	PushNotificationOptIn bool   `json:"push_notification_opt_in"`
}

SignupRequest represents a request body to create a new account.

type SignupResponse

type SignupResponse struct {
	Login Login `json:"login_response"`
}

SignupResponse represents a response body in signup process.

type StartupData

type StartupData struct {
	User User `json:"user"`
}

StartupData contains info about freshly authnticated user.

type Store

type Store struct {
	Branch        string        `json:"branch"`
	CoverPicture  Picture       `json:"cover_picture"`
	Description   string        `json:"description"`
	Distance      float64       `json:"distance"`
	FavoriteCount int           `json:"favorite_count"`
	Hidden        bool          `json:"hidden"`
	Items         []StoreItems  `json:"items"`
	LogoPicture   Picture       `json:"logo_picture"`
	Milestones    []Milestones  `json:"milestones"`
	StoreID       string        `json:"store_id"`
	StoreLocation StoreLocation `json:"store_location"`
	StoreName     string        `json:"store_name"`
	StoreTimeZone string        `json:"store_time_zone"`
	TaxIdentifier string        `json:"tax_identifier"`
	WeCare        bool          `json:"we_care"`
	Website       string        `json:"website"`
}

Store represents a Too Good To Go Store details.

type StoreItems

type StoreItems struct {
	DisplayName    string         `json:"display_name"`
	Distance       float64        `json:"distance"`
	Favorite       bool           `json:"favorite"`
	InSalesWindow  bool           `json:"in_sales_window"`
	Item           Item           `json:"item"`
	ItemsAvailable int            `json:"items_available"`
	NewItem        bool           `json:"new_item"`
	PickupInterval PickupInterval `json:"pickup_interval"`
	PickupLocation PickupLocation `json:"pickup_location"`
	PurchaseEnd    string         `json:"purchase_end"`
}

StoreItems represents a Too Good To Go Store Items details.

type StoreLocation

type StoreLocation PickupLocation

StoreLocation represents a Too Good To Go Store Location details which has same structure as PickupLocation.

type StoreLogo struct {
	PictureID              string `json:"picture_id"`
	CurrentURL             string `json:"current_url"`
	IsAutomaticallyCreated bool   `json:"is_automatically_created"`
}

StoreLogo represents Too Good To Go Store Logo.

type User

type User struct {
	UserID string `json:"user_id"`
}

User contains info about user's ID.

Jump to

Keyboard shortcuts

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