Skip to content

Commit

Permalink
Reorganise modules for better readability
Browse files Browse the repository at this point in the history
Hopefully this should provide a more helpful overview of the project's
structure when going through the file tree and documentation quickly.
  • Loading branch information
lnikkila committed Mar 20, 2017
1 parent 8b81ba5 commit 64030d1
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 35 deletions.
2 changes: 1 addition & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use Mix.Config

config :exquickbooks,
backend: ExQuickBooks.MockBackend,
backend: ExQuickBooks.Backend.Mock,
consumer_key: "key",
consumer_secret: "secret"
8 changes: 4 additions & 4 deletions lib/exquickbooks/item.ex → lib/exquickbooks/api/item.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule ExQuickBooks.Item do
defmodule ExQuickBooks.API.Item do
@moduledoc """
Functions for interacting with the Item API.
Expand All @@ -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.
Expand Down Expand Up @@ -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) ::
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule ExQuickBooks.Preferences do
defmodule ExQuickBooks.API.Preferences do
@moduledoc """
Functions for interacting with the Preferences API.
Expand All @@ -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.
Expand All @@ -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) ::
Expand Down
2 changes: 1 addition & 1 deletion lib/exquickbooks/backend.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
defmodule ExQuickBooks.Backend do
@moduledoc false

alias ExQuickBooks.Request
alias ExQuickBooks.Backend.Request
alias HTTPoison.Error
alias HTTPoison.Response

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule ExQuickBooks.HTTPoisonBackend do
defmodule ExQuickBooks.Backend.HTTPoison do
@moduledoc false
@behaviour ExQuickBooks.Backend

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule ExQuickBooks.MockBackend do
defmodule ExQuickBooks.Backend.Mock do
@moduledoc false
@behaviour ExQuickBooks.Backend

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule ExQuickBooks.JSONEndpoint do
defmodule ExQuickBooks.Endpoint.JSON do
@moduledoc false

import ExQuickBooks.Endpoint, only: [
Expand Down
10 changes: 5 additions & 5 deletions lib/exquickbooks/oauth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
defmodule ExQuickBooks.AccessToken do
defmodule ExQuickBooks.OAuth.AccessToken do
@moduledoc """
OAuth 1.0a token/secret pair for authenticating API calls.
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/exquickbooks/endpoint_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/exquickbooks/oauth_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions test/support/api_case.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule ExQuickBooks.APICase do
end
end

alias ExQuickBooks.MockBackend
alias ExQuickBooks.Backend
alias HTTPoison.Response

def http_200_response do
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 64030d1

Please sign in to comment.