exNoops v0.1.1 Exnoops.Fizzbot View Source
Module to interact with Github's Noop: Fizzbot
See the official noop
documentation for API information
Link to this section Summary
Link to this section Functions
Link to this function
answer_question(question_id, answer) View Source
Submit an answer to Fizzbot
Examples
iex> Exnoops.Fizzbot.answer_question(1, %{"answer" => "COBOL"})
{:ok,
%{
"result" => "correct",
"message" => "Of course. How interesting. Are you ready for your first REAL question?",
"nextQuestion" => "/fizzbot/questions/1234567"
}
}
Link to this function
ask_question(question_id \\ 0) View Source
Query Fizzbot for a question
If you don't provide a question number, it will query the default endpoint which returns the instructions.
Note: Due to the many possible keys in each response, minimal processing will occur.
Examples
iex> Exnoops.Fizzbot.ask_question()
{:ok,
%{
"message" => "Thank you for your application to Noops Inc.\n\nOur automated fizzbot interview process will help us determine if you have what it takes to become a Noop.\n\nFor each question, you will GET the question and then give us the answer back to the same URL.\nYou will also find the URL for the next question in the nextQuestion parameter for each response.\n\nThe first question is at https://api.noopschallenge.com/fizzbot/questions/1.\n\nGood Luck\n",
"nextQuestion" => "/fizzbot/questions/1"
}
}
iex> Exnoops.Fizzbot.ask_question(1)
{:ok,
%{
"message" => "What is your favorite programming language?\nMine is COBOL, of course.\nPOST your answer back to this URL in JSON format. If you are having difficulties, see the exampleResponse provided.",
"exampleResponse" => %{ "answer" => "COBOL" }
}
}
iex> Exnoops.Fizzbot.ask_question(1234567)
{:ok,
%{
"message" => "FizzBuzz is the name of the game.\nHere's a list of numbers.\nSend me back a string as follows:\nFor each number:\nIf it is divisible by 3, print \"Fizz\".\nIf it is divisible by 5, print \"Buzz\".\nIf it is divisible by 3 and 5, print \"FizzBuzz\".\nOtherwise, print the number.\n\nEach entry in the string should be separated by a space.\n\nFor example, if the numbers are [1, 2, 3, 4, 5], you would send back:\n\n{\n \"answer\": \"1 2 Fizz 4 Buzz\"\n}\n",
"rules" => [
%{ "number" => 3, "response" => "Fizz" },
%{ "number" => 5, "response" => "Buzz" }
],
"numbers" => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ],
"exampleResponse" => %{ "answer" => "1 2 Fizz 4 Buzz..." }
}
}