api.integrations.shopify.files ============================== .. py:module:: api.integrations.shopify.files .. autoapi-nested-parse:: A product's documentation PDF: uploaded to the store's Files, then referenced by a metafield. A PDF goes through a staged upload: ask Shopify for an upload target, post the file there, create the file from it, and wait until Shopify has processed it. Needs the `read_files` and `write_files` scopes. Attributes ---------- .. autoapisummary:: api.integrations.shopify.files.logger api.integrations.shopify.files.REQUEST_TIMEOUT_SECONDS api.integrations.shopify.files.FILE_READY_POLL_SECONDS api.integrations.shopify.files.FILE_READY_MAX_POLLS api.integrations.shopify.files.MAX_FILE_BYTES api.integrations.shopify.files.STORAGE_ERROR_HINTS Exceptions ---------- .. autoapisummary:: api.integrations.shopify.files.ShopifyFileError api.integrations.shopify.files.ShopifyFileTooLargeError Classes ------- .. autoapisummary:: api.integrations.shopify.files.ShopifyFiles Functions --------- .. autoapisummary:: api.integrations.shopify.files.format_megabytes api.integrations.shopify.files.product_gid Module Contents --------------- .. py:data:: logger .. py:data:: REQUEST_TIMEOUT_SECONDS :value: 60 .. py:data:: FILE_READY_POLL_SECONDS :value: 1.0 .. py:data:: FILE_READY_MAX_POLLS :value: 30 .. py:data:: MAX_FILE_BYTES :value: 20971520 .. py:data:: STORAGE_ERROR_HINTS .. py:exception:: ShopifyFileError Bases: :py:obj:`api.integrations.shopify.graphql.ShopifyError` A file upload or metafield write that did not complete. .. py:exception:: ShopifyFileTooLargeError Bases: :py:obj:`ShopifyFileError` Larger than MAX_FILE_BYTES: refused before any request. .. py:function:: format_megabytes(size: int) -> str .. py:function:: product_gid(product_id: int | str) -> str .. py:class:: ShopifyFiles(domain: str, api_version: str, token_provider: api.integrations.shopify.auth.TokenProvider = get_shopify_access_token) .. py:method:: get_product_documentation(product_id: int | str, namespace: str, file_key: str, source_key: str) -> tuple[str | None, str | None] (file metafield, source metafield) currently on the product; None when unset. .. py:method:: upload_pdf(content: bytes, filename: str, alt: str = '') -> str Uploads a PDF to the store's Files, waits until Shopify has processed it, and returns its id. .. py:method:: set_product_metafields(product_id: int | str, metafields: list[dict[str, str]]) -> None Sets `{namespace, key, type, value}` metafields, all or none (metafieldsSet upserts).