Aura.Common (Aura v0.9.1)
View SourceCommon capabilities across all Aura services
๐ Resources
- ๐ฌ Contact the maintainer (he's happy to help!)
Summary
Types
A human-readable name for this API key
The path parameter of the request
An email address associated with this record
Name of the package
The version of a release
The name of the repository
A unique, human-readable ID for a user
Functions
Determines a api_path/0
by investigating opts for a :repo
key, representing a Aura.Model.HexRepo
.
Implements Hex API's pagination mechanism by returning a Stream.resource/3
Types
@type api_key_name() :: String.t()
A human-readable name for this API key
๐ป Examples
"my_computer"
@type api_path() :: String.t()
The path parameter of the request
๐ป Examples
"/packages"
@type email() :: String.t()
An email address associated with this record
๐ป Examples
"hello@example.com"
@type package_name() :: String.t()
Name of the package
๐ป Examples
"plug"
@type release_version() :: String.t()
The version of a release
๐ป Examples
"1.2.3"
@type repo_name() :: String.t()
The name of the repository
๐ป Examples
"hexpm"
@type username() :: String.t()
A unique, human-readable ID for a user
๐ป Examples
"camatcode"
Functions
Determines a api_path/0
by investigating opts for a :repo
key, representing a Aura.Model.HexRepo
.
If present, path will be modified to scope solely to that repo, otherwise the path is unmodified.
๐ท๏ธ Params
- opts :: option parameters used to modify requests
- path ::
api_path/0
โคต๏ธ Returns
โ On Success
{path, opts}
๐ป Examples
iex> alias Aura.Common
iex> alias Aura.Model.HexPackage
iex> opts = [repo_url: "http://localhost:4000/api", repo: "hexpm", page: 2, sort: :total_downloads]
iex> {_path, _opts} = Common.determine_path(opts, "/packages")
{"/repos/hexpm/packages", [repo_url: "http://localhost:4000/api", page: 2, sort: :total_downloads]}
@spec stream_paginate( path :: api_path(), build_func :: (map() -> map()), opts :: list() ) :: Enumerable.t()
Implements Hex API's pagination mechanism by returning a Stream.resource/3
๐ท๏ธ Params
- path ::
api_path/0
- build_func :: a function that takes in a map and returns a struct representing what's being paginated
- opts :: option parameters used to modify requests
โคต๏ธ Returns
โ On Success
a `Stream.resource/3`
๐ป Examples
iex> alias Aura.Common
iex> alias Aura.Model.HexPackage
iex> opts = [repo_url: "http://localhost:4000/api", repo: "hexpm", page: 2, sort: :total_downloads]
iex> {path, opts} = Common.determine_path(opts, "/packages")
iex> packages = Common.stream_paginate(path, &HexPackage.build/1, opts)
iex> Enum.empty?(packages)
false