Api reference
components.shop.public.auth ¶
saleor_alaner_authorization ¶
Authorization strategy for shop endpoints called from the Saleor Dashboard.
Flow:
1. Frontend (shop-saleor-app) forwards the Saleor AppBridge JWT in the
X-Saleor-App-Token header.
2. authenticator verifies the JWT signature against the cached Saleor
JWKS (refresh-on-failure), validates iss/is_staff/exp, and
stashes claims on g.
3. authorize looks up the active AlanEmployee by alan_email
matching the JWT's email claim, then stashes the resolved user on
g.current_user. Result cached per email (1h TTL).
The email lookup (vs. an OIDC/keycloak chain) keeps the strategy portable across prod / staging / per-developer envs where keycloak ids differ but the Alaner email stays the same.
On any failure: raises BaseErrorCode.authorization_error (HTTP 401).
SaleorAlanerAuthorizationStrategy ¶
Bases: BaseAuthorizationStrategy
Restrict access to Alaners authenticated via the Saleor Dashboard.
Source code in components/shop/public/auth/saleor_alaner_authorization.py
authenticator ¶
Verify the Saleor AppBridge JWT and stash claims on g.
Source code in components/shop/public/auth/saleor_alaner_authorization.py
authorize ¶
Resolve the Saleor staff user to an Alaner and gate the request.
Source code in components/shop/public/auth/saleor_alaner_authorization.py
ensure_custom_authorization
class-attribute
instance-attribute
¶
components.shop.public.business_logic ¶
favorites ¶
Public re-exports for cross-component callers (e.g. eyewear dual-write).
create_favorite_for_feature_user ¶
Source code in components/shop/internal/business_logic/favorites/favorite.py
delete_favorite_for_feature_user ¶
Source code in components/shop/internal/business_logic/favorites/favorite.py
components.shop.public.commands ¶
backfill_shop_visits ¶
backfill_shop_visits ¶
Backfill shop visits from Segment.
Source code in components/shop/public/commands/backfill_shop_visits.py
global_invoicing ¶
process_contact_lens_invoicing ¶
Process the contact lens invoicing for a given period.
Source code in components/shop/public/commands/global_invoicing.py
import_eyewear_frames_to_saleor ¶
import_eyewear_frames_to_saleor ¶
Import eyewear frames from a CSV export into Saleor as Products + Variants.
Source code in components/shop/public/commands/import_eyewear_frames_to_saleor.py
supplier_action ¶
check_missing_skus ¶
Cross-check every active Saleor SKU against the supplier's Shopify catalog.
Variants whose SKU is missing on Shopify cause the parent product to be unpublished on French channels. Transient Shopify failures do NOT trigger an unpublish; they are surfaced in the Slack alert so ops can re-check manually.
Source code in components/shop/public/commands/supplier_action.py
daily_routine ¶
Source code in components/shop/public/commands/supplier_action.py
fulfill_orders ¶
Source code in components/shop/public/commands/supplier_action.py
run_supplier_action ¶
Source code in components/shop/public/commands/supplier_action.py
sync_delivery_status ¶
Source code in components/shop/public/commands/supplier_action.py
synchronize_catalog ¶
Source code in components/shop/public/commands/supplier_action.py
synchronize_stocks ¶
Source code in components/shop/public/commands/supplier_action.py
update_draft_orders ¶
Source code in components/shop/public/commands/supplier_action.py
update_orders_by_numbers ¶
Source code in components/shop/public/commands/supplier_action.py
update_recent_orders ¶
Source code in components/shop/public/commands/supplier_action.py
update_trackings ¶
Source code in components/shop/public/commands/supplier_action.py
sync_product_recommendations ¶
sync_product_recommendations ¶
Synchronize product recommendations on Saleor.
Source code in components/shop/public/commands/sync_product_recommendations.py
sync_saleor_channels ¶
sync_saleor_channels ¶
Synchronize two Saleor channels
Source code in components/shop/public/commands/sync_saleor_channels.py
components.shop.public.controllers ¶
admin_cancellation_mail ¶
admin_cancellation_mail_blp
module-attribute
¶
admin_cancellation_mail_blp = CustomBlueprint(
"shop_admin_cancellation_mail",
__name__,
url_prefix="/api/shop-admin",
)
admin_order ¶
ApproveFulfillmentPostJsonSchema ¶
Bases: Schema
JSON body for POST approve fulfillment.
Generic across product families — for product-specific metadata (e.g.
the lens the optician picked for a glasses order) use a per-family
endpoint such as /approve-glasses which translates typed fields into
the opaque fulfillment_metadata accepted by
approve_or_cancel_fulfillment.
decision_reason
class-attribute
instance-attribute
¶
ApproveGlassesFulfillmentPostJsonSchema ¶
Bases: Schema
JSON body for POST approve-glasses — the glasses-specific approve flow.
Wraps the generic approve flow with the SKU of the lens variant the
optician picked in the dashboard modal. Persisted as fulfillment
metadata under the optician-selected-lens-sku key.
Richer audit info (variant name + Saleor product URL) is recorded as a Saleor order event written client-side from the modal — keeps that content out of the Alan backend.
CancelFulfillmentPostJsonSchema ¶
Bases: Schema
JSON body for POST cancel fulfillment.
HelpFulfillmentPostJsonSchema ¶
Bases: Schema
JSON body for POST help on a Saleor fulfillment.
UploadInvoicePostFilesSchema ¶
Bases: Schema
Files for invoice upload (multipart/form-data).
admin_order_blp
module-attribute
¶
admin_testimonial ¶
TestimonialPayload
dataclass
¶
TestimonialPayload(
testimonial=None,
internal_comment=None,
alan_answer=None,
is_reviewed=False,
is_visible_from_product=False,
)
Bases: DataClassJsonMixin
Data class for admin testimonial payload.
admin_testimonial_blp
module-attribute
¶
admin_testimonial_blp = CustomBlueprint(
"shop_admin_testimonial",
__name__,
url_prefix="/api/shop-admin",
)
admin_vouchers ¶
CreateAdminVoucherPostJsonSchema ¶
ListAdminVouchersGetQuerySchema ¶
Bases: Schema
Query params for GET /shop-admin/vouchers.
admin_vouchers_blp
module-attribute
¶
admin_vouchers_blp = CustomBlueprint(
"shop_admin_vouchers",
__name__,
url_prefix="/api/shop-admin",
)
intercom ¶
CreateConversationForFulfillmentPostJsonSchema ¶
Bases: Schema
Schema for POST /create_conversation_for_fulfillment.
fulfillment_id
class-attribute
instance-attribute
¶
fulfillment_id = Str(
required=True,
validate=OwnerController(NoOwner),
metadata={"description": "The ID of the fulfillment"},
)
intercom_space
class-attribute
instance-attribute
¶
intercom_space = Enum(
IntercomSpace,
by_value=True,
required=True,
validate=OwnerController(NoOwner),
metadata={
"description": "The Intercom space to use (shop or care)"
},
)
operator_full_name
class-attribute
instance-attribute
¶
operator_full_name = Str(
required=True,
validate=OwnerController(NoOwner),
metadata={
"description": "The full name of Saleor connected user"
},
)
order_id
class-attribute
instance-attribute
¶
order_id = Str(
required=True,
validate=OwnerController(NoOwner),
metadata={"description": "The ID of the order"},
)
template_id
class-attribute
instance-attribute
¶
template_id = Str(
required=True,
validate=OwnerController(NoOwner),
metadata={"description": "The ID of the template"},
)
intercom_blp
module-attribute
¶
intercom_blp = SaleorExtensionBlueprint(
"shop_intercom",
__name__,
url_prefix="/api/shop-saleor-extension/intercom",
auth_context_providers=[
SaleorAppBridgeAuthContextProvider()
],
)
invoice_documents ¶
GetInvoiceDocumentsGetQuerySchema ¶
shop_invoice_documents_blp
module-attribute
¶
shop_invoice_documents_blp = CustomBlueprint(
"shop_invoice_documents",
__name__,
url_prefix="/api/shop/invoice_documents",
)
invoicing ¶
InvoicingSchema ¶
Bases: Schema
Schema for POST /generate_and_upload_invoice and GET /retrieve_transactions_to_invoice.
app_id
class-attribute
instance-attribute
¶
shop_invoicing_blp
module-attribute
¶
shop_invoicing_blp = SaleorExtensionBlueprint(
"shop_invoicing",
__name__,
url_prefix="/api/shop-saleor-extension/invoicing",
auth_context_providers=[
SaleorAppBridgeAuthContextProvider()
],
)
saleor_admin_token ¶
saleor_admin_token_blp
module-attribute
¶
saleor_admin_token_blp = CustomBlueprint(
"shop_admin_saleor_token",
__name__,
url_prefix="/api/shop-admin",
)
saleor_checkout ¶
saleor_manifest ¶
FULFILLMENT_EVENTS_SUBSCRIPTION_QUERY
module-attribute
¶
FULFILLMENT_EVENTS_SUBSCRIPTION_QUERY = "subscription {\n event {\n ... on FulfillmentApproved {\n __typename\n order {\n id\n }\n fulfillment {\n id\n }\n }\n ... on FulfillmentCanceled {\n __typename\n order {\n id\n }\n fulfillment {\n id\n }\n }\n }\n}\n"
ORDER_EVENTS_SUBSCRIPTION_QUERY
module-attribute
¶
ORDER_EVENTS_SUBSCRIPTION_QUERY = "subscription {\n event {\n ... on OrderCancelled {\n __typename\n order {\n id\n }\n }\n ... on OrderConfirmed {\n __typename\n order {\n id\n }\n }\n ... on OrderCreated {\n __typename\n order {\n id\n }\n }\n ... on OrderFulfilled {\n __typename\n order {\n id\n }\n }\n ... on OrderUpdated {\n __typename\n order {\n id\n }\n }\n ... on OrderRefunded {\n __typename\n order {\n id\n }\n }\n ... on OrderPaid {\n __typename\n order {\n id\n }\n }\n ... on OrderMetadataUpdated {\n __typename\n order {\n id\n }\n }\n ... on OrderFullyRefunded {\n __typename\n order {\n id\n }\n }\n ... on OrderFullyPaid {\n __typename\n order {\n id\n }\n }\n ... on OrderExpired {\n __typename\n order {\n id\n }\n }\n }\n}\n"
PAYMENT_EVENTS_SUBSCRIPTION_QUERY
module-attribute
¶
PAYMENT_EVENTS_SUBSCRIPTION_QUERY = "subscription {\n event {\n ... on TransactionInitializeSession {\n __typename\n transaction {\n ...SaleorTransactionItem\n }\n action {\n ...SaleorTransactionProcessAction\n }\n sourceObject {\n __typename\n ...SaleorOrder\n ...SaleorCheckout\n }\n }\n ... on TransactionProcessSession {\n __typename\n transaction {\n ...SaleorTransactionItem\n }\n action {\n ...SaleorTransactionProcessAction\n }\n }\n }\n}\n\nfragment SaleorTransactionItem on TransactionItem {\n id\n pspReference\n}\n\nfragment SaleorTransactionProcessAction on TransactionProcessAction {\n actionType\n amount\n currency\n}\n\nfragment SaleorOrder on Order {\n id\n}\n\nfragment SaleorCheckout on Checkout {\n id\n}\n"
PERMISSIONS
module-attribute
¶
PERMISSIONS = [
"HANDLE_CHECKOUTS",
"HANDLE_PAYMENTS",
"HANDLE_TAXES",
"IMPERSONATE_USER",
"MANAGE_CHANNELS",
"MANAGE_CHECKOUTS",
"MANAGE_DISCOUNTS",
"MANAGE_GIFT_CARD",
"MANAGE_MENUS",
"MANAGE_OBSERVABILITY",
"MANAGE_ORDERS",
"MANAGE_ORDERS_IMPORT",
"MANAGE_PAGES",
"MANAGE_PAGE_TYPES_AND_ATTRIBUTES",
"MANAGE_PLUGINS",
"MANAGE_PRODUCTS",
"MANAGE_PRODUCT_TYPES_AND_ATTRIBUTES",
"MANAGE_SETTINGS",
"MANAGE_SHIPPING",
"MANAGE_STAFF",
"MANAGE_TAXES",
"MANAGE_TRANSLATIONS",
"MANAGE_USERS",
]
TRANSACTION_EVENTS_SUBSCRIPTION_QUERY
module-attribute
¶
TRANSACTION_EVENTS_SUBSCRIPTION_QUERY = "subscription {\n event {\n ... on TransactionCancelationRequested {\n __typename\n transaction {\n ...SaleorTransactionItem\n }\n action {\n ...SaleorTransactionAction\n }\n }\n ... on TransactionChargeRequested {\n __typename\n transaction {\n ...SaleorTransactionItem\n }\n action {\n ...SaleorTransactionAction\n }\n }\n ... on TransactionRefundRequested {\n __typename\n transaction {\n ...SaleorTransactionItem\n }\n action {\n ...SaleorTransactionAction\n }\n }\n }\n}\n\nfragment SaleorTransactionItem on TransactionItem {\n id\n pspReference\n}\n\nfragment SaleorTransactionAction on TransactionAction {\n actionType\n amount\n currency\n}\n"
shop_saleor_manifest_blp
module-attribute
¶
shop_saleor_manifest_blp = CustomBlueprint(
"shop_saleor_manifest",
__name__,
url_prefix="/api/shop/saleor_manifest",
auth_context_providers=[AnonymousAuthContextProvider()],
)
saleor_register ¶
shop_saleor_register_blp
module-attribute
¶
shop_saleor_register_blp = CustomBlueprint(
"shop_saleor_register",
__name__,
url_prefix="/api/shop/saleor_register",
auth_context_providers=[AnonymousAuthContextProvider()],
)
saleor_webhook ¶
SaleorFulfillmentEventsPostJsonSchema ¶
SaleorOrderEventsPostJsonSchema ¶
Bases: _SaleorWebhookBaseSchema
order
class-attribute
instance-attribute
¶
SaleorPaymentEventsPostJsonSchema ¶
Bases: _SaleorWebhookBaseSchema
SaleorTransactionEventsPostJsonSchema ¶
shop_saleor_webhooks_blp
module-attribute
¶
shop_saleor_webhooks_blp = CustomBlueprint(
"shop_saleor_webhooks",
__name__,
url_prefix="/api/shop/saleor_webhooks",
auth_context_providers=[AnonymousAuthContextProvider()],
)
saleor_webhooks_config ¶
shop_saleor_webhooks_config_blp
module-attribute
¶
shop_saleor_webhooks_config_blp = CustomBlueprint(
"shop_saleor_webhooks_config",
__name__,
url_prefix="/api/shop/saleor_webhooks_config",
auth_context_providers=[AnonymousAuthContextProvider()],
)
shop_favorites ¶
ShopFavoritesDeleteQueryArgs
dataclass
¶
Args for DELETE /favorites — sku passed as query param so SKUs containing '/' are safe.
ShopFavoritesDeleteQuerySchema
module-attribute
¶
ShopFavoritesPostJsonArgs
dataclass
¶
Args for POST /favorites.
ShopFavoritesPostJsonSchema
module-attribute
¶
shop_favorites_blp
module-attribute
¶
shop_favorites_blp = CustomBlueprint(
"shop_favorites",
__name__,
url_prefix="/api/shop/favorites",
)
shop_user ¶
sku ¶
SkuCheckPostJsonSchema ¶
Bases: Schema
Schema for POST /sku/check.
pairs
class-attribute
instance-attribute
¶
pairs = List(
Nested(_SkuCheckPairSchema),
required=True,
validate=Length(min=1),
metadata={
"description": "Warehouse / SKU pairs to verify."
},
)
sku_blp
module-attribute
¶
sku_blp = SaleorExtensionBlueprint(
"shop_sku",
__name__,
url_prefix="/api/shop-saleor-extension/sku",
auth_context_providers=[
SaleorAppBridgeAuthContextProvider()
],
)
components.shop.public.enums ¶
ContactLensAddition ¶
ContactLensItemType ¶
ContactLensND ¶
ContactLensProductType ¶
Bases: AlanBaseEnum
This enum is used to store the product type of a contact lens.
contact_lens_bi_monthly
class-attribute
instance-attribute
¶
contact_lens_bifocal
class-attribute
instance-attribute
¶
contact_lens_colored
class-attribute
instance-attribute
¶
contact_lens_extended_wear
class-attribute
instance-attribute
¶
contact_lens_for_sport
class-attribute
instance-attribute
¶
contact_lens_monthly
class-attribute
instance-attribute
¶
contact_lens_multifocal
class-attribute
instance-attribute
¶
contact_lens_progressive
class-attribute
instance-attribute
¶
contact_lens_spherical
class-attribute
instance-attribute
¶
ContactLensSolutionType ¶
Bases: AlanBaseEnum
This enum is used to store the solution type of a contact lens.
solution_travel_kit
class-attribute
instance-attribute
¶
ContactLensStatus ¶
Bases: AlanBaseEnum
This enum is used to store the status of a contact lens.
InvoicingDocumentType ¶
Bases: AlanBaseEnum
This enum is used to store the type of invoice generation.
PrescriptionCheckProblemSeverity ¶
PrescriptionCheckProblemType ¶
Bases: AlanBaseEnum
This enum is used to store the type of a prescription check problem.
SkuCheckStatus ¶
Bases: AlanBaseEnum
Outcome of a per-(warehouse, SKU) existence check against the supplier's source-of-truth.
error covers transient supplier failures captured per-pair so a single broken SKU does
not fail the whole batch — the underlying exception is logged server-side.
not_applicable is returned when the supplier exists but has no Shopify processor
(e.g. Sveltus, Nutri&Co) and is therefore covered by the daily catalog sync instead.
unknown_warehouse is returned when the warehouse slug does not resolve to any
registered supplier (typo, decommissioned warehouse, or a slug Ops typed manually).
TransactionType ¶
UsageSource ¶
UsageStatus ¶
UsageType ¶
components.shop.public.events ¶
ShopTestimonialPublished
dataclass
¶
ShopTestimonialPublished(
testimonial,
rating,
product_id,
user_name,
app_user_id,
app_id,
external_order_id,
)
Bases: WebhookMessage
Event triggered when a ShopTestimonial has been published.
components.shop.public.flask_admin_configuration ¶
components.shop.public.globalization ¶
base_prescription_checker ¶
BasePrescriptionChecker ¶
Bases: ABC
Base class for prescription checkers, providing methods to implement the prescription checking logic.
Source code in components/shop/public/globalization/base_prescription_checker.py
check_contact_lens_prescription_content
abstractmethod
¶
check_contact_lens_prescription_content(
beneficiary_user_id,
content,
contact_lens_items,
order_date=None,
)
Check the contact lenses prescription content.
Source code in components/shop/public/globalization/base_prescription_checker.py
check_glasses_prescription_content
abstractmethod
¶
Check the glasses prescription content.
Source code in components/shop/public/globalization/base_prescription_checker.py
check_saleor_contact_lens_checkout_prescription_content
abstractmethod
¶
Check the SaleorCheckout contact lens prescription.
Source code in components/shop/public/globalization/base_prescription_checker.py
check_saleor_contact_lens_fulfillment_prescription
abstractmethod
¶
Check the SaleorOrder prescription.
Source code in components/shop/public/globalization/base_prescription_checker.py
check_saleor_glasses_checkout_prescription_content
abstractmethod
¶
Check the SaleorCheckout glasses prescription.
Source code in components/shop/public/globalization/base_prescription_checker.py
document_content_is_of_type
abstractmethod
¶
Abstract method to check if the document content is of the given type.
extract_prescription_duration_in_years
abstractmethod
¶
Extract prescription duration in years from transcription.
Source code in components/shop/public/globalization/base_prescription_checker.py
retrieve_prescription_content
abstractmethod
¶
retrieve_prescription_content(
prescription_id,
compute_if_not_parsed_yet=False,
use_transcription=False,
automated_parsing_only=False,
)
Abstract method to retrieve the prescription content.
Source code in components/shop/public/globalization/base_prescription_checker.py
retrieve_prescription_transcription
abstractmethod
¶
Abstract method to retrieve the prescription transcription.
base_shop_adapter ¶
BaseShopAdapter ¶
Bases: ABC
Base class for shop adapters, providing methods to implement the Shop.
create_insurance_document_from_parsed_partner_invoice
abstractmethod
¶
Persist the country-specific claim representation for an uploaded partner invoice.
Receives the parsed invoice returned by the shop-level
parse_and_validate_partner_invoice. Returns the new insurance
document id.
Source code in components/shop/public/globalization/base_shop_adapter.py
generate_contact_lens_global_invoice
abstractmethod
¶
Generate the invoice from Alan Tech to Alan Insurance for the contact lens claim transactions of a given period.
Source code in components/shop/public/globalization/base_shop_adapter.py
generate_credit_note
abstractmethod
¶
generate_order_invoice
abstractmethod
¶
generate_order_invoice(
order,
is_preview=False,
invoice_type=InvoicingDocumentType.regular_invoice,
)
Generate an invoice for an order.
Source code in components/shop/public/globalization/base_shop_adapter.py
get_contact_lens_coverage_definition
abstractmethod
¶
Return contact lens coverage definition, abstracted from country-specific guarantee codes.
get_contact_lens_global_invoice_url
abstractmethod
¶
get_coverage_usage_for_user
abstractmethod
¶
Return the remaining usage for a user.
get_glasses_coverage_definition
abstractmethod
¶
Return glasses coverage definition, abstracted from country-specific guarantee codes.
get_marmot_profile_url
abstractmethod
¶
get_order_beneficiary_info
abstractmethod
¶
Return the beneficiary info (name, SSN, gender, birth date) needed by an optician to issue an invoice for a shop order.
Source code in components/shop/public/globalization/base_shop_adapter.py
get_order_invoice_url
abstractmethod
¶
Get the URL of the order invoice.
get_pending_claim_usages_for_user
abstractmethod
¶
Return the uninvoiced orders for a user.
return SaleorHelper().get_pending_claim_usages_for_user( app_id=AppName.ALAN_FR, user_id=user_id, usage_type=usage_type, )
Source code in components/shop/public/globalization/base_shop_adapter.py
get_prescription_checker
abstractmethod
¶
has_pending_shop_order
abstractmethod
¶
Return True if the prescription is linked to at least one pending shop order.
resolve_user_name_from_insurance_profile_id
abstractmethod
¶
Resolve a user's full name from their insurance profile ID.
resolve_user_name_from_user_id
abstractmethod
¶
Resolve a user's first and last name from their user ID.
tombstone_insurance_document
abstractmethod
¶
Tombstone (soft delete) an insurance document.
upload_invoicing_document
abstractmethod
¶
Upload invoicing document.
upload_order_invoice
abstractmethod
¶
Upload order invoice and create the corresponding care acts.
shop_adapter ¶
get_app_specific_shop_adapter ¶
Return an app-specific shop adapter based on the app ID or raise an error if not found.
Source code in components/shop/public/globalization/shop_adapter.py
get_app_specific_shop_adapter_or_none ¶
Return an app-specific shop adapter based on the app ID.
Source code in components/shop/public/globalization/shop_adapter.py
components.shop.public.services ¶
discounts ¶
create_shop_discount ¶
Create a discount to be used in the shop During the transition period, we create both a shopify discount code and a saleor voucher So the member will be able to find the discount in both places
Source code in components/shop/public/services/discounts.py
get_processed_orders_with_discounts ¶
Get orders with discounts processed after date from shopify
Source code in components/shop/public/services/discounts.py
products ¶
AvailableShopProductTypes ¶
Bases: str, Enum
Duplicated from clinic — shop can't import clinic.
PRODUCT_TYPES_BY_SPECIALTY
module-attribute
¶
ProductData
dataclass
¶
get_product_types_for_specialty ¶
Return the shop product types a given medical specialty can recommend.
get_shop_products ¶
Fetch shop products from the FR Saleor channel.