Current section

Files

Jump to
ndc_ex_sdk lib message ndc_merge.ex
Raw

lib/message/ndc_merge.ex

defmodule NDCMerge do
def get_headers(headers, method) do
Enum.map(headers, fn ({key, value}) ->
{key, String.replace(value, "{{NDC-method}}", method)}
end)
end
def get_method_headers(generic_h, nil), do: generic_h
def get_method_headers(generic_h, method_h), do: generic_h ++ method_h
def get_headers_consumer(headers, nil), do: headers
def get_headers_consumer(headers, consumer), do: headers ++ consumer
def getData(data, nil), do: data
def getData(data, credentials), do: data ++ credentials
def is_ssl(config, path) when config == nil or path == nil, do: [timeout: 60000, recv_timeout: 60000]
def is_ssl(ssl_config, path) when ssl_config != nil do
path = "#{path}keys/"
[
timeout: 60000,
recv_timeout: 60000,
hackney: [
ssl_options: [
cacertfile: path <> ssl_config["cacertfile"], # CA certificate used to validate server cert; path(), "string" is ok
certfile: path <> ssl_config["certfile"], # client certificate, signed by CA; path(), "string" is ok
keyfile: path <> ssl_config["keyfile"], # private key for client.crt; path(). "string" is ok
password: ssl_config["password"] # password for keyfile; string(), "string" not ok, use 'char list'
]
]
]
end
end