Skip to content

Commit

Permalink
Add RecordManager#get_author_feed
Browse files Browse the repository at this point in the history
  • Loading branch information
cribbles committed May 4, 2023
1 parent f4da5ed commit a358c78
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
16 changes: 14 additions & 2 deletions lib/record_manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 27,16 @@ defmodule BlueskyEx.Client.RecordManager do
def get_timeline(session, opts \\ []),
do: fetch_data(:get_timeline, session, query: build_feed_query(opts))

@spec get_author_feed(Session.t(), Keyword.t()) :: Response.t()
def get_author_feed(session, opts \\ []),
do:
fetch_data(:get_author_feed, session,
query: Map.merge(build_feed_query(opts), build_actor_query(session))
)

@spec get_profile(Session.t()) :: Response.t()
def get_profile(session),
do: fetch_data(:get_profile, session, query: %{"actor" => session.did})
do: fetch_data(:get_profile, session, query: build_actor_query(session))

@spec create_post(Session.t(), text: String.t()) :: Response.t()
def create_post(session, text: text),
Expand Down Expand Up @@ -128,6 135,11 @@ defmodule BlueskyEx.Client.RecordManager do
algorithm = Keyword.get(opts, :algorithm, "reverse-chronological")
limit = Keyword.get(opts, :limit, 30)

%{"limit" => limit, "algorithm" => algorithm}
%{limit: limit, algorithm: algorithm}
end

@spec build_actor_query(Session.t()) :: RequestUtils.URI.query_params()
defp build_actor_query(session) do
%{actor: session.did}
end
end
3 changes: 2 additions & 1 deletion lib/request_utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 43,14 @@ defmodule BlueskyEx.Client.RequestUtils do

@type pds :: String.t()
@type uri :: String.t()
@type query_params :: %{String.t() => integer() | String.t()}
@type query_params :: %{atom() => integer() | String.t()}

require URI.Builder
import URI.Builder

# GET
build_uri(:get_account_invite_codes, "com.atproto.server.getAccountInviteCodes", [:pds])
build_uri(:get_author_feed, "app.bsky.feed.getAuthorFeed", [:pds, :query])
build_uri(:get_notifications, "app.bsky.notification.listNotifications", [:pds, :query])
build_uri(:get_popular, "app.bsky.unspecced.getPopular", [:pds, :query])
build_uri(:get_profile, "app.bsky.actor.getProfile", [:pds, :query])
Expand Down

0 comments on commit a358c78

Please sign in to comment.