Hi All…
I’m new to this, and trying to write a little bit of Elixir what will just make a post call to the SimpliSafe API to read the value of a freeze sensor. I could knock this out any number of ways of course, I’m using Elixir to learn Elixir.
The code I wrote to do it seems okay but I must have missed something because I’m getting the error pasted below. The code is below that. What did I mess up? Also, I understand the code has other issues at the moment. For now I just want it to compile.
Thanks…
$ iex -S mix
== Compilation error in file lib/simplisafe/ssfreeze.ex ==
** (UndefinedFunctionError) function Simplisafe.ssFreeze/0 is undefined or private
Simplisafe.ssFreeze()
(stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
(stdlib) erl_eval.erl:878: :erl_eval.expr_list/6
(stdlib) erl_eval.erl:404: :erl_eval.expr/5
defmodule Simplisafe.ssFreeze do
@user_agent [ { “User-agent”, “Elixir” } ]
def fetch(user, password) do
ss_url
|> do_login(user, password)
|> handle_response
end
defp ss_url do
“https://simplisafe.com/mobile/login/”
end
defp handle_response({ :ok, %{status_code: 200, body: body}}) do
{ :ok, body }
end
defp handle_response({ _, %{status_code: _, body: body}}) do
{ :error, body }
end
defp post_body(user, password) do
%{“name” => "jim@example.com",
“password” => “my_pass”,
“device_name” => “my_iphone”,
“device_uuid” => “51644e80-1b62-11e3-b773-0800200c9a66”,
“version” => “1200”,
“no_persist” => “1”,
“XDEBUG_SESSION_START” => “session_name”,
} |> Poison.encode!
end
defp do_login(url, user, password) do
HTTPoison.post(url, post_body(user, password), %{“Content-Type” => “application/json”})
end
end