class OrdersBackend(ServiceBackend): service_path = "orders" model_class = OrdersModel _schema_draft = OrderFromCartDraftSchema _schema_update = OrderUpdateSchema _schema_query_response = OrderPagedQueryResponseSchema def urls(self): return [ ("^$", "GET", self.query), ("^$", "POST", self.create), ("^key=(?P<key>[^/]+)$", "GET", self.get_by_key), ("^(?P<id>[^/]+)$", "GET", self.get_by_id), ("^key=(?P<key>[^/]+)$", "POST", self.update_by_key), ("^(?P<id>[^/]+)$", "POST", self.update_by_id), ("^(?P<id>[^/]+)$", "DELETE", self.delete_by_id), ] _actions = { "changeOrderState": update_enum_attribute("orderState", "order_state"), "changePaymentState": update_enum_attribute("paymentState", "payment_state"), "changeShipmentState": update_enum_attribute("shipmentState", "shipment_state"), "addDelivery": add_delivery(), "setShippingAddress": update_attribute("shippingAddress", "address"), "setBillingAddress": update_attribute("billingAddress", "address"), "setCustomerEmail": update_attribute("customerEmail", "email"), "setCustomField": set_custom_field(), "addPayment": add_payment(), }
class CartsBackend(ServiceBackend): service_path = "carts" model_class = CartsModel _schema_draft = schemas.CartDraftSchema _schema_update = schemas.CartUpdateSchema _schema_query_response = schemas.CartPagedQueryResponseSchema def urls(self): return [ ("^$", "GET", self.query), ("^$", "POST", self.create), ("^(?P<id>[^/]+)$", "GET", self.get_by_id), ("^(?P<id>[^/]+)$", "POST", self.update_by_id), ] _actions = { "addPayment": add_payment(), "setCustomField": set_custom_field(), }