Skip to content

Commit 2b93d5c

Browse files
fix: add missing json tags, python readme
1 parent 5702367 commit 2b93d5c

5 files changed

Lines changed: 120 additions & 36 deletions

File tree

pkg/category_structs.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ import (
88
// ProductResults is the flattened result from product search endpoints.
99
// Endpoint: GET /api/products
1010
type ProductResults struct {
11-
Products []Product
11+
Products []Product `json:"products"`
1212
Pagination struct {
13-
ObjectsPerPage int
14-
CurrentPage int
15-
PageCount int
16-
ObjectCount int
17-
}
13+
ObjectsPerPage int `json:"objectsPerPage"`
14+
CurrentPage int `json:"currentPage"`
15+
PageCount int `json:"pageCount"`
16+
ObjectCount int `json:"objectCount"`
17+
} `json:"pagination"`
1818
SearchTerm struct {
19-
Original string
20-
Corrected *string // non-nil if API corrected a typo
21-
}
19+
Original string `json:"original"`
20+
Corrected *string `json:"corrected"`
21+
} `json:"searchTerm"`
2222
}
2323

2424
func (pr ProductResults) String() string {

pkg/discounts_struct.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ type RawOffer struct {
118118

119119
// Discounts is the struct that holds cleaned up discount data.
120120
type Discounts struct {
121-
Categories []DiscountCategory
122-
ValidUntil time.Time
121+
Categories []DiscountCategory `json:"categories"`
122+
ValidUntil time.Time `json:"validUntil"`
123123
}
124124

125125
// GroupByProductCategory groups the discounts by their product category and returns the results.
@@ -165,24 +165,24 @@ func (d Discounts) String() string {
165165
// It contains an index for sorting the categories in their intended order and the actual discounts.
166166
// Calling GroupByProductCategory reorders the discounts by their product category (z. B. "Nahrungsmittel").
167167
type DiscountCategory struct {
168-
ID string
169-
Title string
170-
Index int
171-
Offers []Discount
168+
ID string `json:"id"`
169+
Title string `json:"title"`
170+
Index int `json:"index"`
171+
Offers []Discount `json:"offers"`
172172
}
173173

174174
// Discount is the actual discount with some of the information provided by rewe.
175175
type Discount struct {
176-
Title string
177-
Subtitle string
178-
Images []string
179-
PriceRaw string
176+
Title string `json:"title"`
177+
Subtitle string `json:"subtitle"`
178+
Images []string `json:"images"`
179+
PriceRaw string `json:"priceRaw"`
180180
// Price is the parsed price in euros. Check PriceParseFail before using -
181181
// if true, Price is 0.0 due to parse failure, not because item is free.
182-
Price float64
183-
PriceParseFail bool
184-
Manufacturer string
185-
ArticleNo string
186-
NutriScore string
187-
ProductCategory string
182+
Price float64 `json:"price"`
183+
PriceParseFail bool `json:"priceParseFail"`
184+
Manufacturer string `json:"manufacturer"`
185+
ArticleNo string `json:"articleNo"`
186+
NutriScore string `json:"nutriScore"`
187+
ProductCategory string `json:"productCategory"`
188188
}

pkg/products.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,19 +179,19 @@ func getProductsCommon(marketID string, opts *ProductOpts, queryParams url.Value
179179
return ProductResults{
180180
Products: raw.Data.Products.Products,
181181
Pagination: struct {
182-
ObjectsPerPage int
183-
CurrentPage int
184-
PageCount int
185-
ObjectCount int
182+
ObjectsPerPage int `json:"objectsPerPage"`
183+
CurrentPage int `json:"currentPage"`
184+
PageCount int `json:"pageCount"`
185+
ObjectCount int `json:"objectCount"`
186186
}{
187187
ObjectsPerPage: raw.Data.Products.Pagination.ObjectsPerPage,
188188
CurrentPage: raw.Data.Products.Pagination.CurrentPage,
189189
PageCount: raw.Data.Products.Pagination.PageCount,
190190
ObjectCount: raw.Data.Products.Pagination.ObjectCount,
191191
},
192192
SearchTerm: struct {
193-
Original string
194-
Corrected *string
193+
Original string `json:"original"`
194+
Corrected *string `json:"corrected"`
195195
}{
196196
Original: raw.Data.Products.Search.Term.Original,
197197
Corrected: raw.Data.Products.Search.Term.Corrected,

python/README.md

Lines changed: 88 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ python python/build_lib.py
2727
cd python && pip install -e .
2828
```
2929

30-
This builds both the Linux .so and Windows .dll.
30+
This builds both the Linux .so and Windows .dll. For macOS, see [building from source](#macos).
3131

3232
## Usage
3333

@@ -37,16 +37,92 @@ from rewerse import Rewerse
3737
client = Rewerse(cert="certificate.pem", key="private.key")
3838

3939
markets = client.market_search("Berlin")
40+
# [
41+
# {
42+
# "wwIdent": "8547534",
43+
# "name": "REWE Markt",
44+
# "companyName": "REWE Karsten Schmidt oHG",
45+
# "street": "Schönhauser Allee 80",
46+
# "zipCode": "10439",
47+
# "city": "Berlin",
48+
# "location": {"latitude": 52.54984, "longitude": 13.41488},
49+
# "openingStatus": {"openState": "CLOSED", "statusText": "Geschlossen", ...},
50+
# "serviceFlags": {"hasPickup": true},
51+
# ...
52+
# },
53+
# ...
54+
# ]
55+
4056
market_id = markets[0]["wwIdent"]
4157

42-
response = client.get_products(market_id, "Milch")
58+
products = client.get_products(market_id, "Milch")
59+
# {
60+
# "products": [
61+
# {
62+
# "productId": "677067",
63+
# "title": "Weihenstephan H-Milch 3,5% 1l",
64+
# "listing": {
65+
# "currentRetailPrice": 99,
66+
# "grammage": "1l",
67+
# "discount": {"__typename": "RegularProductDiscount", "validTo": "04.04."},
68+
# "loyaltyBonus": {"bonusType": "CENT", "bonusValue": 10},
69+
# ...
70+
# },
71+
# "attributes": {"isOrganic": false, "isVegan": false, "isBulkyGood": true, ...},
72+
# ...
73+
# },
74+
# ...
75+
# ],
76+
# "pagination": {"objectsPerPage": 30, "currentPage": 1, "pageCount": 24, "objectCount": 706},
77+
# "searchTerm": {"original": "Milch", "corrected": null}
78+
# }
79+
4380
discounts = client.get_discounts(market_id)
81+
# {
82+
# "categories": [
83+
# {
84+
# "id": "markt-topangebote",
85+
# "title": "Top-Angebote in deinem Markt",
86+
# "index": 3,
87+
# "offers": [
88+
# {
89+
# "title": "Kinder Riegel",
90+
# "subtitle": "je 18 x 21-g-Pckg. (1 kg = 11.56)",
91+
# "price": 3.99,
92+
# "priceRaw": "3,99 €",
93+
# "manufacturer": "FERRERO",
94+
# "articleNo": "249183",
95+
# "productCategory": "suesses-und-salziges",
96+
# ...
97+
# },
98+
# ...
99+
# ]
100+
# },
101+
# ...
102+
# ],
103+
# "validUntil": "2026-04-05T00:00:00Z"
104+
# }
105+
44106
recipes = client.recipe_search(search_term="Pasta")
107+
# {
108+
# "totalCount": 150,
109+
# "recipes": [
110+
# {
111+
# "id": "60f6d89e-640e-4911-8b61-628250c2217a",
112+
# "title": "Bruschetta Pasta",
113+
# "duration": "25 min",
114+
# "difficultyLevel": 1,
115+
# "difficultyDescription": "Einfach"
116+
# },
117+
# ...
118+
# ],
119+
# "metadata": {"collections": ["Vegetarisch"], "difficulties": ["Gering", "Mittel", "Hoch"], ...}
120+
# }
45121
```
46122

47123
## Methods
48124

49-
All methods raise `RewerseError` on failure. Responses are untyped dicts; see [Go structs](https://pkg.go.dev/github.com/ByteSizedMarius/rewerse-engineering/pkg) for field definitions.
125+
All methods raise `RewerseError` on failure. Responses are untyped dicts; field definitions, filter constants, and enum values are documented in the [Go reference](https://pkg.go.dev/github.com/ByteSizedMarius/rewerse-engineering/pkg#pkg-types).
50126

51127
### Markets
52128

@@ -65,6 +141,8 @@ All methods raise `RewerseError` on failure. Responses are untyped dicts; see [G
65141
| `get_product_suggestions(query, *, page=1, objects_per_page=25)` | Autocomplete suggestions |
66142
| `get_product_recommendations(market_id, listing_id)` | Related product recommendations |
67143

144+
See [`ProductFilter`](https://pkg.go.dev/github.com/ByteSizedMarius/rewerse-engineering/pkg#ProductFilter). Prices in `currentRetailPrice` are in **cents** (divide by 100 for euros).
145+
68146
### Discounts
69147

70148
| Method | Description |
@@ -76,11 +154,13 @@ All methods raise `RewerseError` on failure. Responses are untyped dicts; see [G
76154

77155
| Method | Description |
78156
|--------|-------------|
79-
| `recipe_search(*, search_term="", sorting="RELEVANCE_DESC", difficulty="", collection="", page=1, objects_per_page=20)` | Search recipes. Difficulty: `"Gering"`, `"Mittel"`, `"Hoch"`. Collection: `"Vegetarisch"`, `"Vegan"` |
157+
| `recipe_search(*, search_term="", sorting="RELEVANCE_DESC", difficulty="", collection="", page=1, objects_per_page=20)` | Search recipes |
80158
| `get_recipe_details(recipe_id)` | Get full recipe with ingredients and steps |
81159
| `get_recipe_popular_terms()` | Get popular recipe search terms |
82160
| `get_recipe_hub()` | Get recipe homepage (recipe of the day, popular, categories) |
83161

162+
See [`RecipeDifficulty`](https://pkg.go.dev/github.com/ByteSizedMarius/rewerse-engineering/pkg#RecipeDifficulty), [`RecipeCollection`](https://pkg.go.dev/github.com/ByteSizedMarius/rewerse-engineering/pkg#RecipeCollection).
163+
84164
### Shop & Services
85165

86166
| Method | Description |
@@ -89,6 +169,8 @@ All methods raise `RewerseError` on failure. Responses are untyped dicts; see [G
89169
| `get_service_portfolio(zipcode)` | Get available REWE services for a zip code |
90170
| `get_recalls()` | Get current product recalls |
91171

172+
See [`ServiceType`](https://pkg.go.dev/github.com/ByteSizedMarius/rewerse-engineering/pkg#ServiceType). Must match market capabilities — check `serviceFlags.hasPickup` from `get_market_details()`.
173+
92174
### Basket
93175

94176
| Method | Description |
@@ -98,6 +180,8 @@ All methods raise `RewerseError` on failure. Responses are untyped dicts; see [G
98180
| `set_basket_item(basket_id, market_id, zip_code, service_type, listing_id, quantity, version)` | Add/update item quantity in basket |
99181
| `remove_basket_item(basket_id, market_id, zip_code, service_type, listing_id)` | Remove item from basket |
100182

183+
See [`ServiceType`](https://pkg.go.dev/github.com/ByteSizedMarius/rewerse-engineering/pkg#ServiceType). `version`: basket state version for optimistic locking (from previous basket response). Prices in cents.
184+
101185
### Delivery
102186

103187
| Method | Description |

python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "rewerse"
7-
version = "0.1.0"
7+
version = "0.1.1"
88
description = "Python bindings for the REWE mobile API"
99
readme = "README.md"
1010
requires-python = ">=3.10"

0 commit comments

Comments
 (0)