View Source Exbitly (Exbitly v0.1.0)

Exbitly's main module. You can find all the functions you can use in Exbitly in this module.

Link to this section Summary

Functions

Takes a domain and a long URL and returns the shortened URL. If an error occurs, raises an exception.

Takes a domain and a long URL and returns the shortened URL. If an error occurs, returns the error body.

Link to this section Functions

Link to this function

shorten!(domain, long_url)

View Source
@spec shorten!(String.t(), String.t()) :: {:ok, String.t()} | no_return()

Takes a domain and a long URL and returns the shortened URL. If an error occurs, raises an exception.

parameters

Parameters

  • domain: The domain of the shortened URL.
  • long_url: The long URL to be shortened.

examples

Examples

Exbitly.shorten!("bit.ly", "http://www.example.com")
# {:ok, "http://bit.ly/short_url"}

Exbitly.shorten!("random", "http://www.example.com")
# ** (Exbitly.Error) An error occured while shortening the URL. Message: INVALID_ARG_DOMAIN - Description: The value provided is invalid.
Link to this function

shorten(domain, long_url)

View Source
@spec shorten(String.t(), String.t()) :: {:ok, String.t()} | {:error, map()}

Takes a domain and a long URL and returns the shortened URL. If an error occurs, returns the error body.

parameters

Parameters

  • domain: The domain of the shortened URL.
  • long_url: The long URL to be shortened.

examples

Examples

Exbitly.shorten("bit.ly", "http://www.example.com")
# {:ok, "http://bit.ly/short_url"}

Exbitly.shorten("random", "http://www.example.com")
# {:error, %{
#   "description" => "The value provided is invalid.",
#   "errors" => [%{"error_code" => "invalid", "field" => "domain"}],
#   "message" => "INVALID_ARG_DOMAIN",
#   "resource" => "bitlinks"
# }}