Skip to content

Conversation

@othonalberto
Copy link

This pull-request adds support to View Recently Viewed Records api. (#65)

This is my first Elixir pull request, so please let me know if I made any mistake or could improve something :)

@sourcelevel-bot
Copy link

Hello, @othonalberto! This is your first Pull Request that will be reviewed by SourceLevel, an automatic Code Review service. It will leave comments on this diff with potential issues and style violations found in the code as you push new commits. You can also see all the issues found on this Pull Request on its review page. Please check our documentation for more information.

Copy link
Owner

@chulkilee chulkilee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi! Thanks for your contribution :) Left feedback - let me know if anything is unclear!

end

@doc """
Get recently viewed items
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the same convention with other functions

  • End the first sentence with period
  • Add link to the API doc

Comment on lines +389 to +390
{:ok, %Response{status: 200, body: []}} -> {:ok, []}
{:ok, %Response{status: 200, body: body}} -> {:ok, SObject.build(body)}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces SObject.build/1 to take a list of sobject, not a sobject - which adds new responsibility to the public function, more than the function name implies.

We can just use Enum.map/2 here.

      {:ok, %Response{status: 200, body: body}} -> {:ok, Enum.map(body, &SObject.build/1) }

@spec build(map) :: t
def build(%{"attributes" => %{}} = raw), do: do_build(raw)

def build([%{"attributes" => %{"url" => _, "type" => _}, "Id" => _, "Name" => _} | _] = raw) do
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beside it's necessary addition...

  • This breaks the typespec (@spec build(map) :: t) as now it returns the list.
  • This adds get_recently_viewed_items specific handling to this function; such handling should happen there, not here.

def get_recently_viewed_items(client, limit) do
case Client.request(client, %Request{
method: :get,
url: "recent/?limit=#{limit}"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Use query option like other functions - instead of baking the query params into url option.
  • Set the default limit (200) per doc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants