Fix `create_status` and `relationships` endpoints
parent
fe7213bba9
commit
d6f998099c
|
@ -337,13 +337,20 @@ defmodule Hunter do
|
|||
## Parameters
|
||||
|
||||
* `conn` - connection credentials
|
||||
* `text` - [String]
|
||||
* `in_reply_to_id` - [Integer]
|
||||
* `media_ids` - [Array<Integer>]
|
||||
* `status` - text of the status
|
||||
* `options` - option list
|
||||
|
||||
## Options
|
||||
|
||||
* `in_reply_to_id` - local ID of the status you want to reply to
|
||||
* `media_ids` - list of media IDs to attach to the status (maximum: 4)
|
||||
* `sensitive` - whether the media of the status is NSFW
|
||||
* `spoiler_text` - text to be shown as a warning before the actual content
|
||||
* `visibility` - either `direct`, `private`, `unlisted` or `public`
|
||||
|
||||
"""
|
||||
@spec create_status(Hunter.Client.t, String.t, non_neg_integer, [non_neg_integer]) :: Hunter.Status.t | no_return
|
||||
defdelegate create_status(conn, text, in_reply_to_id \\ nil, media_ids \\ []), to: Hunter.Status
|
||||
@spec create_status(Hunter.Client.t, String.t, Keyword.t) :: Hunter.Status.t | no_return
|
||||
defdelegate create_status(conn, status, options \\ []), to: Hunter.Status
|
||||
|
||||
@doc """
|
||||
Retrieve status
|
||||
|
@ -464,9 +471,11 @@ defmodule Hunter do
|
|||
|
||||
## Options
|
||||
|
||||
* `only_media` - only return `Hunter.Status.t` that have media attachments
|
||||
* `exclude_replies` - skip statuses that reply to other statuses
|
||||
* `max_id` - [Integer]
|
||||
* `since_id` - [Integer]
|
||||
* `limit` - [Integer]
|
||||
* `limit` - [Integer]
|
||||
|
||||
"""
|
||||
@spec statuses(Hunter.Client.t, non_neg_integer, Keyword.t) :: [Hunter.Status.t]
|
||||
|
|
|
@ -279,12 +279,19 @@ defmodule Hunter.Api do
|
|||
## Parameters
|
||||
|
||||
* `conn` - connection credentials
|
||||
* `text` - [String]
|
||||
* `in_reply_to_id` - [Integer]
|
||||
* `media_ids` - [Array<Integer>]
|
||||
* `status` - text of the status
|
||||
* `options` - option list
|
||||
|
||||
## Options
|
||||
|
||||
* `in_reply_to_id` - local ID of the status you want to reply to
|
||||
* `media_ids` - list of media IDs to attach to the status (maximum: 4)
|
||||
* `sensitive` - whether the media of the status is NSFW
|
||||
* `spoiler_text` - text to be shown as a warning before the actual content
|
||||
* `visibility` - either `direct`, `private`, `unlisted` or `public`
|
||||
|
||||
"""
|
||||
@callback create_status(conn :: Hunter.Client.t, text :: String.t, in_reply_to_id :: non_neg_integer, media_ids :: [non_neg_integer]) :: Hunter.Status.t | no_return
|
||||
@callback create_status(conn :: Hunter.Client.t, status :: String.t, options :: Keyword.t) :: Hunter.Status.t | no_return
|
||||
|
||||
@doc """
|
||||
Retrieve status
|
||||
|
@ -395,6 +402,8 @@ defmodule Hunter.Api do
|
|||
|
||||
## Options
|
||||
|
||||
* `only_media` - only return `Hunter.Status.t` that have media attachments
|
||||
* `exclude_replies` - skip statuses that reply to other statuses
|
||||
* `max_id` - [Integer]
|
||||
* `since_id` - [Integer]
|
||||
* `limit` - [Integer]
|
||||
|
|
|
@ -85,6 +85,7 @@ defmodule Hunter.Api.HTTPClient do
|
|||
|> transform(:application)
|
||||
end
|
||||
|
||||
# TODO: Review this function
|
||||
def upload_media(conn, file) do
|
||||
:post
|
||||
|> Request.request!(process_url(conn, "/api/v1/media"), {:file, file}, get_headers(conn))
|
||||
|
@ -93,7 +94,7 @@ defmodule Hunter.Api.HTTPClient do
|
|||
|
||||
def relationships(conn, ids) do
|
||||
:get
|
||||
|> Request.request!(process_url(conn, "/api/v1/accounts/relationships"), [], get_headers(conn), [id: ids])
|
||||
|> Request.request!(process_url(conn, "/api/v1/accounts/relationships"), %{id: ids}, get_headers(conn))
|
||||
|> transform(:relationships)
|
||||
end
|
||||
|
||||
|
@ -141,11 +142,11 @@ defmodule Hunter.Api.HTTPClient do
|
|||
|> transform(:result)
|
||||
end
|
||||
|
||||
def create_status(conn, text, in_reply_to_id, _media_ids) do
|
||||
payload = %{status: text, in_reply_to_id: in_reply_to_id}
|
||||
def create_status(conn, status, options) do
|
||||
body = Map.put(options, :status, status)
|
||||
|
||||
:post
|
||||
|> Request.request!(process_url(conn, "/api/v1/statuses"), payload, get_headers(conn))
|
||||
|> Request.request!(process_url(conn, "/api/v1/statuses"), body, get_headers(conn))
|
||||
|> transform(:status)
|
||||
end
|
||||
|
||||
|
|
|
@ -79,14 +79,21 @@ defmodule Hunter.Status do
|
|||
## Parameters
|
||||
|
||||
* `conn` - connection credentials
|
||||
* `text` - [String]
|
||||
* `in_reply_to_id` - status identifier
|
||||
* `media_ids` - [Array<Integer>]
|
||||
* `status` - text of the status
|
||||
* `options` - option list
|
||||
|
||||
## Options
|
||||
|
||||
* `in_reply_to_id` - local ID of the status you want to reply to
|
||||
* `media_ids` - list of media IDs to attach to the status (maximum: 4)
|
||||
* `sensitive` - whether the media of the status is NSFW
|
||||
* `spoiler_text` - text to be shown as a warning before the actual content
|
||||
* `visibility` - either `direct`, `private`, `unlisted` or `public`
|
||||
|
||||
"""
|
||||
@spec create_status(Hunter.Client.t, String.t, status_id, [non_neg_integer]) :: Hunter.Status.t | no_return
|
||||
def create_status(conn, text, in_reply_to_id \\ nil, media_ids \\ []) do
|
||||
@hunter_api.create_status(conn, text, in_reply_to_id, media_ids)
|
||||
@spec create_status(Hunter.Client.t, String.t, Keyword.t) :: Hunter.Status.t | no_return
|
||||
def create_status(conn, status, options \\ []) do
|
||||
@hunter_api.create_status(conn, status, Map.new(options))
|
||||
end
|
||||
|
||||
@doc """
|
||||
|
@ -226,6 +233,8 @@ defmodule Hunter.Status do
|
|||
|
||||
## Options
|
||||
|
||||
* `only_media` - only return `Hunter.Status.t` that have media attachments
|
||||
* `exclude_replies` - skip statuses that reply to other statuses
|
||||
* `max_id` - [Integer]
|
||||
* `since_id` - [Integer]
|
||||
* `limit` - [Integer]
|
||||
|
@ -266,9 +275,10 @@ defmodule Hunter.Status do
|
|||
|
||||
## Options
|
||||
|
||||
* `max_id` - [Integer]
|
||||
* `since_id` - [Integer]
|
||||
* `limit` - [Integer]
|
||||
* `max_id` - [Integer]
|
||||
* `since_id` - [Integer]
|
||||
* `limit` - [Integer]
|
||||
* `local` - only return statuses originating from this instance
|
||||
|
||||
"""
|
||||
@spec public_timeline(Hunter.Client.t, Keyword.t) :: [Hunter.Status.t]
|
||||
|
@ -287,9 +297,10 @@ defmodule Hunter.Status do
|
|||
|
||||
## Options
|
||||
|
||||
* `max_id` - [Integer]
|
||||
* `since_id` - [Integer]
|
||||
* `limit` - [Integer]
|
||||
* `max_id` - [Integer]
|
||||
* `since_id` - [Integer]
|
||||
* `limit` - [Integer]
|
||||
* `local` - only return statuses originating from this instance
|
||||
|
||||
"""
|
||||
@spec hashtag_timeline(Hunter.Client.t, [String.t], Keyword.t) :: [Hunter.Status.t]
|
||||
|
|
|
@ -12,7 +12,7 @@ defmodule Hunter.Api.InMemory do
|
|||
%{name: :card_by_status, arity: 2, as: %Hunter.Card{}},
|
||||
%{name: :clear_notifications, arity: 1, as: %{}},
|
||||
%{name: :create_app, arity: 5, as: %Hunter.Application{}},
|
||||
%{name: :create_status, arity: 4, as: %Hunter.Status{}},
|
||||
%{name: :create_status, arity: 3, as: %Hunter.Status{}},
|
||||
%{name: :favourite, arity: 2, as: %Hunter.Status{}},
|
||||
%{name: :favourited_by, arity: 2, as: [%Hunter.Account{}]},
|
||||
%{name: :favourites, arity: 1, as: [%Hunter.Status{}]},
|
||||
|
|
Loading…
Reference in New Issue