Commit 9f55d35568f24bb6e8b0bebf958519d8b7e5cd22

Stephen Moloney 2017-03-02T22:42:00

fix bug encoding query string

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 95a8c96..067ac29 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,11 @@
 # Changelog
 
 
+## v0.3.2
+
+[bug fix]
+- Fix setting the query string bug (typo) - `url.encode_query(qs_map)` -> `URI.encode_query(qs_map)`
+
 ## v0.3.1
 
 [changes]
diff --git a/lib/ex_ovh/transformation/url.ex b/lib/ex_ovh/transformation/url.ex
index a49b4b4..56348ae 100644
--- a/lib/ex_ovh/transformation/url.ex
+++ b/lib/ex_ovh/transformation/url.ex
@@ -14,19 +14,15 @@ defmodule ExOvh.Transformation.Url do
     |> Map.put(:completed_transformations, trans ++ [:url])
   end
   @spec apply(HTTPipe.Conn.t, map, atom) :: HTTPipe.Conn.t
-  def apply(%HTTPipe.Conn{request: %HTTPipe.Request{url: url}} = conn, query_string, client) when query_string == %{} do
-    ovh_config = client.ovh_config()
-    trans = Map.get(conn, :completed_transformations, [])
-    url = ovh_config[:endpoint] <> ovh_config[:api_version] <> url
-    request = Map.put(conn.request, :url, url)
-    Map.put(conn, :request, request)
-    |> Map.put(:completed_transformations, trans ++ [:url])
+  def apply(%HTTPipe.Conn{request: %HTTPipe.Request{url: url}} = conn, query_string_map, client) when query_string_map == %{} do
+    apply(conn, client)
   end
-  def apply(%HTTPipe.Conn{request: %HTTPipe.Request{url: url}} = conn, query_string, client) do
+  def apply(%HTTPipe.Conn{request: %HTTPipe.Request{url: url}} = conn, query_string_map, client) do
     ovh_config = client.ovh_config()
     trans = Map.get(conn, :completed_transformations, [])
-    url = ovh_config[:endpoint] <> ovh_config[:api_version] <> url <> "?" <> (query_string |> url.encode_query())
+    url = ovh_config[:endpoint] <> ovh_config[:api_version] <> url
     request = Map.put(conn.request, :url, url)
+    |> add_query_string(query_string_map)
     Map.put(conn, :request, request)
     |> Map.put(:completed_transformations, trans ++ [:url])
   end
@@ -34,7 +30,7 @@ defmodule ExOvh.Transformation.Url do
 
   @doc ~S"""
   Add the request string to a request from a map of `name`=`value` elements. Use instead of
-  `ExOvh.Transformation.url.apply/3` when the `client` is not available but the request should
+  `ExOvh.Transformation.Url.apply/3` when the `client` is not available but the request should
   be modified without marking it as fully `transformed` with :url.
 
   To be used for GET requests.
@@ -53,7 +49,7 @@ defmodule ExOvh.Transformation.Url do
   @spec add_query_string(HTTPipe.Request.t, map) :: HTTPipe.Request.t
   def add_query_string(%HTTPipe.Request{} = request, qs_map) when qs_map == %{}, do: request
   def add_query_string(%HTTPipe.Request{url: url} = request, qs_map) do
-    url = url <> "?" <> url.encode_query(qs_map)
+    url = url <> "?" <> URI.encode_query(qs_map)
     Map.put(request, :url, url)
   end
 
diff --git a/lib/ex_ovh/v1/cloud.ex b/lib/ex_ovh/v1/cloud.ex
index c917754..9393d01 100644
--- a/lib/ex_ovh/v1/cloud.ex
+++ b/lib/ex_ovh/v1/cloud.ex
@@ -1,6 +1,6 @@
 defmodule ExOvh.V1.Cloud do
   @moduledoc ~s"""
-  Helper functions for building queries directed at the cloudstorage related parts of the `/cloud` part of the [OVH API](https://api.ovh.com/console/).
+  Helper functions for building requests directed at the cloudstorage related parts of the `/cloud` part of the [OVH API](https://api.ovh.com/console/).
 
   See `ExOvh.V1.Cloud` for generic cloud requests.
 
diff --git a/mix.exs b/mix.exs
index 59a727e..eb53f6a 100644
--- a/mix.exs
+++ b/mix.exs
@@ -1,6 +1,6 @@
 defmodule ExOvh.Mixfile do
   use Mix.Project
-  @version "0.3.1"
+  @version "0.3.2"
   @elixir ">= 1.2.0"
 
   def project do