ArcGIS. Feature. MutationResult
(ArcGIS v1.0.2)
View Source
Helpers for validating ArcGIS Feature Service mutation responses.
Validation is opt-in and does not change the response from ArcGIS.Feature.mutate/3.
ArcGIS.Feature.mutate(service, mutations)
|> ArcGIS.Feature.MutationResult.validate()
Summary
Functions
Given a validated mutation result, this function traverses the validation and returns only the failed mutations.
Validates an response from a mutation request.
Functions
Given a validated mutation result, this function traverses the validation and returns only the failed mutations.
@spec validate({:ok, results} | {:error, reason}) :: {:ok, results} | {:error, {:mutation_failed, results} | {:unexpected_mutation_result, term()} | reason} when results: term(), reason: term()
Validates an response from a mutation request.
Returns {:ok, results} unchanged on success and passes request errors through
unchanged.
Checks addResults, updateResults, and deleteResults, including nested
attachments and assetMaps, using string keys. Returns
{:error, {:mutation_failed, results}} with the entire original response if
any failure is reported. Top-level error and "success" => false responses
also count as failures. No entries or context are removed.
Unsupported values in the response or inspected result groups return
{:error, {:unexpected_mutation_result, value}}.
Async acknowledgements containing statusUrl or resultUrl pass through as
{:ok, response}; this does not confirm that the edits succeeded.
Fetch the final result separately and pass it to this function.
Examples
iex> ArcGIS.Feature.MutationResult.validate({:ok, %{"addResults" => [%{"success" => true}]}})
{:ok, %{adds: %{failures: [], failures?: false, successes: [%{"success" => true}]}, failures?: false}}
iex> ArcGIS.Feature.MutationResult.validate({:ok, %{"deleteResults" => [%{"success" => false, "objectId" => 1}]}})
{:error, %{deletes: %{failures: [%{"objectId" => 1, "success" => false}], failures?: true, successes: []}, failures?: true}}