diff --git a/config/dev.exs b/config/dev.exs deleted file mode 100644 index d38828d..0000000 --- a/config/dev.exs +++ /dev/null @@ -1,3 +0,0 @@ -use Mix.Config - -config :smartsheet, client: Smartsheet.MockClient diff --git a/config/prod.exs b/config/prod.exs deleted file mode 100644 index d4752d9..0000000 --- a/config/prod.exs +++ /dev/null @@ -1,3 +0,0 @@ -use Mix.Config - -config :smartsheet, client: Smartsheet.Client diff --git a/config/test.exs b/config/test.exs index d38828d..a519467 100644 --- a/config/test.exs +++ b/config/test.exs @@ -1,3 +1,3 @@ use Mix.Config -config :smartsheet, client: Smartsheet.MockClient +config :smartsheet, api_key: "Test123" diff --git a/lib/smartsheet/mock_client/mock_client.ex b/lib/smartsheet/mock_client/mock_client.ex deleted file mode 100644 index 9327cbb..0000000 --- a/lib/smartsheet/mock_client/mock_client.ex +++ /dev/null @@ -1,47 +0,0 @@ -defmodule Smartsheet.MockClient do - def get("/sheets/get_sheet_fail_id", _header, _options) do - Smartsheet.MockClient.ResponseFixtures.get_sheet_failure("get_sheet_fail_id") - end - - def get("/sheets/" <> id, _headers, _options) do - Smartsheet.MockClient.ResponseFixtures.get_sheet_success(id) - end - - def post("/sheets", _attributes, _headers) do - Smartsheet.MockClient.ResponseFixtures.create_sheet_success() - end - - def post("/sheets/:id/rows", rows, _headers) do - Smartsheet.MockClient.ResponseFixtures.add_rows_success(rows) - end - - def post("/sheets/" <> suffix, attributes, headers) do - case String.split(suffix, "/") do - ["add_rows_fail_id", "rows"] -> - Smartsheet.MockClient.ResponseFixtures.add_rows_failure() - - [_id, "rows"] -> - Smartsheet.MockClient.post("/sheets/:id/rows", attributes, headers) - - _ -> - nil - end - end - - def put("/sheets/:id/rows", rows, _headers) do - Smartsheet.MockClient.ResponseFixtures.update_rows_success(rows) - end - - def put("/sheets/" <> suffix, attributes, headers) do - case String.split(suffix, "/") do - ["update_rows_fail_id", "rows"] -> - Smartsheet.MockClient.ResponseFixtures.update_rows_failure() - - [_id, "rows"] -> - Smartsheet.MockClient.put("/sheets/:id/rows", attributes, headers) - - _ -> - nil - end - end -end diff --git a/lib/smartsheet/mock_client/request_fixtures.ex b/lib/smartsheet/mock_client/request_fixtures.ex deleted file mode 100644 index 31741b1..0000000 --- a/lib/smartsheet/mock_client/request_fixtures.ex +++ /dev/null @@ -1,25 +0,0 @@ -defmodule Smartsheet.MockClient.RequestFixtures do - def create_sheet_success() do - columns = [ - %{ - primary: true, - title: "Column_1", - type: Smartsheet.Column.ColumnType.text_number() - } - ] - - %{name: "Create Sheet Success", columns: columns} - end - - def create_sheet_failure() do - columns = [ - %{ - primary: false, - title: "Column_1", - type: Smartsheet.Column.ColumnType.text_number() - } - ] - - %{name: "Create Sheet Failure", columns: columns} - end -end diff --git a/lib/smartsheet/parse_response.ex b/lib/smartsheet/parse_response.ex index c7140bf..85234b1 100644 --- a/lib/smartsheet/parse_response.ex +++ b/lib/smartsheet/parse_response.ex @@ -89,12 +89,12 @@ defmodule Smartsheet.ParseResponse do Enum.map(columns, fn column -> struct(Smartsheet.Column, column) end) end - def success_response(response = %HTTPoison.Response{}, data) do + defp success_response(response = %HTTPoison.Response{}, data) do formatted_response = Smartsheet.Response.format(response) {:ok, formatted_response, data} end - def error_response(response = %HTTPoison.Response{}) do + defp error_response(response = %HTTPoison.Response{}) do formatted_response = Smartsheet.Response.format(response) {:error, formatted_response} end diff --git a/lib/smartsheet/mock_client/response_fixtures.ex b/lib/smartsheet/response_fixtures.ex similarity index 100% rename from lib/smartsheet/mock_client/response_fixtures.ex rename to lib/smartsheet/response_fixtures.ex diff --git a/mix.exs b/mix.exs index 73d7e44..6feb93f 100644 --- a/mix.exs +++ b/mix.exs @@ -6,7 +6,7 @@ defmodule Smartsheet.MixProject do app: :smartsheet, description: "HTTP wrapper around the Smartsheet API", package: package(), - version: "2.0.0", + version: "2.1.0", elixir: "~> 1.10", start_permanent: Mix.env() == :prod, deps: deps() diff --git a/test/smartsheet/http_client_test.exs b/test/smartsheet/http_client_test.exs index 5d31793..c8924a4 100644 --- a/test/smartsheet/http_client_test.exs +++ b/test/smartsheet/http_client_test.exs @@ -81,7 +81,7 @@ defmodule Smartsheet.HttpClientTest do test "it appends Authorization Headers" do headers = {"Content-Type", "application/json"} - assert [{:Authorization, "Bearer "} | {"Content-Type", "application/json"}] == + assert [{:Authorization, "Bearer Test123"} | {"Content-Type", "application/json"}] == HttpClient.process_request_headers(headers) end end