# SOLAPI SDK for Elixir
> [!CAUTION]
> **Experimental** - 이 SDK는 현재 실험 단계입니다. API가 예고 없이 변경될 수 있으며, 프로덕션 환경에서의 사용은 권장하지 않습니다. 피드백은 [GitHub Discussions](https://github.com/orgs/solapi/discussions)에 남겨주세요!
SMS, LMS, MMS, 카카오 알림톡/친구톡 발송을 지원하는 SOLAPI 공식 Elixir SDK입니다.
## 빠른 시작
**1. 의존성 추가** (`mix.exs`):
```elixir
def deps do
[{:solapi, "~> 0.1.0"}]
end
```
**2. 환경 변수 설정**:
```bash
export SOLAPI_API_KEY="your_api_key"
export SOLAPI_API_SECRET="your_api_secret"
```
**3. 메시지 발송**:
```elixir
Solapi.send(%{to: "01012345678", from: "0212345678", text: "안녕하세요!"})
```
> **사전 준비**: [API 키 발급](https://console.solapi.com/credentials) | [발신번호 등록](https://console.solapi.com/senderids)
## 설정
### 환경 변수 (권장)
`config/runtime.exs`:
```elixir
config :solapi,
api_key: System.get_env("SOLAPI_API_KEY"),
api_secret: System.get_env("SOLAPI_API_SECRET")
```
### 런타임 클라이언트
```elixir
client = Solapi.client(api_key: "key", api_secret: "secret")
Solapi.send(client, %{to: "01012345678", from: "0212345678", text: "안녕하세요!"})
```
## 사용법
### SMS
```elixir
Solapi.send(%{to: "01012345678", from: "0212345678", text: "안녕하세요!"})
```
### LMS (장문)
```elixir
Solapi.send(%{to: "01012345678", from: "0212345678", subject: "공지", text: "장문 메시지..."})
```
### MMS (이미지)
```elixir
Solapi.send(%{to: "01012345678", from: "0212345678", type: "MMS", text: "내용", image_id: "IMG_ID"})
```
### 카카오 알림톡
```elixir
Solapi.send(%{
to: "01012345678",
from: "0212345678",
kakao_options: %{
"pfId" => "KA01PF...",
"templateId" => "KA01TP...",
"variables" => %{"#{고객명}" => "홍길동"}
}
})
```
### 대량 발송
```elixir
messages = [
%{to: "01012345678", from: "0212345678", text: "메시지 1"},
%{to: "01087654321", from: "0212345678", text: "메시지 2"}
]
Solapi.send(client, messages)
```
## 에러 처리
| 타입 | 설명 |
|------|------|
| `Solapi.Error.ValidationError` | 필수 파라미터 누락 |
| `Solapi.Error.ApiError` | API 응답 에러 (인증 실패 등) |
| `Solapi.Error.NetworkError` | 네트워크 오류 |
```elixir
case Solapi.send(message) do
{:ok, response} -> IO.puts("성공: #{response["messageId"]}")
{:error, %Solapi.Error.ApiError{message: msg}} -> IO.puts("실패: #{msg}")
{:error, error} -> IO.puts("에러: #{inspect(error)}")
end
```
## 문서
- **예제**: [examples/](./examples)
- **API 문서**: [HexDocs](https://hexdocs.pm/solapi)
- **SOLAPI 문서**: [developers.solapi.com](https://developers.solapi.com)
## 라이선스
MIT License - [LICENSE](./LICENSE)