Commit 2cbab347b8bd00e8f1cdab7b3375a10a0a795d6a

Stephen Moloney 2016-02-18T22:44:55

change to Webstorage.Request

diff --git a/lib/ovh/openstack_api/webstorage/request.ex b/lib/ovh/openstack_api/webstorage/request.ex
index 9af33a4..5cd5e5f 100644
--- a/lib/ovh/openstack_api/webstorage/request.ex
+++ b/lib/ovh/openstack_api/webstorage/request.ex
@@ -10,18 +10,29 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Request do
 
     {method, uri, options} = Auth.prepare_request(client, query, service)
     resp = HTTPotion.request(method, uri, options)
-    resp =
-    %{
-      body: resp.body |> Poison.decode!(),
-      headers: resp.headers,
-      status_code: resp.status_code
-    }
+    |> Og.log_return(:debug)
 
     if resp.status_code >= 100 and resp.status_code < 300 do
-     {:ok, resp}
+      try do
+        {:ok, %{
+               body: resp.body |> Poison.decode!(),
+               headers: resp.headers,
+               status_code: resp.status_code
+              }
+        }
+      rescue
+        _ ->
+        {:ok, %{
+               body: resp.body,
+               headers: resp.headers,
+               status_code: resp.status_code
+              }
+        }
+      end
     else
      {:error, resp}
     end
+
   end
 
 
diff --git a/lib/query/ovh/webstorage/query.ex b/lib/query/ovh/webstorage/query.ex
index 3a22bc8..73e1539 100644
--- a/lib/query/ovh/webstorage/query.ex
+++ b/lib/query/ovh/webstorage/query.ex
@@ -34,7 +34,7 @@ defmodule ExOvh.Query.Ovh.Webstorage do
 
       import ExOvh.Query.Ovh.Webstorage
       service_name = "cdnwebstorage-????"
-      resp = ExOvh.ovh_request(get_webstorage_service(service_name), %{})
+      {:ok, resp} = ExOvh.ovh_request(get_webstorage_service(service_name), %{})
       %{
         "domain" => domain,
         "storageLimit => storage_limit,
@@ -54,7 +54,7 @@ defmodule ExOvh.Query.Ovh.Webstorage do
 
       import ExOvh.Query.Ovh.Webstorage
       service_name = "cdnwebstorage-????"
-      resp = ExOvh.ovh_request(get_webstorage_service_info(service_name), %{})
+      {:ok, resp} = ExOvh.ovh_request(get_webstorage_service_info(service_name), %{})
   """
   @spec get_webstorage_service_info(service_name :: String.t)
                                :: ExOvh.Client.raw_query_t
@@ -72,7 +72,7 @@ defmodule ExOvh.Query.Ovh.Webstorage do
 
       import ExOvh.Query.Ovh.Webstorage
       # service_name = "cdnwebstorage-????"
-      resp = ExOvh.ovh_request(get_webstorage_service_stats(service_name, "month", "backend"), %{})
+      {:ok, resp} = ExOvh.ovh_request(get_webstorage_service_stats(service_name, "month", "backend"), %{})
   """
   @spec get_webstorage_service_stats(service_name :: String.t, period :: String.t, type :: String.t)
                                :: ExOvh.Client.raw_query_t
@@ -89,7 +89,7 @@ defmodule ExOvh.Query.Ovh.Webstorage do
 
       import ExOvh.Query.Ovh.Webstorage
       # service_name = "cdnwebstorage-????"
-      resp = ExOvh.ovh_request(get_webstorage_credentials(service_name), %{})
+      {:ok, resp} = ExOvh.ovh_request(get_webstorage_credentials(service_name), %{})
   """
   @spec get_webstorage_credentials(service_name :: String.t)
                                :: ExOvh.Client.raw_query_t