Packages
smppex
0.2.1
3.3.0
3.2.4
3.2.3
3.2.2
3.2.1
3.2.0
retired
3.1.0
retired
3.0.6
3.0.5
3.0.4
3.0.3
3.0.2
3.0.1
3.0.0
2.4.0
2.3.3
2.3.2
2.3.1
2.3.0
2.2.9
2.2.8
2.2.7
2.2.6
2.2.5
2.2.4
2.2.3
2.2.2
2.2.1
2.2.0
2.1.0
2.0.1
2.0.0
1.0.1
0.3.2
0.3.1
0.3.0
0.2.1
0.2.0
0.1.12
0.1.11
0.1.10
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1
SMPP 3.4 protocol and framework implemented in Elixir
Current section
Files
Jump to
Current section
Files
lib/smppex/pdu/message_state.ex
defmodule SMPPEX.Pdu.MessageState do
@moduledoc """
Module for operating with `deliver_sm` message states.
"""
statuses = [
{:ENROUTE, 1},
{:DELIVERED, 2},
{:EXPIRED, 3},
{:DELETED, 4},
{:UNDELIVERABLE, 5},
{:ACCEPTED, 6},
{:UNKNOWN, 7},
{:REJECTED, 8}
]
@type state :: integer
@type state_name :: atom
@spec code_by_name(state_name) :: state
@doc """
Converts atom representing message state to integer value.
## Example
iex(1)> SMPPEX.Pdu.MessageState.code_by_name(:DELIVERED)
2
"""
def code_by_name(state_name)
@spec format(state) :: String.t
@doc """
Converts integer message state value to string representation.
## Example
iex(1)> SMPPEX.Pdu.MessageState.format(2)
"DELIVERED"
iex(2)> SMPPEX.Pdu.MessageState.format(12345)
"12345"
"""
def format(state)
Enum.each statuses, fn({name, code}) ->
def code_by_name(unquote(name)), do: unquote(code)
def format(unquote(code)), do: unquote(to_string(name))
end
def format(code) when is_integer(code), do: to_string(code)
end