 defmodule ExMoney.Saltedge.Client do
-
-  @client_id Application.get_env(:ex_money, :saltedge_client_id)
-  @service_secret Application.get_env(:ex_money, :saltedge_service_secret)
   @base_url "https://www.saltedge.com/api/v2/"
 
   @doc """

      {"Content-type", "application/json"},
      {"Expires-at", expires_at},
      {"Signature", signature(request)},
      {"Client-id", @client_id},
      {"Service-secret", @service_secret}
    ]

    {:ok, response} = HTTPoison.request(method, url, body, headers)

  iex> ExMoney.SaltedgeClient.request(:post, "logins", body)
  """
  def request(method, endpoint, body \\ "") do
    client_id = Application.get_env(:ex_money, :saltedge_client_id)
    service_secret = Application.get_env(:ex_money, :saltedge_service_secret)

    url = @base_url <> endpoint
    str_method = to_string(method) |> String.upcase
    request = "#{expires_at}|#{str_method}|#{url}|#{body}"
