 defmodule SMPPEX.Pdu do
   alias SMPPEX.Protocol.CommandNames
+  alias SMPPEX.Pdu
 
   defstruct [
     command_id: 0,

  def new(command_id, command_status, sequence_number) do
    case CommandNames.name_by_id(command_id) do
      {:ok, name} ->
        {:ok, %SMPPEX.Pdu{
          command_id: command_id,
          command_name: name,
          command_status: command_status,
          sequence_number: sequence_number
        }}
      :unknown ->
        {:unknown, %SMPPEX.Pdu{
          command_id: command_id,
          command_status: command_status,
          sequence_number: sequence_number,

  end

  def set_body(pdu, body) do
    %Pdu{ pdu | body: body }
  end

  def set_mandatory_fields(pdu, fields) do
    %Pdu{ pdu | mandatory: fields }
  end

  def set_optional_fields(pdu, tlvs) do
    %Pdu{ pdu | optional: tlvs }
  end
end
