Skip to content

Commit

Permalink
Disambiguate get function
Browse files Browse the repository at this point in the history
In order to avoid conflict with the HTTPoison-provided get function and
its typespec, rename `get/3` to `client_get/3`. Perform the same
defensive rename for `post/3`.
  • Loading branch information
fastjames committed Jun 28, 2022
1 parent b9f9e09 commit 91bda65
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/forcex/bulk.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,34 +59,34 @@ defmodule Forcex.Bulk do
request!(method, url, body, headers, extra_options() ++ options) |> process_response
end

def get(path, headers \\ [], client) do
def client_get(path, headers \\ [], client) do
url = "https://#{client.host}/services/async/#{client.api_version}" <> path
raw_request(:get, url, "", headers ++ authorization_header(client), [])
end

def post(path, body \\ "", client) do
def client_post(path, body \\ "", client) do
url = "https://#{client.host}/services/async/#{client.api_version}" <> path
json_request(:post, url, body, authorization_header(client), [])
end

@spec create_query_job(binary, map) :: job
def create_query_job(sobject, client) do
payload = %{"operation" => "query", "object" => sobject, "concurrencyMode" => "Parallel", "contentType" => "JSON"}
post("/job", payload, client)
client_post("/job", payload, client)
end

@spec close_job(job | id, map) :: job
def close_job(job, client) when is_map(job) do
close_job(job.id, client)
end
def close_job(id, client) when is_binary(id) do
post("/job/#{id}", %{"state" => "Closed"}, client)
client_post("/job/#{id}", %{"state" => "Closed"}, client)
end

@spec fetch_job_status(job | id, map) :: job
def fetch_job_status(job, client) when is_map(job), do: fetch_job_status(job.id, client)
def fetch_job_status(id, client) when is_binary(id) do
get("/job/#{id}", client)
client_get("/job/#{id}", client)
end

@spec create_query_batch(String.t, job | id, map) :: job
Expand All @@ -105,7 +105,7 @@ defmodule Forcex.Bulk do
fetch_batch_status(id, job.id, client)
end
def fetch_batch_status(id, job_id, client) when is_binary(id) and is_binary(job_id) do
get("/job/#{job_id}/batch/#{id}", client)
client_get("/job/#{job_id}/batch/#{id}", client)
end

@spec fetch_batch_result_status(batch, map) :: list(String.t)
Expand All @@ -114,7 +114,7 @@ defmodule Forcex.Bulk do
end
@spec fetch_batch_result_status(id, id, map) :: list(String.t)
def fetch_batch_result_status(batch_id, job_id, client) when is_binary(batch_id) and is_binary(job_id) do
get("/job/#{job_id}/batch/#{batch_id}/result", client)
client_get("/job/#{job_id}/batch/#{batch_id}/result", client)
end

@spec fetch_results(id, batch, map) :: list(map)
Expand All @@ -123,7 +123,7 @@ defmodule Forcex.Bulk do
end
@spec fetch_results(id, id, id, map) :: list(map)
def fetch_results(id, batch_id, job_id, client) when is_binary(id) and is_binary(batch_id) and is_binary(job_id) do
get("/job/#{job_id}/batch/#{batch_id}/result/#{id}", client)
client_get("/job/#{job_id}/batch/#{batch_id}/result/#{id}", client)
end

defp find_header(headers, header_name) do
Expand Down

0 comments on commit 91bda65

Please sign in to comment.