Random user generator is an Elixir client for randomuser.me API
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config
fixture/vcr_cassettes
lib
test
.gitignore
.travis.yml
README.md
mix.exs
mix.lock

README.md

RandomUser Build Status Coverage Status Deps Status

Features

  • Return one random user
  • Return multiple random users
  • Seeds (always returns Becky Sims)
  • Choose gender, nationality and other options
  • Format results

Installation

This package is available in Hex and can be installed as follows:

  1. Add random_user to your list of dependencies in mix.exs:
```elixir
def deps do
  [{:random_user, "~> 0.3.3"}]
end
```
  1. Ensure random_user is started before your application:
```elixir
def application do
  [applications: [:random_user]]
end
```

Usage

One Random User

# Returns one random user
RandomUser.Random.one

# Returns a random female user
RandomUser.Random.one(%{ gender: "female" })

# Returns a random British female user
RandomUser.Random.one(%{ gender: "female", nat: "gb" })

Multiple Random Users

# Returns 50 users
RandomUser.Random.multiple(50)

# Returns 50 female users
RandomUser.Random.multiple(50, %{ gender: "female" })

# Returns 50 female users from AU and NZ
RandomUser.Random.multiple(50, %{ gender: "female", nat: "au,nz" })

Get results easily with Parser

For one random user:

res = RandomUser.Random.one |> RandomUser.Parser.results |> RandomUser.Parser.parse
res.gender
res.picture["large"]

For multiple random users:

users = RandomUser.Random.multiple(2) |> RandomUser.Parser.results
Enum.map(users, fn u ->
  user = RandomUser.Parser.parse(u)
  large_pic = user.picture["large"]
end)