ExShopify v0.2.0 ExShopify.CustomCollection
Reader’s response to an article in a blog.
Summary
Functions
Get a count of all custom collections that contain a given product
Create a new custom collection
Remove custom collection
Get a single custom collection
Get a list of all custom collections that contain a given product
Update an existing custom collection
Types
custom_collection_plural()
custom_collection_plural() :: {:ok, [%ExShopify.CustomCollection{body_html: term, handle: term, id: term, image: term, metafields: term, published: term, published_at: term, published_scope: term, sort_order: term, template_suffix: term, title: term, updated_at: term}], %ExShopify.Meta{api_call_limit: term}}
custom_collection_singular()
custom_collection_singular() :: {:ok, %ExShopify.CustomCollection{body_html: term, handle: term, id: term, image: term, metafields: term, published: term, published_at: term, published_scope: term, sort_order: term, template_suffix: term, title: term, updated_at: term}, %ExShopify.Meta{api_call_limit: term}}
Functions
count(session)
count(%ExShopify.Session{access_token: term, api_key: term, domain: term, port: term, protocol: term, secret: term, shop_name: term, shop_url: term}) :: ExShopify.Resource.count | ExShopify.Resource.error
count(session, params)
count(%ExShopify.Session{access_token: term, api_key: term, domain: term, port: term, protocol: term, secret: term, shop_name: term, shop_url: term}, map) :: ExShopify.Resource.count | ExShopify.Resource.error
Get a count of all custom collections that contain a given product.
Examples
Count all collections
iex> ExShopify.CustomCollection.count(session)
{:ok, count, meta}
Count all custom collections for a certain product_id
iex> ExShopify.CustomCollection.count(session, %{product_id: 632910392})
{:ok, count, meta}
create(session, params)
create(%ExShopify.Session{access_token: term, api_key: term, domain: term, port: term, protocol: term, secret: term, shop_name: term, shop_url: term}, map) :: custom_collection_singular | ExShopify.Resource.error
Create a new custom collection.
Examples
Create a collection with title Macbooks
iex> params = %ExShopify.CustomCollection{title: "Macbooks"}
iex> ExShopify.CustomCollection.create(session, params)
{:ok, custom_collection, meta}
Create a new, but unpublished collection
iex> params = %ExShopify.CustomCollection{
...> title: "Macbooks",
...> published: false
...> }
iex> ExShopify.CustomCollection.create(session, params)
{:ok, custom_collection, meta}
Create a new collection with an image which will be downloaded by Shopify
iex> params = %ExShopify.CustomCollection{
...> title: "Macbooks",
...> image: %{
...> src: "http://example.com/rails_logo.gif"
...> }
...> }
iex> ExShopify.CustomCollection.create(session, params)
{:ok, custom_collection, meta}
Create a new collection with a base64 encoded image
iex> params = %ExShopify.CustomCollection{
...> title: "Macbooks",
...> image: %{
...> attachment: Base.encode64(File.read("path/to/image.png"))
...> }
...> }
iex> ExShopify.CustomCollection.create(session, params)
{:ok, custom_collection, meta}
Create a collection with a collect
iex> params = %ExShopify.CustomCollection{
...> title: "Macbooks",
...> collects: [
...> %ExShopify.Collection{product_id: "921728736"}
...> ]
...> }
iex> ExShopify.CustomCollection.create(session, params)
{:ok, custom_collection, meta}
Create a collection with a metafield
iex> params = %ExShopify.CustomCollection{
...> title: "Macbooks",
...> metafields: [
...> %ExShopify.Metafield{
...> key: "new",
...> value: "newvalue",
...> value_type: "string",
...> namespace: "global"
...> }
...> ]
...> }
iex> ExShopify.CustomCollection.create(session, params)
{:ok, custom_collection, meta}
delete(session, id)
delete(%ExShopify.Session{access_token: term, api_key: term, domain: term, port: term, protocol: term, secret: term, shop_name: term, shop_url: term}, integer | String.t) :: ExShopify.Resource.only_meta | ExShopify.Resource.error
Remove custom collection.
Examples
iex> ExShopify.CustomCollection.delete(session, 841564295)
{:ok, meta}
find(session, id)
find(%ExShopify.Session{access_token: term, api_key: term, domain: term, port: term, protocol: term, secret: term, shop_name: term, shop_url: term}, integer | String.t) :: custom_collection_singular | ExShopify.Resource.error
find(session, id, params)
find(%ExShopify.Session{access_token: term, api_key: term, domain: term, port: term, protocol: term, secret: term, shop_name: term, shop_url: term}, integer | String.t, map) :: custom_collection_singular | ExShopify.Resource.error
Get a single custom collection.
Examples
iex> ExShopify.CustomCollection.find(session, 841564295)
{:ok, custom_collection, meta}
list(session)
list(%ExShopify.Session{access_token: term, api_key: term, domain: term, port: term, protocol: term, secret: term, shop_name: term, shop_url: term}) :: custom_collection_plural | ExShopify.Resource.error
list(session, params)
list(%ExShopify.Session{access_token: term, api_key: term, domain: term, port: term, protocol: term, secret: term, shop_name: term, shop_url: term}, map) :: custom_collection_plural | ExShopify.Resource.error
Get a list of all custom collections that contain a given product.
Examples
List all collections
iex> ExShopify.CustomCollection.list(session)
{:ok, custom_collections, meta}
List all custom collections for a certain product_id
iex> ExShopify.CustomCollection.list(session, %{product_id: 632910392})
{:ok, custom_collections, meta}
Get a list of specific custom collections
iex> ExShopify.CustomCollection.list(session, %{ids: [395646240, 691652237, 841564295]})
{:ok, custom_collections, meta}
update(session, id, params)
update(%ExShopify.Session{access_token: term, api_key: term, domain: term, port: term, protocol: term, secret: term, shop_name: term, shop_url: term}, integer | String.t, map) :: custom_collection_singular | ExShopify.Resource.error
Update an existing custom collection.
Examples
Change the description of a collection
iex> params = %{body_html: "<p>5000 songs in your pocket</p>"}
iex> ExShopify.CustomCollection.update(session, 841564295, params)
{:ok, custom_collection, meta}
Add a collect to an existing collection and update the sort value of the existing collect
Use product_id
for products being added to the collection, and id for products that were already in the collection.
iex> params = %{
...> collects: [
...> %{product_id: 921728736, sort_value: "0000000001"},
...> %{id: 841564295, sort_value: "0000000002"}
...> ]
...> }
iex> ExShopify.CustomCollection.update(session, 841564295, params)
{:ok, custom_collection, meta}
Update a collection, clearing the collection image
iex> params = %{image: ""}
iex> ExShopify.CustomCollection.update(session, 841564295, params)
{:ok, custom_collection, meta}