Packages

An API wrapper for the programming game Stockfighter.

Current section

Files

Jump to
xfighter lib xfighter.ex
Raw

lib/xfighter.ex

defmodule Xfighter do
alias Xfighter.Exception.ConnectionError
import Xfighter.API, only: [request: 2]
require Logger
@doc """
A simple health check for the API.
## Example:
iex> Xfighter.heartbeat
true
"""
@spec heartbeat :: boolean
def heartbeat do
try do
case request(:get, "/heartbeat") do
{200, _body} -> true
_otherwise -> false
end
rescue
_e in ConnectionError -> false
_e in InvalidJSON -> false
end
end
end #defmodule