Skip to content

Commit 4d58198

Browse files
Merge pull request #1 from solapi/impr/add-fax-and-voice-messages
SOLAPI Elixir SDK 0.1.1
2 parents 2856aa1 + eaeb000 commit 4d58198

File tree

3 files changed

+65
-1
lines changed

3 files changed

+65
-1
lines changed

lib/solapi/message/service.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ defmodule Solapi.Message.Service do
8989
|> maybe_add("kakaoOptions", get_field(message, :kakao_options, "kakaoOptions"))
9090
|> maybe_add("rcsOptions", get_field(message, :rcs_options, "rcsOptions"))
9191
|> maybe_add("customFields", get_field(message, :custom_fields, "customFields"))
92+
|> maybe_add("faxOptions", get_field(message, :fax_options, "faxOptions"))
93+
|> maybe_add("voiceOptions", get_field(message, :voice_options, "voiceOptions"))
9294
end
9395

9496
defp get_field(message, atom_key, string_key) do

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
defmodule Solapi.MixProject do
22
use Mix.Project
33

4-
@version "0.1.0"
4+
@version "0.1.1"
55
@source_url "https://github.com/solapi/solapi-elixir"
66

77
def project do

test/solapi/message/service_test.exs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,68 @@ defmodule Solapi.Message.ServiceTest do
103103

104104
assert {:error, %Solapi.Error.ValidationError{}} = result
105105
end
106+
107+
test "FAX 메시지 발송 (faxOptions 포함)", %{bypass: bypass, client: client} do
108+
Bypass.expect(bypass, "POST", "/messages/v4/send-many/detail", fn conn ->
109+
{:ok, body, conn} = Plug.Conn.read_body(conn)
110+
decoded = Jason.decode!(body)
111+
112+
message = hd(decoded["messages"])
113+
assert message["to"] == "0212345678"
114+
assert message["from"] == "0312345678"
115+
assert message["faxOptions"]["fileIds"] == ["file_id_123", "file_id_456"]
116+
117+
response = %{
118+
"groupId" => "G_FAX",
119+
"messageId" => "M_FAX"
120+
}
121+
122+
conn
123+
|> Plug.Conn.put_resp_content_type("application/json")
124+
|> Plug.Conn.resp(200, Jason.encode!(response))
125+
end)
126+
127+
result =
128+
Service.send(client, %{
129+
to: "0212345678",
130+
from: "0312345678",
131+
fax_options: %{fileIds: ["file_id_123", "file_id_456"]}
132+
})
133+
134+
assert {:ok, %{"messageId" => "M_FAX"}} = result
135+
end
136+
137+
test "음성 메시지 발송 (voiceOptions 포함)", %{bypass: bypass, client: client} do
138+
Bypass.expect(bypass, "POST", "/messages/v4/send-many/detail", fn conn ->
139+
{:ok, body, conn} = Plug.Conn.read_body(conn)
140+
decoded = Jason.decode!(body)
141+
142+
message = hd(decoded["messages"])
143+
assert message["to"] == "01012345678"
144+
assert message["from"] == "0212345678"
145+
assert message["text"] == "음성 메시지 테스트입니다."
146+
assert message["voiceOptions"]["voiceType"] == "FEMALE"
147+
148+
response = %{
149+
"groupId" => "G_VOICE",
150+
"messageId" => "M_VOICE"
151+
}
152+
153+
conn
154+
|> Plug.Conn.put_resp_content_type("application/json")
155+
|> Plug.Conn.resp(200, Jason.encode!(response))
156+
end)
157+
158+
result =
159+
Service.send(client, %{
160+
to: "01012345678",
161+
from: "0212345678",
162+
text: "음성 메시지 테스트입니다.",
163+
voice_options: %{voiceType: "FEMALE"}
164+
})
165+
166+
assert {:ok, %{"messageId" => "M_VOICE"}} = result
167+
end
106168
end
107169

108170
describe "send/1 with config" do

0 commit comments

Comments
 (0)