diff --git a/README.md b/README.md index d226f76..ac655a9 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ dependencies in `mix.exs`: ```elixir def deps do - [{:exquickbooks, "~> 0.4.0"}] + [{:exquickbooks, "~> 0.5.0"}] end ``` diff --git a/config/test.exs b/config/test.exs index 65804eb..5d875e6 100644 --- a/config/test.exs +++ b/config/test.exs @@ -1,6 +1,6 @@ use Mix.Config config :exquickbooks, - backend: ExQuickBooks.MockBackend, + backend: ExQuickBooks.Backend.Mock, consumer_key: "key", consumer_secret: "secret" diff --git a/lib/exquickbooks/item.ex b/lib/exquickbooks/api/item.ex similarity index 88% rename from lib/exquickbooks/item.ex rename to lib/exquickbooks/api/item.ex index 867601f..5533f07 100644 --- a/lib/exquickbooks/item.ex +++ b/lib/exquickbooks/api/item.ex @@ -1,4 +1,4 @@ -defmodule ExQuickBooks.Item do +defmodule ExQuickBooks.API.Item do @moduledoc """ Functions for interacting with the Item API. @@ -7,9 +7,9 @@ defmodule ExQuickBooks.Item do """ use ExQuickBooks.Endpoint, base_url: ExQuickBooks.accounting_api - use ExQuickBooks.JSONEndpoint + use ExQuickBooks.Endpoint.JSON - alias ExQuickBooks.AccessToken + alias ExQuickBooks.OAuth.AccessToken @doc """ Creates an item. @@ -40,7 +40,7 @@ defmodule ExQuickBooks.Item do Updates and retrieves an item. The item map must define all of the keys in the full item map returned by - `read_item/3`, otherwise the omitted values are set to their default values + `read_item/2`, otherwise the omitted values are set to their default values or NULL. """ @spec update_item(AccessToken.t, json_map) :: diff --git a/lib/exquickbooks/preferences.ex b/lib/exquickbooks/api/preferences.ex similarity index 90% rename from lib/exquickbooks/preferences.ex rename to lib/exquickbooks/api/preferences.ex index 1a1287e..8e433b6 100644 --- a/lib/exquickbooks/preferences.ex +++ b/lib/exquickbooks/api/preferences.ex @@ -1,4 +1,4 @@ -defmodule ExQuickBooks.Preferences do +defmodule ExQuickBooks.API.Preferences do @moduledoc """ Functions for interacting with the Preferences API. @@ -7,9 +7,9 @@ defmodule ExQuickBooks.Preferences do """ use ExQuickBooks.Endpoint, base_url: ExQuickBooks.accounting_api - use ExQuickBooks.JSONEndpoint + use ExQuickBooks.Endpoint.JSON - alias ExQuickBooks.AccessToken + alias ExQuickBooks.OAuth.AccessToken @doc """ Retrieves preferences for the realm. @@ -26,7 +26,7 @@ defmodule ExQuickBooks.Preferences do Updates and retrieves preferences for the realm. This operation performs a full update. The preferences map must define all of - the keys in the full preferences map returned by `read_preferences/2`, + the keys in the full preferences map returned by `read_preferences/1`, otherwise the omitted values are set to their default values or NULL. """ @spec update_preferences(AccessToken.t, json_map) :: diff --git a/lib/exquickbooks/backend.ex b/lib/exquickbooks/backend.ex index 869fd5d..9a33b77 100644 --- a/lib/exquickbooks/backend.ex +++ b/lib/exquickbooks/backend.ex @@ -1,7 +1,7 @@ defmodule ExQuickBooks.Backend do @moduledoc false - alias ExQuickBooks.Request + alias ExQuickBooks.Backend.Request alias HTTPoison.Error alias HTTPoison.Response diff --git a/lib/exquickbooks/httpoison_backend.ex b/lib/exquickbooks/backend/httpoison.ex similarity index 85% rename from lib/exquickbooks/httpoison_backend.ex rename to lib/exquickbooks/backend/httpoison.ex index 30acdfd..b40d6e5 100644 --- a/lib/exquickbooks/httpoison_backend.ex +++ b/lib/exquickbooks/backend/httpoison.ex @@ -1,4 +1,4 @@ -defmodule ExQuickBooks.HTTPoisonBackend do +defmodule ExQuickBooks.Backend.HTTPoison do @moduledoc false @behaviour ExQuickBooks.Backend diff --git a/test/support/mock_backend.ex b/lib/exquickbooks/backend/mock.ex similarity index 95% rename from test/support/mock_backend.ex rename to lib/exquickbooks/backend/mock.ex index 0953f21..fdda747 100644 --- a/test/support/mock_backend.ex +++ b/lib/exquickbooks/backend/mock.ex @@ -1,4 +1,4 @@ -defmodule ExQuickBooks.MockBackend do +defmodule ExQuickBooks.Backend.Mock do @moduledoc false @behaviour ExQuickBooks.Backend diff --git a/lib/exquickbooks/json_endpoint.ex b/lib/exquickbooks/endpoint/json.ex similarity index 97% rename from lib/exquickbooks/json_endpoint.ex rename to lib/exquickbooks/endpoint/json.ex index 71c9f79..675540c 100644 --- a/lib/exquickbooks/json_endpoint.ex +++ b/lib/exquickbooks/endpoint/json.ex @@ -1,4 +1,4 @@ -defmodule ExQuickBooks.JSONEndpoint do +defmodule ExQuickBooks.Endpoint.JSON do @moduledoc false import ExQuickBooks.Endpoint, only: [ diff --git a/lib/exquickbooks/oauth.ex b/lib/exquickbooks/oauth.ex index 2b9583d..2499354 100644 --- a/lib/exquickbooks/oauth.ex +++ b/lib/exquickbooks/oauth.ex @@ -15,8 +15,8 @@ defmodule ExQuickBooks.OAuth do {:ok, request_token} = ExQuickBooks.get_request_token(callback_url) ``` - The token is an `ExQuickBooks.RequestToken`, see its documentation for more - details. + The token is an `ExQuickBooks.OAuth.RequestToken`, see its documentation for + more details. You should redirect the user to `request_token.redirect_url` to authorise your application to access their QuickBooks data. After that step they are @@ -48,14 +48,14 @@ defmodule ExQuickBooks.OAuth do ``` Now you can store the access token and use it in API calls to authenticate on - behalf of the user. The token is an `ExQuickBooks.AccessToken`, see its + behalf of the user. The token is an `ExQuickBooks.OAuth.AccessToken`, see its documentation for more details. """ use ExQuickBooks.Endpoint, base_url: ExQuickBooks.oauth_api - alias ExQuickBooks.AccessToken - alias ExQuickBooks.RequestToken + alias ExQuickBooks.OAuth.AccessToken + alias ExQuickBooks.OAuth.RequestToken @doc """ Retrieves a new request token. diff --git a/lib/exquickbooks/access_token.ex b/lib/exquickbooks/oauth/access_token.ex similarity index 95% rename from lib/exquickbooks/access_token.ex rename to lib/exquickbooks/oauth/access_token.ex index 0e46abe..b31c8a8 100644 --- a/lib/exquickbooks/access_token.ex +++ b/lib/exquickbooks/oauth/access_token.ex @@ -1,4 +1,4 @@ -defmodule ExQuickBooks.AccessToken do +defmodule ExQuickBooks.OAuth.AccessToken do @moduledoc """ OAuth 1.0a token/secret pair for authenticating API calls. diff --git a/lib/exquickbooks/request_token.ex b/lib/exquickbooks/oauth/request_token.ex similarity index 95% rename from lib/exquickbooks/request_token.ex rename to lib/exquickbooks/oauth/request_token.ex index e1a61bb..82aa60c 100644 --- a/lib/exquickbooks/request_token.ex +++ b/lib/exquickbooks/oauth/request_token.ex @@ -1,4 +1,4 @@ -defmodule ExQuickBooks.RequestToken do +defmodule ExQuickBooks.OAuth.RequestToken do @moduledoc """ OAuth 1.0a token/secret pair for requesting an access token. diff --git a/mix.exs b/mix.exs index 21d31ab..8150320 100644 --- a/mix.exs +++ b/mix.exs @@ -3,7 +3,7 @@ defmodule ExQuickBooks.Mixfile do def project do [app: :exquickbooks, - version: "0.4.0", + version: "0.5.0", elixir: "~> 1.4", # Compilation diff --git a/test/exquickbooks/item_test.exs b/test/exquickbooks/api/item_test.exs similarity index 94% rename from test/exquickbooks/item_test.exs rename to test/exquickbooks/api/item_test.exs index 5699186..522727e 100644 --- a/test/exquickbooks/item_test.exs +++ b/test/exquickbooks/api/item_test.exs @@ -1,9 +1,9 @@ -defmodule ExQuickBooks.ItemTest do +defmodule ExQuickBooks.API.ItemTest do use ExUnit.Case, async: false use ExQuickBooks.APICase - alias ExQuickBooks.AccessToken - alias ExQuickBooks.Item + alias ExQuickBooks.API.Item + alias ExQuickBooks.OAuth.AccessToken doctest Item diff --git a/test/exquickbooks/preferences_test.exs b/test/exquickbooks/api/preferences_test.exs similarity index 89% rename from test/exquickbooks/preferences_test.exs rename to test/exquickbooks/api/preferences_test.exs index 8c1f461..5df57bb 100644 --- a/test/exquickbooks/preferences_test.exs +++ b/test/exquickbooks/api/preferences_test.exs @@ -1,9 +1,9 @@ -defmodule ExQuickBooks.PreferencesTest do +defmodule ExQuickBooks.API.PreferencesTest do use ExUnit.Case, async: false use ExQuickBooks.APICase - alias ExQuickBooks.AccessToken - alias ExQuickBooks.Preferences + alias ExQuickBooks.API.Preferences + alias ExQuickBooks.OAuth.AccessToken doctest Preferences diff --git a/test/exquickbooks/json_endpoint_test.exs b/test/exquickbooks/endpoint/json_endpoint_test.exs similarity index 94% rename from test/exquickbooks/json_endpoint_test.exs rename to test/exquickbooks/endpoint/json_endpoint_test.exs index 4666ce9..3d2e8d1 100644 --- a/test/exquickbooks/json_endpoint_test.exs +++ b/test/exquickbooks/endpoint/json_endpoint_test.exs @@ -1,10 +1,10 @@ -defmodule ExQuickBooks.JSONEndpointTest do +defmodule ExQuickBooks.Endpoint.JSONTest do use ExUnit.Case, async: false use ExQuickBooks.APICase use ExQuickBooks.Endpoint, base_url: "http://localhost/" - use ExQuickBooks.JSONEndpoint + use ExQuickBooks.Endpoint.JSON - doctest ExQuickBooks.JSONEndpoint + doctest ExQuickBooks.Endpoint.JSON test "send_json_request/1 sets appropriate headers" do request(:get, "path") |> send_json_request diff --git a/test/exquickbooks/endpoint_test.exs b/test/exquickbooks/endpoint_test.exs index 5635b74..741d6f0 100644 --- a/test/exquickbooks/endpoint_test.exs +++ b/test/exquickbooks/endpoint_test.exs @@ -3,7 +3,7 @@ defmodule ExQuickBooks.EndpointTest do use ExQuickBooks.APICase use ExQuickBooks.Endpoint, base_url: "http://localhost/" - alias ExQuickBooks.AccessToken + alias ExQuickBooks.OAuth.AccessToken alias ExQuickBooks.Request doctest ExQuickBooks.Endpoint diff --git a/test/exquickbooks/oauth_test.exs b/test/exquickbooks/oauth_test.exs index bac2216..b39bbeb 100644 --- a/test/exquickbooks/oauth_test.exs +++ b/test/exquickbooks/oauth_test.exs @@ -2,9 +2,9 @@ defmodule ExQuickBooks.OAuthTest do use ExUnit.Case, async: false use ExQuickBooks.APICase - alias ExQuickBooks.AccessToken alias ExQuickBooks.OAuth - alias ExQuickBooks.RequestToken + alias ExQuickBooks.OAuth.AccessToken + alias ExQuickBooks.OAuth.RequestToken doctest OAuth diff --git a/test/support/api_case.ex b/test/support/api_case.ex index df9c337..7a88f31 100644 --- a/test/support/api_case.ex +++ b/test/support/api_case.ex @@ -5,7 +5,7 @@ defmodule ExQuickBooks.APICase do end end - alias ExQuickBooks.MockBackend + alias ExQuickBooks.Backend alias HTTPoison.Response def http_200_response do @@ -43,8 +43,8 @@ defmodule ExQuickBooks.APICase do } end - defdelegate take_request, to: MockBackend - defdelegate send_response(response), to: MockBackend + defdelegate take_request, to: Backend.Mock + defdelegate send_response(response), to: Backend.Mock defp type_for_extension("json"), do: "application/json" defp type_for_extension(_), do: "text/plain"