Documentation
¶
Overview ¶
Package rewerse provides a simple interface to interact with the REWE API. Only Getters are implemented.
Index ¶
- Variables
- func BuildCustomRequest(host, path string) (req *http.Request, err error)
- func CloseWithWrap(f io.Closer, e *error)
- func DoRequest(req *http.Request, dest any) (err error)
- func GetCoupons() (oc OneScanCoupons, c Coupons, err error)
- func SetCertificate(clientCert, clientKey string) error
- type CloseError
- type Coupons
- type Discount
- type DiscountCategory
- type Discounts
- type Market
- type MarketDetails
- type Markets
- type OneScanCoupons
- type Product
- type ProductOpts
- type ProductSearchResults
- type RawDiscounts
- type Recall
- type Recalls
- type Recipe
- type RecipeHub
- type ShopCategory
- type ShopOverview
Constants ¶
This section is empty.
Variables ¶
var (
Client *http.Client
)
Functions ¶
func CloseWithWrap ¶
func GetCoupons ¶
func GetCoupons() (oc OneScanCoupons, c Coupons, err error)
GetCoupons returns all available coupons There are two differerent coupons-structs: OneScanCoupons and Coupons I'm not sure what the difference is and I don't really care either. Please let me know!
func SetCertificate ¶
Types ¶
type CloseError ¶
type CloseError struct {
OriginalError, CloseError error
}
func (CloseError) Error ¶
func (c CloseError) Error() string
type Coupons ¶
type Coupons struct { Data struct { GetCoupons struct { CouponStatus string `json:"couponStatus"` PaybackEwe any `json:"paybackEwe"` Coupons []struct { CouponID int `json:"couponId"` CouponType string `json:"couponType"` Title string `json:"title"` Subtitle string `json:"subtitle"` Validity struct { ValidFrom time.Time `json:"validFrom"` ValidTo time.Time `json:"validTo"` } `json:"validity"` ProductLogo string `json:"productLogo"` Description struct { RedeemDescription any `json:"redeemDescription"` Combinability string `json:"combinability"` Validity any `json:"validity"` TermsOfUse string `json:"termsOfUse"` Disclaimer any `json:"disclaimer"` } `json:"description"` OfferTitle string `json:"offerTitle"` DisplayClassification any `json:"displayClassification"` CouponDetails any `json:"couponDetails"` Activated any `json:"activated"` Preview any `json:"preview"` IsNew any `json:"isNew"` } `json:"coupons"` } `json:"getCoupons"` } `json:"data"` Extensions struct { HTTP []struct { Path []string `json:"path"` Message string `json:"message"` StatusCode int `json:"statusCode"` ResponseBody any `json:"responseBody"` } `json:"http"` } `json:"extensions"` }
Coupons is a struct for the raw data returned by the Coupons endpoint
type Discount ¶
type Discount struct { Title string Subtitle string Images []string PriceRaw string Price float64 Manufacturer string ArticleNo string NutriScore string ProductCategory string }
Discount is the actual discount with some of the information provided by rewe.
type DiscountCategory ¶
DiscountCategory is the category defined by rewe for the presentation of the discounts. It contains an index for sorting the categories in their intended order and the actual discounts. Calling GroupByProductCategory reorders the discounts by their product category (z. B. "Nahrungsmittel").
type Discounts ¶
type Discounts struct { Categories []DiscountCategory ValidUntil time.Time }
Discounts is the struct that holds cleaned up discount data.
func GetDiscounts ¶
GetDiscounts returns the discounts from the API with less bloat. It contains the discount categories, which in turn contain the actual discounts. I removed various parameters I deemed unnecessary and parsed into different datatypes where it made sense to me. The struct Discounts also provides some helper methods.
func (Discounts) GroupByProductCategory ¶
GroupByProductCategory groups the discounts by their product category and returns the results.
type Market ¶
type Market struct { ID string `json:"id"` Name string `json:"name"` AddressLine1 string `json:"addressLine1"` RawValues struct { PostalCode string `json:"postalCode"` City string `json:"city"` } `json:"rawValues"` }
Market represents a single search result
type MarketDetails ¶
type MarketDetails struct { MarketItem struct { ID string `json:"id"` Name string `json:"name"` TypeID string `json:"typeId"` AddressLine1 string `json:"addressLine1"` AddressLine2 string `json:"addressLine2"` OpeningInfo string `json:"openingInfo"` OpeningInfoPrefix string `json:"openingInfoPrefix"` OpeningType string `json:"openingType"` FeatureTypes []any `json:"featureTypes"` Location struct { Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` } `json:"location"` RawValues struct { Attributes []any `json:"attributes"` PostalCode string `json:"postalCode"` City string `json:"city"` } `json:"rawValues"` } `json:"marketItem"` Phone string `json:"phone"` RatingURL string `json:"ratingUrl"` IsLSFK bool `json:"isLSFK"` OpeningTimes []struct { Days string `json:"days"` Hours string `json:"hours"` } `json:"openingTimes"` SpecialOpeningTimes []any `json:"specialOpeningTimes"` Services []any `json:"services"` FeatureCategories []any `json:"featureCategories"` Actions []struct { Type string `json:"type"` Title string `json:"title"` } `json:"actions"` }
MarketDetails is a struct that holds detailed information about a single market It is returned by the GetMarketDetails function
func GetMarketDetails ¶
func GetMarketDetails(marketID string) (md MarketDetails, err error)
GetMarketDetails returns the details of the market with the given ID.
func (MarketDetails) String ¶
func (md MarketDetails) String() string
type Markets ¶
type Markets []Market
Markets is a struct that holds a list of Market structs It is returned by the MarketSearch
func MarketSearch ¶
MarketSearch searches for markets based on the given query. Fuzzy search; accepts PLZ, city, marketname, street, etc.
type OneScanCoupons ¶
type OneScanCoupons struct { AppID string `json:"appId"` Code string `json:"code"` Coupons []struct { ImageURL string `json:"imageUrl"` Description string `json:"description"` Banner string `json:"banner"` Title string `json:"title"` Subtitle string `json:"subtitle"` Provider string `json:"provider"` Validity string `json:"validity"` InformationURL string `json:"informationUrl"` RawValues struct { ID string `json:"id"` } `json:"rawValues"` } `json:"coupons"` }
OneScanCoupons is a struct for the raw data returned by the OneScan-Coupons endpoint
func (OneScanCoupons) String ¶
func (o OneScanCoupons) String() string
type Product ¶
type Product struct { ProductID string `json:"productId"` Title string `json:"title"` DepositLabel any `json:"depositLabel"` ImageURL string `json:"imageURL"` Attributes struct { IsBulkyGood bool `json:"isBulkyGood"` IsOrganic bool `json:"isOrganic"` IsVegan bool `json:"isVegan"` IsVegetarian bool `json:"isVegetarian"` IsDairyFree bool `json:"isDairyFree"` IsGlutenFree bool `json:"isGlutenFree"` IsBiocide bool `json:"isBiocide"` IsAgeRestricted any `json:"isAgeRestricted"` IsRegional bool `json:"isRegional"` IsNew bool `json:"isNew"` } `json:"attributes"` OrderLimit int `json:"orderLimit"` Categories []string `json:"categories"` DetailsViewRequired bool `json:"detailsViewRequired"` ArticleID string `json:"articleId"` Listing struct { ListingID string `json:"listingId"` ListingVersion int `json:"listingVersion"` CurrentRetailPrice int `json:"currentRetailPrice"` TotalRefundPrice any `json:"totalRefundPrice"` Grammage string `json:"grammage"` Discount any `json:"discount"` LoyaltyBonus any `json:"loyaltyBonus"` } `json:"listing"` Advertisement any `json:"advertisement"` }
type ProductOpts ¶
type ProductSearchResults ¶
type ProductSearchResults struct { Data struct { Products struct { Pagination struct { ObjectsPerPage int `json:"objectsPerPage"` CurrentPage int `json:"currentPage"` PageCount int `json:"pageCount"` ObjectCount int `json:"objectCount"` } `json:"pagination"` Search struct { Term struct { Original string `json:"original"` Corrected any `json:"corrected"` } `json:"term"` } `json:"search"` Products []Product `json:"products"` } `json:"products"` } `json:"data"` Extensions struct { HTTP []struct { Path []string `json:"path"` Message string `json:"message"` StatusCode int `json:"statusCode"` ResponseBody any `json:"responseBody"` } `json:"http"` } `json:"extensions"` }
func GetCategoryProducts ¶
func GetCategoryProducts(marketID, categorySlug string, opts *ProductOpts) (ProductSearchResults, error)
func GetProducts ¶
func GetProducts(marketID, search string, opts *ProductOpts) (ProductSearchResults, error)
func (ProductSearchResults) String ¶
func (psr ProductSearchResults) String() string
type RawDiscounts ¶
type RawDiscounts struct { Data struct { Offers struct { Handout struct { Width int `json:"width"` Height int `json:"height"` Images []struct { Original string `json:"original"` Thumbnail string `json:"thumbnail"` } `json:"images"` } `json:"handout"` Categories []struct { ID string `json:"id"` Title string `json:"title"` MoodURL any `json:"moodUrl"` Order int `json:"order"` BackgroundColor string `json:"backgroundColor"` ForegroundColor string `json:"foregroundColor"` Offers []struct { CellType string `json:"cellType"` Overline string `json:"overline"` Title string `json:"title"` Subtitle string `json:"subtitle"` Images []string `json:"images"` Biozid bool `json:"biozid"` PriceData struct { Price string `json:"price"` RegularPrice string `json:"regularPrice"` } `json:"priceData"` LoyaltyBonus any `json:"loyaltyBonus"` Detail struct { Sensational any `json:"sensational"` PitchIn string `json:"pitchIn"` Tags []any `json:"tags"` Contents []struct { Header string `json:"header"` Titles []string `json:"titles"` } `json:"contents"` Biocide bool `json:"biocide"` NutriScore string `json:"nutriScore"` } `json:"detail"` RawValues struct { CategoryTitle string `json:"categoryTitle"` PriceAverage float64 `json:"priceAverage"` FlyerPage int `json:"flyerPage"` Nan string `json:"nan"` } `json:"rawValues"` } `json:"offers"` } `json:"categories"` UntilDate float64 `json:"untilDate"` HasOnlineOffers bool `json:"hasOnlineOffers"` } `json:"offers"` } `json:"data"` Extensions struct { HTTP []struct { Path []string `json:"path"` Message string `json:"message"` StatusCode int `json:"statusCode"` ResponseBody any `json:"responseBody"` } `json:"http"` } `json:"extensions"` }
RawDiscounts is the struct that holds the raw discount data from the rewe API.
func GetDiscountsRaw ¶
func GetDiscountsRaw(marketID string) (rd RawDiscounts, err error)
GetDiscountsRaw returns the raw data from the API in a RawDiscounts struct. It contains links to the handout (Prospekt) as well as discount categories, which in turn contain the actual discounts.
type Recall ¶
type Recall struct { RecallURL string `json:"recallUrl"` SubjectProduct string `json:"subjectProduct"` SubjectReason string `json:"subjectReason"` }
Recall is the struct for a single recall
type Recalls ¶
type Recalls []Recall
Recalls is the struct for Rewe Product-Recalls
func GetRecalls ¶
GetRecalls returns all currently ongoing recalls from Rewe
type Recipe ¶
type Recipe struct { ID string `json:"id"` Title string `json:"title"` DetailURL string `json:"detailUrl"` ImageURL string `json:"imageUrl"` Duration string `json:"duration"` DifficultyLevel int `json:"difficultyLevel"` DifficultyDescription string `json:"difficultyDescription"` }
Recipe is the struct for a single recipe
type RecipeHub ¶
type RecipeHub struct { RecipeOfTheDay Recipe `json:"recipeOfTheDay"` PopularRecipes []Recipe `json:"popularRecipes"` Categories []struct { Type string `json:"type"` Title string `json:"title"` SearchQuery string `json:"searchQuery"` } `json:"categories"` }
RecipeHub is the struct for the Data returned by the Rewe Recipe-Page
func GetRecipeHub ¶
GetRecipeHub returns the Data from the RecipeHub
type ShopCategory ¶
type ShopCategory struct { ID string `json:"id"` Name string `json:"name"` Slug string `json:"slug"` ProductCount int `json:"productCount"` ImageURL string `json:"imageUrl"` ChildCategories []ShopCategory }
func (ShopCategory) String ¶
func (sc ShopCategory) String() string
func (ShopCategory) StringAll ¶
func (sc ShopCategory) StringAll() string
type ShopOverview ¶
type ShopOverview struct { ProductRecalls Recalls `json:"productRecalls"` ProductCategories []ShopCategory `json:"productCategories"` }
func GetShopOverview ¶
func GetShopOverview(marketID string) (so ShopOverview, err error)
func (ShopOverview) GetName ¶
func (so ShopOverview) GetName() string
func (ShopOverview) String ¶
func (so ShopOverview) String() string
func (ShopOverview) StringAll ¶
func (so ShopOverview) StringAll() string