Skip to content

Conversation

wawashra
Copy link

@wawashra wawashra commented Sep 2, 2025

No description provided.

@wawashra wawashra requested a review from Abdallahj94 September 2, 2025 09:36
Comment on lines 85 to 113
@spec get_available_objects(binary()) :: {:ok, list()} | {:error, any()}
def get_available_objects(app_token) do
with {:ok, client} <- get_client(app_token),
{:ok, %{"sobjects" => objects}} <- ExForce.describe_global(client) do
objects
|> Enum.filter(&targeted_object?/1)
|> Enum.reject(&untargeted_object?/1)
|> Enum.map(fn object -> Map.delete(object, "urls") end)
end
end

@spec get_available_custom_objects(binary()) :: {:ok, list()} | {:error, any()}
def get_available_custom_objects(app_token) do
with {:ok, client} <- get_client(app_token) do
{:ok, %{"sobjects" => objects}} = ExForce.describe_global(client)

objects
|> Enum.filter(fn object -> object["custom"] == true end)
|> Enum.reject(fn object -> String.contains?(object["name"], "Userpilot") end)
|> Enum.map(fn object ->
%{
name: object["name"],
label: object["label"],
custom: object["custom"]
}
end)
end
end

Choose a reason for hiding this comment

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

Suggested change
@spec get_available_objects(binary()) :: {:ok, list()} | {:error, any()}
def get_available_objects(app_token) do
with {:ok, client} <- get_client(app_token),
{:ok, %{"sobjects" => objects}} <- ExForce.describe_global(client) do
objects
|> Enum.filter(&targeted_object?/1)
|> Enum.reject(&untargeted_object?/1)
|> Enum.map(fn object -> Map.delete(object, "urls") end)
end
end
@spec get_available_custom_objects(binary()) :: {:ok, list()} | {:error, any()}
def get_available_custom_objects(app_token) do
with {:ok, client} <- get_client(app_token) do
{:ok, %{"sobjects" => objects}} = ExForce.describe_global(client)
objects
|> Enum.filter(fn object -> object["custom"] == true end)
|> Enum.reject(fn object -> String.contains?(object["name"], "Userpilot") end)
|> Enum.map(fn object ->
%{
name: object["name"],
label: object["label"],
custom: object["custom"]
}
end)
end
end
@spec get_available_objects(binary()) :: {:ok, list()} | {:error, any()}
def get_available_objects(app_token) do
with {:ok, client} <- get_client(app_token),
{:ok, %{"sobjects" => objects}} <- ExForce.describe_global(client) do
objects
|> Enum.filter(&targeted_object?/1)
|> Enum.map(&to_object/1)
end
end
@spec get_available_custom_objects(binary()) :: {:ok, list()} | {:error, any()}
def get_available_custom_objects(app_token) do
with {:ok, client} <- get_client(app_token) do
{:ok, %{"sobjects" => objects}} = ExForce.describe_global(client)
objects
|> Enum.filter(fn object ->
object["custom"] == true and not String.contains?(object["name"], "Userpilot")
end)
|> Enum.map(&to_object/1)
end
end
defp to_object(%{"name" => name, "label" => label, "custom" => custom}) do
%{
name: name,
label: label,
custom: custom
}
end

Comment on lines +582 to +583
defp untargeted_object?(object),
do: String.contains?(object["name"], "Userpilot")

Choose a reason for hiding this comment

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

Suggested change
defp untargeted_object?(object),
do: String.contains?(object["name"], "Userpilot")

@wawashra wawashra requested a review from Abdallahj94 September 2, 2025 17:01
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