Shopify Margin Rules Endpoints¶
Location: backend/service_multi-repricer/app/api/v1/endpoints/shopify.py
These endpoints provide CRUD for ShopifyMarginRule objects used by the Shopify repricer.
Endpoints
- POST
/margin-rules— Create a margin rule - Request JSON:
{ "buy_price": Decimal, "target_margin": Decimal, "min_profit": Decimal } -
Response:
ShopifyMarginRuleResponse(201 Created) -
GET
/margin-rules/{id}— Fetch a single margin rule by id - Path:
id(int) -
Response:
ShopifyMarginRuleResponse(200) -
GET
/margin-rules— List margin rules - Query:
skip(default 0),limit(default 100) -
Response: list of
ShopifyMarginRuleResponse(200) -
PUT
/margin-rules/{id}— Update an existing margin rule - Request JSON:
ShopifyMarginRuleUpdatefields (partial updates allowed) -
Response:
ShopifyMarginRuleResponse(200) -
DELETE
/margin-rules/{id}— Delete a margin rule - Side effect: clears
ShopifyDetails.margin_rule_idfor articles referencing the removed rule (attempts DB update before delete) - Response:
ShopifyMarginRuleResponse(200)
Example: create margin rule
curl -X POST "http://localhost:8000/api/v1/multi/margin-rules" \
-H "Content-Type: application/json" \
-d '{"buy_price": 5.00, "target_margin": 15.00, "min_profit": 2.50}'
Notes
- The endpoints use
CRUDShopifyMarginRule(crud/shopify_margin_rules.py) to persist rules. - Responses are typed with Pydantic models from
models/shopify_margin_rules.py. - Deleting a rule will attempt to clear any article references; failures during the clearing step return 500.
Shopify Endpoints¶
Router prefix: /shopify → full base: /api/v1/multi/shopify
Summary: Shopify margin rules, recalc and export endpoints.
Implementation: backend/service_multi-repricer/app/api/v1/endpoints/shopify.py
TODO: Populate detailed method table and examples.