Packages
ndc_ex_sdk
0.2.14
0.2.30
0.2.29
0.2.27
0.2.26
0.2.25
0.2.24
0.2.23
0.2.22
0.2.21
0.2.20
0.2.19
0.2.18
0.2.17
0.2.16
0.2.15
0.2.14
0.2.13
0.2.12
0.2.11
0.2.10
0.2.9
0.2.8
0.2.7
0.2.6
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
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.10
0.0.9
0.0.8
0.0.7
0.0.6
0.0.5
0.0.4
0.0.3
0.0.2
0.0.1
This is an Elixir package that wrapps any NDC-compliant API. It's host-agnostic and quite flexible-through-configuration so that it can reach NDC hosts with a certain flexibility
Current section
Files
Jump to
Current section
Files
lib/message/soap_helper.ex
defmodule SoapHelper do
#require Tuple
defp get_attributes(method, config, type) do
if !is_nil(config[:attributes][:all]) do
method = :all;
end
if !is_nil(config[:attributes][method][type]) do
for {key, val} <- config[:attributes][method][type], into: %{}, do: {String.to_atom(key), val}
else
%{}
end
end
defp change_credential({header, nil, [{transaction, attr_trans, [{tc, nil, [{iden, t}, trace, script]}]}]}, credential) do
#IO.inspect(Enum.to_list(t));
{header, nil, [{transaction, attr_trans, [{tc, nil, [{iden, t}, trace, script]}]}]}
#{transaction, attr_trans, [tc, nil, [{iden, Tuple.append(t, agt: credential)}, trace, script]]}
end
defp get_soap_header(config, credential) when config == nil, do: {}
defp get_soap_header(config, credential), do: change_credential(config, credential)
#defp fix_structure({type, attrs, [document]}), do: [{type, attrs, document}]
defp fix_structure({type, attrs, document}), do: [{type, attrs, document}]
def add_soap(xml, config, method, credential) when config == nil, do: xml
def add_soap(xml, config, method, credential) when config != nil do
if(!is_nil(config[:soap_header])) do
{:"#{config[:request_namespace]}:Envelope", get_attributes(method, config, :envelope),[get_soap_header(config[:soap_header], credential), {:"#{config[:request_namespace]}:Body", get_attributes(method, config, :body), Tuple.to_list(xml)}]}
else
{:"#{config[:request_namespace]}:Envelope", get_attributes(method, config, :envelope),[{:"#{config[:request_namespace]}:Body", get_attributes(method, config, :body), fix_structure(xml)}]}
end
end
end