mix format

master
Milton Mazzarri 2017-10-26 14:16:42 -05:00
parent 156124101a
commit 605a062c86
No known key found for this signature in database
GPG Key ID: CF3DE6E356E17F1E
28 changed files with 447 additions and 347 deletions

View File

@ -4,7 +4,7 @@ defmodule Hunter do
"""
@hunter_version Mix.Project.config[:version]
@hunter_version Mix.Project.config()[:version]
@doc """
Retrieve account of authenticated user
@ -14,7 +14,7 @@ defmodule Hunter do
* `conn` - connection credentials
"""
@spec verify_credentials(Hunter.Client.t) :: Hunter.Account.t
@spec verify_credentials(Hunter.Client.t()) :: Hunter.Account.t()
defdelegate verify_credentials(conn), to: Hunter.Account
@doc """
@ -33,7 +33,7 @@ defmodule Hunter do
* `header` - base64 encoded image to display as the user's header image (e.g. `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUoAAADrCAYAAAA...`)
"""
@spec update_credentials(Hunter.Client.t, map) :: Hunter.Account.t
@spec update_credentials(Hunter.Client.t(), map) :: Hunter.Account.t()
defdelegate update_credentials(conn, data), to: Hunter.Account
@doc """
@ -45,7 +45,7 @@ defmodule Hunter do
* `id` - account identifier
"""
@spec account(Hunter.Client.t, non_neg_integer) :: Hunter.Account.t
@spec account(Hunter.Client.t(), non_neg_integer) :: Hunter.Account.t()
defdelegate account(conn, id), to: Hunter.Account
@doc """
@ -64,7 +64,7 @@ defmodule Hunter do
* `limit` - maximum number of followers to get, default: 40, maximum: 80
"""
@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()]
defdelegate followers(conn, id, options \\ []), to: Hunter.Account
@doc """
@ -83,7 +83,7 @@ defmodule Hunter do
* `limit` - maximum number of followings to get, default: 40, maximum: 80
"""
@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()]
defdelegate following(conn, id, options \\ []), to: Hunter.Account
@doc """
@ -95,7 +95,7 @@ defmodule Hunter do
* `uri` - URI of the remote user, in the format of `username@domain`
"""
@spec follow_by_uri(Hunter.Client.t, String.t) :: Hunter.Account.t
@spec follow_by_uri(Hunter.Client.t(), String.t()) :: Hunter.Account.t()
defdelegate follow_by_uri(conn, uri), to: Hunter.Account
@doc """
@ -112,7 +112,7 @@ defmodule Hunter do
* `limit`: maximum number of matching accounts to return, default: 40
"""
@spec search_account(Hunter.Client.t, Keyword.t) :: [Hunter.Account.t]
@spec search_account(Hunter.Client.t(), Keyword.t()) :: [Hunter.Account.t()]
defdelegate search_account(conn, options), to: Hunter.Account
@doc """
@ -129,7 +129,7 @@ defmodule Hunter do
* `limit` - maximum number of blocks to get, default: 40, max: 80
"""
@spec blocks(Hunter.Client.t, Keyword.t) :: [Hunter.Account.t]
@spec blocks(Hunter.Client.t(), Keyword.t()) :: [Hunter.Account.t()]
defdelegate blocks(conn, options \\ []), to: Hunter.Account
@doc """
@ -147,7 +147,7 @@ defmodule Hunter do
* `limit` - maximum number of requests to get, default: 40, max: 80
"""
@spec follow_requests(Hunter.Client.t, Keyword.t) :: [Hunter.Account.t]
@spec follow_requests(Hunter.Client.t(), Keyword.t()) :: [Hunter.Account.t()]
defdelegate follow_requests(conn, options \\ []), to: Hunter.Account
@doc """
@ -165,7 +165,7 @@ defmodule Hunter do
* `limit` - maximum number of mutes to get, default: 40, max: 80
"""
@spec mutes(Hunter.Client.t, Keyword.t) :: [Hunter.Account.t]
@spec mutes(Hunter.Client.t(), Keyword.t()) :: [Hunter.Account.t()]
defdelegate mutes(conn, options \\ []), to: Hunter.Account
@doc """
@ -177,7 +177,7 @@ defmodule Hunter do
* `id` - follow request id
"""
@spec accept_follow_request(Hunter.Client.t, non_neg_integer) :: boolean
@spec accept_follow_request(Hunter.Client.t(), non_neg_integer) :: boolean
defdelegate accept_follow_request(conn, id), to: Hunter.Account
@doc """
@ -189,7 +189,7 @@ defmodule Hunter do
* `id` - follow request id
"""
@spec reject_follow_request(Hunter.Client.t, non_neg_integer) :: boolean
@spec reject_follow_request(Hunter.Client.t(), non_neg_integer) :: boolean
defdelegate reject_follow_request(conn, id), to: Hunter.Account
## Application
@ -222,8 +222,16 @@ defmodule Hunter do
different instance. default: `https://mastodon.social`
"""
@spec create_app(String.t, String.t, [String.t], String.t, Keyword.t) :: Hunter.Application.t | no_return
defdelegate create_app(name, redirect_uri \\ "urn:ietf:wg:oauth:2.0:oob", scopes \\ ["read"], website \\ nil, options \\ []), to: Hunter.Application
@spec create_app(String.t(), String.t(), [String.t()], String.t(), Keyword.t()) ::
Hunter.Application.t() | no_return
defdelegate create_app(
name,
redirect_uri \\ "urn:ietf:wg:oauth:2.0:oob",
scopes \\ ["read"],
website \\ nil,
options \\ []
),
to: Hunter.Application
@doc """
Load persisted application's credentials
@ -233,7 +241,7 @@ defmodule Hunter do
* `name` - application's name
"""
@spec load_credentials(String.t) :: Hunter.Application.t
@spec load_credentials(String.t()) :: Hunter.Application.t()
defdelegate load_credentials(name), to: Hunter.Application
@doc """
@ -245,13 +253,13 @@ defmodule Hunter do
* `bearer_token` - [String] OAuth access token for your authenticated user
"""
@spec new(Keyword.t) :: Hunter.Client.t
@spec new(Keyword.t()) :: Hunter.Client.t()
defdelegate new(options \\ []), to: Hunter.Client
@doc """
User agent of the client
"""
@spec user_agent() :: String.t
@spec user_agent() :: String.t()
defdelegate user_agent, to: Hunter.Client
@doc """
@ -263,7 +271,7 @@ defmodule Hunter do
* `file` - media to be uploaded
"""
@spec upload_media(Hunter.Client.t, Path.t) :: Hunter.Attachment.t
@spec upload_media(Hunter.Client.t(), Path.t()) :: Hunter.Attachment.t()
defdelegate upload_media(conn, file), to: Hunter.Attachment
@doc """
@ -275,7 +283,7 @@ defmodule Hunter do
* `id` - list of relationship IDs
"""
@spec relationships(Hunter.Client.t, [non_neg_integer]) :: [Hunter.Relationship.t]
@spec relationships(Hunter.Client.t(), [non_neg_integer]) :: [Hunter.Relationship.t()]
defdelegate relationships(conn, ids), to: Hunter.Relationship
@doc """
@ -287,7 +295,7 @@ defmodule Hunter do
* `id` - user identifier
"""
@spec follow(Hunter.Client.t, non_neg_integer) :: Hunter.Relationship.t
@spec follow(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t()
defdelegate follow(conn, id), to: Hunter.Relationship
@doc """
@ -299,7 +307,7 @@ defmodule Hunter do
* `id` - user identifier
"""
@spec unfollow(Hunter.Client.t, non_neg_integer) :: Hunter.Relationship.t
@spec unfollow(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t()
defdelegate unfollow(conn, id), to: Hunter.Relationship
@doc """
@ -311,7 +319,7 @@ defmodule Hunter do
* `id` - user identifier
"""
@spec block(Hunter.Client.t, non_neg_integer) :: Hunter.Relationship.t
@spec block(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t()
defdelegate block(conn, id), to: Hunter.Relationship
@doc """
@ -321,7 +329,7 @@ defmodule Hunter do
* `id` - user identifier
"""
@spec unblock(Hunter.Client.t, non_neg_integer) :: Hunter.Relationship.t
@spec unblock(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t()
defdelegate unblock(conn, id), to: Hunter.Relationship
@doc """
@ -333,7 +341,7 @@ defmodule Hunter do
* `id` - user identifier
"""
@spec mute(Hunter.Client.t, non_neg_integer) :: Hunter.Relationship.t
@spec mute(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t()
defdelegate mute(conn, id), to: Hunter.Relationship
@doc """
@ -345,7 +353,7 @@ defmodule Hunter do
* `id` - user identifier
"""
@spec unmute(Hunter.Client.t, non_neg_integer) :: Hunter.Relationship.t
@spec unmute(Hunter.Client.t(), non_neg_integer) :: Hunter.Relationship.t()
defdelegate unmute(conn, id), to: Hunter.Relationship
@doc """
@ -362,7 +370,7 @@ defmodule Hunter do
* `resolve` - whether to resolve non-local accounts
"""
@spec search(Hunter.Client.t, String.t, Keyword.t) :: Hunter.Result.t
@spec search(Hunter.Client.t(), String.t(), Keyword.t()) :: Hunter.Result.t()
defdelegate search(conn, query, options \\ []), to: Hunter.Result
@doc """
@ -383,7 +391,7 @@ defmodule Hunter do
* `visibility` - either `direct`, `private`, `unlisted` or `public`
"""
@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
defdelegate create_status(conn, status, options \\ []), to: Hunter.Status
@doc """
@ -395,7 +403,7 @@ defmodule Hunter do
* `id` - status identifier
"""
@spec status(Hunter.Client.t, non_neg_integer) :: Hunter.Status.t
@spec status(Hunter.Client.t(), non_neg_integer) :: Hunter.Status.t()
defdelegate status(conn, id), to: Hunter.Status
@doc """
@ -407,7 +415,7 @@ defmodule Hunter do
* `id` - status identifier
"""
@spec destroy_status(Hunter.Client.t, non_neg_integer) :: boolean
@spec destroy_status(Hunter.Client.t(), non_neg_integer) :: boolean
defdelegate destroy_status(conn, id), to: Hunter.Status
@doc """
@ -419,7 +427,7 @@ defmodule Hunter do
* `id` - status identifier
"""
@spec reblog(Hunter.Client.t, non_neg_integer) :: Hunter.Status.t
@spec reblog(Hunter.Client.t(), non_neg_integer) :: Hunter.Status.t()
defdelegate reblog(conn, id), to: Hunter.Status
@doc """
@ -431,7 +439,7 @@ defmodule Hunter do
* `id` - status identifier
"""
@spec unreblog(Hunter.Client.t, non_neg_integer) :: Hunter.Status.t
@spec unreblog(Hunter.Client.t(), non_neg_integer) :: Hunter.Status.t()
defdelegate unreblog(conn, id), to: Hunter.Status
@doc """
@ -450,7 +458,7 @@ defmodule Hunter do
* `limit` - maximum number of *reblogged by* to get, default: 40, max: 80
"""
@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()]
defdelegate reblogged_by(conn, id, options \\ []), to: Hunter.Account
@doc """
@ -462,7 +470,7 @@ defmodule Hunter do
* `id` - status identifier
"""
@spec favourite(Hunter.Client.t, non_neg_integer) :: Hunter.Status.t
@spec favourite(Hunter.Client.t(), non_neg_integer) :: Hunter.Status.t()
defdelegate favourite(conn, id), to: Hunter.Status
@doc """
@ -474,7 +482,7 @@ defmodule Hunter do
* `id` - status identifier
"""
@spec unfavourite(Hunter.Client.t, non_neg_integer) :: Hunter.Status.t
@spec unfavourite(Hunter.Client.t(), non_neg_integer) :: Hunter.Status.t()
defdelegate unfavourite(conn, id), to: Hunter.Status
@doc """
@ -492,7 +500,7 @@ defmodule Hunter do
* `limit` - maximum of favourites to get, default: 20, max: 40
"""
@spec favourites(Hunter.Client.t, Keyword.t) :: [Hunter.Status.t]
@spec favourites(Hunter.Client.t(), Keyword.t()) :: [Hunter.Status.t()]
defdelegate favourites(conn, options \\ []), to: Hunter.Status
@doc """
@ -512,7 +520,7 @@ defmodule Hunter 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()]
defdelegate favourited_by(conn, id, options \\ []), to: Hunter.Account
@doc """
@ -533,7 +541,7 @@ defmodule Hunter do
* `limit` - maximum number of statuses to get, default: 20, max: 40
"""
@spec statuses(Hunter.Client.t, non_neg_integer, Keyword.t) :: [Hunter.Status.t]
@spec statuses(Hunter.Client.t(), non_neg_integer, Keyword.t()) :: [Hunter.Status.t()]
defdelegate statuses(conn, account_id, options \\ []), to: Hunter.Status
@doc """
@ -551,7 +559,7 @@ defmodule Hunter do
* `limit` - maximum number of statuses on the requested timeline to get, default: 20, max: 40
"""
@spec home_timeline(Hunter.Client.t, Keyword.t) :: [Hunter.Status.t]
@spec home_timeline(Hunter.Client.t(), Keyword.t()) :: [Hunter.Status.t()]
defdelegate home_timeline(conn, options \\ []), to: Hunter.Status
@doc """
@ -570,7 +578,7 @@ defmodule Hunter do
* `limit` - maximum number of statuses on the requested timeline to get, default: 20, max: 40
"""
@spec public_timeline(Hunter.Client.t, Keyword.t) :: [Hunter.Status.t]
@spec public_timeline(Hunter.Client.t(), Keyword.t()) :: [Hunter.Status.t()]
defdelegate public_timeline(conn, options \\ []), to: Hunter.Status
@doc """
@ -590,7 +598,7 @@ defmodule Hunter do
* `limit` - maximum number of statuses on the requested timeline to get, default: 20, max: 40
"""
@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()]
defdelegate hashtag_timeline(conn, hashtag, options \\ []), to: Hunter.Status
@doc """
@ -601,7 +609,7 @@ defmodule Hunter do
* `conn` - connection credentials
"""
@spec instance_info(Hunter.Client.t) :: Hunter.Instance.t
@spec instance_info(Hunter.Client.t()) :: Hunter.Instance.t()
defdelegate instance_info(conn), to: Hunter.Instance
@doc """
@ -619,7 +627,7 @@ defmodule Hunter do
* `limit` - maximum number of notifications to get, default: 15, max: 30
"""
@spec notifications(Hunter.Client.t, Keyword.t) :: [Hunter.Notification.t]
@spec notifications(Hunter.Client.t(), Keyword.t()) :: [Hunter.Notification.t()]
defdelegate notifications(conn, options \\ []), to: Hunter.Notification
@doc """
@ -631,7 +639,7 @@ defmodule Hunter do
* `id` - notification identifier
"""
@spec notification(Hunter.Client.t, non_neg_integer) :: Hunter.Notification.t
@spec notification(Hunter.Client.t(), non_neg_integer) :: Hunter.Notification.t()
defdelegate notification(conn, id), to: Hunter.Notification
@doc """
@ -642,7 +650,7 @@ defmodule Hunter do
* `conn` - connection credentials
"""
@spec clear_notifications(Hunter.Client.t) :: boolean
@spec clear_notifications(Hunter.Client.t()) :: boolean
defdelegate clear_notifications(conn), to: Hunter.Notification
@doc """
@ -654,7 +662,7 @@ defmodule Hunter do
* `id` - notification id
"""
@spec clear_notification(Hunter.Client.t, non_neg_integer) :: boolean
@spec clear_notification(Hunter.Client.t(), non_neg_integer) :: boolean
defdelegate clear_notification(conn, id), to: Hunter.Notification
@doc """
@ -665,7 +673,7 @@ defmodule Hunter do
* `conn` - connection credentials
"""
@spec reports(Hunter.Client.t) :: [Hunter.Report.t]
@spec reports(Hunter.Client.t()) :: [Hunter.Report.t()]
defdelegate reports(conn), to: Hunter.Report
@doc """
@ -679,7 +687,8 @@ defmodule Hunter do
* `comment` - a comment to associate with the report
"""
@spec report(Hunter.Client.t, non_neg_integer, [non_neg_integer], String.t) :: Hunter.Report.t
@spec report(Hunter.Client.t(), non_neg_integer, [non_neg_integer], String.t()) ::
Hunter.Report.t()
defdelegate report(conn, account_id, status_ids, comment), to: Hunter.Report
@doc """
@ -691,7 +700,7 @@ defmodule Hunter do
* `id` - status identifier
"""
@spec status_context(Hunter.Client.t, non_neg_integer) :: Hunter.Context.t
@spec status_context(Hunter.Client.t(), non_neg_integer) :: Hunter.Context.t()
defdelegate status_context(conn, id), to: Hunter.Context
@doc """
@ -703,7 +712,7 @@ defmodule Hunter do
* `id` - status id
"""
@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()
defdelegate card_by_status(conn, id), to: Hunter.Card
@doc """
@ -761,6 +770,6 @@ defmodule Hunter do
@doc """
Returns Hunter version
"""
@spec version() :: String.t
@spec version() :: String.t()
def version(), do: @hunter_version
end

View File

@ -27,39 +27,41 @@ defmodule Hunter.Account do
@hunter_api Hunter.Config.hunter_api()
@type t :: %__MODULE__{
id: non_neg_integer,
username: String.t,
acct: String.t,
display_name: String.t,
note: String.t,
url: String.t,
avatar: String.t,
avatar_static: String.t,
header: String.t,
header_static: String.t,
locked: String.t,
created_at: String.t,
followers_count: non_neg_integer,
following_count: non_neg_integer,
statuses_count: non_neg_integer
}
id: non_neg_integer,
username: String.t(),
acct: String.t(),
display_name: String.t(),
note: String.t(),
url: String.t(),
avatar: String.t(),
avatar_static: String.t(),
header: String.t(),
header_static: String.t(),
locked: String.t(),
created_at: String.t(),
followers_count: non_neg_integer,
following_count: non_neg_integer,
statuses_count: non_neg_integer
}
@derive [Poison.Encoder]
defstruct [:id,
:username,
:acct,
:display_name,
:note,
:url,
:avatar,
:avatar_static,
:header,
:header_static,
:locked,
:created_at,
:followers_count,
:following_count,
:statuses_count]
defstruct [
:id,
:username,
:acct,
:display_name,
:note,
:url,
:avatar,
:avatar_static,
:header,
:header_static,
:locked,
:created_at,
:followers_count,
:following_count,
:statuses_count
]
@doc """
Retrieve account of authenticated user
@ -85,7 +87,7 @@ defmodule Hunter.Account do
url: "https://social.lou.lt/@milmazz", username: "milmazz"}
"""
@spec verify_credentials(Hunter.Client.t) :: Hunter.Account.t
@spec verify_credentials(Hunter.Client.t()) :: Hunter.Account.t()
def verify_credentials(conn) do
@hunter_api.verify_credentials(conn)
end
@ -106,7 +108,7 @@ defmodule Hunter.Account do
* `header` - base64 encoded image to display as the user's header image (e.g. `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUoAAADrCAYAAAA...`)
"""
@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
@hunter_api.update_credentials(conn, data)
end
@ -120,7 +122,7 @@ defmodule Hunter.Account do
* `id` - account id
"""
@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
@hunter_api.account(conn, id)
end
@ -141,7 +143,7 @@ defmodule Hunter.Account do
* `limit` - maximum number of followers to get, default: 40, maximum: 80
"""
@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
@hunter_api.followers(conn, id, options)
end
@ -162,7 +164,7 @@ defmodule Hunter.Account do
* `limit` - maximum number of followings to get, default: 40, maximum: 80
"""
@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
@hunter_api.following(conn, id, options)
end
@ -176,7 +178,7 @@ defmodule Hunter.Account do
* `uri` - URI of the remote user, in the format of `username@domain`
"""
@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
@hunter_api.follow_by_uri(conn, uri)
end
@ -195,7 +197,7 @@ defmodule Hunter.Account do
* `limit`: maximum number of matching accounts to return, default: 40
"""
@spec search_account(Hunter.Client.t, Keyword.t) :: [Hunter.Account.t]
@spec search_account(Hunter.Client.t(), Keyword.t()) :: [Hunter.Account.t()]
def search_account(conn, options) do
opts = %{
q: Keyword.fetch!(options, :q),
@ -219,7 +221,7 @@ defmodule Hunter.Account do
* `limit` - maximum number of blocks to get, default: 40, max: 80
"""
@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
@hunter_api.blocks(conn, options)
end
@ -239,7 +241,7 @@ defmodule Hunter.Account do
* `limit` - maximum number of requests to get, default: 40, max: 80
"""
@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
@hunter_api.follow_requests(conn, options)
end
@ -259,7 +261,7 @@ defmodule Hunter.Account do
* `limit` - maximum number of mutes to get, default: 40, max: 80
"""
@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
@hunter_api.mutes(conn, options)
end
@ -273,7 +275,7 @@ defmodule Hunter.Account do
* `id` - follow request id
"""
@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
@hunter_api.follow_request_action(conn, id, :authorize)
end
@ -287,7 +289,7 @@ defmodule Hunter.Account do
* `id` - follow request id
"""
@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
@hunter_api.follow_request_action(conn, id, :reject)
end
@ -308,7 +310,7 @@ defmodule Hunter.Account do
* `limit` - maximum number of *reblogged by* to get, default: 40, max: 80
"""
@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
@hunter_api.reblogged_by(conn, id, options)
end
@ -330,7 +332,7 @@ 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
@hunter_api.favourited_by(conn, id, options)
end

View File

@ -13,7 +13,7 @@ defmodule Hunter.Api do
* `conn` - connection credentials
"""
@callback verify_credentials(conn :: Hunter.Client.t) :: Hunter.Account.t
@callback verify_credentials(conn :: Hunter.Client.t()) :: Hunter.Account.t()
@doc """
Make changes to the authenticated user
@ -31,7 +31,7 @@ defmodule Hunter.Api do
* `header` - base64 encoded image to display as the user's header image (e.g. `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAUoAAADrCAYAAAA...`)
"""
@callback update_credentials(Hunter.Client.t, map) :: Hunter.Account.t
@callback update_credentials(Hunter.Client.t(), map) :: Hunter.Account.t()
@doc """
Retrieve account
@ -42,7 +42,7 @@ defmodule Hunter.Api do
* `id` - account identifier
"""
@callback account(conn :: Hunter.Client.t, id :: non_neg_integer) :: Hunter.Account.t
@callback account(conn :: Hunter.Client.t(), id :: non_neg_integer) :: Hunter.Account.t()
@doc """
Get a list of followers
@ -60,7 +60,8 @@ defmodule Hunter.Api do
* `limit` - maximum number of followings to get, default: 40, maximum: 80
"""
@callback followers(conn :: Hunter.Client.t, id :: non_neg_integer, options :: Keyword.t) :: Hunter.Account.t
@callback followers(conn :: Hunter.Client.t(), id :: non_neg_integer, options :: Keyword.t()) ::
Hunter.Account.t()
@doc """
Get a list of followed accounts
@ -78,7 +79,8 @@ defmodule Hunter.Api do
* `limit` - maximum number of followings to get, default: 40, maximum: 80
"""
@callback following(conn :: Hunter.Client.t, id :: non_neg_integer, options :: Keyword.t) :: Hunter.Account.t
@callback following(conn :: Hunter.Client.t(), id :: non_neg_integer, options :: Keyword.t()) ::
Hunter.Account.t()
@doc """
Follow a remote user
@ -89,7 +91,7 @@ defmodule Hunter.Api do
* `uri` - URI of the remote user, in the format of `username@domain`
"""
@callback follow_by_uri(conn :: Hunter.Client.t, id :: non_neg_integer) :: Hunter.Account.t
@callback follow_by_uri(conn :: Hunter.Client.t(), id :: non_neg_integer) :: Hunter.Account.t()
@doc """
Search for accounts
@ -105,7 +107,7 @@ defmodule Hunter.Api do
* `limit`: maximum number of matching accounts to return, default: 40
"""
@callback search_account(conn :: Hunter.Client.t, options :: map) :: [Hunter.Account.t]
@callback search_account(conn :: Hunter.Client.t(), options :: map) :: [Hunter.Account.t()]
@doc """
Retrieve user's blocks
@ -121,7 +123,7 @@ defmodule Hunter.Api do
* `limit` - maximum number of blocks to get, default: 40, max: 80
"""
@callback blocks(conn :: Hunter.Client.t, options :: Keyword.t) :: [Hunter.Account.t]
@callback blocks(conn :: Hunter.Client.t(), options :: Keyword.t()) :: [Hunter.Account.t()]
@doc """
Retrieve a list of follow requests
@ -138,7 +140,9 @@ defmodule Hunter.Api do
* `limit` - maximum number of requests to get, default: 40, max: 80
"""
@callback follow_requests(conn :: Hunter.Client.t, options :: Keyword.t) :: [Hunter.Account.t]
@callback follow_requests(conn :: Hunter.Client.t(), options :: Keyword.t()) :: [
Hunter.Account.t()
]
@doc """
Retrieve user's mutes
@ -155,7 +159,7 @@ defmodule Hunter.Api do
* `limit` - maximum number of mutes to get, default: 40, max: 80
"""
@callback mutes(conn :: Hunter.Client.t, options :: Keyword.t) :: [Hunter.Account.t]
@callback mutes(conn :: Hunter.Client.t(), options :: Keyword.t()) :: [Hunter.Account.t()]
@doc """
Accepts or Rejects a follow request
@ -172,7 +176,11 @@ defmodule Hunter.Api do
* `:reject` - reject a follow request
"""
@callback follow_request_action(conn :: Hunter.Client.t, id :: non_neg_integer, action :: atom) :: boolean
@callback follow_request_action(
conn :: Hunter.Client.t(),
id :: non_neg_integer,
action :: atom
) :: boolean
## Application
@ -197,7 +205,13 @@ defmodule Hunter.Api do
Multiple scopes can be requested during the authorization phase with the `scope` query param
"""
@callback create_app(name :: String.t, redirect_uri :: String.t, scopes :: [String.t], website :: String.t, base_url :: String.t) :: Hunter.Application.t | no_return
@callback create_app(
name :: String.t(),
redirect_uri :: String.t(),
scopes :: [String.t()],
website :: String.t(),
base_url :: String.t()
) :: Hunter.Application.t() | no_return
@doc """
Upload a media file
@ -208,7 +222,7 @@ defmodule Hunter.Api do
* `file` - media to be uploaded
"""
@callback upload_media(conn :: Hunter.Client.t, file :: Path.t) :: Hunter.Attachment.t
@callback upload_media(conn :: Hunter.Client.t(), file :: Path.t()) :: Hunter.Attachment.t()
## Relationship
@ -221,7 +235,9 @@ defmodule Hunter.Api do
* `id` - list of relationship IDs
"""
@callback relationships(conn :: Hunter.Client.t, ids :: [non_neg_integer]) :: [Hunter.Relationship.t]
@callback relationships(conn :: Hunter.Client.t(), ids :: [non_neg_integer]) :: [
Hunter.Relationship.t()
]
@doc """
Follow a user
@ -232,7 +248,7 @@ defmodule Hunter.Api do
* `id` - user id
"""
@callback follow(conn :: Hunter.Client.t, id :: non_neg_integer) :: Hunter.Relationship.t
@callback follow(conn :: Hunter.Client.t(), id :: non_neg_integer) :: Hunter.Relationship.t()
@doc """
Unfollow a user
@ -243,7 +259,7 @@ defmodule Hunter.Api do
* `id` - user identifier
"""
@callback unfollow(conn :: Hunter.Client.t, id :: non_neg_integer) :: Hunter.Relationship.t
@callback unfollow(conn :: Hunter.Client.t(), id :: non_neg_integer) :: Hunter.Relationship.t()
@doc """
Block a user
@ -254,7 +270,7 @@ defmodule Hunter.Api do
* `id` - user identifier
"""
@callback block(conn :: Hunter.Client.t, id :: non_neg_integer) :: Hunter.Relationship.t
@callback block(conn :: Hunter.Client.t(), id :: non_neg_integer) :: Hunter.Relationship.t()
@doc """
Unblock a user
@ -263,7 +279,7 @@ defmodule Hunter.Api do
* `id` - user identifier
"""
@callback unblock(conn :: Hunter.Client.t, id :: non_neg_integer) :: Hunter.Relationship.t
@callback unblock(conn :: Hunter.Client.t(), id :: non_neg_integer) :: Hunter.Relationship.t()
@doc """
Mute a user
@ -274,7 +290,7 @@ defmodule Hunter.Api do
* `id` - user identifier
"""
@callback mute(conn :: Hunter.Client.t, id :: non_neg_integer) :: Hunter.Relationship.t
@callback mute(conn :: Hunter.Client.t(), id :: non_neg_integer) :: Hunter.Relationship.t()
@doc """
Unmute a user
@ -285,7 +301,7 @@ defmodule Hunter.Api do
* `id` - user identifier
"""
@callback unmute(conn :: Hunter.Client.t, id :: non_neg_integer) :: Hunter.Relationship.t
@callback unmute(conn :: Hunter.Client.t(), id :: non_neg_integer) :: Hunter.Relationship.t()
## Result
@ -303,7 +319,8 @@ defmodule Hunter.Api do
* `resolve` - whether to resolve non-local accounts
"""
@callback search(conn :: Hunter.Client.t, query :: String.t, options :: Keyword.t) :: Hunter.Result.t
@callback search(conn :: Hunter.Client.t(), query :: String.t(), options :: Keyword.t()) ::
Hunter.Result.t()
## Status
@ -325,7 +342,8 @@ defmodule Hunter.Api do
* `visibility` - either `direct`, `private`, `unlisted` or `public`
"""
@callback create_status(conn :: Hunter.Client.t, status :: String.t, options :: Keyword.t) :: Hunter.Status.t | no_return
@callback create_status(conn :: Hunter.Client.t(), status :: String.t(), options :: Keyword.t()) ::
Hunter.Status.t() | no_return
@doc """
Retrieve status
@ -336,7 +354,7 @@ defmodule Hunter.Api do
* `id` - status identifier
"""
@callback status(conn :: Hunter.Client.t, id :: non_neg_integer) :: Hunter.Status.t
@callback status(conn :: Hunter.Client.t(), id :: non_neg_integer) :: Hunter.Status.t()
@doc """
Destroy status
@ -347,7 +365,7 @@ defmodule Hunter.Api do
* `id` - status identifier
"""
@callback destroy_status(conn :: Hunter.Client.t, id :: non_neg_integer) :: boolean
@callback destroy_status(conn :: Hunter.Client.t(), id :: non_neg_integer) :: boolean
@doc """
Reblog a status
@ -358,7 +376,7 @@ defmodule Hunter.Api do
* `id` - status identifier
"""
@callback reblog(conn :: Hunter.Client.t, id :: non_neg_integer) :: Hunter.Status.t
@callback reblog(conn :: Hunter.Client.t(), id :: non_neg_integer) :: Hunter.Status.t()
@doc """
Undo a reblog of a status
@ -369,7 +387,7 @@ defmodule Hunter.Api do
* `id` - status identifier
"""
@callback unreblog(conn :: Hunter.Client.t, id :: non_neg_integer) :: Hunter.Status.t
@callback unreblog(conn :: Hunter.Client.t(), id :: non_neg_integer) :: Hunter.Status.t()
@doc """
Fetch the list of users who reblogged the status.
@ -387,7 +405,8 @@ defmodule Hunter.Api do
* `limit` - maximum number of *reblogged by* to get, default: 40, max: 80
"""
@callback reblogged_by(conn :: Hunter.Client.t, id :: non_neg_integer, options :: Keyword.t) :: [Hunter.Account.t]
@callback reblogged_by(conn :: Hunter.Client.t(), id :: non_neg_integer, options :: Keyword.t()) ::
[Hunter.Account.t()]
@doc """
Favorite a status
@ -398,7 +417,7 @@ defmodule Hunter.Api do
* `id` - status identifier
"""
@callback favourite(conn :: Hunter.Client.t, id :: non_neg_integer) :: Hunter.Status.t
@callback favourite(conn :: Hunter.Client.t(), id :: non_neg_integer) :: Hunter.Status.t()
@doc """
Undo a favorite of a status
@ -409,7 +428,7 @@ defmodule Hunter.Api do
* `id` - status identifier
"""
@callback unfavourite(conn :: Hunter.Client.t, id :: non_neg_integer) :: Hunter.Status.t
@callback unfavourite(conn :: Hunter.Client.t(), id :: non_neg_integer) :: Hunter.Status.t()
@doc """
Fetch a user's favourites
@ -426,7 +445,7 @@ defmodule Hunter.Api do
* `limit` - maximum of favourites to get, default: 20, max: 40
"""
@callback favourites(conn :: Hunter.Client.t, options :: Keyword.t) :: [Hunter.Status.t]
@callback favourites(conn :: Hunter.Client.t(), options :: Keyword.t()) :: [Hunter.Status.t()]
@doc """
Fetch the list of users who favourited the status.
@ -444,7 +463,11 @@ defmodule Hunter.Api do
* `limit` - maximum number of *favourited by* to get, default: 40, max: 80
"""
@callback favourited_by(conn :: Hunter.Client.t, id :: non_neg_integer, options :: Keyword.t) :: [Hunter.Account.t]
@callback favourited_by(
conn :: Hunter.Client.t(),
id :: non_neg_integer,
options :: Keyword.t()
) :: [Hunter.Account.t()]
@doc """
Get a list of statuses by a user
@ -464,7 +487,8 @@ defmodule Hunter.Api do
* `limit` - maximum number of statuses to get, default: 20, max: 40
"""
@callback statuses(conn :: Hunter.Client.t, account_id :: non_neg_integer, options :: map) :: [Hunter.Status.t]
@callback statuses(conn :: Hunter.Client.t(), account_id :: non_neg_integer, options :: map) ::
[Hunter.Status.t()]
@doc """
Retrieve statuses from the home timeline
@ -481,7 +505,7 @@ defmodule Hunter.Api do
* `limit` - maximum number of statuses on the requested timeline to get, default: 20, max: 40
"""
@callback home_timeline(conn :: Hunter.Client.t, options :: map) :: [Hunter.Status.t]
@callback home_timeline(conn :: Hunter.Client.t(), options :: map) :: [Hunter.Status.t()]
@doc """
Retrieve statuses from the public timeline
@ -499,7 +523,7 @@ defmodule Hunter.Api do
* `limit` - maximum number of statuses on the requested timeline to get, default: 20, max: 40
"""
@callback public_timeline(conn :: Hunter.Client.t, options :: map) :: [Hunter.Status.t]
@callback public_timeline(conn :: Hunter.Client.t(), options :: map) :: [Hunter.Status.t()]
@doc """
Retrieve statuses from a hashtag
@ -518,7 +542,8 @@ defmodule Hunter.Api do
* `limit` - maximum number of statuses on the requested timeline to get, default: 20, max: 40
"""
@callback hashtag_timeline(conn :: Hunter.Client.t, hashtag :: [String.t], options :: map) :: [Hunter.Status]
@callback hashtag_timeline(conn :: Hunter.Client.t(), hashtag :: [String.t()], options :: map) ::
[Hunter.Status]
@doc """
Retrieve instance information
@ -528,7 +553,7 @@ defmodule Hunter.Api do
* `conn` - connection credentials
"""
@callback instance_info(conn :: Hunter.Client.t) :: Hunter.Instance.t
@callback instance_info(conn :: Hunter.Client.t()) :: Hunter.Instance.t()
@doc """
Retrieve user's notifications
@ -545,7 +570,9 @@ defmodule Hunter.Api do
* `limit` - maximum number of notifications to get, default: 15, max: 30
"""
@callback notifications(conn :: Hunter.Client.t, options :: Keyword.t) :: [Hunter.Notification.t]
@callback notifications(conn :: Hunter.Client.t(), options :: Keyword.t()) :: [
Hunter.Notification.t()
]
@doc """
Retrieve single notification
@ -556,7 +583,7 @@ defmodule Hunter.Api do
* `id` - notification identifier
"""
@callback notification(conn :: Hunter.Client.t, non_neg_integer) :: Hunter.Notification.t
@callback notification(conn :: Hunter.Client.t(), non_neg_integer) :: Hunter.Notification.t()
@doc """
Deletes all notifications from the Mastodon server for the authenticated user
@ -566,7 +593,7 @@ defmodule Hunter.Api do
* `conn` - connection credentials
"""
@callback clear_notifications(conn :: Hunter.Client.t) :: boolean
@callback clear_notifications(conn :: Hunter.Client.t()) :: boolean
@doc """
Dismiss a single notification
@ -577,7 +604,7 @@ defmodule Hunter.Api do
* `id` - notification id
"""
@callback clear_notification(conn :: Hunter.Client.t, id :: non_neg_integer) :: boolean
@callback clear_notification(conn :: Hunter.Client.t(), id :: non_neg_integer) :: boolean
@doc """
Retrieve a user's reports
@ -587,7 +614,7 @@ defmodule Hunter.Api do
* `conn` - connection credentials
"""
@callback reports(conn :: Hunter.Client.t) :: [Hunter.Report.t]
@callback reports(conn :: Hunter.Client.t()) :: [Hunter.Report.t()]
@doc """
Report a user
@ -600,7 +627,12 @@ defmodule Hunter.Api do
* `comment` - a comment to associate with the report
"""
@callback report(conn :: Hunter.Client.t, account_id :: non_neg_integer, status_ids :: [non_neg_integer], comment :: String.t) :: Hunter.Report.t
@callback report(
conn :: Hunter.Client.t(),
account_id :: non_neg_integer,
status_ids :: [non_neg_integer],
comment :: String.t()
) :: Hunter.Report.t()
@doc """
Retrieve status context
@ -611,7 +643,7 @@ defmodule Hunter.Api do
* `id` - status identifier
"""
@callback status_context(conn :: Hunter.Client.t, id :: non_neg_integer) :: Hunter.Context.t
@callback status_context(conn :: Hunter.Client.t(), id :: non_neg_integer) :: Hunter.Context.t()
@doc """
Retrieve a card associated with a status
@ -622,7 +654,7 @@ defmodule Hunter.Api do
* `id` - status id
"""
@callback card_by_status(conn :: Hunter.Client.t, id :: non_neg_integer) :: Hunter.Card.t
@callback card_by_status(conn :: Hunter.Client.t(), id :: non_neg_integer) :: Hunter.Card.t()
@doc """
Retrieve access token
@ -635,7 +667,12 @@ defmodule Hunter.Api do
* `base_url` - API base url, default: `https://mastodon.social`
"""
@callback log_in(app :: Hunter.Application.t, username :: String.t, password :: String.t, base_url :: String.t) :: Hunter.Client.t
@callback log_in(
app :: Hunter.Application.t(),
username :: String.t(),
password :: String.t(),
base_url :: String.t()
) :: Hunter.Client.t()
@doc """
Fetch user's blocked domains
@ -652,7 +689,7 @@ defmodule Hunter.Api do
* `limit` - maximum number of blocks to get, default: 40, max: 80
"""
@callback blocked_domains(conn :: Hunter.Client.t, options :: Keyword.t) :: list
@callback blocked_domains(conn :: Hunter.Client.t(), options :: Keyword.t()) :: list
@doc """
Block a domain
@ -663,7 +700,7 @@ defmodule Hunter.Api do
* `domain` - domain to block
"""
@callback block_domain(conn :: Hunter.Client.t, domain :: String.t) :: boolean
@callback block_domain(conn :: Hunter.Client.t(), domain :: String.t()) :: boolean
@doc """
Unblock a domain
@ -674,5 +711,5 @@ defmodule Hunter.Api do
* `domain` - domain to unblock
"""
@callback unblock_domain(conn :: Hunter.Client.t, domain :: String.t) :: boolean
@callback unblock_domain(conn :: Hunter.Client.t(), domain :: String.t()) :: boolean
end

View File

@ -78,7 +78,7 @@ defmodule Hunter.Api.HTTPClient do
client_name: name,
redirect_uris: redirect_uri,
scopes: Enum.join(scopes, " "),
website: website,
website: website
}
"/api/v1/apps"
@ -136,7 +136,8 @@ defmodule Hunter.Api.HTTPClient do
end
def search(conn, query, options) do
options = options |> Keyword.merge([q: query]) |> Map.new()
options = options |> Keyword.merge(q: query) |> Map.new()
"/api/v1/search"
|> process_url(conn)
|> request!(:result, :get, options, get_headers(conn))
@ -144,6 +145,7 @@ defmodule Hunter.Api.HTTPClient do
def create_status(conn, status, options) do
body = Map.put(options, :status, status)
"/api/v1/statuses"
|> process_url(conn)
|> request!(:status, :post, body, get_headers(conn))
@ -287,7 +289,12 @@ defmodule Hunter.Api.HTTPClient do
|> request!(:card, :get, [], get_headers(conn))
end
def log_in(%Hunter.Application{client_id: client_id, client_secret: client_secret}, username, password, base_url) do
def log_in(
%Hunter.Application{client_id: client_id, client_secret: client_secret},
username,
password,
base_url
) do
payload = %{
client_id: client_id,
client_secret: client_secret,
@ -333,7 +340,7 @@ defmodule Hunter.Api.HTTPClient do
end
defp get_headers(%Hunter.Client{bearer_token: token}) do
["Authorization": "Bearer #{token}"]
[Authorization: "Bearer #{token}"]
end
defp process_url(endpoint, %Hunter.Client{base_url: base_url}) do
@ -365,7 +372,10 @@ defmodule Hunter.Api.HTTPClient do
end
defp transform(body, :context) do
Poison.decode!(body, as: %Hunter.Context{ancestors: [%Hunter.Status{}], descendants: [%Hunter.Status{}]})
Poison.decode!(
body,
as: %Hunter.Context{ancestors: [%Hunter.Status{}], descendants: [%Hunter.Status{}]}
)
end
defp transform(body, :instance) do
@ -405,7 +415,10 @@ defmodule Hunter.Api.HTTPClient do
end
defp transform(body, :result) do
Poison.decode!(body, as: %Hunter.Result{accounts: [%Hunter.Account{}], statuses: [%Hunter.Status{}]})
Poison.decode!(
body,
as: %Hunter.Result{accounts: [%Hunter.Account{}], statuses: [%Hunter.Status{}]}
)
end
defp transform(body, _) do

View File

@ -15,10 +15,10 @@ defmodule Hunter.Application do
@hunter_api Hunter.Config.hunter_api()
@type t :: %__MODULE__{
id: non_neg_integer,
client_id: String.t,
client_secret: String.t
}
id: non_neg_integer,
client_id: String.t(),
client_secret: String.t()
}
@derive [Poison.Encoder]
defstruct [:id, :client_id, :client_secret]
@ -60,8 +60,15 @@ defmodule Hunter.Application do
id: 1234}
"""
@spec create_app(String.t, String.t, [String.t], String.t, Keyword.t) :: Hunter.Application.t | no_return
def create_app(client_name, redirect_uris \\ "urn:ietf:wg:oauth:2.0:oob", scopes \\ ["read"], website \\ nil, options \\ []) do
@spec create_app(String.t(), String.t(), [String.t()], String.t(), Keyword.t()) ::
Hunter.Application.t() | no_return
def create_app(
client_name,
redirect_uris \\ "urn:ietf:wg:oauth:2.0:oob",
scopes \\ ["read"],
website \\ nil,
options \\ []
) do
save? = Keyword.get(options, :save?, false)
base_url = Keyword.get(options, :api_base_url, Hunter.Config.api_base_url())
@ -80,7 +87,7 @@ defmodule Hunter.Application do
* `name` - application name
"""
@spec load_credentials(String.t) :: Hunter.Application.t
@spec load_credentials(String.t()) :: Hunter.Application.t()
def load_credentials(name) do
Hunter.Config.home()
|> Path.join("apps/#{name}.json")

View File

@ -19,14 +19,14 @@ defmodule Hunter.Attachment do
@hunter_api Hunter.Config.hunter_api()
@type t :: %__MODULE__{
id: non_neg_integer,
type: String.t,
url: String.t,
remote_url: String.t,
preview_url: String.t,
text_url: String.t,
meta: String.t
}
id: non_neg_integer,
type: String.t(),
url: String.t(),
remote_url: String.t(),
preview_url: String.t(),
text_url: String.t(),
meta: String.t()
}
@derive [Poison.Encoder]
defstruct [:id, :type, :url, :remote_url, :preview_url, :text_url, :meta]
@ -40,7 +40,7 @@ defmodule Hunter.Attachment do
* `file` - media to be uploaded
"""
@spec upload_media(Hunter.Client.t, Path.t) :: Hunter.Attachment.t
@spec upload_media(Hunter.Client.t(), Path.t()) :: Hunter.Attachment.t()
def upload_media(conn, file) do
@hunter_api.upload_media(conn, file)
end

View File

@ -24,23 +24,35 @@ defmodule Hunter.Card do
@hunter_api Hunter.Config.hunter_api()
@type t :: %__MODULE__{
url: String.t,
title: String.t,
description: String.t,
image: String.t,
type: String.t,
author_name: String.t,
author_url: String.t,
provider_name: String.t,
provider_url: String.t,
html: String.t,
width: non_neg_integer,
height: non_neg_integer
}
url: String.t(),
title: String.t(),
description: String.t(),
image: String.t(),
type: String.t(),
author_name: String.t(),
author_url: String.t(),
provider_name: String.t(),
provider_url: String.t(),
html: String.t(),
width: non_neg_integer,
height: non_neg_integer
}
@derive [Poison.Encoder]
defstruct [:url, :title, :description, :image, :type, :author_name, :author_url, :provider_name, :provider_url,
:html, :width, :height]
defstruct [
:url,
:title,
:description,
:image,
:type,
:author_name,
:author_url,
:provider_name,
:provider_url,
:html,
:width,
:height
]
@doc """
Retrieve a card associated with a status
@ -60,7 +72,7 @@ defmodule Hunter.Card do
title: "milmazz/hunter", url: "https://github.com/milmazz/hunter"}
"""
@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
@hunter_api.card_by_status(conn, id)
end

View File

@ -6,9 +6,9 @@ defmodule Hunter.Client do
@hunter_api Hunter.Config.hunter_api()
@type t :: %__MODULE__{
base_url: String.t,
bearer_token: String.t
}
base_url: String.t(),
bearer_token: String.t()
}
@derive [Poison.Encoder]
defstruct [:base_url, :bearer_token]
@ -22,7 +22,7 @@ defmodule Hunter.Client do
* `bearer_token` - [String] OAuth access token for your authenticated user
"""
@spec new(Keyword.t) :: Hunter.Client.t
@spec new(Keyword.t()) :: Hunter.Client.t()
def new(options \\ []) do
struct(Hunter.Client, options)
end
@ -30,9 +30,9 @@ defmodule Hunter.Client do
@doc """
User agent of the client
"""
@spec user_agent() :: String.t
@spec user_agent() :: String.t()
def user_agent() do
"Hunter.Elixir/#{Hunter.version}"
"Hunter.Elixir/#{Hunter.version()}"
end
@doc """
@ -46,7 +46,7 @@ defmodule Hunter.Client do
* `base_url` - API base url, default: `https://mastodon.social`
"""
@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
@hunter_api.log_in(app, username, password, base_url || Hunter.Config.api_base_url())
end

View File

@ -5,7 +5,7 @@ defmodule Hunter.Config do
@api_base_url "https://mastodon.social"
def hunter_api() do
@hunter_api
@hunter_api
end
def api_base_url() do

View File

@ -11,9 +11,9 @@ defmodule Hunter.Context do
@hunter_api Hunter.Config.hunter_api()
@type t :: %__MODULE__{
ancestors: [Hunter.Status.t],
descendants: [Hunter.Status.t]
}
ancestors: [Hunter.Status.t()],
descendants: [Hunter.Status.t()]
}
@derive [Poison.Encoder]
defstruct [:ancestors, :descendants]
@ -27,7 +27,7 @@ defmodule Hunter.Context do
* `id` - status identifier
"""
@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
@hunter_api.status_context(conn, id)
end

View File

@ -20,7 +20,7 @@ defmodule Hunter.Domain do
* `limit` - maximum number of blocks to get, default: 40, max: 80
"""
@spec blocked_domains(Hunter.Client.t, Keyword.t) :: list
@spec blocked_domains(Hunter.Client.t(), Keyword.t()) :: list
def blocked_domains(conn, options \\ []) do
@hunter_api.blocked_domains(conn, options)
end
@ -34,7 +34,7 @@ defmodule Hunter.Domain do
* `domain` - domain to block
"""
@spec block_domain(Hunter.Client.t, String.t) :: boolean
@spec block_domain(Hunter.Client.t(), String.t()) :: boolean
def block_domain(conn, domain) do
@hunter_api.block_domain(conn, domain)
end
@ -48,7 +48,7 @@ defmodule Hunter.Domain do
* `domain` - domain to unblock
"""
@spec unblock_domain(Hunter.Client.t, String.t) :: boolean
@spec unblock_domain(Hunter.Client.t(), String.t()) :: boolean
def unblock_domain(conn, domain) do
@hunter_api.unblock_domain(conn, domain)
end

View File

@ -17,11 +17,11 @@ defmodule Hunter.EventStream do
"""
@type t :: %__MODULE__{
id: String.t,
event: String.t,
data: String.t,
retry: non_neg_integer
}
id: String.t(),
event: String.t(),
data: String.t(),
retry: non_neg_integer
}
defstruct [:id, :event, :data, :retry]
end

View File

@ -17,12 +17,12 @@ defmodule Hunter.Instance do
@hunter_api Hunter.Config.hunter_api()
@type t :: %__MODULE__{
uri: String.t,
title: String.t,
description: String.t,
email: String.t,
version: String.t
}
uri: String.t(),
title: String.t(),
description: String.t(),
email: String.t(),
version: String.t()
}
@derive [Poison.Encoder]
defstruct [:uri, :title, :description, :email, :version]
@ -44,7 +44,7 @@ defmodule Hunter.Instance do
uri: "social.lou.lt"}
"""
@spec instance_info(Hunter.Client.t) :: Hunter.Instance.t
@spec instance_info(Hunter.Client.t()) :: Hunter.Instance.t()
def instance_info(conn) do
@hunter_api.instance_info(conn)
end

View File

@ -11,13 +11,12 @@ defmodule Hunter.Mention do
"""
@type t :: %__MODULE__{
url: String.t,
username: String.t,
acct: String.t,
id: non_neg_integer
}
url: String.t(),
username: String.t(),
acct: String.t(),
id: non_neg_integer
}
@derive [Poison.Encoder]
defstruct [:url, :username, :acct, :id]
end

View File

@ -17,12 +17,12 @@ defmodule Hunter.Notification do
@hunter_api Hunter.Config.hunter_api()
@type t :: %__MODULE__{
id: String.t,
type: String.t,
created_at: String.t,
account: Hunter.Account.t,
status: Hunter.Status.t
}
id: String.t(),
type: String.t(),
created_at: String.t(),
account: Hunter.Account.t(),
status: Hunter.Status.t()
}
@derive [Poison.Encoder]
defstruct [:id, :type, :created_at, :account, :status]
@ -47,7 +47,7 @@ defmodule Hunter.Notification do
#=> [%Hunter.Notification{account: %{"acct" => "paperswelove@mstdn.io", ...}]
"""
@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
@hunter_api.notifications(conn, options)
end
@ -66,7 +66,7 @@ defmodule Hunter.Notification do
#=> %Hunter.Notification{account: %{"acct" => "paperswelove@mstdn.io", ...}
"""
@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
@hunter_api.notification(conn, id)
end
@ -79,7 +79,7 @@ defmodule Hunter.Notification do
* `conn` - connection credentials
"""
@spec clear_notifications(Hunter.Client.t) :: boolean
@spec clear_notifications(Hunter.Client.t()) :: boolean
def clear_notifications(conn) do
@hunter_api.clear_notifications(conn)
end
@ -93,7 +93,7 @@ defmodule Hunter.Notification do
* `id` - notification id
"""
@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
@hunter_api.clear_notification(conn, id)
end

View File

@ -19,14 +19,14 @@ defmodule Hunter.Relationship do
@hunter_api Hunter.Config.hunter_api()
@type t :: %__MODULE__{
id: non_neg_integer,
following: boolean,
followed_by: boolean,
blocking: boolean,
muting: boolean,
requested: boolean,
domain_blocking: boolean
}
id: non_neg_integer,
following: boolean,
followed_by: boolean,
blocking: boolean,
muting: boolean,
requested: boolean,
domain_blocking: boolean
}
@derive [Poison.Encoder]
defstruct [:id, :following, :followed_by, :blocking, :muting, :requested, :domain_blocking]
@ -40,7 +40,7 @@ defmodule Hunter.Relationship do
* `id` - list of relationship IDs
"""
@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
@hunter_api.relationships(conn, ids)
end
@ -54,7 +54,7 @@ defmodule Hunter.Relationship do
* `id` - user id
"""
@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
@hunter_api.follow(conn, id)
end
@ -68,7 +68,7 @@ defmodule Hunter.Relationship do
* `id` - user id
"""
@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
@hunter_api.unfollow(conn, id)
end
@ -82,7 +82,7 @@ defmodule Hunter.Relationship do
* `id` - user id
"""
@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
@hunter_api.block(conn, id)
end
@ -94,7 +94,7 @@ defmodule Hunter.Relationship do
* `id` - user id
"""
@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
@hunter_api.unblock(conn, id)
end
@ -108,7 +108,7 @@ defmodule Hunter.Relationship do
* `id` - user id
"""
@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
@hunter_api.mute(conn, id)
end
@ -122,7 +122,7 @@ defmodule Hunter.Relationship do
* `id` - user id
"""
@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
@hunter_api.unmute(conn, id)
end

View File

@ -14,9 +14,9 @@ defmodule Hunter.Report do
@hunter_api Hunter.Config.hunter_api()
@type t :: %__MODULE__{
id: non_neg_integer,
action_taken: String.t
}
id: non_neg_integer,
action_taken: String.t()
}
@derive [Poison.Encoder]
defstruct [:id, :action_taken]
@ -29,7 +29,7 @@ defmodule Hunter.Report do
* `conn` - connection credentials
"""
@spec reports(Hunter.Client.t) :: [Hunter.Report.t]
@spec reports(Hunter.Client.t()) :: [Hunter.Report.t()]
def reports(conn) do
@hunter_api.reports(conn)
end
@ -45,7 +45,8 @@ defmodule Hunter.Report do
* `comment` - a comment to associate with the report
"""
@spec report(Hunter.Client.t, non_neg_integer, [non_neg_integer], String.t) :: Hunter.Report.t
@spec report(Hunter.Client.t(), non_neg_integer, [non_neg_integer], String.t()) ::
Hunter.Report.t()
def report(conn, account_id, status_ids, comment) do
@hunter_api.report(conn, account_id, status_ids, comment)
end

View File

@ -19,8 +19,10 @@ defmodule Hunter.Request do
case HTTPoison.request(method, url, body, headers, options) do
{:ok, %{status_code: status, body: body}} when status in 200..299 ->
{:ok, body}
{:ok, %{body: body}} ->
{:error, body}
{:error, %HTTPoison.Error{reason: reason}} ->
{:error, reason}
end
@ -30,14 +32,19 @@ defmodule Hunter.Request do
case data do
[] ->
"{}"
data when is_binary(data) ->
data
_ ->
Poison.encode!(data)
end
end
defp process_request_header(data) do
Keyword.merge(["Content-Type": "application/json", "Accept": "Application/json; Charset=utf-8"], data)
Keyword.merge(
["Content-Type": "application/json", Accept: "Application/json; Charset=utf-8"],
data
)
end
end

View File

@ -12,10 +12,10 @@ defmodule Hunter.Result do
@hunter_api Hunter.Config.hunter_api()
@type t :: %__MODULE__{
accounts: [Hunter.Account.t],
statuses: [Hunter.Status.t],
hashtags: [String.t]
}
accounts: [Hunter.Account.t()],
statuses: [Hunter.Status.t()],
hashtags: [String.t()]
}
@derive [Poison.Encoder]
defstruct accounts: [],
@ -38,7 +38,7 @@ defmodule Hunter.Result do
* `resolve` - Whether to resolve non-local accounts
"""
@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
@hunter_api.search(conn, query, options)
end

View File

@ -30,51 +30,53 @@ defmodule Hunter.Status do
@hunter_api Hunter.Config.hunter_api()
@type t :: %__MODULE__{
id: non_neg_integer,
uri: String.t,
url: String.t,
account: Hunter.Account.t,
in_reply_to_id: non_neg_integer,
reblog: Hunter.Status.t | nil,
content: String.t,
created_at: String.t,
reblogs_count: non_neg_integer,
favourites_count: non_neg_integer,
reblogged: boolean,
favourited: boolean,
sensitive: boolean,
spoiler_text: String.t,
media_attachments: [Hunter.Attachment.t],
mentions: [Hunter.Mention.t],
tags: [Hunter.Tag.t],
application: Hunter.Application.t,
language: String.t
}
id: non_neg_integer,
uri: String.t(),
url: String.t(),
account: Hunter.Account.t(),
in_reply_to_id: non_neg_integer,
reblog: Hunter.Status.t() | nil,
content: String.t(),
created_at: String.t(),
reblogs_count: non_neg_integer,
favourites_count: non_neg_integer,
reblogged: boolean,
favourited: boolean,
sensitive: boolean,
spoiler_text: String.t(),
media_attachments: [Hunter.Attachment.t()],
mentions: [Hunter.Mention.t()],
tags: [Hunter.Tag.t()],
application: Hunter.Application.t(),
language: String.t()
}
@type status_id :: non_neg_integer
@derive [Poison.Encoder]
defstruct [:id,
:uri,
:url,
:account,
:in_reply_to_id,
:in_reply_to_account_id,
:reblog,
:content,
:created_at,
:reblogs_count,
:favourites_count,
:reblogged,
:favourited,
:sensitive,
:spoiler_text,
:visibility,
:media_attachments,
:mentions,
:tags,
:application,
:language]
defstruct [
:id,
:uri,
:url,
:account,
:in_reply_to_id,
:in_reply_to_account_id,
:reblog,
:content,
:created_at,
:reblogs_count,
:favourites_count,
:reblogged,
:favourited,
:sensitive,
:spoiler_text,
:visibility,
:media_attachments,
:mentions,
:tags,
:application,
:language
]
@doc """
Create new status
@ -94,7 +96,7 @@ defmodule Hunter.Status do
* `visibility` - either `direct`, `private`, `unlisted` or `public`
"""
@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
@hunter_api.create_status(conn, status, Map.new(options))
end
@ -108,7 +110,7 @@ defmodule Hunter.Status do
* `id` - status identifier
"""
@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
@hunter_api.status(conn, id)
end
@ -122,7 +124,7 @@ defmodule Hunter.Status do
* `id` - status identifier
"""
@spec destroy_status(Hunter.Client.t, status_id) :: boolean
@spec destroy_status(Hunter.Client.t(), status_id) :: boolean
def destroy_status(conn, id) do
@hunter_api.destroy_status(conn, id)
end
@ -136,7 +138,7 @@ defmodule Hunter.Status do
* `id` - status identifier
"""
@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
@hunter_api.reblog(conn, id)
end
@ -150,7 +152,7 @@ defmodule Hunter.Status do
* `id` - status identifier
"""
@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
@hunter_api.unreblog(conn, id)
end
@ -164,7 +166,7 @@ defmodule Hunter.Status do
* `id` - status identifier
"""
@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
@hunter_api.favourite(conn, id)
end
@ -178,7 +180,7 @@ defmodule Hunter.Status do
* `id` - status identifier
"""
@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
@hunter_api.unfavourite(conn, id)
end
@ -198,7 +200,7 @@ defmodule Hunter.Status do
* `limit` - maximum of favourites to get, default: 20, max: 40
"""
@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
@hunter_api.favourites(conn, options)
end
@ -221,7 +223,7 @@ defmodule Hunter.Status do
* `limit` - maximum number of statuses to get, default: 20, max: 40
"""
@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
@hunter_api.statuses(conn, account_id, Map.new(options))
end
@ -241,7 +243,7 @@ defmodule Hunter.Status do
* `limit` - maximum number of statuses on the requested timeline to get, default: 20, max: 40
"""
@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
@hunter_api.home_timeline(conn, Map.new(options))
end
@ -262,7 +264,7 @@ defmodule Hunter.Status do
* `limit` - maximum number of statuses on the requested timeline to get, default: 20, max: 40
"""
@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
@hunter_api.public_timeline(conn, Map.new(options))
end
@ -284,7 +286,7 @@ defmodule Hunter.Status do
* `limit` - maximum number of statuses on the requested timeline to get, default: 20, max: 40
"""
@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
@hunter_api.hashtag_timeline(conn, hashtag, Map.new(options))
end

View File

@ -10,9 +10,9 @@ defmodule Hunter.Tag do
"""
@type t :: %__MODULE__{
name: String.t,
url: String.t
}
name: String.t(),
url: String.t()
}
@derive [Poison.Encoder]
defstruct [:name, :url]

54
mix.exs
View File

@ -2,17 +2,19 @@ defmodule Hunter.Mixfile do
use Mix.Project
def project do
[app: :hunter,
version: "0.5.0-dev",
elixir: "~> 1.3",
docs: docs(),
package: package(),
source_url: "https://github.com/milmazz/hunter",
description: "Elixir client for Mastodon, a GNU social-compatible micro-blogging service",
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
elixirc_paths: elixirc_paths(Mix.env),
deps: deps()]
[
app: :hunter,
version: "0.5.0-dev",
elixir: "~> 1.3",
docs: docs(),
package: package(),
source_url: "https://github.com/milmazz/hunter",
description: "Elixir client for Mastodon, a GNU social-compatible micro-blogging service",
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
elixirc_paths: elixirc_paths(Mix.env()),
deps: deps()
]
end
# Configuration for the OTP application
@ -24,23 +26,31 @@ defmodule Hunter.Mixfile do
end
defp deps do
[{:httpoison, "~> 0.10.0"},
{:poison, "~> 3.0"},
{:ex_doc, "~> 0.14", only: :dev, runtime: false}]
[
{:httpoison, "~> 0.10.0"},
{:poison, "~> 3.0"},
{:ex_doc, "~> 0.14", only: :dev, runtime: false}
]
end
defp package do
[licenses: ["Apache 2.0"],
maintainers: ["Milton Mazzarri"],
links: %{"GitHub" => "https://github.com/milmazz/hunter"}]
[
licenses: ["Apache 2.0"],
maintainers: ["Milton Mazzarri"],
links: %{"GitHub" => "https://github.com/milmazz/hunter"}
]
end
defp docs do
[extras: ["README.md": [title: "README"],
"CONTRIBUTING.md": [title: "How to contribute"],
"CODE_OF_CONDUCT.md": [title: "Code of Conduct"],
"CHANGELOG.md": [title: "Changelog"]],
main: "readme"]
[
extras: [
"README.md": [title: "README"],
"CONTRIBUTING.md": [title: "How to contribute"],
"CODE_OF_CONDUCT.md": [title: "Code of Conduct"],
"CHANGELOG.md": [title: "Changelog"]
],
main: "readme"
]
end
# Specifies which paths to compile per environment

View File

@ -4,8 +4,8 @@ defmodule Hunter.AccountTest do
alias Hunter.Account
setup do
[conn: Hunter.Client.new([base_url: "https://example.com", bearer_token: "123456"])]
setup do
[conn: Hunter.Client.new(base_url: "https://example.com", bearer_token: "123456")]
end
test "verify credentials", %{conn: conn} do
@ -27,6 +27,7 @@ defmodule Hunter.AccountTest do
end
test "following a remote user", %{conn: conn} do
assert %Account{username: "paperswelove"} = Account.follow_by_uri(conn, "paperswelove@mstdn.io")
assert %Account{username: "paperswelove"} =
Account.follow_by_uri(conn, "paperswelove@mstdn.io")
end
end

View File

@ -5,7 +5,7 @@ defmodule Hunter.CardTest do
alias Hunter.Card
setup do
[conn: Hunter.Client.new([base_url: "https://example.com", bearer_token: "123456"])]
[conn: Hunter.Client.new(base_url: "https://example.com", bearer_token: "123456")]
end
test "verify a card associated with a status", %{conn: conn} do

View File

@ -5,7 +5,7 @@ defmodule Hunter.InstanceTest do
alias Hunter.Instance
setup do
[conn: Hunter.Client.new([base_url: "https://example.com", bearer_token: "123456"])]
[conn: Hunter.Client.new(base_url: "https://example.com", bearer_token: "123456")]
end
test "verify instance information", %{conn: conn} do

View File

@ -5,7 +5,7 @@ defmodule Hunter.NotificationTest do
alias Hunter.Notification
setup do
[conn: Hunter.Client.new([base_url: "https://example.com", bearer_token: "123456"])]
[conn: Hunter.Client.new(base_url: "https://example.com", bearer_token: "123456")]
end
test "fetch user's notifications", %{conn: conn} do

View File

@ -5,7 +5,7 @@ defmodule Hunter.StatusTest do
alias Hunter.Status
setup do
[conn: Hunter.Client.new([base_url: "https://example.com", bearer_token: "123456"])]
[conn: Hunter.Client.new(base_url: "https://example.com", bearer_token: "123456")]
end
test "home timeline should return a collection of statuses", %{conn: conn} do

View File

@ -47,21 +47,21 @@ defmodule Hunter.Api.InMemory do
%{name: :unreblog, arity: 2, as: %Hunter.Status{}},
%{name: :update_credentials, arity: 2, as: %Hunter.Account{}},
%{name: :upload_media, arity: 2, as: %Hunter.Attachment{}},
%{name: :verify_credentials, arity: 1, as: %Hunter.Account{}},
%{name: :verify_credentials, arity: 1, as: %Hunter.Account{}}
]
|> Enum.map(fn %{name: name, arity: arity, as: as} ->
params = for _ <- 1..arity, do: {:_, [], nil}
as = Macro.escape(as)
params = for _ <- 1..arity, do: {:_, [], nil}
as = Macro.escape(as)
def unquote(name)(unquote_splicing(params)) do
file = to_string(unquote(name))
def unquote(name)(unquote_splicing(params)) do
file = to_string(unquote(name))
"../fixtures/#{file}.json"
|> Path.expand(__DIR__)
|> File.read!()
|> Poison.decode!(as: unquote(as))
end
end)
"../fixtures/#{file}.json"
|> Path.expand(__DIR__)
|> File.read!()
|> Poison.decode!(as: unquote(as))
end
end)
def destroy_status(_, _), do: true
def follow_request_action(_, _, _), do: true