-
Notifications
You must be signed in to change notification settings - Fork 0
SOLAPI Elixir SDK 0.1.1 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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"]} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Elixir에서는 원자(atom) 키에 대해 스네이크 케이스(snake_case)를 사용하는 것이 일반적인 컨벤션입니다. |
||
| }) | ||
|
|
||
| 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"} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| }) | ||
|
|
||
| assert {:ok, %{"messageId" => "M_VOICE"}} = result | ||
| end | ||
| end | ||
|
|
||
| describe "send/1 with config" do | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트 코드에서 제안된 스네이크 케이스 원자 키(
:file_ids,:voice_type)를 API가 요구하는 카멜 케이스 문자열 키(fileIds,voiceType)로 변환하기 위해, 옵션 맵의 키를 변환하는 로직을 추가해야 합니다. 이렇게 하면 Elixir 코드베이스에서는 일관된 스네이크 케이스를 유지하면서 외부 API와의 연동을 원활하게 할 수 있습니다.아래와 같이 키를 변환하는 함수를 호출하도록 변경하고, 해당 함수를 모듈 내에 비공개 함수로 추가하는 것을 제안합니다.
추가할 헬퍼 함수 예시:
transform_option_keys/1함수는kakaoOptions,rcsOptions등 다른 옵션에도 일관되게 적용하여 라이브러리 전반의 일관성을 높일 수 있습니다.