Mpx
Elixir wrapper for the Ministry Platform REST API
Installation
If available in Hex, the package can be installed
by adding mpx to your list of dependencies in mix.exs:
def deps do
[
{:mpx, "~> 0.2.2"}
]
end
The only required configuration is the base url of your MP instance:
config :mpx,
mp_base_url: System.get_env("MP_BASE_URL"),
Running Integration Tests
First create a integration.exs in the config folder. Populate with:
use Mix.Config
config :mpx,
mp_base_url: System.get_env("MP_BASE_URL"),
mp_username: "a_real_username",
mp_password: "a_real_password",
mp_client_id: "a_real_client_id",
mp_client_secret: "a_real_client_secret"
Now run
MIX_ENV=integration mix test --only integration
Usage
Currently only a few endpoints are supported:
/tables(get and delete)/tables/:id(get)
Set configuration options to authenticate with MP in your config.exs. You can use
{:system, "ENV_NAME"} for runtime configuration.
config :mpx,
mp_base_url: {:system, "MP_HOST"},
mp_username: System.get_env("MP_USERNAME"),
mp_password: {:system, "MP_PASSWORD"},
mp_client_id: {:system, "MP_CLIENT_ID"},
mp_client_secret: {:system, "MP_CLIENT_SECRET"}
Now call
{:ok, token} = Mpx.Authentication.authenticate()
to get a reuseable authentication token.
If you prefer not to use elixir configuration to setup you user credentials:
{:ok, token} = Mpx.Authentication.authenticate(username: "username", password: "password", client_id: "clientid", client_secret: "clientsecret")
See the documentation for more usage details
Development
Install dependencies
mix deps.get
Run application
iex -S mix