Implements recently viewed records api#67
Implements recently viewed records api#67othonalberto wants to merge 4 commits intochulkilee:mainfrom
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. |
chulkilee
left a comment
There was a problem hiding this comment.
Hi! Thanks for your contribution :) Left feedback - let me know if anything is unclear!
| end | ||
|
|
||
| @doc """ | ||
| Get recently viewed items |
There was a problem hiding this comment.
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.
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 |
There was a problem hiding this comment.
Beside it's necessary addition...
- This breaks the typespec (
@spec build(map) :: t) as now it returns the list. - This adds
get_recently_viewed_itemsspecific 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.
- Use
queryoption like other functions - instead of baking the query params intourloption. - 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 :)