Shopifex.Plug (Shopifex v2.1.20) View Source

An API for accessing the Shopify session data for the current request.

Link to this section Summary

Functions

Build the Shopifex session. Used in various :shopifex_* pipelines.

Get current request shop resource for give conn.

Get host parameter provided in URL params when Shopify loaded your app in the Shopify admin portal.

Places given shop into current session, making it accessible later on via Shopifex.Plug.current_shop(conn)

Returns the token for the current session in a plug which has passed through a :shopify_* pipeline.

Link to this section Types

Specs

shop() :: %{access_token: String.t(), scope: String.t(), url: String.t()}

Specs

shopify_host() :: String.t()

Link to this section Functions

Specs

build_hmac(conn :: Plug.Conn.t()) :: String.t()
Link to this function

build_session(conn, shop, host, locale \\ "en")

View Source

Specs

build_session(
  conn :: Plug.Conn.t(),
  shop :: shop(),
  shopify_host :: shopify_host(),
  locale :: Gettext.locale()
) :: Plug.Conn.t()

Build the Shopifex session. Used in various :shopifex_* pipelines.

Specs

current_shop(conn :: Plug.Conn.t()) :: shop()

Get current request shop resource for give conn.

Available in all requests which have passed through a :shopify_* pipeline.

Examples:

iex> current_shop(conn)
%MyApp.Shop{}
Link to this function

current_shopify_host(arg1)

View Source

Specs

current_shopify_host(conn :: Plug.Conn.t()) :: shopify_host()

Get host parameter provided in URL params when Shopify loaded your app in the Shopify admin portal.

Useful when initializing app-bridge instance from SPA application.

Examples:

iex> current_shopify_host(conn)
"host from URL search parameter"

Specs

get_hmac(conn :: Plug.Conn.t()) :: String.t() | nil
Link to this function

put_shop_in_session(conn, shop)

View Source

Specs

put_shop_in_session(conn :: Plug.Conn.t(), shop :: shop()) :: Plug.Conn.t()

Places given shop into current session, making it accessible later on via Shopifex.Plug.current_shop(conn)

Specs

session_token(conn :: Plug.Conn.t()) :: Guardian.Token.token() | nil

Returns the token for the current session in a plug which has passed through a :shopify_* pipeline.

Example

iex> session_token(conn)
"header.payload.signature"