mix format
parent
156124101a
commit
605a062c86
111
lib/hunter.ex
111
lib/hunter.ex
|
@ -4,7 +4,7 @@ defmodule Hunter do
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@hunter_version Mix.Project.config[:version]
|
@hunter_version Mix.Project.config()[:version]
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Retrieve account of authenticated user
|
Retrieve account of authenticated user
|
||||||
|
@ -14,7 +14,7 @@ defmodule Hunter do
|
||||||
* `conn` - connection credentials
|
* `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
|
defdelegate verify_credentials(conn), to: Hunter.Account
|
||||||
|
|
||||||
@doc """
|
@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...`)
|
* `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
|
defdelegate update_credentials(conn, data), to: Hunter.Account
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -45,7 +45,7 @@ defmodule Hunter do
|
||||||
* `id` - account identifier
|
* `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
|
defdelegate account(conn, id), to: Hunter.Account
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -64,7 +64,7 @@ defmodule Hunter do
|
||||||
* `limit` - maximum number of followers to get, default: 40, maximum: 80
|
* `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
|
defdelegate followers(conn, id, options \\ []), to: Hunter.Account
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -83,7 +83,7 @@ defmodule Hunter do
|
||||||
* `limit` - maximum number of followings to get, default: 40, maximum: 80
|
* `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
|
defdelegate following(conn, id, options \\ []), to: Hunter.Account
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -95,7 +95,7 @@ defmodule Hunter do
|
||||||
* `uri` - URI of the remote user, in the format of `username@domain`
|
* `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
|
defdelegate follow_by_uri(conn, uri), to: Hunter.Account
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -112,7 +112,7 @@ defmodule Hunter do
|
||||||
* `limit`: maximum number of matching accounts to return, default: 40
|
* `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
|
defdelegate search_account(conn, options), to: Hunter.Account
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -129,7 +129,7 @@ defmodule Hunter do
|
||||||
* `limit` - maximum number of blocks to get, default: 40, max: 80
|
* `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
|
defdelegate blocks(conn, options \\ []), to: Hunter.Account
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -147,7 +147,7 @@ defmodule Hunter do
|
||||||
* `limit` - maximum number of requests to get, default: 40, max: 80
|
* `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
|
defdelegate follow_requests(conn, options \\ []), to: Hunter.Account
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -165,7 +165,7 @@ defmodule Hunter do
|
||||||
* `limit` - maximum number of mutes to get, default: 40, max: 80
|
* `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
|
defdelegate mutes(conn, options \\ []), to: Hunter.Account
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -177,7 +177,7 @@ defmodule Hunter do
|
||||||
* `id` - follow request id
|
* `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
|
defdelegate accept_follow_request(conn, id), to: Hunter.Account
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -189,7 +189,7 @@ defmodule Hunter do
|
||||||
* `id` - follow request id
|
* `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
|
defdelegate reject_follow_request(conn, id), to: Hunter.Account
|
||||||
|
|
||||||
## Application
|
## Application
|
||||||
|
@ -222,8 +222,16 @@ defmodule Hunter do
|
||||||
different instance. default: `https://mastodon.social`
|
different instance. default: `https://mastodon.social`
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@spec create_app(String.t, String.t, [String.t], String.t, Keyword.t) :: Hunter.Application.t | no_return
|
@spec create_app(String.t(), String.t(), [String.t()], String.t(), Keyword.t()) ::
|
||||||
defdelegate create_app(name, redirect_uri \\ "urn:ietf:wg:oauth:2.0:oob", scopes \\ ["read"], website \\ nil, options \\ []), to: Hunter.Application
|
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 """
|
@doc """
|
||||||
Load persisted application's credentials
|
Load persisted application's credentials
|
||||||
|
@ -233,7 +241,7 @@ defmodule Hunter do
|
||||||
* `name` - application's name
|
* `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
|
defdelegate load_credentials(name), to: Hunter.Application
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -245,13 +253,13 @@ defmodule Hunter do
|
||||||
* `bearer_token` - [String] OAuth access token for your authenticated user
|
* `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
|
defdelegate new(options \\ []), to: Hunter.Client
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
User agent of the client
|
User agent of the client
|
||||||
"""
|
"""
|
||||||
@spec user_agent() :: String.t
|
@spec user_agent() :: String.t()
|
||||||
defdelegate user_agent, to: Hunter.Client
|
defdelegate user_agent, to: Hunter.Client
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -263,7 +271,7 @@ defmodule Hunter do
|
||||||
* `file` - media to be uploaded
|
* `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
|
defdelegate upload_media(conn, file), to: Hunter.Attachment
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -275,7 +283,7 @@ defmodule Hunter do
|
||||||
* `id` - list of relationship IDs
|
* `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
|
defdelegate relationships(conn, ids), to: Hunter.Relationship
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -287,7 +295,7 @@ defmodule Hunter do
|
||||||
* `id` - user identifier
|
* `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
|
defdelegate follow(conn, id), to: Hunter.Relationship
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -299,7 +307,7 @@ defmodule Hunter do
|
||||||
* `id` - user identifier
|
* `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
|
defdelegate unfollow(conn, id), to: Hunter.Relationship
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -311,7 +319,7 @@ defmodule Hunter do
|
||||||
* `id` - user identifier
|
* `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
|
defdelegate block(conn, id), to: Hunter.Relationship
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -321,7 +329,7 @@ defmodule Hunter do
|
||||||
* `id` - user identifier
|
* `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
|
defdelegate unblock(conn, id), to: Hunter.Relationship
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -333,7 +341,7 @@ defmodule Hunter do
|
||||||
* `id` - user identifier
|
* `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
|
defdelegate mute(conn, id), to: Hunter.Relationship
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -345,7 +353,7 @@ defmodule Hunter do
|
||||||
* `id` - user identifier
|
* `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
|
defdelegate unmute(conn, id), to: Hunter.Relationship
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -362,7 +370,7 @@ defmodule Hunter do
|
||||||
* `resolve` - whether to resolve non-local accounts
|
* `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
|
defdelegate search(conn, query, options \\ []), to: Hunter.Result
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -383,7 +391,7 @@ defmodule Hunter do
|
||||||
* `visibility` - either `direct`, `private`, `unlisted` or `public`
|
* `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
|
defdelegate create_status(conn, status, options \\ []), to: Hunter.Status
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -395,7 +403,7 @@ defmodule Hunter do
|
||||||
* `id` - status identifier
|
* `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
|
defdelegate status(conn, id), to: Hunter.Status
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -407,7 +415,7 @@ defmodule Hunter do
|
||||||
* `id` - status identifier
|
* `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
|
defdelegate destroy_status(conn, id), to: Hunter.Status
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -419,7 +427,7 @@ defmodule Hunter do
|
||||||
* `id` - status identifier
|
* `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
|
defdelegate reblog(conn, id), to: Hunter.Status
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -431,7 +439,7 @@ defmodule Hunter do
|
||||||
* `id` - status identifier
|
* `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
|
defdelegate unreblog(conn, id), to: Hunter.Status
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -450,7 +458,7 @@ defmodule Hunter do
|
||||||
* `limit` - maximum number of *reblogged by* to get, default: 40, max: 80
|
* `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
|
defdelegate reblogged_by(conn, id, options \\ []), to: Hunter.Account
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -462,7 +470,7 @@ defmodule Hunter do
|
||||||
* `id` - status identifier
|
* `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
|
defdelegate favourite(conn, id), to: Hunter.Status
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -474,7 +482,7 @@ defmodule Hunter do
|
||||||
* `id` - status identifier
|
* `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
|
defdelegate unfavourite(conn, id), to: Hunter.Status
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -492,7 +500,7 @@ defmodule Hunter do
|
||||||
* `limit` - maximum of favourites to get, default: 20, max: 40
|
* `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
|
defdelegate favourites(conn, options \\ []), to: Hunter.Status
|
||||||
|
|
||||||
@doc """
|
@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
|
defdelegate favourited_by(conn, id, options \\ []), to: Hunter.Account
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -533,7 +541,7 @@ defmodule Hunter do
|
||||||
* `limit` - maximum number of statuses to get, default: 20, max: 40
|
* `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
|
defdelegate statuses(conn, account_id, options \\ []), to: Hunter.Status
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -551,7 +559,7 @@ defmodule Hunter do
|
||||||
* `limit` - maximum number of statuses on the requested timeline to get, default: 20, max: 40
|
* `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
|
defdelegate home_timeline(conn, options \\ []), to: Hunter.Status
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -570,7 +578,7 @@ defmodule Hunter do
|
||||||
* `limit` - maximum number of statuses on the requested timeline to get, default: 20, max: 40
|
* `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
|
defdelegate public_timeline(conn, options \\ []), to: Hunter.Status
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -590,7 +598,7 @@ defmodule Hunter do
|
||||||
* `limit` - maximum number of statuses on the requested timeline to get, default: 20, max: 40
|
* `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
|
defdelegate hashtag_timeline(conn, hashtag, options \\ []), to: Hunter.Status
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -601,7 +609,7 @@ defmodule Hunter do
|
||||||
* `conn` - connection credentials
|
* `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
|
defdelegate instance_info(conn), to: Hunter.Instance
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -619,7 +627,7 @@ defmodule Hunter do
|
||||||
* `limit` - maximum number of notifications to get, default: 15, max: 30
|
* `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
|
defdelegate notifications(conn, options \\ []), to: Hunter.Notification
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -631,7 +639,7 @@ defmodule Hunter do
|
||||||
* `id` - notification identifier
|
* `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
|
defdelegate notification(conn, id), to: Hunter.Notification
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -642,7 +650,7 @@ defmodule Hunter do
|
||||||
* `conn` - connection credentials
|
* `conn` - connection credentials
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@spec clear_notifications(Hunter.Client.t) :: boolean
|
@spec clear_notifications(Hunter.Client.t()) :: boolean
|
||||||
defdelegate clear_notifications(conn), to: Hunter.Notification
|
defdelegate clear_notifications(conn), to: Hunter.Notification
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -654,7 +662,7 @@ defmodule Hunter do
|
||||||
* `id` - notification id
|
* `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
|
defdelegate clear_notification(conn, id), to: Hunter.Notification
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -665,7 +673,7 @@ defmodule Hunter do
|
||||||
* `conn` - connection credentials
|
* `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
|
defdelegate reports(conn), to: Hunter.Report
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -679,7 +687,8 @@ defmodule Hunter do
|
||||||
* `comment` - a comment to associate with the report
|
* `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
|
defdelegate report(conn, account_id, status_ids, comment), to: Hunter.Report
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -691,7 +700,7 @@ defmodule Hunter do
|
||||||
* `id` - status identifier
|
* `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
|
defdelegate status_context(conn, id), to: Hunter.Context
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -703,7 +712,7 @@ defmodule Hunter do
|
||||||
* `id` - status id
|
* `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
|
defdelegate card_by_status(conn, id), to: Hunter.Card
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -761,6 +770,6 @@ defmodule Hunter do
|
||||||
@doc """
|
@doc """
|
||||||
Returns Hunter version
|
Returns Hunter version
|
||||||
"""
|
"""
|
||||||
@spec version() :: String.t
|
@spec version() :: String.t()
|
||||||
def version(), do: @hunter_version
|
def version(), do: @hunter_version
|
||||||
end
|
end
|
||||||
|
|
|
@ -27,39 +27,41 @@ defmodule Hunter.Account do
|
||||||
@hunter_api Hunter.Config.hunter_api()
|
@hunter_api Hunter.Config.hunter_api()
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
id: non_neg_integer,
|
id: non_neg_integer,
|
||||||
username: String.t,
|
username: String.t(),
|
||||||
acct: String.t,
|
acct: String.t(),
|
||||||
display_name: String.t,
|
display_name: String.t(),
|
||||||
note: String.t,
|
note: String.t(),
|
||||||
url: String.t,
|
url: String.t(),
|
||||||
avatar: String.t,
|
avatar: String.t(),
|
||||||
avatar_static: String.t,
|
avatar_static: String.t(),
|
||||||
header: String.t,
|
header: String.t(),
|
||||||
header_static: String.t,
|
header_static: String.t(),
|
||||||
locked: String.t,
|
locked: String.t(),
|
||||||
created_at: String.t,
|
created_at: String.t(),
|
||||||
followers_count: non_neg_integer,
|
followers_count: non_neg_integer,
|
||||||
following_count: non_neg_integer,
|
following_count: non_neg_integer,
|
||||||
statuses_count: non_neg_integer
|
statuses_count: non_neg_integer
|
||||||
}
|
}
|
||||||
|
|
||||||
@derive [Poison.Encoder]
|
@derive [Poison.Encoder]
|
||||||
defstruct [:id,
|
defstruct [
|
||||||
:username,
|
:id,
|
||||||
:acct,
|
:username,
|
||||||
:display_name,
|
:acct,
|
||||||
:note,
|
:display_name,
|
||||||
:url,
|
:note,
|
||||||
:avatar,
|
:url,
|
||||||
:avatar_static,
|
:avatar,
|
||||||
:header,
|
:avatar_static,
|
||||||
:header_static,
|
:header,
|
||||||
:locked,
|
:header_static,
|
||||||
:created_at,
|
:locked,
|
||||||
:followers_count,
|
:created_at,
|
||||||
:following_count,
|
:followers_count,
|
||||||
:statuses_count]
|
:following_count,
|
||||||
|
:statuses_count
|
||||||
|
]
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Retrieve account of authenticated user
|
Retrieve account of authenticated user
|
||||||
|
@ -85,7 +87,7 @@ defmodule Hunter.Account do
|
||||||
url: "https://social.lou.lt/@milmazz", username: "milmazz"}
|
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
|
def verify_credentials(conn) do
|
||||||
@hunter_api.verify_credentials(conn)
|
@hunter_api.verify_credentials(conn)
|
||||||
end
|
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...`)
|
* `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
|
def update_credentials(conn, data) do
|
||||||
@hunter_api.update_credentials(conn, data)
|
@hunter_api.update_credentials(conn, data)
|
||||||
end
|
end
|
||||||
|
@ -120,7 +122,7 @@ defmodule Hunter.Account do
|
||||||
* `id` - account id
|
* `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
|
def account(conn, id) do
|
||||||
@hunter_api.account(conn, id)
|
@hunter_api.account(conn, id)
|
||||||
end
|
end
|
||||||
|
@ -141,7 +143,7 @@ defmodule Hunter.Account do
|
||||||
* `limit` - maximum number of followers to get, default: 40, maximum: 80
|
* `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
|
def followers(conn, id, options \\ []) do
|
||||||
@hunter_api.followers(conn, id, options)
|
@hunter_api.followers(conn, id, options)
|
||||||
end
|
end
|
||||||
|
@ -162,7 +164,7 @@ defmodule Hunter.Account do
|
||||||
* `limit` - maximum number of followings to get, default: 40, maximum: 80
|
* `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
|
def following(conn, id, options \\ []) do
|
||||||
@hunter_api.following(conn, id, options)
|
@hunter_api.following(conn, id, options)
|
||||||
end
|
end
|
||||||
|
@ -176,7 +178,7 @@ defmodule Hunter.Account do
|
||||||
* `uri` - URI of the remote user, in the format of `username@domain`
|
* `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
|
def follow_by_uri(conn, uri) do
|
||||||
@hunter_api.follow_by_uri(conn, uri)
|
@hunter_api.follow_by_uri(conn, uri)
|
||||||
end
|
end
|
||||||
|
@ -195,7 +197,7 @@ defmodule Hunter.Account do
|
||||||
* `limit`: maximum number of matching accounts to return, default: 40
|
* `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
|
def search_account(conn, options) do
|
||||||
opts = %{
|
opts = %{
|
||||||
q: Keyword.fetch!(options, :q),
|
q: Keyword.fetch!(options, :q),
|
||||||
|
@ -219,7 +221,7 @@ defmodule Hunter.Account do
|
||||||
* `limit` - maximum number of blocks to get, default: 40, max: 80
|
* `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
|
def blocks(conn, options \\ []) do
|
||||||
@hunter_api.blocks(conn, options)
|
@hunter_api.blocks(conn, options)
|
||||||
end
|
end
|
||||||
|
@ -239,7 +241,7 @@ defmodule Hunter.Account do
|
||||||
* `limit` - maximum number of requests to get, default: 40, max: 80
|
* `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
|
def follow_requests(conn, options \\ []) do
|
||||||
@hunter_api.follow_requests(conn, options)
|
@hunter_api.follow_requests(conn, options)
|
||||||
end
|
end
|
||||||
|
@ -259,7 +261,7 @@ defmodule Hunter.Account do
|
||||||
* `limit` - maximum number of mutes to get, default: 40, max: 80
|
* `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
|
def mutes(conn, options \\ []) do
|
||||||
@hunter_api.mutes(conn, options)
|
@hunter_api.mutes(conn, options)
|
||||||
end
|
end
|
||||||
|
@ -273,7 +275,7 @@ defmodule Hunter.Account do
|
||||||
* `id` - follow request id
|
* `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
|
def accept_follow_request(conn, id) do
|
||||||
@hunter_api.follow_request_action(conn, id, :authorize)
|
@hunter_api.follow_request_action(conn, id, :authorize)
|
||||||
end
|
end
|
||||||
|
@ -287,7 +289,7 @@ defmodule Hunter.Account do
|
||||||
* `id` - follow request id
|
* `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
|
def reject_follow_request(conn, id) do
|
||||||
@hunter_api.follow_request_action(conn, id, :reject)
|
@hunter_api.follow_request_action(conn, id, :reject)
|
||||||
end
|
end
|
||||||
|
@ -308,7 +310,7 @@ defmodule Hunter.Account do
|
||||||
* `limit` - maximum number of *reblogged by* to get, default: 40, max: 80
|
* `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
|
def reblogged_by(conn, id, options \\ []) do
|
||||||
@hunter_api.reblogged_by(conn, id, options)
|
@hunter_api.reblogged_by(conn, id, options)
|
||||||
end
|
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
|
def favourited_by(conn, id, options \\ []) do
|
||||||
@hunter_api.favourited_by(conn, id, options)
|
@hunter_api.favourited_by(conn, id, options)
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ defmodule Hunter.Api do
|
||||||
* `conn` - connection credentials
|
* `conn` - connection credentials
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@callback verify_credentials(conn :: Hunter.Client.t) :: Hunter.Account.t
|
@callback verify_credentials(conn :: Hunter.Client.t()) :: Hunter.Account.t()
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Make changes to the authenticated user
|
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...`)
|
* `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 """
|
@doc """
|
||||||
Retrieve account
|
Retrieve account
|
||||||
|
@ -42,7 +42,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - account identifier
|
* `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 """
|
@doc """
|
||||||
Get a list of followers
|
Get a list of followers
|
||||||
|
@ -60,7 +60,8 @@ defmodule Hunter.Api do
|
||||||
* `limit` - maximum number of followings to get, default: 40, maximum: 80
|
* `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 """
|
@doc """
|
||||||
Get a list of followed accounts
|
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
|
* `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 """
|
@doc """
|
||||||
Follow a remote user
|
Follow a remote user
|
||||||
|
@ -89,7 +91,7 @@ defmodule Hunter.Api do
|
||||||
* `uri` - URI of the remote user, in the format of `username@domain`
|
* `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 """
|
@doc """
|
||||||
Search for accounts
|
Search for accounts
|
||||||
|
@ -105,7 +107,7 @@ defmodule Hunter.Api do
|
||||||
* `limit`: maximum number of matching accounts to return, default: 40
|
* `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 """
|
@doc """
|
||||||
Retrieve user's blocks
|
Retrieve user's blocks
|
||||||
|
@ -121,7 +123,7 @@ defmodule Hunter.Api do
|
||||||
* `limit` - maximum number of blocks to get, default: 40, max: 80
|
* `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 """
|
@doc """
|
||||||
Retrieve a list of follow requests
|
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
|
* `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 """
|
@doc """
|
||||||
Retrieve user's mutes
|
Retrieve user's mutes
|
||||||
|
@ -155,7 +159,7 @@ defmodule Hunter.Api do
|
||||||
* `limit` - maximum number of mutes to get, default: 40, max: 80
|
* `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 """
|
@doc """
|
||||||
Accepts or Rejects a follow request
|
Accepts or Rejects a follow request
|
||||||
|
@ -172,7 +176,11 @@ defmodule Hunter.Api do
|
||||||
* `:reject` - reject a follow request
|
* `: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
|
## Application
|
||||||
|
|
||||||
|
@ -197,7 +205,13 @@ defmodule Hunter.Api do
|
||||||
Multiple scopes can be requested during the authorization phase with the `scope` query param
|
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 """
|
@doc """
|
||||||
Upload a media file
|
Upload a media file
|
||||||
|
@ -208,7 +222,7 @@ defmodule Hunter.Api do
|
||||||
* `file` - media to be uploaded
|
* `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
|
## Relationship
|
||||||
|
|
||||||
|
@ -221,7 +235,9 @@ defmodule Hunter.Api do
|
||||||
* `id` - list of relationship IDs
|
* `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 """
|
@doc """
|
||||||
Follow a user
|
Follow a user
|
||||||
|
@ -232,7 +248,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - user id
|
* `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 """
|
@doc """
|
||||||
Unfollow a user
|
Unfollow a user
|
||||||
|
@ -243,7 +259,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - user identifier
|
* `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 """
|
@doc """
|
||||||
Block a user
|
Block a user
|
||||||
|
@ -254,7 +270,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - user identifier
|
* `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 """
|
@doc """
|
||||||
Unblock a user
|
Unblock a user
|
||||||
|
@ -263,7 +279,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - user identifier
|
* `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 """
|
@doc """
|
||||||
Mute a user
|
Mute a user
|
||||||
|
@ -274,7 +290,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - user identifier
|
* `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 """
|
@doc """
|
||||||
Unmute a user
|
Unmute a user
|
||||||
|
@ -285,7 +301,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - user identifier
|
* `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
|
## Result
|
||||||
|
|
||||||
|
@ -303,7 +319,8 @@ defmodule Hunter.Api do
|
||||||
* `resolve` - whether to resolve non-local accounts
|
* `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
|
## Status
|
||||||
|
|
||||||
|
@ -325,7 +342,8 @@ defmodule Hunter.Api do
|
||||||
* `visibility` - either `direct`, `private`, `unlisted` or `public`
|
* `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 """
|
@doc """
|
||||||
Retrieve status
|
Retrieve status
|
||||||
|
@ -336,7 +354,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - status identifier
|
* `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 """
|
@doc """
|
||||||
Destroy status
|
Destroy status
|
||||||
|
@ -347,7 +365,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - status identifier
|
* `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 """
|
@doc """
|
||||||
Reblog a status
|
Reblog a status
|
||||||
|
@ -358,7 +376,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - status identifier
|
* `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 """
|
@doc """
|
||||||
Undo a reblog of a status
|
Undo a reblog of a status
|
||||||
|
@ -369,7 +387,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - status identifier
|
* `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 """
|
@doc """
|
||||||
Fetch the list of users who reblogged the status.
|
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
|
* `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 """
|
@doc """
|
||||||
Favorite a status
|
Favorite a status
|
||||||
|
@ -398,7 +417,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - status identifier
|
* `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 """
|
@doc """
|
||||||
Undo a favorite of a status
|
Undo a favorite of a status
|
||||||
|
@ -409,7 +428,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - status identifier
|
* `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 """
|
@doc """
|
||||||
Fetch a user's favourites
|
Fetch a user's favourites
|
||||||
|
@ -426,7 +445,7 @@ defmodule Hunter.Api do
|
||||||
* `limit` - maximum of favourites to get, default: 20, max: 40
|
* `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 """
|
@doc """
|
||||||
Fetch the list of users who favourited the status.
|
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
|
* `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 """
|
@doc """
|
||||||
Get a list of statuses by a user
|
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
|
* `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 """
|
@doc """
|
||||||
Retrieve statuses from the home timeline
|
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
|
* `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 """
|
@doc """
|
||||||
Retrieve statuses from the public timeline
|
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
|
* `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 """
|
@doc """
|
||||||
Retrieve statuses from a hashtag
|
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
|
* `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 """
|
@doc """
|
||||||
Retrieve instance information
|
Retrieve instance information
|
||||||
|
@ -528,7 +553,7 @@ defmodule Hunter.Api do
|
||||||
* `conn` - connection credentials
|
* `conn` - connection credentials
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@callback instance_info(conn :: Hunter.Client.t) :: Hunter.Instance.t
|
@callback instance_info(conn :: Hunter.Client.t()) :: Hunter.Instance.t()
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Retrieve user's notifications
|
Retrieve user's notifications
|
||||||
|
@ -545,7 +570,9 @@ defmodule Hunter.Api do
|
||||||
* `limit` - maximum number of notifications to get, default: 15, max: 30
|
* `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 """
|
@doc """
|
||||||
Retrieve single notification
|
Retrieve single notification
|
||||||
|
@ -556,7 +583,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - notification identifier
|
* `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 """
|
@doc """
|
||||||
Deletes all notifications from the Mastodon server for the authenticated user
|
Deletes all notifications from the Mastodon server for the authenticated user
|
||||||
|
@ -566,7 +593,7 @@ defmodule Hunter.Api do
|
||||||
* `conn` - connection credentials
|
* `conn` - connection credentials
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@callback clear_notifications(conn :: Hunter.Client.t) :: boolean
|
@callback clear_notifications(conn :: Hunter.Client.t()) :: boolean
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Dismiss a single notification
|
Dismiss a single notification
|
||||||
|
@ -577,7 +604,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - notification id
|
* `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 """
|
@doc """
|
||||||
Retrieve a user's reports
|
Retrieve a user's reports
|
||||||
|
@ -587,7 +614,7 @@ defmodule Hunter.Api do
|
||||||
* `conn` - connection credentials
|
* `conn` - connection credentials
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@callback reports(conn :: Hunter.Client.t) :: [Hunter.Report.t]
|
@callback reports(conn :: Hunter.Client.t()) :: [Hunter.Report.t()]
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Report a user
|
Report a user
|
||||||
|
@ -600,7 +627,12 @@ defmodule Hunter.Api do
|
||||||
* `comment` - a comment to associate with the report
|
* `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 """
|
@doc """
|
||||||
Retrieve status context
|
Retrieve status context
|
||||||
|
@ -611,7 +643,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - status identifier
|
* `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 """
|
@doc """
|
||||||
Retrieve a card associated with a status
|
Retrieve a card associated with a status
|
||||||
|
@ -622,7 +654,7 @@ defmodule Hunter.Api do
|
||||||
* `id` - status id
|
* `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 """
|
@doc """
|
||||||
Retrieve access token
|
Retrieve access token
|
||||||
|
@ -635,7 +667,12 @@ defmodule Hunter.Api do
|
||||||
* `base_url` - API base url, default: `https://mastodon.social`
|
* `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 """
|
@doc """
|
||||||
Fetch user's blocked domains
|
Fetch user's blocked domains
|
||||||
|
@ -652,7 +689,7 @@ defmodule Hunter.Api do
|
||||||
* `limit` - maximum number of blocks to get, default: 40, max: 80
|
* `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 """
|
@doc """
|
||||||
Block a domain
|
Block a domain
|
||||||
|
@ -663,7 +700,7 @@ defmodule Hunter.Api do
|
||||||
* `domain` - domain to block
|
* `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 """
|
@doc """
|
||||||
Unblock a domain
|
Unblock a domain
|
||||||
|
@ -674,5 +711,5 @@ defmodule Hunter.Api do
|
||||||
* `domain` - domain to unblock
|
* `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
|
end
|
||||||
|
|
|
@ -78,7 +78,7 @@ defmodule Hunter.Api.HTTPClient do
|
||||||
client_name: name,
|
client_name: name,
|
||||||
redirect_uris: redirect_uri,
|
redirect_uris: redirect_uri,
|
||||||
scopes: Enum.join(scopes, " "),
|
scopes: Enum.join(scopes, " "),
|
||||||
website: website,
|
website: website
|
||||||
}
|
}
|
||||||
|
|
||||||
"/api/v1/apps"
|
"/api/v1/apps"
|
||||||
|
@ -136,7 +136,8 @@ defmodule Hunter.Api.HTTPClient do
|
||||||
end
|
end
|
||||||
|
|
||||||
def search(conn, query, options) do
|
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"
|
"/api/v1/search"
|
||||||
|> process_url(conn)
|
|> process_url(conn)
|
||||||
|> request!(:result, :get, options, get_headers(conn))
|
|> request!(:result, :get, options, get_headers(conn))
|
||||||
|
@ -144,6 +145,7 @@ defmodule Hunter.Api.HTTPClient do
|
||||||
|
|
||||||
def create_status(conn, status, options) do
|
def create_status(conn, status, options) do
|
||||||
body = Map.put(options, :status, status)
|
body = Map.put(options, :status, status)
|
||||||
|
|
||||||
"/api/v1/statuses"
|
"/api/v1/statuses"
|
||||||
|> process_url(conn)
|
|> process_url(conn)
|
||||||
|> request!(:status, :post, body, get_headers(conn))
|
|> request!(:status, :post, body, get_headers(conn))
|
||||||
|
@ -287,7 +289,12 @@ defmodule Hunter.Api.HTTPClient do
|
||||||
|> request!(:card, :get, [], get_headers(conn))
|
|> request!(:card, :get, [], get_headers(conn))
|
||||||
end
|
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 = %{
|
payload = %{
|
||||||
client_id: client_id,
|
client_id: client_id,
|
||||||
client_secret: client_secret,
|
client_secret: client_secret,
|
||||||
|
@ -333,7 +340,7 @@ defmodule Hunter.Api.HTTPClient do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_headers(%Hunter.Client{bearer_token: token}) do
|
defp get_headers(%Hunter.Client{bearer_token: token}) do
|
||||||
["Authorization": "Bearer #{token}"]
|
[Authorization: "Bearer #{token}"]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp process_url(endpoint, %Hunter.Client{base_url: base_url}) do
|
defp process_url(endpoint, %Hunter.Client{base_url: base_url}) do
|
||||||
|
@ -365,7 +372,10 @@ defmodule Hunter.Api.HTTPClient do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp transform(body, :context) do
|
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
|
end
|
||||||
|
|
||||||
defp transform(body, :instance) do
|
defp transform(body, :instance) do
|
||||||
|
@ -405,7 +415,10 @@ defmodule Hunter.Api.HTTPClient do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp transform(body, :result) do
|
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
|
end
|
||||||
|
|
||||||
defp transform(body, _) do
|
defp transform(body, _) do
|
||||||
|
|
|
@ -15,10 +15,10 @@ defmodule Hunter.Application do
|
||||||
@hunter_api Hunter.Config.hunter_api()
|
@hunter_api Hunter.Config.hunter_api()
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
id: non_neg_integer,
|
id: non_neg_integer,
|
||||||
client_id: String.t,
|
client_id: String.t(),
|
||||||
client_secret: String.t
|
client_secret: String.t()
|
||||||
}
|
}
|
||||||
|
|
||||||
@derive [Poison.Encoder]
|
@derive [Poison.Encoder]
|
||||||
defstruct [:id, :client_id, :client_secret]
|
defstruct [:id, :client_id, :client_secret]
|
||||||
|
@ -60,8 +60,15 @@ defmodule Hunter.Application do
|
||||||
id: 1234}
|
id: 1234}
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@spec create_app(String.t, String.t, [String.t], String.t, Keyword.t) :: Hunter.Application.t | no_return
|
@spec create_app(String.t(), String.t(), [String.t()], String.t(), Keyword.t()) ::
|
||||||
def create_app(client_name, redirect_uris \\ "urn:ietf:wg:oauth:2.0:oob", scopes \\ ["read"], website \\ nil, options \\ []) do
|
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)
|
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, Hunter.Config.api_base_url())
|
||||||
|
|
||||||
|
@ -80,7 +87,7 @@ defmodule Hunter.Application do
|
||||||
* `name` - application name
|
* `name` - application name
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@spec load_credentials(String.t) :: Hunter.Application.t
|
@spec load_credentials(String.t()) :: Hunter.Application.t()
|
||||||
def load_credentials(name) do
|
def load_credentials(name) do
|
||||||
Hunter.Config.home()
|
Hunter.Config.home()
|
||||||
|> Path.join("apps/#{name}.json")
|
|> Path.join("apps/#{name}.json")
|
||||||
|
|
|
@ -19,14 +19,14 @@ defmodule Hunter.Attachment do
|
||||||
@hunter_api Hunter.Config.hunter_api()
|
@hunter_api Hunter.Config.hunter_api()
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
id: non_neg_integer,
|
id: non_neg_integer,
|
||||||
type: String.t,
|
type: String.t(),
|
||||||
url: String.t,
|
url: String.t(),
|
||||||
remote_url: String.t,
|
remote_url: String.t(),
|
||||||
preview_url: String.t,
|
preview_url: String.t(),
|
||||||
text_url: String.t,
|
text_url: String.t(),
|
||||||
meta: String.t
|
meta: String.t()
|
||||||
}
|
}
|
||||||
|
|
||||||
@derive [Poison.Encoder]
|
@derive [Poison.Encoder]
|
||||||
defstruct [:id, :type, :url, :remote_url, :preview_url, :text_url, :meta]
|
defstruct [:id, :type, :url, :remote_url, :preview_url, :text_url, :meta]
|
||||||
|
@ -40,7 +40,7 @@ defmodule Hunter.Attachment do
|
||||||
* `file` - media to be uploaded
|
* `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
|
def upload_media(conn, file) do
|
||||||
@hunter_api.upload_media(conn, file)
|
@hunter_api.upload_media(conn, file)
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,23 +24,35 @@ defmodule Hunter.Card do
|
||||||
@hunter_api Hunter.Config.hunter_api()
|
@hunter_api Hunter.Config.hunter_api()
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
url: String.t,
|
url: String.t(),
|
||||||
title: String.t,
|
title: String.t(),
|
||||||
description: String.t,
|
description: String.t(),
|
||||||
image: String.t,
|
image: String.t(),
|
||||||
type: String.t,
|
type: String.t(),
|
||||||
author_name: String.t,
|
author_name: String.t(),
|
||||||
author_url: String.t,
|
author_url: String.t(),
|
||||||
provider_name: String.t,
|
provider_name: String.t(),
|
||||||
provider_url: String.t,
|
provider_url: String.t(),
|
||||||
html: String.t,
|
html: String.t(),
|
||||||
width: non_neg_integer,
|
width: non_neg_integer,
|
||||||
height: non_neg_integer
|
height: non_neg_integer
|
||||||
}
|
}
|
||||||
|
|
||||||
@derive [Poison.Encoder]
|
@derive [Poison.Encoder]
|
||||||
defstruct [:url, :title, :description, :image, :type, :author_name, :author_url, :provider_name, :provider_url,
|
defstruct [
|
||||||
:html, :width, :height]
|
:url,
|
||||||
|
:title,
|
||||||
|
:description,
|
||||||
|
:image,
|
||||||
|
:type,
|
||||||
|
:author_name,
|
||||||
|
:author_url,
|
||||||
|
:provider_name,
|
||||||
|
:provider_url,
|
||||||
|
:html,
|
||||||
|
:width,
|
||||||
|
:height
|
||||||
|
]
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Retrieve a card associated with a status
|
Retrieve a card associated with a status
|
||||||
|
@ -60,7 +72,7 @@ defmodule Hunter.Card do
|
||||||
title: "milmazz/hunter", url: "https://github.com/milmazz/hunter"}
|
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
|
def card_by_status(conn, id) do
|
||||||
@hunter_api.card_by_status(conn, id)
|
@hunter_api.card_by_status(conn, id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,9 +6,9 @@ defmodule Hunter.Client do
|
||||||
@hunter_api Hunter.Config.hunter_api()
|
@hunter_api Hunter.Config.hunter_api()
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
base_url: String.t,
|
base_url: String.t(),
|
||||||
bearer_token: String.t
|
bearer_token: String.t()
|
||||||
}
|
}
|
||||||
|
|
||||||
@derive [Poison.Encoder]
|
@derive [Poison.Encoder]
|
||||||
defstruct [:base_url, :bearer_token]
|
defstruct [:base_url, :bearer_token]
|
||||||
|
@ -22,7 +22,7 @@ defmodule Hunter.Client do
|
||||||
* `bearer_token` - [String] OAuth access token for your authenticated user
|
* `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
|
def new(options \\ []) do
|
||||||
struct(Hunter.Client, options)
|
struct(Hunter.Client, options)
|
||||||
end
|
end
|
||||||
|
@ -30,9 +30,9 @@ defmodule Hunter.Client do
|
||||||
@doc """
|
@doc """
|
||||||
User agent of the client
|
User agent of the client
|
||||||
"""
|
"""
|
||||||
@spec user_agent() :: String.t
|
@spec user_agent() :: String.t()
|
||||||
def user_agent() do
|
def user_agent() do
|
||||||
"Hunter.Elixir/#{Hunter.version}"
|
"Hunter.Elixir/#{Hunter.version()}"
|
||||||
end
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
|
@ -46,7 +46,7 @@ defmodule Hunter.Client do
|
||||||
* `base_url` - API base url, default: `https://mastodon.social`
|
* `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
|
def log_in(app, username, password, base_url \\ nil) do
|
||||||
@hunter_api.log_in(app, username, password, base_url || Hunter.Config.api_base_url())
|
@hunter_api.log_in(app, username, password, base_url || Hunter.Config.api_base_url())
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ defmodule Hunter.Config do
|
||||||
@api_base_url "https://mastodon.social"
|
@api_base_url "https://mastodon.social"
|
||||||
|
|
||||||
def hunter_api() do
|
def hunter_api() do
|
||||||
@hunter_api
|
@hunter_api
|
||||||
end
|
end
|
||||||
|
|
||||||
def api_base_url() do
|
def api_base_url() do
|
||||||
|
|
|
@ -11,9 +11,9 @@ defmodule Hunter.Context do
|
||||||
@hunter_api Hunter.Config.hunter_api()
|
@hunter_api Hunter.Config.hunter_api()
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
ancestors: [Hunter.Status.t],
|
ancestors: [Hunter.Status.t()],
|
||||||
descendants: [Hunter.Status.t]
|
descendants: [Hunter.Status.t()]
|
||||||
}
|
}
|
||||||
|
|
||||||
@derive [Poison.Encoder]
|
@derive [Poison.Encoder]
|
||||||
defstruct [:ancestors, :descendants]
|
defstruct [:ancestors, :descendants]
|
||||||
|
@ -27,7 +27,7 @@ defmodule Hunter.Context do
|
||||||
* `id` - status identifier
|
* `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
|
def status_context(conn, id) do
|
||||||
@hunter_api.status_context(conn, id)
|
@hunter_api.status_context(conn, id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,7 +20,7 @@ defmodule Hunter.Domain do
|
||||||
* `limit` - maximum number of blocks to get, default: 40, max: 80
|
* `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
|
def blocked_domains(conn, options \\ []) do
|
||||||
@hunter_api.blocked_domains(conn, options)
|
@hunter_api.blocked_domains(conn, options)
|
||||||
end
|
end
|
||||||
|
@ -34,7 +34,7 @@ defmodule Hunter.Domain do
|
||||||
* `domain` - domain to block
|
* `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
|
def block_domain(conn, domain) do
|
||||||
@hunter_api.block_domain(conn, domain)
|
@hunter_api.block_domain(conn, domain)
|
||||||
end
|
end
|
||||||
|
@ -48,7 +48,7 @@ defmodule Hunter.Domain do
|
||||||
* `domain` - domain to unblock
|
* `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
|
def unblock_domain(conn, domain) do
|
||||||
@hunter_api.unblock_domain(conn, domain)
|
@hunter_api.unblock_domain(conn, domain)
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,11 +17,11 @@ defmodule Hunter.EventStream do
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
id: String.t,
|
id: String.t(),
|
||||||
event: String.t,
|
event: String.t(),
|
||||||
data: String.t,
|
data: String.t(),
|
||||||
retry: non_neg_integer
|
retry: non_neg_integer
|
||||||
}
|
}
|
||||||
|
|
||||||
defstruct [:id, :event, :data, :retry]
|
defstruct [:id, :event, :data, :retry]
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,12 +17,12 @@ defmodule Hunter.Instance do
|
||||||
@hunter_api Hunter.Config.hunter_api()
|
@hunter_api Hunter.Config.hunter_api()
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
uri: String.t,
|
uri: String.t(),
|
||||||
title: String.t,
|
title: String.t(),
|
||||||
description: String.t,
|
description: String.t(),
|
||||||
email: String.t,
|
email: String.t(),
|
||||||
version: String.t
|
version: String.t()
|
||||||
}
|
}
|
||||||
|
|
||||||
@derive [Poison.Encoder]
|
@derive [Poison.Encoder]
|
||||||
defstruct [:uri, :title, :description, :email, :version]
|
defstruct [:uri, :title, :description, :email, :version]
|
||||||
|
@ -44,7 +44,7 @@ defmodule Hunter.Instance do
|
||||||
uri: "social.lou.lt"}
|
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
|
def instance_info(conn) do
|
||||||
@hunter_api.instance_info(conn)
|
@hunter_api.instance_info(conn)
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,13 +11,12 @@ defmodule Hunter.Mention do
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
url: String.t,
|
url: String.t(),
|
||||||
username: String.t,
|
username: String.t(),
|
||||||
acct: String.t,
|
acct: String.t(),
|
||||||
id: non_neg_integer
|
id: non_neg_integer
|
||||||
}
|
}
|
||||||
|
|
||||||
@derive [Poison.Encoder]
|
@derive [Poison.Encoder]
|
||||||
defstruct [:url, :username, :acct, :id]
|
defstruct [:url, :username, :acct, :id]
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,12 +17,12 @@ defmodule Hunter.Notification do
|
||||||
@hunter_api Hunter.Config.hunter_api()
|
@hunter_api Hunter.Config.hunter_api()
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
id: String.t,
|
id: String.t(),
|
||||||
type: String.t,
|
type: String.t(),
|
||||||
created_at: String.t,
|
created_at: String.t(),
|
||||||
account: Hunter.Account.t,
|
account: Hunter.Account.t(),
|
||||||
status: Hunter.Status.t
|
status: Hunter.Status.t()
|
||||||
}
|
}
|
||||||
|
|
||||||
@derive [Poison.Encoder]
|
@derive [Poison.Encoder]
|
||||||
defstruct [:id, :type, :created_at, :account, :status]
|
defstruct [:id, :type, :created_at, :account, :status]
|
||||||
|
@ -47,7 +47,7 @@ defmodule Hunter.Notification do
|
||||||
#=> [%Hunter.Notification{account: %{"acct" => "paperswelove@mstdn.io", ...}]
|
#=> [%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
|
def notifications(conn, options \\ []) do
|
||||||
@hunter_api.notifications(conn, options)
|
@hunter_api.notifications(conn, options)
|
||||||
end
|
end
|
||||||
|
@ -66,7 +66,7 @@ defmodule Hunter.Notification do
|
||||||
#=> %Hunter.Notification{account: %{"acct" => "paperswelove@mstdn.io", ...}
|
#=> %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
|
def notification(conn, id) do
|
||||||
@hunter_api.notification(conn, id)
|
@hunter_api.notification(conn, id)
|
||||||
end
|
end
|
||||||
|
@ -79,7 +79,7 @@ defmodule Hunter.Notification do
|
||||||
* `conn` - connection credentials
|
* `conn` - connection credentials
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@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)
|
@hunter_api.clear_notifications(conn)
|
||||||
end
|
end
|
||||||
|
@ -93,7 +93,7 @@ defmodule Hunter.Notification do
|
||||||
* `id` - notification id
|
* `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
|
def clear_notification(conn, id) do
|
||||||
@hunter_api.clear_notification(conn, id)
|
@hunter_api.clear_notification(conn, id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,14 +19,14 @@ defmodule Hunter.Relationship do
|
||||||
@hunter_api Hunter.Config.hunter_api()
|
@hunter_api Hunter.Config.hunter_api()
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
id: non_neg_integer,
|
id: non_neg_integer,
|
||||||
following: boolean,
|
following: boolean,
|
||||||
followed_by: boolean,
|
followed_by: boolean,
|
||||||
blocking: boolean,
|
blocking: boolean,
|
||||||
muting: boolean,
|
muting: boolean,
|
||||||
requested: boolean,
|
requested: boolean,
|
||||||
domain_blocking: boolean
|
domain_blocking: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
@derive [Poison.Encoder]
|
@derive [Poison.Encoder]
|
||||||
defstruct [:id, :following, :followed_by, :blocking, :muting, :requested, :domain_blocking]
|
defstruct [:id, :following, :followed_by, :blocking, :muting, :requested, :domain_blocking]
|
||||||
|
@ -40,7 +40,7 @@ defmodule Hunter.Relationship do
|
||||||
* `id` - list of relationship IDs
|
* `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
|
def relationships(conn, ids) do
|
||||||
@hunter_api.relationships(conn, ids)
|
@hunter_api.relationships(conn, ids)
|
||||||
end
|
end
|
||||||
|
@ -54,7 +54,7 @@ defmodule Hunter.Relationship do
|
||||||
* `id` - user id
|
* `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
|
def follow(conn, id) do
|
||||||
@hunter_api.follow(conn, id)
|
@hunter_api.follow(conn, id)
|
||||||
end
|
end
|
||||||
|
@ -68,7 +68,7 @@ defmodule Hunter.Relationship do
|
||||||
* `id` - user id
|
* `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
|
def unfollow(conn, id) do
|
||||||
@hunter_api.unfollow(conn, id)
|
@hunter_api.unfollow(conn, id)
|
||||||
end
|
end
|
||||||
|
@ -82,7 +82,7 @@ defmodule Hunter.Relationship do
|
||||||
* `id` - user id
|
* `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
|
def block(conn, id) do
|
||||||
@hunter_api.block(conn, id)
|
@hunter_api.block(conn, id)
|
||||||
end
|
end
|
||||||
|
@ -94,7 +94,7 @@ defmodule Hunter.Relationship do
|
||||||
* `id` - user id
|
* `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
|
def unblock(conn, id) do
|
||||||
@hunter_api.unblock(conn, id)
|
@hunter_api.unblock(conn, id)
|
||||||
end
|
end
|
||||||
|
@ -108,7 +108,7 @@ defmodule Hunter.Relationship do
|
||||||
* `id` - user id
|
* `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
|
def mute(conn, id) do
|
||||||
@hunter_api.mute(conn, id)
|
@hunter_api.mute(conn, id)
|
||||||
end
|
end
|
||||||
|
@ -122,7 +122,7 @@ defmodule Hunter.Relationship do
|
||||||
* `id` - user id
|
* `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
|
def unmute(conn, id) do
|
||||||
@hunter_api.unmute(conn, id)
|
@hunter_api.unmute(conn, id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -14,9 +14,9 @@ defmodule Hunter.Report do
|
||||||
@hunter_api Hunter.Config.hunter_api()
|
@hunter_api Hunter.Config.hunter_api()
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
id: non_neg_integer,
|
id: non_neg_integer,
|
||||||
action_taken: String.t
|
action_taken: String.t()
|
||||||
}
|
}
|
||||||
|
|
||||||
@derive [Poison.Encoder]
|
@derive [Poison.Encoder]
|
||||||
defstruct [:id, :action_taken]
|
defstruct [:id, :action_taken]
|
||||||
|
@ -29,7 +29,7 @@ defmodule Hunter.Report do
|
||||||
* `conn` - connection credentials
|
* `conn` - connection credentials
|
||||||
|
|
||||||
"""
|
"""
|
||||||
@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)
|
@hunter_api.reports(conn)
|
||||||
end
|
end
|
||||||
|
@ -45,7 +45,8 @@ defmodule Hunter.Report do
|
||||||
* `comment` - a comment to associate with the report
|
* `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
|
def report(conn, account_id, status_ids, comment) do
|
||||||
@hunter_api.report(conn, account_id, status_ids, comment)
|
@hunter_api.report(conn, account_id, status_ids, comment)
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,8 +19,10 @@ defmodule Hunter.Request do
|
||||||
case HTTPoison.request(method, url, body, headers, options) do
|
case HTTPoison.request(method, url, body, headers, options) do
|
||||||
{:ok, %{status_code: status, body: body}} when status in 200..299 ->
|
{:ok, %{status_code: status, body: body}} when status in 200..299 ->
|
||||||
{:ok, body}
|
{:ok, body}
|
||||||
|
|
||||||
{:ok, %{body: body}} ->
|
{:ok, %{body: body}} ->
|
||||||
{:error, body}
|
{:error, body}
|
||||||
|
|
||||||
{:error, %HTTPoison.Error{reason: reason}} ->
|
{:error, %HTTPoison.Error{reason: reason}} ->
|
||||||
{:error, reason}
|
{:error, reason}
|
||||||
end
|
end
|
||||||
|
@ -30,14 +32,19 @@ defmodule Hunter.Request do
|
||||||
case data do
|
case data do
|
||||||
[] ->
|
[] ->
|
||||||
"{}"
|
"{}"
|
||||||
|
|
||||||
data when is_binary(data) ->
|
data when is_binary(data) ->
|
||||||
data
|
data
|
||||||
|
|
||||||
_ ->
|
_ ->
|
||||||
Poison.encode!(data)
|
Poison.encode!(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp process_request_header(data) do
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,10 +12,10 @@ defmodule Hunter.Result do
|
||||||
@hunter_api Hunter.Config.hunter_api()
|
@hunter_api Hunter.Config.hunter_api()
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
accounts: [Hunter.Account.t],
|
accounts: [Hunter.Account.t()],
|
||||||
statuses: [Hunter.Status.t],
|
statuses: [Hunter.Status.t()],
|
||||||
hashtags: [String.t]
|
hashtags: [String.t()]
|
||||||
}
|
}
|
||||||
|
|
||||||
@derive [Poison.Encoder]
|
@derive [Poison.Encoder]
|
||||||
defstruct accounts: [],
|
defstruct accounts: [],
|
||||||
|
@ -38,7 +38,7 @@ defmodule Hunter.Result do
|
||||||
* `resolve` - Whether to resolve non-local accounts
|
* `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
|
def search(conn, query, options \\ []) do
|
||||||
@hunter_api.search(conn, query, options)
|
@hunter_api.search(conn, query, options)
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,51 +30,53 @@ defmodule Hunter.Status do
|
||||||
@hunter_api Hunter.Config.hunter_api()
|
@hunter_api Hunter.Config.hunter_api()
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
id: non_neg_integer,
|
id: non_neg_integer,
|
||||||
uri: String.t,
|
uri: String.t(),
|
||||||
url: String.t,
|
url: String.t(),
|
||||||
account: Hunter.Account.t,
|
account: Hunter.Account.t(),
|
||||||
in_reply_to_id: non_neg_integer,
|
in_reply_to_id: non_neg_integer,
|
||||||
reblog: Hunter.Status.t | nil,
|
reblog: Hunter.Status.t() | nil,
|
||||||
content: String.t,
|
content: String.t(),
|
||||||
created_at: String.t,
|
created_at: String.t(),
|
||||||
reblogs_count: non_neg_integer,
|
reblogs_count: non_neg_integer,
|
||||||
favourites_count: non_neg_integer,
|
favourites_count: non_neg_integer,
|
||||||
reblogged: boolean,
|
reblogged: boolean,
|
||||||
favourited: boolean,
|
favourited: boolean,
|
||||||
sensitive: boolean,
|
sensitive: boolean,
|
||||||
spoiler_text: String.t,
|
spoiler_text: String.t(),
|
||||||
media_attachments: [Hunter.Attachment.t],
|
media_attachments: [Hunter.Attachment.t()],
|
||||||
mentions: [Hunter.Mention.t],
|
mentions: [Hunter.Mention.t()],
|
||||||
tags: [Hunter.Tag.t],
|
tags: [Hunter.Tag.t()],
|
||||||
application: Hunter.Application.t,
|
application: Hunter.Application.t(),
|
||||||
language: String.t
|
language: String.t()
|
||||||
}
|
}
|
||||||
|
|
||||||
@type status_id :: non_neg_integer
|
@type status_id :: non_neg_integer
|
||||||
|
|
||||||
@derive [Poison.Encoder]
|
@derive [Poison.Encoder]
|
||||||
defstruct [:id,
|
defstruct [
|
||||||
:uri,
|
:id,
|
||||||
:url,
|
:uri,
|
||||||
:account,
|
:url,
|
||||||
:in_reply_to_id,
|
:account,
|
||||||
:in_reply_to_account_id,
|
:in_reply_to_id,
|
||||||
:reblog,
|
:in_reply_to_account_id,
|
||||||
:content,
|
:reblog,
|
||||||
:created_at,
|
:content,
|
||||||
:reblogs_count,
|
:created_at,
|
||||||
:favourites_count,
|
:reblogs_count,
|
||||||
:reblogged,
|
:favourites_count,
|
||||||
:favourited,
|
:reblogged,
|
||||||
:sensitive,
|
:favourited,
|
||||||
:spoiler_text,
|
:sensitive,
|
||||||
:visibility,
|
:spoiler_text,
|
||||||
:media_attachments,
|
:visibility,
|
||||||
:mentions,
|
:media_attachments,
|
||||||
:tags,
|
:mentions,
|
||||||
:application,
|
:tags,
|
||||||
:language]
|
:application,
|
||||||
|
:language
|
||||||
|
]
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Create new status
|
Create new status
|
||||||
|
@ -94,7 +96,7 @@ defmodule Hunter.Status do
|
||||||
* `visibility` - either `direct`, `private`, `unlisted` or `public`
|
* `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
|
def create_status(conn, status, options \\ []) do
|
||||||
@hunter_api.create_status(conn, status, Map.new(options))
|
@hunter_api.create_status(conn, status, Map.new(options))
|
||||||
end
|
end
|
||||||
|
@ -108,7 +110,7 @@ defmodule Hunter.Status do
|
||||||
* `id` - status identifier
|
* `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
|
def status(conn, id) do
|
||||||
@hunter_api.status(conn, id)
|
@hunter_api.status(conn, id)
|
||||||
end
|
end
|
||||||
|
@ -122,7 +124,7 @@ defmodule Hunter.Status do
|
||||||
* `id` - status identifier
|
* `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
|
def destroy_status(conn, id) do
|
||||||
@hunter_api.destroy_status(conn, id)
|
@hunter_api.destroy_status(conn, id)
|
||||||
end
|
end
|
||||||
|
@ -136,7 +138,7 @@ defmodule Hunter.Status do
|
||||||
* `id` - status identifier
|
* `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
|
def reblog(conn, id) do
|
||||||
@hunter_api.reblog(conn, id)
|
@hunter_api.reblog(conn, id)
|
||||||
end
|
end
|
||||||
|
@ -150,7 +152,7 @@ defmodule Hunter.Status do
|
||||||
* `id` - status identifier
|
* `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
|
def unreblog(conn, id) do
|
||||||
@hunter_api.unreblog(conn, id)
|
@hunter_api.unreblog(conn, id)
|
||||||
end
|
end
|
||||||
|
@ -164,7 +166,7 @@ defmodule Hunter.Status do
|
||||||
* `id` - status identifier
|
* `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
|
def favourite(conn, id) do
|
||||||
@hunter_api.favourite(conn, id)
|
@hunter_api.favourite(conn, id)
|
||||||
end
|
end
|
||||||
|
@ -178,7 +180,7 @@ defmodule Hunter.Status do
|
||||||
* `id` - status identifier
|
* `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
|
def unfavourite(conn, id) do
|
||||||
@hunter_api.unfavourite(conn, id)
|
@hunter_api.unfavourite(conn, id)
|
||||||
end
|
end
|
||||||
|
@ -198,7 +200,7 @@ defmodule Hunter.Status do
|
||||||
* `limit` - maximum of favourites to get, default: 20, max: 40
|
* `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
|
def favourites(conn, options \\ []) do
|
||||||
@hunter_api.favourites(conn, options)
|
@hunter_api.favourites(conn, options)
|
||||||
end
|
end
|
||||||
|
@ -221,7 +223,7 @@ defmodule Hunter.Status do
|
||||||
* `limit` - maximum number of statuses to get, default: 20, max: 40
|
* `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
|
def statuses(conn, account_id, options \\ []) do
|
||||||
@hunter_api.statuses(conn, account_id, Map.new(options))
|
@hunter_api.statuses(conn, account_id, Map.new(options))
|
||||||
end
|
end
|
||||||
|
@ -241,7 +243,7 @@ defmodule Hunter.Status do
|
||||||
* `limit` - maximum number of statuses on the requested timeline to get, default: 20, max: 40
|
* `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
|
def home_timeline(conn, options \\ []) do
|
||||||
@hunter_api.home_timeline(conn, Map.new(options))
|
@hunter_api.home_timeline(conn, Map.new(options))
|
||||||
end
|
end
|
||||||
|
@ -262,7 +264,7 @@ defmodule Hunter.Status do
|
||||||
* `limit` - maximum number of statuses on the requested timeline to get, default: 20, max: 40
|
* `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
|
def public_timeline(conn, options \\ []) do
|
||||||
@hunter_api.public_timeline(conn, Map.new(options))
|
@hunter_api.public_timeline(conn, Map.new(options))
|
||||||
end
|
end
|
||||||
|
@ -284,7 +286,7 @@ defmodule Hunter.Status do
|
||||||
* `limit` - maximum number of statuses on the requested timeline to get, default: 20, max: 40
|
* `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
|
def hashtag_timeline(conn, hashtag, options \\ []) do
|
||||||
@hunter_api.hashtag_timeline(conn, hashtag, Map.new(options))
|
@hunter_api.hashtag_timeline(conn, hashtag, Map.new(options))
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,9 +10,9 @@ defmodule Hunter.Tag do
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@type t :: %__MODULE__{
|
@type t :: %__MODULE__{
|
||||||
name: String.t,
|
name: String.t(),
|
||||||
url: String.t
|
url: String.t()
|
||||||
}
|
}
|
||||||
|
|
||||||
@derive [Poison.Encoder]
|
@derive [Poison.Encoder]
|
||||||
defstruct [:name, :url]
|
defstruct [:name, :url]
|
||||||
|
|
54
mix.exs
54
mix.exs
|
@ -2,17 +2,19 @@ defmodule Hunter.Mixfile do
|
||||||
use Mix.Project
|
use Mix.Project
|
||||||
|
|
||||||
def project do
|
def project do
|
||||||
[app: :hunter,
|
[
|
||||||
version: "0.5.0-dev",
|
app: :hunter,
|
||||||
elixir: "~> 1.3",
|
version: "0.5.0-dev",
|
||||||
docs: docs(),
|
elixir: "~> 1.3",
|
||||||
package: package(),
|
docs: docs(),
|
||||||
source_url: "https://github.com/milmazz/hunter",
|
package: package(),
|
||||||
description: "Elixir client for Mastodon, a GNU social-compatible micro-blogging service",
|
source_url: "https://github.com/milmazz/hunter",
|
||||||
build_embedded: Mix.env == :prod,
|
description: "Elixir client for Mastodon, a GNU social-compatible micro-blogging service",
|
||||||
start_permanent: Mix.env == :prod,
|
build_embedded: Mix.env() == :prod,
|
||||||
elixirc_paths: elixirc_paths(Mix.env),
|
start_permanent: Mix.env() == :prod,
|
||||||
deps: deps()]
|
elixirc_paths: elixirc_paths(Mix.env()),
|
||||||
|
deps: deps()
|
||||||
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Configuration for the OTP application
|
# Configuration for the OTP application
|
||||||
|
@ -24,23 +26,31 @@ defmodule Hunter.Mixfile do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp deps do
|
defp deps do
|
||||||
[{:httpoison, "~> 0.10.0"},
|
[
|
||||||
{:poison, "~> 3.0"},
|
{:httpoison, "~> 0.10.0"},
|
||||||
{:ex_doc, "~> 0.14", only: :dev, runtime: false}]
|
{:poison, "~> 3.0"},
|
||||||
|
{:ex_doc, "~> 0.14", only: :dev, runtime: false}
|
||||||
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp package do
|
defp package do
|
||||||
[licenses: ["Apache 2.0"],
|
[
|
||||||
maintainers: ["Milton Mazzarri"],
|
licenses: ["Apache 2.0"],
|
||||||
links: %{"GitHub" => "https://github.com/milmazz/hunter"}]
|
maintainers: ["Milton Mazzarri"],
|
||||||
|
links: %{"GitHub" => "https://github.com/milmazz/hunter"}
|
||||||
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp docs do
|
defp docs do
|
||||||
[extras: ["README.md": [title: "README"],
|
[
|
||||||
"CONTRIBUTING.md": [title: "How to contribute"],
|
extras: [
|
||||||
"CODE_OF_CONDUCT.md": [title: "Code of Conduct"],
|
"README.md": [title: "README"],
|
||||||
"CHANGELOG.md": [title: "Changelog"]],
|
"CONTRIBUTING.md": [title: "How to contribute"],
|
||||||
main: "readme"]
|
"CODE_OF_CONDUCT.md": [title: "Code of Conduct"],
|
||||||
|
"CHANGELOG.md": [title: "Changelog"]
|
||||||
|
],
|
||||||
|
main: "readme"
|
||||||
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Specifies which paths to compile per environment
|
# Specifies which paths to compile per environment
|
||||||
|
|
|
@ -4,8 +4,8 @@ defmodule Hunter.AccountTest do
|
||||||
|
|
||||||
alias Hunter.Account
|
alias Hunter.Account
|
||||||
|
|
||||||
setup do
|
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
|
end
|
||||||
|
|
||||||
test "verify credentials", %{conn: conn} do
|
test "verify credentials", %{conn: conn} do
|
||||||
|
@ -27,6 +27,7 @@ defmodule Hunter.AccountTest do
|
||||||
end
|
end
|
||||||
|
|
||||||
test "following a remote user", %{conn: conn} do
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ defmodule Hunter.CardTest do
|
||||||
alias Hunter.Card
|
alias Hunter.Card
|
||||||
|
|
||||||
setup do
|
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
|
end
|
||||||
|
|
||||||
test "verify a card associated with a status", %{conn: conn} do
|
test "verify a card associated with a status", %{conn: conn} do
|
||||||
|
|
|
@ -5,7 +5,7 @@ defmodule Hunter.InstanceTest do
|
||||||
alias Hunter.Instance
|
alias Hunter.Instance
|
||||||
|
|
||||||
setup do
|
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
|
end
|
||||||
|
|
||||||
test "verify instance information", %{conn: conn} do
|
test "verify instance information", %{conn: conn} do
|
||||||
|
|
|
@ -5,7 +5,7 @@ defmodule Hunter.NotificationTest do
|
||||||
alias Hunter.Notification
|
alias Hunter.Notification
|
||||||
|
|
||||||
setup do
|
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
|
end
|
||||||
|
|
||||||
test "fetch user's notifications", %{conn: conn} do
|
test "fetch user's notifications", %{conn: conn} do
|
||||||
|
|
|
@ -5,7 +5,7 @@ defmodule Hunter.StatusTest do
|
||||||
alias Hunter.Status
|
alias Hunter.Status
|
||||||
|
|
||||||
setup do
|
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
|
end
|
||||||
|
|
||||||
test "home timeline should return a collection of statuses", %{conn: conn} do
|
test "home timeline should return a collection of statuses", %{conn: conn} do
|
||||||
|
|
|
@ -47,21 +47,21 @@ defmodule Hunter.Api.InMemory do
|
||||||
%{name: :unreblog, arity: 2, as: %Hunter.Status{}},
|
%{name: :unreblog, arity: 2, as: %Hunter.Status{}},
|
||||||
%{name: :update_credentials, arity: 2, as: %Hunter.Account{}},
|
%{name: :update_credentials, arity: 2, as: %Hunter.Account{}},
|
||||||
%{name: :upload_media, arity: 2, as: %Hunter.Attachment{}},
|
%{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} ->
|
|> Enum.map(fn %{name: name, arity: arity, as: as} ->
|
||||||
params = for _ <- 1..arity, do: {:_, [], nil}
|
params = for _ <- 1..arity, do: {:_, [], nil}
|
||||||
as = Macro.escape(as)
|
as = Macro.escape(as)
|
||||||
|
|
||||||
def unquote(name)(unquote_splicing(params)) do
|
def unquote(name)(unquote_splicing(params)) do
|
||||||
file = to_string(unquote(name))
|
file = to_string(unquote(name))
|
||||||
|
|
||||||
"../fixtures/#{file}.json"
|
"../fixtures/#{file}.json"
|
||||||
|> Path.expand(__DIR__)
|
|> Path.expand(__DIR__)
|
||||||
|> File.read!()
|
|> File.read!()
|
||||||
|> Poison.decode!(as: unquote(as))
|
|> Poison.decode!(as: unquote(as))
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
def destroy_status(_, _), do: true
|
def destroy_status(_, _), do: true
|
||||||
def follow_request_action(_, _, _), do: true
|
def follow_request_action(_, _, _), do: true
|
||||||
|
|
Loading…
Reference in New Issue