process_request_options(options)
|> process_sni_options(url)
+ params = Keyword.get(options, :params, [])
+
%{}
|> Builder.method(method)
|> Builder.headers(headers)
|> Builder.opts(options)
|> Builder.url(url)
|> Builder.add_param(:body, :body, body)
+ |> Builder.add_param(:query, :query, params)
|> Enum.into([])
|> (&Tesla.request(Connection.new(), &1)).()
end
Map
"""
@spec add_param(map(), atom, atom, any()) :: map()
+ def add_param(request, :query, :query, values), do: Map.put(request, :query, values)
+
def add_param(request, :body, :body, value), do: Map.put(request, :body, value)
def add_param(request, :body, key, value) do
|> Map.put_new_lazy(:body, &Tesla.Multipart.new/0)
|> Map.update!(
:body,
- &Tesla.Multipart.add_field(&1, key, Poison.encode!(value),
+ &Tesla.Multipart.add_field(
+ &1,
+ key,
+ Jason.encode!(value),
headers: [{:"Content-Type", "application/json"}]
)
)