Packages
shopifex
2.4.0
2.4.0
2.3.0
2.2.2
2.2.1
2.2.0
2.1.20
2.1.19
2.1.18
2.1.17
2.1.16
2.1.15
2.1.14
2.1.13
2.1.12
2.1.11
2.1.10
2.1.9
2.1.8
2.1.7
2.1.6
2.1.5
2.1.4
2.1.3
2.1.2
2.1.1
2.1.0
2.0.1
2.0.0
1.1.1
1.1.0
1.0.1
1.0.0
0.6.2
0.6.1
0.6.0
0.5.7
0.5.6
0.5.5
0.5.4
0.5.3
0.5.2
0.5.1
0.5.0
0.4.1
0.4.0
0.3.6
0.3.5
0.3.4
0.3.3
0.3.2
0.3.1
0.3.0
0.2.1
0.2.0
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
Phoenix boilerplate for Shopify Embedded App SDK
Current section
Files
Jump to
Current section
Files
lib/shopifex/shop.ex
defmodule Shopifex.Shop do
@moduledoc """
A specification for how Shopifex is to interact with your Shopify
shops table.
## Options
* `:url_field` - the field which Shopifex will use to find a shop by url. Defaults to `:url`
* `:filters` - a list of tuples to be used as filter keys which Shopifex will use when
loading your shop from your database table. Defaults to `[]`
* `:preloads` - a list of preloads which Shopifex will pass unchanged to `MyApp.Repo.preload/2`
## Example:
```elixir
defmodule MyApp.CommercePlatformInstallation do
use MyApp.Schema
use Shopifex.Shop, url_field: :installation_identifier, filters: [{:platform, "shopify"}, {:disabled_at, nil}]
schema "commerce_platform_installations" do
field(:installation_identifier, :string)
field(:provider, :string, default: "shopify")
field(:disabled_at, :utc_datetime)
# ...
end
end
```
"""
@default_url_field :url
@default_scope_field :scope
@default_filter_keys []
@default_preloads []
defmacro __using__(opts \\ []) do
url_key = Keyword.get(opts, :url_field, @default_url_field)
scope_key = Keyword.get(opts, :scope_field, @default_scope_field)
filters = Keyword.get(opts, :filters, @default_filter_keys)
preloads = Keyword.get(opts, :preloads, @default_preloads)
quote do
def shopifex_url_field(), do: unquote(url_key)
def shopifex_scope_field(), do: unquote(scope_key)
def shopifex_filters(), do: unquote(filters)
def shopifex_preloads(), do: unquote(preloads)
end
end
end