ExShopify v0.2.0 ExShopify.Product
Individual item for sale in a Shopify store.
Summary
Functions
Receive a count of all products
Create a new product
Remove a product from the database
Receive a single product
Receive a list of all products
Modify an existing product
Types
product_plural()
product_plural() :: {:ok, [%ExShopify.Product{body_html: term, created_at: term, handle: term, id: term, images: term, metafields_global_description_tag: term, metafields_global_title_tag: term, options: term, product_type: term, published_at: term, published_scope: term, tags: term, template_suffix: term, title: term, updated_at: term, variants: term, vendor: term}], %ExShopify.Meta{api_call_limit: term}}
product_singular()
product_singular() :: {:ok, %ExShopify.Product{body_html: term, created_at: term, handle: term, id: term, images: term, metafields_global_description_tag: term, metafields_global_title_tag: term, options: term, product_type: term, published_at: term, published_scope: term, tags: term, template_suffix: term, title: term, updated_at: term, variants: term, vendor: 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
Receive a count of all products.
Examples
iex> ExShopify.Product.count(session)
{: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) :: product_singular | ExShopify.Resource.error
Create a new product.
Examples
Create a new product with the default variant and a product image which will be downloaded by Shopify
iex> params = %ExShopify.Product{
...> title: "Burton Custom Freestyle 151",
...> body_html: "<strong>Good snowboard!</strong>",
...> vendor: "Burton",
...> product_type: "Snowboard",
...> images: [
...> %ExShopify.ProductImage{
...> src: "http://example.com/elixir_logo.gif"
...> }
...> ]
...> }
iex> ExShopify.Product.create(session, params)
{:ok, product, meta}
Create a product with a metafield
iex> params = %ExShopify.Product{
...> title: "Burton Custom Freestyle 151",
...> body_html: "<strong>Good snowboard!</strong>",
...> vendor: "Burton",
...> product_type: "Snowboard",
...> metafields: [
...> %ExShopify.Metafield{
...> key: "new",
...> value: "newvalue",
...> value_type: "string",
...> namespace: "global"
...> }
...> ]
...> }
iex> ExShopify.Product.create(session, params)
{:ok, product, meta}
Create a new product with multiple product variants
iex> params = %ExShopify.Product{
...> title: "Burton Custom Freestyle 151",
...> body_html: "<strong>Good snowboard!</strong>",
...> vendor: "Burton",
...> product_type: "Snowboard",
...> variants: [
...> %ExShopify.ProductVariant{
...> option1: "First",
...> price: "10.00",
...> sku: 123
...> },
...> %ExShopify.ProductVariant{
...> option1: "Second",
...> price: "20.00",
...> sku: 123
...> }
...> ]
...> }
iex> ExShopify.Product.create(session, params)
{:ok, product, meta}
Create a new, but unpublished product
iex> params = %ExShopify.Product{
...> title: "Burton Custom Freestyle 151",
...> body_html: "<strong>Good snowboard!</strong>",
...> vendor: "Burton",
...> product_type: "Snowboard",
...> published: false
...> }
iex> ExShopify.Product.create(session, params)
{:ok, product, 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.meta_only | ExShopify.Resource.error
Remove a product from the database.
Examples
iex> ExShopify.Product.delete(session, 632910392)
{: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) :: product_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) :: product_singular | ExShopify.Resource.error
Receive a single product.
Examples
iex> ExShopify.Product.find(session, 632910392)
{:ok, product, 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}) :: product_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) :: product_plural | ExShopify.Resource.error
Receive a list of all products.
Examples
iex> ExShopify.Product.list(session)
{:ok, products, 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) :: product_singular | ExShopify.Resource.error
Modify an existing product.
Examples
Update a product’s title
iex> params = %{
...> title: "New product title"
...> }
iex> ExShopify.Product.update(session, 632910392, params)
{:ok, product, meta}
Add a metafield to an existing product
iex> params = %{
...> metafields: [
...> %{
...> key: "new",
...> value: "newvalue",
...> value_type: "string",
...> namespace: "global"
...> }
...> ]
...> }
iex> ExShopify.Product.update(session, 632910392, params)
{:ok, product, meta}
Update a product, adding a new product image
iex> params = %{
...> images: [
...> %{id: 850703190},
...> %{id: 562641783},
...> %{src: "http://example.com/elixir_logo.gif"}
...> ]
...> }
iex> ExShopify.Product.update(session, 632910392, params)
{:ok, product, meta}