-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implements recently viewed records api #67
base: main
Are you sure you want to change the base?
Implements recently viewed records api #67
Conversation
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. |
There was a problem hiding this 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!
@@ -376,6 +376,23 @@ defmodule ExForce do | |||
) | |||
end | |||
|
|||
@doc """ | |||
Get recently viewed items |
There was a problem hiding this comment.
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
{:ok, %Response{status: 200, body: []}} -> {:ok, []} | ||
{:ok, %Response{status: 200, body: body}} -> {:ok, SObject.build(body)} |
There was a problem hiding this comment.
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) }
@@ -13,6 +13,12 @@ defmodule ExForce.SObject do | |||
@spec build(map) :: t | |||
def build(%{"attributes" => %{}} = raw), do: do_build(raw) | |||
|
|||
def build([%{"attributes" => %{"url" => _, "type" => _}, "Id" => _, "Name" => _} | _] = raw) do |
There was a problem hiding this comment.
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}" |
There was a problem hiding this comment.
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 intourl
option. - Set the default limit (200) per doc
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 :)