diff --git a/lib/solapi/message/service.ex b/lib/solapi/message/service.ex index 90e8f65..c7c9218 100644 --- a/lib/solapi/message/service.ex +++ b/lib/solapi/message/service.ex @@ -89,6 +89,8 @@ defmodule Solapi.Message.Service do |> maybe_add("kakaoOptions", get_field(message, :kakao_options, "kakaoOptions")) |> maybe_add("rcsOptions", get_field(message, :rcs_options, "rcsOptions")) |> maybe_add("customFields", get_field(message, :custom_fields, "customFields")) + |> maybe_add("faxOptions", get_field(message, :fax_options, "faxOptions")) + |> maybe_add("voiceOptions", get_field(message, :voice_options, "voiceOptions")) end defp get_field(message, atom_key, string_key) do diff --git a/mix.exs b/mix.exs index be96126..015c932 100644 --- a/mix.exs +++ b/mix.exs @@ -1,7 +1,7 @@ defmodule Solapi.MixProject do use Mix.Project - @version "0.1.0" + @version "0.1.1" @source_url "https://github.com/solapi/solapi-elixir" def project do diff --git a/test/solapi/message/service_test.exs b/test/solapi/message/service_test.exs index f113f81..6e0dfc5 100644 --- a/test/solapi/message/service_test.exs +++ b/test/solapi/message/service_test.exs @@ -103,6 +103,68 @@ defmodule Solapi.Message.ServiceTest do assert {:error, %Solapi.Error.ValidationError{}} = result end + + test "FAX 메시지 발송 (faxOptions 포함)", %{bypass: bypass, client: client} do + Bypass.expect(bypass, "POST", "/messages/v4/send-many/detail", fn conn -> + {:ok, body, conn} = Plug.Conn.read_body(conn) + decoded = Jason.decode!(body) + + message = hd(decoded["messages"]) + assert message["to"] == "0212345678" + assert message["from"] == "0312345678" + assert message["faxOptions"]["fileIds"] == ["file_id_123", "file_id_456"] + + response = %{ + "groupId" => "G_FAX", + "messageId" => "M_FAX" + } + + conn + |> Plug.Conn.put_resp_content_type("application/json") + |> Plug.Conn.resp(200, Jason.encode!(response)) + end) + + result = + Service.send(client, %{ + to: "0212345678", + from: "0312345678", + fax_options: %{fileIds: ["file_id_123", "file_id_456"]} + }) + + assert {:ok, %{"messageId" => "M_FAX"}} = result + end + + test "음성 메시지 발송 (voiceOptions 포함)", %{bypass: bypass, client: client} do + Bypass.expect(bypass, "POST", "/messages/v4/send-many/detail", fn conn -> + {:ok, body, conn} = Plug.Conn.read_body(conn) + decoded = Jason.decode!(body) + + message = hd(decoded["messages"]) + assert message["to"] == "01012345678" + assert message["from"] == "0212345678" + assert message["text"] == "음성 메시지 테스트입니다." + assert message["voiceOptions"]["voiceType"] == "FEMALE" + + response = %{ + "groupId" => "G_VOICE", + "messageId" => "M_VOICE" + } + + conn + |> Plug.Conn.put_resp_content_type("application/json") + |> Plug.Conn.resp(200, Jason.encode!(response)) + end) + + result = + Service.send(client, %{ + to: "01012345678", + from: "0212345678", + text: "음성 메시지 테스트입니다.", + voice_options: %{voiceType: "FEMALE"} + }) + + assert {:ok, %{"messageId" => "M_VOICE"}} = result + end end describe "send/1 with config" do