Picnic.Resources.Search (Picnic v0.1.0)

Copy Markdown View Source

Product search.

A search returns a flat list of products, most relevant first:

{:ok, products} = Picnic.search(client, "melk")

Picnic serves search as a display page, so the response carries banners, category headers and promotion tiles around the products. This module keeps the products and drops the presentation. When you want the whole page, ask for it directly:

Picnic.request(client, :get, "/pages/search-page-results",
  params: [search_term: "melk"]
)

Summary

Functions

Searches the product catalogue.

Functions

search(client, term, opts \\ [])

@spec search(Picnic.Client.t(), String.t(), keyword()) ::
  {:ok, term()} | {:error, Picnic.Error.t()}

Searches the product catalogue.

Returns the matching products as plain maps; pass as: :struct to decode them into Picnic.Schema.SearchResult structs. Remaining options are forwarded to the request. A search that matches nothing is {:ok, []}.