JikanEx.Url (JikanEx v0.1.5) View Source
Interface to build Jikan URLs. These are then passed onto JikanEx.Request.request/3.
In here, generally, URLs shouldn't start with a slash, and should typically have a slash at the end. The final / is removed when adding query parameters or in JikanEx.Request.request/3.
Link to this section Summary
Functions
Add a page number to the URL, calls JikanEx.Url.path/2
Formats a map of GET params into a URL
Formats a GET key and value into a URL
Add the endpoint (a string, atom, or integer) to the URL
Adds multiple URL parts (joined by '/') to a URL
Removes a trailing forward slash from a URL
Link to this section Types
Specs
Specs
Specs
parameters() :: %{optional(parameter_key()) => parameter_val()} | %{}
Specs
Specs
url() :: String.t()
Link to this section Functions
Specs
Add a page number to the URL, calls JikanEx.Url.path/2
Example
iex> JikanEx.Url.page("animelist/all/", 2)
"animelist/all/2/"
Specs
params(url(), parameters()) :: url()
Formats a map of GET params into a URL
Example
iex> JikanEx.Url.params("animelist/all/2", %{year: 2019, airing_status: "complete"})
"animelist/all/2?airing_status=complete&year=2019&"
Specs
params(url(), parameter_key(), parameter_val()) :: url()
Formats a GET key and value into a URL
Example
iex> JikanEx.Url.params("animelist/all/2/", "year", 2019)
"animelist/all/2?year=2019&"
Specs
Add the endpoint (a string, atom, or integer) to the URL
Example
iex> JikanEx.Url.path("anime/5/", "videos")
"anime/5/videos/"
Specs
Adds multiple URL parts (joined by '/') to a URL
Example
iex> JikanEx.Url.paths("anime/", [1, :character_staff])
"anime/1/character_staff/"
Specs
Removes a trailing forward slash from a URL
iex> JikanEx.Url.trim_url("username/animelist/2/")
"username/animelist/2"
iex> JikanEx.Url.trim_url("username/animelist/2")
"username/animelist/2"