View Source JikanEx.UrlBuilders (JikanEx v0.1.6)

Creates the URLs for Jikan endpoints. These are called from JikanEx.Request and aren't typically used by calling them directly.

Summary

Functions

Builds a URL from a list of paths and a param_map

Similar to build_url/4 but doesn't accept a MAL ID

Build a URL from a function name, (MAL) id, paths, parameter map

Functions

build(path_list, param_map \\ %{})

Builds a URL from a list of paths and a param_map

Example

iex> JikanEx.UrlBuilders.build([:user, "nekomata1037", :animelist, :completed, 2], %{year: 2019})
"user/nekomata1037/animelist/completed/2?year=2019&"

build_url(function_env, paths, parameters)

@spec build_url(
  tuple(),
  [JikanEx.Url.path()],
  JikanEx.Url.parameters()
) :: JikanEx.Url.url()

Similar to build_url/4 but doesn't accept a MAL ID

Example

iex> JikanEx.UrlBuilders.build_url({:search!, 0}, ["anime"], %{:q => "k-on", "limit" => 5})
"search/anime?q=k-on&limit=5&"

build_url(function_env, id, paths, parameters)

Build a URL from a function name, (MAL) id, paths, parameter map

Accepts the __ENV__.function from the calling function as the first argument (to turn into the first URL part), the MAL ID for the second and additional paths/params as third/fourth

Example

iex> JikanEx.UrlBuilders.build_url({:anime!, 0}, 1, [:characters_staff], %{})
"anime/1/characters_staff/"