CatalogApi.Category (CatalogApi v0.0.17) View Source

Defines the CatalogApi.Category struct and functions which are responsible for parsing categories from CatalogApi responses.

Link to this section Summary

Functions

Casts a map representing a Category which results from parsing JSON representing a category into a %CatalogApi.Category{} struct.

Accepts a raw JSON response from the CatalogApi.catalog_breakdon/2 function and casts all categories as %CatalogApi.Category{} structs.

Link to this section Types

Specs

t() :: %CatalogApi.Category{
  category_id: term(),
  children: term(),
  depth: term(),
  item_count: term(),
  name: term(),
  parent_category_id: term()
}

Link to this section Functions

Specs

cast(map()) :: t()

Casts a map representing a Category which results from parsing JSON representing a category into a %CatalogApi.Category{} struct.

If the category has any categories enumerated in its "children" key, then it casts those children recursively as well.

Link to this function

extract_categories_from_json(arg1)

View Source

Specs

extract_categories_from_json(any()) :: {:ok, [t()]}

Accepts a raw JSON response from the CatalogApi.catalog_breakdon/2 function and casts all categories as %CatalogApi.Category{} structs.

If the given json is not recognized or is an invalid format then it returns an error tuple of the format: {:error, :unparseable_catalog_api_categories}