Skip to content

Latest commit

 

History

History
94 lines (63 loc) · 2.93 KB

File metadata and controls

94 lines (63 loc) · 2.93 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

SOLAPI SDK for Elixir - provides SMS, LMS, MMS, 카카오 알림톡/친구톡 messaging capabilities via the SOLAPI REST API.

Development Commands

# Install dependencies
mix deps.get

# Run all tests
mix test

# Run a single test file
mix test test/solapi/auth/hmac_test.exs

# Run a specific test by line number
mix test test/solapi_test.exs:27

# Format code
mix format

# Static analysis
mix dialyzer

# Code linting
mix credo

# Generate documentation
mix docs

Architecture

Core Modules

  • Solapi (lib/solapi.ex) - Main facade module providing client/1 and send/1,2 functions
  • Solapi.Http.Client (lib/solapi/http/client.ex) - Req-based HTTP client with automatic retry (exponential backoff), HMAC authentication, and JSON handling
  • Solapi.Message.Service (lib/solapi/message/service.ex) - Message sending service; all messages route through /messages/v4/send-many/detail endpoint
  • Solapi.Auth.Hmac (lib/solapi/auth/hmac.ex) - HMAC-SHA256 authentication header generation (format: HMAC-SHA256 apiKey=..., date=..., salt=..., signature=...)
  • Solapi.Config (lib/solapi/config.ex) - Application configuration wrapper

Error Types

  • Solapi.Error.ApiError - API response errors (status, code, message)
  • Solapi.Error.ValidationError - Input validation errors (message, field)
  • Solapi.Error.NetworkError - Transport/connection errors (reason, retries_exhausted)

Usage Patterns

Two ways to use the SDK:

  1. Application config (reads from :solapi app config):

    Solapi.send(%{to: "...", from: "...", text: "..."})
  2. Explicit client (runtime credentials):

    client = Solapi.client(api_key: "key", api_secret: "secret")
    Solapi.send(client, %{to: "...", from: "...", text: "..."})

Configuration

Set via environment variables in config/runtime.exs:

  • SOLAPI_API_KEY - API key
  • SOLAPI_API_SECRET - API secret

Or programmatically via Solapi.Config.put/2.

Testing

Tests use Bypass to mock HTTP responses. See test/solapi_test.exs for integration test patterns.

Coding Standards

Tidy First principles are automatically applied when implementing new features, refactoring, or making code changes. Claude Code will proactively invoke the tidy-first agent to:

  1. Analyze code for tidying opportunities before changes
  2. Separate structural changes from behavioral changes
  3. Follow TDD workflow (Red → Green → Refactor)
  4. Detect risk signals (scope creep, unnecessary complexity)

See .claude/agents/tidy-first/AGENT.md for detailed guidelines.

Quick Reference

  • Structural changes (tidyings): Guard Clauses, Extract Helper, Rename, etc.
  • Behavioral changes (features): Actual functionality changes
  • Rule: These MUST be in separate commits