Allow runtime configuration changes

master
Milton Mazzarri 2019-03-19 12:18:34 -05:00
parent d2a99b9abf
commit 808e2adcda
No known key found for this signature in database
GPG Key ID: 9F4193F2B5A558FE
15 changed files with 71 additions and 70 deletions

View File

@ -27,7 +27,7 @@ defmodule Hunter.Account do
* `bot` - whether this account is a bot or not * `bot` - whether this account is a bot or not
""" """
@hunter_api Hunter.Config.hunter_api() alias Hunter.Config
@type t :: %__MODULE__{ @type t :: %__MODULE__{
id: non_neg_integer, id: non_neg_integer,
@ -100,7 +100,7 @@ defmodule Hunter.Account do
""" """
@spec verify_credentials(Hunter.Client.t()) :: Hunter.Account.t() @spec verify_credentials(Hunter.Client.t()) :: Hunter.Account.t()
def verify_credentials(conn) do def verify_credentials(conn) do
@hunter_api.verify_credentials(conn) Config.hunter_api().verify_credentials(conn)
end end
@doc """ @doc """
@ -121,7 +121,7 @@ defmodule Hunter.Account do
""" """
@spec update_credentials(Hunter.Client.t(), map) :: Hunter.Account.t() @spec update_credentials(Hunter.Client.t(), map) :: Hunter.Account.t()
def update_credentials(conn, data) do def update_credentials(conn, data) do
@hunter_api.update_credentials(conn, data) Config.hunter_api().update_credentials(conn, data)
end end
@doc """ @doc """
@ -135,7 +135,7 @@ defmodule Hunter.Account do
""" """
@spec account(Hunter.Client.t(), non_neg_integer) :: Hunter.Account.t() @spec account(Hunter.Client.t(), non_neg_integer) :: Hunter.Account.t()
def account(conn, id) do def account(conn, id) do
@hunter_api.account(conn, id) Config.hunter_api().account(conn, id)
end end
@doc """ @doc """
@ -161,7 +161,7 @@ defmodule Hunter.Account do
""" """
@spec followers(Hunter.Client.t(), non_neg_integer, Keyword.t()) :: [Hunter.Account.t()] @spec followers(Hunter.Client.t(), non_neg_integer, Keyword.t()) :: [Hunter.Account.t()]
def followers(conn, id, options \\ []) do def followers(conn, id, options \\ []) do
@hunter_api.followers(conn, id, options) Config.hunter_api().followers(conn, id, options)
end end
@doc """ @doc """
@ -187,7 +187,7 @@ defmodule Hunter.Account do
""" """
@spec following(Hunter.Client.t(), non_neg_integer, Keyword.t()) :: [Hunter.Account.t()] @spec following(Hunter.Client.t(), non_neg_integer, Keyword.t()) :: [Hunter.Account.t()]
def following(conn, id, options \\ []) do def following(conn, id, options \\ []) do
@hunter_api.following(conn, id, options) Config.hunter_api().following(conn, id, options)
end end
@doc """ @doc """
@ -201,7 +201,7 @@ defmodule Hunter.Account do
""" """
@spec follow_by_uri(Hunter.Client.t(), String.t()) :: Hunter.Account.t() @spec follow_by_uri(Hunter.Client.t(), String.t()) :: Hunter.Account.t()
def follow_by_uri(conn, uri) do def follow_by_uri(conn, uri) do
@hunter_api.follow_by_uri(conn, uri) Config.hunter_api().follow_by_uri(conn, uri)
end end
@doc """ @doc """
@ -225,7 +225,7 @@ defmodule Hunter.Account do
limit: Keyword.get(options, :limit, 40) limit: Keyword.get(options, :limit, 40)
} }
@hunter_api.search_account(conn, opts) Config.hunter_api().search_account(conn, opts)
end end
@doc """ @doc """
@ -244,7 +244,7 @@ defmodule Hunter.Account do
""" """
@spec blocks(Hunter.Client.t(), Keyword.t()) :: [Hunter.Account.t()] @spec blocks(Hunter.Client.t(), Keyword.t()) :: [Hunter.Account.t()]
def blocks(conn, options \\ []) do def blocks(conn, options \\ []) do
@hunter_api.blocks(conn, options) Config.hunter_api().blocks(conn, options)
end end
@doc """ @doc """
@ -264,7 +264,7 @@ defmodule Hunter.Account do
""" """
@spec follow_requests(Hunter.Client.t(), Keyword.t()) :: [Hunter.Account.t()] @spec follow_requests(Hunter.Client.t(), Keyword.t()) :: [Hunter.Account.t()]
def follow_requests(conn, options \\ []) do def follow_requests(conn, options \\ []) do
@hunter_api.follow_requests(conn, options) Config.hunter_api().follow_requests(conn, options)
end end
@doc """ @doc """
@ -284,7 +284,7 @@ defmodule Hunter.Account do
""" """
@spec mutes(Hunter.Client.t(), Keyword.t()) :: [Hunter.Account.t()] @spec mutes(Hunter.Client.t(), Keyword.t()) :: [Hunter.Account.t()]
def mutes(conn, options \\ []) do def mutes(conn, options \\ []) do
@hunter_api.mutes(conn, options) Config.hunter_api().mutes(conn, options)
end end
@doc """ @doc """
@ -298,7 +298,7 @@ defmodule Hunter.Account do
""" """
@spec accept_follow_request(Hunter.Client.t(), non_neg_integer) :: boolean @spec accept_follow_request(Hunter.Client.t(), non_neg_integer) :: boolean
def accept_follow_request(conn, id) do def accept_follow_request(conn, id) do
@hunter_api.follow_request_action(conn, id, :authorize) Config.hunter_api().follow_request_action(conn, id, :authorize)
end end
@doc """ @doc """
@ -312,7 +312,7 @@ defmodule Hunter.Account do
""" """
@spec reject_follow_request(Hunter.Client.t(), non_neg_integer) :: boolean @spec reject_follow_request(Hunter.Client.t(), non_neg_integer) :: boolean
def reject_follow_request(conn, id) do def reject_follow_request(conn, id) do
@hunter_api.follow_request_action(conn, id, :reject) Config.hunter_api().follow_request_action(conn, id, :reject)
end end
@doc """ @doc """
@ -333,7 +333,7 @@ defmodule Hunter.Account do
""" """
@spec reblogged_by(Hunter.Client.t(), non_neg_integer, Keyword.t()) :: [Hunter.Account.t()] @spec reblogged_by(Hunter.Client.t(), non_neg_integer, Keyword.t()) :: [Hunter.Account.t()]
def reblogged_by(conn, id, options \\ []) do def reblogged_by(conn, id, options \\ []) do
@hunter_api.reblogged_by(conn, id, options) Config.hunter_api().reblogged_by(conn, id, options)
end end
@doc """ @doc """
@ -355,6 +355,6 @@ defmodule Hunter.Account do
@spec favourited_by(Hunter.Client.t(), non_neg_integer, Keyword.t()) :: [Hunter.Account.t()] @spec favourited_by(Hunter.Client.t(), non_neg_integer, Keyword.t()) :: [Hunter.Account.t()]
def favourited_by(conn, id, options \\ []) do def favourited_by(conn, id, options \\ []) do
@hunter_api.favourited_by(conn, id, options) Config.hunter_api().favourited_by(conn, id, options)
end end
end end

View File

@ -12,7 +12,7 @@ defmodule Hunter.Application do
* `client_secret` - client secret * `client_secret` - client secret
""" """
@hunter_api Hunter.Config.hunter_api() alias Hunter.Config
@type t :: %__MODULE__{ @type t :: %__MODULE__{
id: non_neg_integer, id: non_neg_integer,
@ -70,9 +70,9 @@ defmodule Hunter.Application do
options \\ [] options \\ []
) do ) do
save? = Keyword.get(options, :save?, false) save? = Keyword.get(options, :save?, false)
base_url = Keyword.get(options, :api_base_url, Hunter.Config.api_base_url()) base_url = Keyword.get(options, :api_base_url, Config.api_base_url())
app = @hunter_api.create_app(client_name, redirect_uris, scopes, website, base_url) app = Config.hunter_api().create_app(client_name, redirect_uris, scopes, website, base_url)
if save?, do: save_credentials(client_name, app) if save?, do: save_credentials(client_name, app)

View File

@ -23,7 +23,7 @@ defmodule Hunter.Attachment do
available and local `url` is missing available and local `url` is missing
""" """
@hunter_api Hunter.Config.hunter_api() alias Hunter.Config
@type t :: %__MODULE__{ @type t :: %__MODULE__{
id: non_neg_integer, id: non_neg_integer,
@ -55,6 +55,6 @@ defmodule Hunter.Attachment do
""" """
@spec upload_media(Hunter.Client.t(), Path.t(), Keyword.t()) :: Hunter.Attachment.t() @spec upload_media(Hunter.Client.t(), Path.t(), Keyword.t()) :: Hunter.Attachment.t()
def upload_media(conn, file, options \\ []) do def upload_media(conn, file, options \\ []) do
@hunter_api.upload_media(conn, file, options) Config.hunter_api().upload_media(conn, file, options)
end end
end end

View File

@ -21,7 +21,7 @@ defmodule Hunter.Card do
* `height` - height in pixels * `height` - height in pixels
""" """
@hunter_api Hunter.Config.hunter_api() alias Hunter.Config
@type t :: %__MODULE__{ @type t :: %__MODULE__{
url: String.t(), url: String.t(),
@ -74,6 +74,6 @@ defmodule Hunter.Card do
""" """
@spec card_by_status(Hunter.Client.t(), non_neg_integer) :: Hunter.Card.t() @spec card_by_status(Hunter.Client.t(), non_neg_integer) :: Hunter.Card.t()
def card_by_status(conn, id) do def card_by_status(conn, id) do
@hunter_api.card_by_status(conn, id) Config.hunter_api().card_by_status(conn, id)
end end
end end

View File

@ -3,7 +3,7 @@ defmodule Hunter.Client do
Defines a `Hunter` client Defines a `Hunter` client
""" """
@hunter_api Hunter.Config.hunter_api() alias Hunter.Config
@type t :: %__MODULE__{ @type t :: %__MODULE__{
base_url: String.t(), base_url: String.t(),
@ -48,6 +48,7 @@ defmodule Hunter.Client do
""" """
@spec log_in(Hunter.Application.t(), String.t(), String.t(), String.t()) :: Hunter.Client.t() @spec log_in(Hunter.Application.t(), String.t(), String.t(), String.t()) :: Hunter.Client.t()
def log_in(app, username, password, base_url \\ nil) do def log_in(app, username, password, base_url \\ nil) do
@hunter_api.log_in(app, username, password, base_url || Hunter.Config.api_base_url()) base_url = base_url || Config.api_base_url()
Config.hunter_api().log_in(app, username, password, base_url)
end end
end end

View File

@ -1,15 +1,14 @@
defmodule Hunter.Config do defmodule Hunter.Config do
@moduledoc false @moduledoc """
Hunter configuration.
@hunter_api Application.get_env(:hunter, :hunter_api, Hunter.Api.HTTPClient) """
@api_base_url "https://mastodon.social"
def hunter_api do def hunter_api do
@hunter_api Application.get_env(:hunter, :hunter_api, Hunter.Api.HTTPClient)
end end
def api_base_url do def api_base_url do
@api_base_url Application.get_env(:hunter, :api_base_url, "https://mastodon.social")
end end
def home do def home do

View File

@ -8,7 +8,7 @@ defmodule Hunter.Context do
* `descendants` - The descendants of the status in the conversation, as a list of Statuses * `descendants` - The descendants of the status in the conversation, as a list of Statuses
""" """
@hunter_api Hunter.Config.hunter_api() alias Hunter.Config
@type t :: %__MODULE__{ @type t :: %__MODULE__{
ancestors: [Hunter.Status.t()], ancestors: [Hunter.Status.t()],
@ -29,6 +29,6 @@ defmodule Hunter.Context do
""" """
@spec status_context(Hunter.Client.t(), non_neg_integer) :: Hunter.Context.t() @spec status_context(Hunter.Client.t(), non_neg_integer) :: Hunter.Context.t()
def status_context(conn, id) do def status_context(conn, id) do
@hunter_api.status_context(conn, id) Config.hunter_api().status_context(conn, id)
end end
end end

View File

@ -3,7 +3,7 @@ defmodule Hunter.Domain do
Domain blocks Domain blocks
""" """
@hunter_api Hunter.Config.hunter_api() alias Hunter.Config
@doc """ @doc """
Fetch user's blocked domains Fetch user's blocked domains
@ -22,7 +22,7 @@ defmodule Hunter.Domain do
""" """
@spec blocked_domains(Hunter.Client.t(), Keyword.t()) :: list @spec blocked_domains(Hunter.Client.t(), Keyword.t()) :: list
def blocked_domains(conn, options \\ []) do def blocked_domains(conn, options \\ []) do
@hunter_api.blocked_domains(conn, options) Config.hunter_api().blocked_domains(conn, options)
end end
@doc """ @doc """
@ -36,7 +36,7 @@ defmodule Hunter.Domain do
""" """
@spec block_domain(Hunter.Client.t(), String.t()) :: boolean @spec block_domain(Hunter.Client.t(), String.t()) :: boolean
def block_domain(conn, domain) do def block_domain(conn, domain) do
@hunter_api.block_domain(conn, domain) Config.hunter_api().block_domain(conn, domain)
end end
@doc """ @doc """
@ -50,6 +50,6 @@ defmodule Hunter.Domain do
""" """
@spec unblock_domain(Hunter.Client.t(), String.t()) :: boolean @spec unblock_domain(Hunter.Client.t(), String.t()) :: boolean
def unblock_domain(conn, domain) do def unblock_domain(conn, domain) do
@hunter_api.unblock_domain(conn, domain) Config.hunter_api().unblock_domain(conn, domain)
end end
end end

View File

@ -15,7 +15,7 @@ defmodule Hunter.Instance do
* `urls` - `streaming_api` * `urls` - `streaming_api`
""" """
@hunter_api Hunter.Config.hunter_api() alias Hunter.Config
@type t :: %__MODULE__{ @type t :: %__MODULE__{
uri: String.t(), uri: String.t(),
@ -48,6 +48,6 @@ defmodule Hunter.Instance do
""" """
@spec instance_info(Hunter.Client.t()) :: Hunter.Instance.t() @spec instance_info(Hunter.Client.t()) :: Hunter.Instance.t()
def instance_info(conn) do def instance_info(conn) do
@hunter_api.instance_info(conn) Config.hunter_api().instance_info(conn)
end end
end end

View File

@ -14,7 +14,7 @@ defmodule Hunter.Notification do
* `status` - The `Hunter.Status` associated with the notification, if applicable * `status` - The `Hunter.Status` associated with the notification, if applicable
""" """
@hunter_api Hunter.Config.hunter_api() alias Hunter.Config
@type t :: %__MODULE__{ @type t :: %__MODULE__{
id: String.t(), id: String.t(),
@ -49,7 +49,7 @@ defmodule Hunter.Notification do
""" """
@spec notifications(Hunter.Client.t(), Keyword.t()) :: [Hunter.Notification.t()] @spec notifications(Hunter.Client.t(), Keyword.t()) :: [Hunter.Notification.t()]
def notifications(conn, options \\ []) do def notifications(conn, options \\ []) do
@hunter_api.notifications(conn, options) Config.hunter_api().notifications(conn, options)
end end
@doc """ @doc """
@ -68,7 +68,7 @@ defmodule Hunter.Notification do
""" """
@spec notification(Hunter.Client.t(), non_neg_integer) :: Hunter.Notification.t() @spec notification(Hunter.Client.t(), non_neg_integer) :: Hunter.Notification.t()
def notification(conn, id) do def notification(conn, id) do
@hunter_api.notification(conn, id) Config.hunter_api().notification(conn, id)
end end
@doc """ @doc """
@ -81,7 +81,7 @@ defmodule Hunter.Notification do
""" """
@spec clear_notifications(Hunter.Client.t()) :: boolean @spec clear_notifications(Hunter.Client.t()) :: boolean
def clear_notifications(conn) do def clear_notifications(conn) do
@hunter_api.clear_notifications(conn) Config.hunter_api().clear_notifications(conn)
end end
@doc """ @doc """
@ -95,6 +95,6 @@ defmodule Hunter.Notification do
""" """
@spec clear_notification(Hunter.Client.t(), non_neg_integer) :: boolean @spec clear_notification(Hunter.Client.t(), non_neg_integer) :: boolean
def clear_notification(conn, id) do def clear_notification(conn, id) do
@hunter_api.clear_notification(conn, id) Config.hunter_api().clear_notification(conn, id)
end end
end end

View File

@ -16,7 +16,7 @@ defmodule Hunter.Relationship do
* `domain_blocking` - whether the user is currently blocking the user's domain * `domain_blocking` - whether the user is currently blocking the user's domain
""" """
@hunter_api Hunter.Config.hunter_api() alias Hunter.Config
@type t :: %__MODULE__{ @type t :: %__MODULE__{
id: non_neg_integer, id: non_neg_integer,
@ -42,7 +42,7 @@ defmodule Hunter.Relationship do
""" """
@spec relationships(Hunter.Client.t(), [non_neg_integer]) :: [Hunter.Relationship.t()] @spec relationships(Hunter.Client.t(), [non_neg_integer]) :: [Hunter.Relationship.t()]
def relationships(conn, ids) do def relationships(conn, ids) do
@hunter_api.relationships(conn, ids) Config.hunter_api().relationships(conn, ids)
end end
@doc """ @doc """
@ -56,7 +56,7 @@ defmodule Hunter.Relationship do
""" """
@spec follow(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t() @spec follow(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t()
def follow(conn, id) do def follow(conn, id) do
@hunter_api.follow(conn, id) Config.hunter_api().follow(conn, id)
end end
@doc """ @doc """
@ -70,7 +70,7 @@ defmodule Hunter.Relationship do
""" """
@spec unfollow(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t() @spec unfollow(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t()
def unfollow(conn, id) do def unfollow(conn, id) do
@hunter_api.unfollow(conn, id) Config.hunter_api().unfollow(conn, id)
end end
@doc """ @doc """
@ -84,7 +84,7 @@ defmodule Hunter.Relationship do
""" """
@spec block(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t() @spec block(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t()
def block(conn, id) do def block(conn, id) do
@hunter_api.block(conn, id) Config.hunter_api().block(conn, id)
end end
@doc """ @doc """
@ -96,7 +96,7 @@ defmodule Hunter.Relationship do
""" """
@spec unblock(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t() @spec unblock(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t()
def unblock(conn, id) do def unblock(conn, id) do
@hunter_api.unblock(conn, id) Config.hunter_api().unblock(conn, id)
end end
@doc """ @doc """
@ -110,7 +110,7 @@ defmodule Hunter.Relationship do
""" """
@spec mute(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t() @spec mute(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t()
def mute(conn, id) do def mute(conn, id) do
@hunter_api.mute(conn, id) Config.hunter_api().mute(conn, id)
end end
@doc """ @doc """
@ -124,6 +124,6 @@ defmodule Hunter.Relationship do
""" """
@spec unmute(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t() @spec unmute(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t()
def unmute(conn, id) do def unmute(conn, id) do
@hunter_api.unmute(conn, id) Config.hunter_api().unmute(conn, id)
end end
end end

View File

@ -11,7 +11,7 @@ defmodule Hunter.Report do
* `action_taken` - action taken in response to the report * `action_taken` - action taken in response to the report
""" """
@hunter_api Hunter.Config.hunter_api() alias Hunter.Config
@type t :: %__MODULE__{ @type t :: %__MODULE__{
id: non_neg_integer, id: non_neg_integer,
@ -31,7 +31,7 @@ defmodule Hunter.Report do
""" """
@spec reports(Hunter.Client.t()) :: [Hunter.Report.t()] @spec reports(Hunter.Client.t()) :: [Hunter.Report.t()]
def reports(conn) do def reports(conn) do
@hunter_api.reports(conn) Config.hunter_api().reports(conn)
end end
@doc """ @doc """
@ -48,6 +48,6 @@ defmodule Hunter.Report do
@spec report(Hunter.Client.t(), non_neg_integer, [non_neg_integer], String.t()) :: @spec report(Hunter.Client.t(), non_neg_integer, [non_neg_integer], String.t()) ::
Hunter.Report.t() Hunter.Report.t()
def report(conn, account_id, status_ids, comment) do def report(conn, account_id, status_ids, comment) do
@hunter_api.report(conn, account_id, status_ids, comment) Config.hunter_api().report(conn, account_id, status_ids, comment)
end end
end end

View File

@ -9,7 +9,7 @@ defmodule Hunter.Result do
* `hashtags` - list of matched hashtags, as strings * `hashtags` - list of matched hashtags, as strings
""" """
@hunter_api Hunter.Config.hunter_api() alias Hunter.Config
@type t :: %__MODULE__{ @type t :: %__MODULE__{
accounts: [Hunter.Account.t()], accounts: [Hunter.Account.t()],
@ -40,6 +40,6 @@ defmodule Hunter.Result do
""" """
@spec search(Hunter.Client.t(), String.t(), Keyword.t()) :: Hunter.Result.t() @spec search(Hunter.Client.t(), String.t(), Keyword.t()) :: Hunter.Result.t()
def search(conn, query, options \\ []) do def search(conn, query, options \\ []) do
@hunter_api.search(conn, query, options) Config.hunter_api().search(conn, query, options)
end end
end end

View File

@ -27,10 +27,10 @@ defmodule Hunter.Status do
* `application` - `Hunter.Application` from which the status was posted * `application` - `Hunter.Application` from which the status was posted
* `language` - detected language for the status, default: en * `language` - detected language for the status, default: en
**NOTE**: When `spoiler_text` is present, `sensitive` is true **NOTE**: When `spoiler_text` is present, `sensitive` is true
""" """
@hunter_api Hunter.Config.hunter_api() alias Hunter.Config
@type t :: %__MODULE__{ @type t :: %__MODULE__{
id: non_neg_integer, id: non_neg_integer,
@ -103,7 +103,7 @@ defmodule Hunter.Status do
""" """
@spec create_status(Hunter.Client.t(), String.t(), Keyword.t()) :: Hunter.Status.t() | no_return @spec create_status(Hunter.Client.t(), String.t(), Keyword.t()) :: Hunter.Status.t() | no_return
def create_status(conn, status, options \\ []) do def create_status(conn, status, options \\ []) do
@hunter_api.create_status(conn, status, Map.new(options)) Config.hunter_api().create_status(conn, status, Map.new(options))
end end
@doc """ @doc """
@ -117,7 +117,7 @@ defmodule Hunter.Status do
""" """
@spec status(Hunter.Client.t(), status_id) :: Hunter.Status.t() @spec status(Hunter.Client.t(), status_id) :: Hunter.Status.t()
def status(conn, id) do def status(conn, id) do
@hunter_api.status(conn, id) Config.hunter_api().status(conn, id)
end end
@doc """ @doc """
@ -131,7 +131,7 @@ defmodule Hunter.Status do
""" """
@spec destroy_status(Hunter.Client.t(), status_id) :: boolean @spec destroy_status(Hunter.Client.t(), status_id) :: boolean
def destroy_status(conn, id) do def destroy_status(conn, id) do
@hunter_api.destroy_status(conn, id) Config.hunter_api().destroy_status(conn, id)
end end
@doc """ @doc """
@ -145,7 +145,7 @@ defmodule Hunter.Status do
""" """
@spec reblog(Hunter.Client.t(), status_id) :: Hunter.Status.t() @spec reblog(Hunter.Client.t(), status_id) :: Hunter.Status.t()
def reblog(conn, id) do def reblog(conn, id) do
@hunter_api.reblog(conn, id) Config.hunter_api().reblog(conn, id)
end end
@doc """ @doc """
@ -159,7 +159,7 @@ defmodule Hunter.Status do
""" """
@spec unreblog(Hunter.Client.t(), status_id) :: Hunter.Status.t() @spec unreblog(Hunter.Client.t(), status_id) :: Hunter.Status.t()
def unreblog(conn, id) do def unreblog(conn, id) do
@hunter_api.unreblog(conn, id) Config.hunter_api().unreblog(conn, id)
end end
@doc """ @doc """
@ -173,7 +173,7 @@ defmodule Hunter.Status do
""" """
@spec favourite(Hunter.Client.t(), status_id) :: Hunter.Status.t() @spec favourite(Hunter.Client.t(), status_id) :: Hunter.Status.t()
def favourite(conn, id) do def favourite(conn, id) do
@hunter_api.favourite(conn, id) Config.hunter_api().favourite(conn, id)
end end
@doc """ @doc """
@ -187,7 +187,7 @@ defmodule Hunter.Status do
""" """
@spec unfavourite(Hunter.Client.t(), status_id) :: Hunter.Status.t() @spec unfavourite(Hunter.Client.t(), status_id) :: Hunter.Status.t()
def unfavourite(conn, id) do def unfavourite(conn, id) do
@hunter_api.unfavourite(conn, id) Config.hunter_api().unfavourite(conn, id)
end end
@doc """ @doc """
@ -207,7 +207,7 @@ defmodule Hunter.Status do
""" """
@spec favourites(Hunter.Client.t(), Keyword.t()) :: [Hunter.Status.t()] @spec favourites(Hunter.Client.t(), Keyword.t()) :: [Hunter.Status.t()]
def favourites(conn, options \\ []) do def favourites(conn, options \\ []) do
@hunter_api.favourites(conn, options) Config.hunter_api().favourites(conn, options)
end end
@doc """ @doc """
@ -230,7 +230,7 @@ defmodule Hunter.Status do
""" """
@spec statuses(Hunter.Client.t(), status_id, Keyword.t()) :: [Hunter.Status.t()] @spec statuses(Hunter.Client.t(), status_id, Keyword.t()) :: [Hunter.Status.t()]
def statuses(conn, account_id, options \\ []) do def statuses(conn, account_id, options \\ []) do
@hunter_api.statuses(conn, account_id, Map.new(options)) Config.hunter_api().statuses(conn, account_id, Map.new(options))
end end
@doc """ @doc """
@ -250,7 +250,7 @@ defmodule Hunter.Status do
""" """
@spec home_timeline(Hunter.Client.t(), Keyword.t()) :: [Hunter.Status.t()] @spec home_timeline(Hunter.Client.t(), Keyword.t()) :: [Hunter.Status.t()]
def home_timeline(conn, options \\ []) do def home_timeline(conn, options \\ []) do
@hunter_api.home_timeline(conn, Map.new(options)) Config.hunter_api().home_timeline(conn, Map.new(options))
end end
@doc """ @doc """
@ -271,7 +271,7 @@ defmodule Hunter.Status do
""" """
@spec public_timeline(Hunter.Client.t(), Keyword.t()) :: [Hunter.Status.t()] @spec public_timeline(Hunter.Client.t(), Keyword.t()) :: [Hunter.Status.t()]
def public_timeline(conn, options \\ []) do def public_timeline(conn, options \\ []) do
@hunter_api.public_timeline(conn, Map.new(options)) Config.hunter_api().public_timeline(conn, Map.new(options))
end end
@doc """ @doc """
@ -293,6 +293,6 @@ defmodule Hunter.Status do
""" """
@spec hashtag_timeline(Hunter.Client.t(), [String.t()], Keyword.t()) :: [Hunter.Status.t()] @spec hashtag_timeline(Hunter.Client.t(), [String.t()], Keyword.t()) :: [Hunter.Status.t()]
def hashtag_timeline(conn, hashtag, options \\ []) do def hashtag_timeline(conn, hashtag, options \\ []) do
@hunter_api.hashtag_timeline(conn, hashtag, Map.new(options)) Config.hunter_api().hashtag_timeline(conn, hashtag, Map.new(options))
end end
end end

View File

@ -1 +1,2 @@
ExUnit.start() ExUnit.start()
Application.put_env(:hunter, :hunter_api, Hunter.Api.InMemory)