Skip to content
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

Adding request_sobject_by_external_id function #63

Closed
wants to merge 1 commit into from

Conversation

hmaiabrex
Copy link

Issue 62

I noticed that ExForce does not have a function to request_sobject_by_external_id. We do have the get_sobject_by_external_id, but it only implements the "GET" method for the REST API endpoint.

This will enable upserting sObjects by external id, for example.

@sourcelevel-bot
Copy link

Hello, @hmaiabrex! 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.

Thanks a lot for the PR! Sorry for the delay.. left a few comments.

@@ -160,6 +161,30 @@ defmodule ExForce do
do:
do_get_sobject(client, "sobjects/#{sobject_name}/#{field_name}/#{URI.encode(field_value)}")

@doc """
Makes a request to a SObject based on the value of a specified extneral ID field. Works similarly to get_sobject_by_external_id, but accepts methods other than GET.
Copy link
Owner

Choose a reason for hiding this comment

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

Could you please make following small changes?

  1. Keep single line at the first paragraph, as it will be shown in the function list doc
  2. Quote the function name with arity, (e.g. get_sobject_by_external_id/4) so that the generated doc has the proper link

See [SObject Rows by External ID](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/resources_sobject_upsert.htm)
Also [Insert or Update (Upsert) a Record Using an External ID](https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_upsert.htm)
"""
@spec request_sobject_by_external_id(client, method, any, field_name, sobject_name, map) ::
Copy link
Owner

Choose a reason for hiding this comment

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

Hm.. so request_sobject_by_external_id(client, :get, fv, fn, sn, attrs) would be same with get_sobject_by_external_id(client, fv, fn, sn, attrs) - right?

Hm.. I'm slightly more inclined to have separate functions instead of one function taking request as an argument - e.g.

get_sobject_by_external_id # GET
create_sobject_by_external_id # POST
create_or_update_sobject_by_external_id # PATCH
delete_sobject_by_external_id # DELETE

and they share the same function.

Because choosing the HTTP request (:get, :post, ..) is implementation details - not the high-level behavior.

Any thought?

@hmaiabrex hmaiabrex closed this Jun 17, 2022
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