Created
July 14, 2023 04:11
-
-
Save denielchiang/e2718a3f24b1e4c6ca7ee0ce9d385d96 to your computer and use it in GitHub Desktop.
helpers/line.ex - first version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@spec send_to_group(String.t()) :: {:ok, String.t()} | {:error, String.t()} | |
def send_to_group(msg) do | |
Req.new(url: "https://notify-api.line.me/api/notify",) | |
|> Req.Request.put_header("Content-Type", "application/x-www-form-urlencoded") | |
|> Req.post( | |
auth: {:bearer, Application.fetch_env!(:line_reminder, :line_token)}, | |
form: [message: msg] | |
) | |
|> case do | |
{:ok, %Req.Response{status: 200}} -> | |
{:ok, "Topic already be sent"} | |
{:ok, _others} -> | |
{:error, "connected but something going wrong"} | |
{:error, _others} -> | |
{:error, "connection failure happen"} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment