Skip to content

Api reference

components.shop.public.commands

app_group

shop_commands module-attribute

shop_commands = AppGroup('shop')

backfill_shop_visits

backfill_shop_visits

backfill_shop_visits(dry_run)

Backfill shop visits from Segment.

Source code in components/shop/public/commands/backfill_shop_visits.py
@shop_commands.command(requires_authentication=False)
@command_with_dry_run
def backfill_shop_visits(dry_run: bool) -> None:
    """Backfill shop visits from Segment."""
    from components.shop.internal.business_logic.users.backfill_shop_visits import (
        backfill_shop_visits as backfill_shop_visits_action,
    )

    backfill_shop_visits_action(dry_run=dry_run)

migrate_testimonials_to_saleor

migrate_testimonials_to_saleor

migrate_testimonials_to_saleor(dry_run)

Migrate testimonials to Saleor by replacing Shopify product ids by Saleor product ids.

Source code in components/shop/public/commands/migrate_testimonials_to_saleor.py
@shop_commands.command(requires_authentication=False)
@command_with_dry_run
def migrate_testimonials_to_saleor(dry_run: bool) -> None:
    """Migrate testimonials to Saleor by replacing Shopify product ids by Saleor product ids."""
    from components.shop.internal.business_logic.testimonials.migrate_testimonials_to_saleor import (
        migrate_testimonials_to_saleor as migrate_testimonials_to_saleor_action,
    )

    migrate_testimonials_to_saleor_action(dry_run=dry_run)

supplier_action

daily_routine

daily_routine(dry_run, supplier)
Source code in components/shop/public/commands/supplier_action.py
@shop_commands.command(requires_authentication=False)
@command_with_dry_run
@click.option(
    "--supplier",
    required=False,
    default="",
    help="slug of the supplier to run the 'daily_routine' action for",
)
def daily_routine(  # noqa: D103
    dry_run: bool,
    supplier: str,
) -> None:
    from components.shop.internal.business_logic.suppliers.supplier_action_manager import (
        SupplierActionManager,
    )

    SupplierActionManager(dry_run=dry_run).run_action(
        action="daily_routine",
        for_supplier_only=supplier if supplier else None,
    )

fulfill_orders

fulfill_orders(dry_run, supplier)
Source code in components/shop/public/commands/supplier_action.py
@shop_commands.command(requires_authentication=False)
@command_with_dry_run
@click.option(
    "--supplier",
    required=False,
    default="",
    help="slug of the supplier to run the 'fulfill_orders' action for",
)
def fulfill_orders(  # noqa: D103
    dry_run: bool,
    supplier: str,
) -> None:
    from components.shop.internal.business_logic.suppliers.supplier_action_manager import (
        SupplierActionManager,
    )

    SupplierActionManager(dry_run=dry_run).run_action(
        action="fulfill_orders",
        for_supplier_only=supplier if supplier else None,
    )

run_supplier_action

run_supplier_action(dry_run, action, supplier, days=None)
Source code in components/shop/public/commands/supplier_action.py
@shop_commands.command(requires_authentication=False)
@command_with_dry_run
@click.option(
    "--action",
    is_flag=False,
    required=True,
    default=None,
    help="be it fulfill_orders, update_recent_orders, update_draft_orders, update_trackings or synchronize_stocks, synchronize_catalog, supplier_routine or all",
)
@click.option(
    "--supplier",
    required=False,
    default="",
    help="slug of the supplier to run the action for",
)
@click.option(
    "--days",
    required=False,
    type=int,
    help="number of days used for the update_recent_orders action",
)
def run_supplier_action(  # noqa: D103
    dry_run: bool,
    action: str,
    supplier: str,
    days: Optional[int] = None,
) -> None:
    from components.shop.internal.business_logic.suppliers.supplier_action_manager import (
        SupplierAction,
        SupplierActionManager,
    )

    extra_args = {}
    if days is not None:
        extra_args["days"] = days

    if action == "all":
        for action_enum in SupplierAction:
            SupplierActionManager(dry_run=dry_run).run_action(
                action=action_enum.value,
                for_supplier_only=supplier if supplier else None,
                extra_args=extra_args,
            )
    else:
        SupplierActionManager(dry_run=dry_run).run_action(
            action=action,
            for_supplier_only=supplier if supplier else None,
            extra_args=extra_args,
        )

sync_delivery_status

sync_delivery_status(dry_run)
Source code in components/shop/public/commands/supplier_action.py
@shop_commands.command(requires_authentication=False)
@command_with_dry_run
def sync_delivery_status(  # noqa: D103
    dry_run: bool,
) -> None:
    from components.shop.internal.business_logic.suppliers.supplier_action_manager import (
        SupplierActionManager,
    )

    SupplierActionManager(dry_run=dry_run).run_action(
        action="sync_delivery_status",
    )

synchronize_catalog

synchronize_catalog(dry_run, supplier)
Source code in components/shop/public/commands/supplier_action.py
@shop_commands.command(requires_authentication=False)
@command_with_dry_run
@click.option(
    "--supplier",
    required=False,
    default="",
    help="slug of the supplier to run the 'synchronize_catalog' action for",
)
def synchronize_catalog(  # noqa: D103
    dry_run: bool,
    supplier: str,
) -> None:
    from components.shop.internal.business_logic.suppliers.supplier_action_manager import (
        SupplierActionManager,
    )

    SupplierActionManager(dry_run=dry_run).run_action(
        action="synchronize_catalog",
        for_supplier_only=supplier if supplier else None,
    )

synchronize_stocks

synchronize_stocks(dry_run, supplier)
Source code in components/shop/public/commands/supplier_action.py
@shop_commands.command(requires_authentication=False)
@command_with_dry_run
@click.option(
    "--supplier",
    required=False,
    default="",
    help="slug of the supplier to run the 'synchronize_stocks' action for",
)
def synchronize_stocks(  # noqa: D103
    dry_run: bool,
    supplier: str,
) -> None:
    from components.shop.internal.business_logic.suppliers.supplier_action_manager import (
        SupplierActionManager,
    )

    SupplierActionManager(dry_run=dry_run).run_action(
        action="synchronize_stocks",
        for_supplier_only=supplier if supplier else None,
    )

update_draft_orders

update_draft_orders(dry_run, supplier)
Source code in components/shop/public/commands/supplier_action.py
@shop_commands.command(requires_authentication=False)
@command_with_dry_run
@click.option(
    "--supplier",
    required=False,
    default="",
    help="slug of the supplier to run the 'update_draft_orders' action for",
)
def update_draft_orders(  # noqa: D103
    dry_run: bool,
    supplier: str,
) -> None:
    from components.shop.internal.business_logic.suppliers.supplier_action_manager import (
        SupplierActionManager,
    )

    SupplierActionManager(dry_run=dry_run).run_action(
        action="update_draft_orders",
        for_supplier_only=supplier if supplier else None,
    )

update_recent_orders

update_recent_orders(dry_run, supplier, days=None)
Source code in components/shop/public/commands/supplier_action.py
@shop_commands.command(requires_authentication=False)
@command_with_dry_run
@click.option(
    "--supplier",
    required=False,
    default="",
    help="slug of the supplier to run the 'update_recent_orders' action for",
)
@click.option(
    "--days",
    required=False,
    type=int,
    help="number of days used for the 'update_recent_orders' action",
)
def update_recent_orders(  # noqa: D103
    dry_run: bool,
    supplier: str,
    days: Optional[int] = None,
) -> None:
    from components.shop.internal.business_logic.suppliers.supplier_action_manager import (
        SupplierActionManager,
    )

    extra_args = {}
    if days is not None:
        extra_args["days"] = days

        SupplierActionManager(dry_run=dry_run).run_action(
            action="update_recent_orders",
            for_supplier_only=supplier if supplier else None,
            extra_args=extra_args,
        )

update_trackings

update_trackings(dry_run, supplier)
Source code in components/shop/public/commands/supplier_action.py
@shop_commands.command(requires_authentication=False)
@command_with_dry_run
@click.option(
    "--supplier",
    required=False,
    default="",
    help="slug of the supplier to run the 'update_trackings' action for",
)
def update_trackings(  # noqa: D103
    dry_run: bool,
    supplier: str,
) -> None:
    from components.shop.internal.business_logic.suppliers.supplier_action_manager import (
        SupplierActionManager,
    )

    SupplierActionManager(dry_run=dry_run).run_action(
        action="update_trackings",
        for_supplier_only=supplier if supplier else None,
    )

sync_product_recommendations

sync_product_recommendations

sync_product_recommendations(dry_run)

Synchronize product recommendations between Shopify and Saleor.

Source code in components/shop/public/commands/sync_product_recommendations.py
@shop_commands.command(requires_authentication=False)
@command_with_dry_run
def sync_product_recommendations(dry_run: bool) -> None:
    """Synchronize product recommendations between Shopify and Saleor."""
    from components.shop.internal.business_logic.recommendations.sync_product_recommendations import (
        sync_product_recommendations as sync_product_recommendations_action,
    )

    sync_product_recommendations_action(dry_run=dry_run)

sync_saleor_channels

sync_saleor_channels

sync_saleor_channels(from_channel, to_channel, dry_run)

Synchronize two Saleor channels

Source code in components/shop/public/commands/sync_saleor_channels.py
@shop_commands.command(requires_authentication=False)
@click.option(
    "--from-channel",
    required=True,
    help="slug of the source channel",
)
@click.option(
    "--to-channel",
    required=True,
    help="slug of the destination channel",
)
@command_with_dry_run
def sync_saleor_channels(from_channel: str, to_channel: str, dry_run: bool) -> None:
    """Synchronize two Saleor channels"""
    from components.shop.internal.business_logic.channels.sync_saleor_channels import (
        sync_saleor_channels as sync_saleor_channels_action,
    )

    sync_saleor_channels_action(
        from_channel_slug=from_channel,
        to_channel_slug=to_channel,
        dry_run=dry_run,
    )

components.shop.public.const

REFUNDABLE_FULFILLMENT_STATUSES module-attribute

REFUNDABLE_FULFILLMENT_STATUSES = [
    RETURNED,
    REFUNDED_AND_RETURNED,
    CANCELED,
]

SHOP_EMAIL module-attribute

SHOP_EMAIL = 'shop@alan.eu'

SHOP_EMAIL_TEMPLATE module-attribute

SHOP_EMAIL_TEMPLATE = 'shop+{supplier_slug}@alan.eu'

UNTRACKED_STOCK module-attribute

UNTRACKED_STOCK = 999

components.shop.public.controllers

admin_cancellation_mail

AdminCancellationMailsController

Bases: BaseController

admin_cancellation_mails_endpoint module-attribute

admin_cancellation_mails_endpoint = Endpoint('')

admin_order

AdminShopOrderController

Bases: BaseController

admin_order_endpoint module-attribute

admin_order_endpoint = Endpoint('')

admin_testimonial

AdminTestimonialController

Bases: BaseController

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.

alan_answer class-attribute instance-attribute
alan_answer = None
internal_comment class-attribute instance-attribute
internal_comment = None
is_reviewed class-attribute instance-attribute
is_reviewed = False
is_visible_from_product class-attribute instance-attribute
is_visible_from_product = False
testimonial class-attribute instance-attribute
testimonial = None

admin_testimonial_endpoint module-attribute

admin_testimonial_endpoint = Endpoint('')

eligibility

ShopEligibilityController

Bases: BaseController

shop_eligibility_endpoint module-attribute

shop_eligibility_endpoint = Endpoint('eligibility')

saleor_checkout

SaleorCheckoutController

Bases: BaseController

saleor_checkout_endpoint module-attribute

saleor_checkout_endpoint = Endpoint('saleor_checkouts')

saleor_webhook

SaleorWebhookController

Bases: BaseController

saleor_webhook_endpoint module-attribute

saleor_webhook_endpoint = Endpoint('saleor_webhooks')

shop_user

ShopUserController

Bases: BaseController

shop_user_endpoint module-attribute

shop_user_endpoint = Endpoint('shop_user')

shopify_discount

ShopifyDiscountController

Bases: BaseController

shopify_discount_endpoint module-attribute

shopify_discount_endpoint = Endpoint('shopify_discount')

shopify_order

ShopifyOrderController

Bases: BaseController

shopify_order_endpoint module-attribute

shopify_order_endpoint = Endpoint('shopify_orders')

stripe_webhook

StripeWebhookController

Bases: BaseController

stripe_webhook_endpoint module-attribute

stripe_webhook_endpoint = Endpoint('stripe_webhooks')

testimonial

TestimonialController

Bases: BaseController

testimonial_endpoint module-attribute

testimonial_endpoint = Endpoint('')

components.shop.public.enums

ContactLensAddition

Bases: AlanBaseEnum

This enum is used to store the addition of a contact lens.

high class-attribute instance-attribute

high = 'high'

low class-attribute instance-attribute

low = 'low'

medium class-attribute instance-attribute

medium = 'medium'

ContactLensItemType

Bases: AlanBaseEnum

This enum is used to store the type of a contact lens item.

left_eye class-attribute instance-attribute

left_eye = 'left_eye'

right_eye class-attribute instance-attribute

right_eye = 'right_eye'

solution class-attribute instance-attribute

solution = 'solution'

ContactLensND

Bases: AlanBaseEnum

This enum is used to store the ND of a contact lens.

D class-attribute instance-attribute

D = 'D'

N class-attribute instance-attribute

N = 'N'

ContactLensProductType

Bases: AlanBaseEnum

This enum is used to store the product type of a contact lens.

contact_lens class-attribute instance-attribute

contact_lens = 'contact_lens'

contact_lens_bi_monthly class-attribute instance-attribute

contact_lens_bi_monthly = 'contact_lens_bi_monthly'

contact_lens_bifocal class-attribute instance-attribute

contact_lens_bifocal = 'contact_lens_bifocal'

contact_lens_colored class-attribute instance-attribute

contact_lens_colored = 'contact_lens_colored'

contact_lens_daily class-attribute instance-attribute

contact_lens_daily = 'contact_lens_daily'

contact_lens_extended_wear class-attribute instance-attribute

contact_lens_extended_wear = 'contact_lens_extended_wear'

contact_lens_for_sport class-attribute instance-attribute

contact_lens_for_sport = 'contact_lens_for_sport'

contact_lens_monthly class-attribute instance-attribute

contact_lens_monthly = 'contact_lens_monthly'

contact_lens_multifocal class-attribute instance-attribute

contact_lens_multifocal = 'contact_lens_multifocal'

contact_lens_progressive class-attribute instance-attribute

contact_lens_progressive = 'contact_lens_progressive'

contact_lens_spherical class-attribute instance-attribute

contact_lens_spherical = 'contact_lens_spherical'

contact_lens_toric class-attribute instance-attribute

contact_lens_toric = 'contact_lens_toric'

ContactLensSolutionType

Bases: AlanBaseEnum

This enum is used to store the solution type of a contact lens.

solution class-attribute instance-attribute

solution = 'solution'

solution_for_rigid class-attribute instance-attribute

solution_for_rigid = 'solution_for_rigid'

solution_for_soft class-attribute instance-attribute

solution_for_soft = 'solution_for_soft'

solution_ophtalmic class-attribute instance-attribute

solution_ophtalmic = 'solution_ophtalmic'

solution_travel_kit class-attribute instance-attribute

solution_travel_kit = 'solution_travel_kit'

ContactLensStatus

Bases: AlanBaseEnum

This enum is used to store the status of a contact lens.

available class-attribute instance-attribute

available = 'available'

not_available class-attribute instance-attribute

not_available = 'not_available'

out_of_stock class-attribute instance-attribute

out_of_stock = 'out_of_stock'

InvoicingDocumentType

Bases: AlanBaseEnum

This enum is used to store the type of invoice generation.

credit_note class-attribute instance-attribute

credit_note = 'credit_note'

invoice_update class-attribute instance-attribute

invoice_update = 'invoice_update'

regular_invoice class-attribute instance-attribute

regular_invoice = 'regular_invoice'

PrescriptionCheckProblemSeverity

Bases: AlanBaseEnum

This enum is used to store the severity of a prescription check problem.

high class-attribute instance-attribute

high = 'high'

low class-attribute instance-attribute

low = 'low'

PrescriptionCheckProblemType

Bases: AlanBaseEnum

This enum is used to store the type of a prescription check problem.

beneficiary class-attribute instance-attribute

beneficiary = 'beneficiary'

brand class-attribute instance-attribute

brand = 'brand'

date class-attribute instance-attribute

date = 'date'

left_addition class-attribute instance-attribute

left_addition = 'left-addition'

left_axis class-attribute instance-attribute

left_axis = 'left-axis'

left_curve class-attribute instance-attribute

left_curve = 'left-curve'

left_cylinder class-attribute instance-attribute

left_cylinder = 'left-cylinder'

left_sphere class-attribute instance-attribute

left_sphere = 'left-sphere'

right_addition class-attribute instance-attribute

right_addition = 'right-addition'

right_axis class-attribute instance-attribute

right_axis = 'right-axis'

right_curve class-attribute instance-attribute

right_curve = 'right-curve'

right_cylinder class-attribute instance-attribute

right_cylinder = 'right-cylinder'

right_sphere class-attribute instance-attribute

right_sphere = 'right-sphere'

trial_lenses class-attribute instance-attribute

trial_lenses = 'trial_lenses'

type class-attribute instance-attribute

type = 'type'

TransactionType

Bases: AlanBaseEnum

This enum is used to store the type of a transaction.

claim class-attribute instance-attribute

claim = 'claim'

stripe class-attribute instance-attribute

stripe = 'stripe'

UsageSource

Bases: AlanBaseEnum

This enum is used to store the source of an claim usage.

backend class-attribute instance-attribute

backend = 'backend'

saleor class-attribute instance-attribute

saleor = 'saleor'

UsageStatus

Bases: AlanBaseEnum

This enum is used to store the status of a claim usage.

pending class-attribute instance-attribute

pending = 'pending'

processed class-attribute instance-attribute

processed = 'processed'

refunded class-attribute instance-attribute

refunded = 'refunded'

UsageType

Bases: AlanBaseEnum

This enum is used to store the type of claim usage.

contact_lens class-attribute instance-attribute

contact_lens = 'contact_lens'

glasses class-attribute instance-attribute

glasses = 'glasses'

other class-attribute instance-attribute

other = 'other'

ValidationDecision

Bases: AlanBaseEnum

This enum is used to store the decision of a validation.

approved class-attribute instance-attribute

approved = 'approved'

rejected class-attribute instance-attribute

rejected = 'rejected'

skipped class-attribute instance-attribute

skipped = 'skipped'

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.

app_id instance-attribute

app_id

app_user_id instance-attribute

app_user_id

external_order_id instance-attribute

external_order_id

product_id instance-attribute

product_id

rating instance-attribute

rating

testimonial instance-attribute

testimonial

user_name instance-attribute

user_name

components.shop.public.flask_admin_configuration

components.shop.public.globalization

base_prescription_checker

BasePrescriptionChecker

BasePrescriptionChecker(saleor_client=None, dry_run=False)

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
def __init__(
    self, saleor_client: Optional[SaleorClient] = None, dry_run: bool = False
):
    self.saleor_client = saleor_client or SaleorClient()
    self.dry_run = dry_run
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
@abstractmethod
def check_contact_lens_prescription_content(
    self,
    beneficiary_user_id: str,
    content: PrescriptionContent,
    contact_lens_items: list[ContactLensItem],
    order_date: date | None = None,
) -> PrescriptionCheckerResult:
    """Check the contact lenses prescription content."""
    pass
check_glasses_prescription_content abstractmethod
check_glasses_prescription_content(
    beneficiary_user_id, beneficiary_calendar_age, content
)

Check the glasses prescription content.

Source code in components/shop/public/globalization/base_prescription_checker.py
@abstractmethod
def check_glasses_prescription_content(
    self,
    beneficiary_user_id: str,
    beneficiary_calendar_age: int,
    content: PrescriptionContent,
) -> PrescriptionCheckerResult:
    """Check the glasses prescription content."""
    pass
check_saleor_contact_lens_checkout_prescription_content abstractmethod
check_saleor_contact_lens_checkout_prescription_content(
    checkout_id, content
)

Check the SaleorCheckout prescription.

Source code in components/shop/public/globalization/base_prescription_checker.py
@abstractmethod
def check_saleor_contact_lens_checkout_prescription_content(
    self,
    checkout_id: str,
    content: PrescriptionContent,
) -> PrescriptionCheckerResult:
    """Check the SaleorCheckout prescription."""
    pass
check_saleor_contact_lens_fulfillment_prescription abstractmethod
check_saleor_contact_lens_fulfillment_prescription(
    order, fulfillment
)

Check the SaleorOrder prescription.

Source code in components/shop/public/globalization/base_prescription_checker.py
@abstractmethod
def check_saleor_contact_lens_fulfillment_prescription(
    self,
    order: SaleorOrder,
    fulfillment: SaleorFulfillment,
) -> PrescriptionCheckerResult:
    """Check the SaleorOrder prescription."""
    pass
document_content_is_of_type abstractmethod
document_content_is_of_type(content, document_type)

Abstract method to check if the document content is of the given type.

Source code in components/shop/public/globalization/base_prescription_checker.py
@abstractmethod
def document_content_is_of_type(
    self,
    content: PrescriptionContent,
    document_type: str,
) -> bool:
    """Abstract method to check if the document content is of the given type."""
    pass
dry_run class-attribute instance-attribute
dry_run = dry_run
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
@abstractmethod
def retrieve_prescription_content(
    self,
    prescription_id: str,
    compute_if_not_parsed_yet: bool = False,
    use_transcription: bool = False,
    automated_parsing_only: bool = False,
) -> Optional[PrescriptionContent]:
    """Abstract method to retrieve the prescription content."""
    pass
retrieve_prescription_transcription abstractmethod
retrieve_prescription_transcription(prescription_id)

Abstract method to retrieve the prescription transcription.

Source code in components/shop/public/globalization/base_prescription_checker.py
@abstractmethod
def retrieve_prescription_transcription(
    self,
    prescription_id: str,
) -> Optional[PrescriptionTranscription]:
    """Abstract method to retrieve the prescription transcription."""
    pass
saleor_client instance-attribute
saleor_client = saleor_client or SaleorClient()

base_shop_adapter

BaseShopAdapter

Bases: ABC

Base class for shop adapters, providing methods to implement the Shop.

generate_credit_note abstractmethod
generate_credit_note(order)

Generate a credit note for an order.

Source code in components/shop/public/globalization/base_shop_adapter.py
@abstractmethod
def generate_credit_note(
    self,
    order: SaleorOrder,
) -> OrderInvoice:
    """Generate a credit note for an order."""
    pass
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
@abstractmethod
def generate_order_invoice(
    self,
    order: SaleorOrder,
    is_preview: bool = False,
    invoice_type: InvoicingDocumentType = InvoicingDocumentType.regular_invoice,
) -> OrderInvoice:
    """Generate an invoice for an order."""
    pass
get_coverage_usage_for_user abstractmethod
get_coverage_usage_for_user(
    user_id, usage_type, reference_date=None
)

Return the remaining usage for a user.

Source code in components/shop/public/globalization/base_shop_adapter.py
@abstractmethod
def get_coverage_usage_for_user(
    self,
    user_id: str,
    usage_type: UsageType,
    reference_date: date | None = None,
) -> CoverageUsage:
    """Return the remaining usage for a user."""
    pass
get_order_invoice_url abstractmethod
get_order_invoice_url(invoice_id)

Get the URL of the order invoice.

Source code in components/shop/public/globalization/base_shop_adapter.py
@abstractmethod
def get_order_invoice_url(
    self,
    invoice_id: str,
) -> str:
    """Get the URL of the order invoice."""
    return f"{current_config['FRONT_END_BASE_URL']}/marmot/document/{invoice_id}"
get_pending_claim_usages_for_user abstractmethod
get_pending_claim_usages_for_user(user_id, usage_type)

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
@abstractmethod
def get_pending_claim_usages_for_user(
    self,
    user_id: str,
    usage_type: UsageType,
) -> list[PendingClaimUsage]:
    """
    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,
    )
    """
    pass
get_prescription_checker abstractmethod
get_prescription_checker(saleor_client, dry_run=False)

Return a prescription checker class.

Source code in components/shop/public/globalization/base_shop_adapter.py
@abstractmethod
def get_prescription_checker(
    self, saleor_client: SaleorClient, dry_run: bool = False
) -> BasePrescriptionChecker:
    """Return a prescription checker class."""
    pass
is_prescription_locked_for_invoicing abstractmethod
is_prescription_locked_for_invoicing(prescription_id)

Return True if the prescription is linked to a pending order not yet invoiced.

return SaleorHelper().is_prescription_locked_for_invoicing( app_id=AppName.ALAN_FR, prescription_id=prescription_id, )

Source code in components/shop/public/globalization/base_shop_adapter.py
@abstractmethod
def is_prescription_locked_for_invoicing(
    self,
    prescription_id: str,
) -> bool:
    """
    Return True if the prescription is linked to a pending order not yet invoiced.

    return SaleorHelper().is_prescription_locked_for_invoicing(
        app_id=AppName.ALAN_FR,
        prescription_id=prescription_id,
    )
    """
    pass
tombstone_insurance_document abstractmethod
tombstone_insurance_document(
    insurance_document_id, force=False
)

Tombstone (soft delete) an insurance document.

Source code in components/shop/public/globalization/base_shop_adapter.py
@abstractmethod
def tombstone_insurance_document(
    self,
    insurance_document_id: str,
    force: bool = False,
) -> None:
    """Tombstone (soft delete) an insurance document."""
    pass
upload_invoicing_document abstractmethod
upload_invoicing_document(
    order, invoicing_document, is_credit_note=False
)

Upload invoicing document.

Source code in components/shop/public/globalization/base_shop_adapter.py
@abstractmethod
def upload_invoicing_document(
    self,
    order: SaleorOrder,
    invoicing_document: OrderInvoice,
    is_credit_note: bool = False,
) -> str | None:
    """Upload invoicing document."""
    pass
upload_order_invoice abstractmethod
upload_order_invoice(order, invoice)

Upload order invoice and create the corresponding care acts.

Source code in components/shop/public/globalization/base_shop_adapter.py
@abstractmethod
def upload_order_invoice(
    self,
    order: SaleorOrder,
    invoice: OrderInvoice,
) -> str | None:
    """Upload order invoice and create the corresponding care acts."""
    pass

shop_adapter

get_app_specific_shop_adapter

get_app_specific_shop_adapter(app_id)

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
def get_app_specific_shop_adapter(app_id: str) -> BaseShopAdapter:
    """Return an app-specific shop adapter based on the app ID or raise an error if not found."""
    shop_adapter = get_app_specific_shop_adapter_or_none(app_id=app_id)
    if not shop_adapter:
        current_logger.error(
            f"Shop: [globalization] No shop adapter found for app_id: {app_id}"
        )
        raise ValueError(f"Shop adapter not found: {app_id}")
    return shop_adapter

get_app_specific_shop_adapter_or_none

get_app_specific_shop_adapter_or_none(app_id)

Return an app-specific shop adapter based on the app ID.

Source code in components/shop/public/globalization/shop_adapter.py
def get_app_specific_shop_adapter_or_none(app_id: str) -> Optional[BaseShopAdapter]:
    """Return an app-specific shop adapter based on the app ID."""
    match app_id:
        case AppName.ALAN_FR:
            from components.fr.internal.shop.public.shop_adapter import (  # noqa: ALN039
                ShopAdapter as ShopAdapterFr,
            )

            return ShopAdapterFr()

    return None

components.shop.public.services

discounts

create_shop_discount

create_shop_discount(code, amount, expires_at, title)

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
def create_shop_discount(
    code: str, amount: VoucherDataAmount, expires_at: datetime, title: str
) -> None:
    """
    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
    """
    from components.shop.internal.business_logic.discounts.create_discount import (
        create_discount,
    )

    return create_discount(
        code=code,
        amount=amount,
        expires_at=expires_at,
        title=title,
    )

get_processed_orders_with_discounts

get_processed_orders_with_discounts(after)

Get orders with discounts processed after date from shopify

Source code in components/shop/public/services/discounts.py
def get_processed_orders_with_discounts(
    after: date,
) -> list[ProcessedOrderAndDiscounts]:
    """
    Get orders with discounts processed after date from shopify
    """
    from components.shop.internal.business_logic.discounts.get_processed_orders_with_discounts import (
        get_processed_orders_with_discounts,
    )

    return get_processed_orders_with_discounts(after=after)