From e59368186f7ac5ba6c88aa36c669509e42e51bbc Mon Sep 17 00:00:00 2001 From: techgaun Date: Tue, 6 Sep 2016 14:25:53 -0500 Subject: [PATCH 1/3] update packages so it works with new elixir versions --- mix.exs | 4 ++-- mix.lock | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/mix.exs b/mix.exs index 2f825fe..b00d899 100644 --- a/mix.exs +++ b/mix.exs @@ -45,8 +45,8 @@ defmodule Forcex.Mixfile do # Type `mix help deps` for more examples and options defp deps do [ - {:httpoison, "~> 0.8"}, - {:exjsx, "~> 3.1"}, + {:httpoison, "~> 0.9"}, + {:exjsx, "~> 3.2"}, {:timex, "~> 2.0"}, {:excoveralls, "~> 0.5", only: :test}, {:ex_doc, "~> 0.11.4", only: :docs}, diff --git a/mix.lock b/mix.lock index 3891795..5366be4 100644 --- a/mix.lock +++ b/mix.lock @@ -1,17 +1,17 @@ -%{"certifi": {:hex, :certifi, "0.4.0"}, - "combine": {:hex, :combine, "0.7.0"}, - "earmark": {:hex, :earmark, "0.2.1"}, - "ex_doc": {:hex, :ex_doc, "0.11.4"}, - "excoveralls": {:hex, :excoveralls, "0.5.2"}, - "exjsx": {:hex, :exjsx, "3.2.0"}, - "gettext": {:hex, :gettext, "0.10.0"}, - "hackney": {:hex, :hackney, "1.6.0"}, - "httpoison": {:hex, :httpoison, "0.8.3"}, - "idna": {:hex, :idna, "1.2.0"}, - "jsx": {:hex, :jsx, "2.6.2"}, - "metrics": {:hex, :metrics, "1.0.1"}, - "mimerl": {:hex, :mimerl, "1.0.2"}, - "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.0"}, +%{"certifi": {:hex, :certifi, "0.4.0", "a7966efb868b179023618d29a407548f70c52466bf1849b9e8ebd0e34b7ea11f", [:rebar3], []}, + "combine": {:hex, :combine, "0.9.2", "cd3c8721f378ebe032487d8a4fa2ced3181a456a3c21b16464da8c46904bb552", [:mix], []}, + "earmark": {:hex, :earmark, "0.2.1", "ba6d26ceb16106d069b289df66751734802777a3cbb6787026dd800ffeb850f3", [:mix], []}, + "ex_doc": {:hex, :ex_doc, "0.11.5", "0dc51cb84f8312162a2313d6c71573a9afa332333d8a332bb12540861b9834db", [:mix], [{:earmark, "~> 0.1.17 or ~> 0.2", [hex: :earmark, optional: true]}]}, + "excoveralls": {:hex, :excoveralls, "0.5.6", "35a903f6f78619ee7f951448dddfbef094b3a0d8581657afaf66465bc930468e", [:mix], [{:exjsx, "~> 3.0", [hex: :exjsx, optional: false]}, {:hackney, ">= 0.12.0", [hex: :hackney, optional: false]}]}, + "exjsx": {:hex, :exjsx, "3.2.0", "7136cc739ace295fc74c378f33699e5145bead4fdc1b4799822d0287489136fb", [:mix], [{:jsx, "~> 2.6.2", [hex: :jsx, optional: false]}]}, + "gettext": {:hex, :gettext, "0.11.0", "80c1dd42d270482418fa158ec5ba073d2980e3718bacad86f3d4ad71d5667679", [:mix], []}, + "hackney": {:hex, :hackney, "1.6.1", "ddd22d42db2b50e6a155439c8811b8f6df61a4395de10509714ad2751c6da817", [:rebar3], [{:certifi, "0.4.0", [hex: :certifi, optional: false]}, {:idna, "1.2.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.0", [hex: :ssl_verify_fun, optional: false]}]}, + "httpoison": {:hex, :httpoison, "0.9.1", "6c2b4eaf2588a6f3ef29663d28c992531ca3f0bc832a97e0359bc822978e1c5d", [:mix], [{:hackney, "~> 1.6.0", [hex: :hackney, optional: false]}]}, + "idna": {:hex, :idna, "1.2.0", "ac62ee99da068f43c50dc69acf700e03a62a348360126260e87f2b54eced86b2", [:rebar3], []}, + "jsx": {:hex, :jsx, "2.6.2", "213721e058da0587a4bce3cc8a00ff6684ced229c8f9223245c6ff2c88fbaa5a", [:mix, :rebar], []}, + "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], []}, + "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []}, + "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.0", "edee20847c42e379bf91261db474ffbe373f8acb56e9079acb6038d4e0bf414f", [:rebar, :make], []}, "ssl_verify_hostname": {:hex, :ssl_verify_hostname, "1.0.6"}, - "timex": {:hex, :timex, "2.1.4"}, - "tzdata": {:hex, :tzdata, "0.5.7"}} + "timex": {:hex, :timex, "2.2.1", "0d69012a7fd69f4cbdaa00cc5f2a5f30f1bed56072fb362ed4bddf60db343022", [:mix], [{:combine, "~> 0.7", [hex: :combine, optional: false]}, {:gettext, "~> 0.10", [hex: :gettext, optional: false]}, {:tzdata, "~> 0.1.8 or ~> 0.5", [hex: :tzdata, optional: false]}]}, + "tzdata": {:hex, :tzdata, "0.5.9", "575be217b039057a47e133b72838cbe104fb5329b19906ea4e66857001c37edb", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, optional: false]}]}} From aabd19395452482d120ebe305e42dba8b6b0768d Mon Sep 17 00:00:00 2001 From: techgaun Date: Tue, 6 Sep 2016 19:26:12 -0500 Subject: [PATCH 2/3] add ability to filter and override default endpoint on compile --- lib/mix/tasks/compile.forcex.ex | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/mix/tasks/compile.forcex.ex b/lib/mix/tasks/compile.forcex.ex index 9e50cd4..6e48c5a 100644 --- a/lib/mix/tasks/compile.forcex.ex +++ b/lib/mix/tasks/compile.forcex.ex @@ -2,11 +2,13 @@ defmodule Mix.Tasks.Compile.Forcex do use Mix.Task @recursive false + @default_endpoint "https://login.salesforce.com" def run(_) do {:ok, _} = Application.ensure_all_started(:forcex) - client = Forcex.Client.login + client = Forcex.Client.default_config + |> Forcex.Client.login(%Forcex.Client{endpoint: config[:endpoint] || @default_endpoint}) case client do %{access_token: nil} -> IO.puts("Invalid configuration/credentials. Cannot generate SObjects.") @@ -21,6 +23,7 @@ defmodule Mix.Tasks.Compile.Forcex do client |> Forcex.describe_global |> Map.get("sobjects") + |> filter_modules for sobject <- sobjects do sobject @@ -30,6 +33,18 @@ defmodule Mix.Tasks.Compile.Forcex do end + defp filter_modules(sobjects) do + case config[:modules] |> is_list do + true -> + sobjects + |> Enum.filter(fn sobject -> + Map.get(sobject, "name", nil) in config[:modules] + end) + false -> + sobjects + end + end + defp generate_module(sobject, client) do name = Map.get(sobject, "name") urls = Map.get(sobject, "urls") @@ -215,4 +230,6 @@ defmodule Mix.Tasks.Compile.Forcex do " * `#{value}`\n" end defp docs_for_picklist_values(_), do: "" + + defp config, do: Application.get_env(:forcex, Forcex.Client) end From 312d14789347fbb7f3dc6bab2cfad5812f3f8fdd Mon Sep 17 00:00:00 2001 From: techgaun Date: Tue, 6 Sep 2016 20:43:19 -0500 Subject: [PATCH 3/3] update readme --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cf7d0bf..18a8d11 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,9 @@ config :forcex, Forcex.Client, password: "my_super_secret_password", security_token: "EMAILED_FROM_SALESFORCE", client_id: "CONNECTED_APP_OAUTH_CLIENT_ID", - client_secret: "CONNECTED_APP_OAUTH_CLIENT_SECRET" + client_secret: "CONNECTED_APP_OAUTH_CLIENT_SECRET", + endpoint: "https://test.salesforce.com", + modules: ["People"] ``` or these environment variables: @@ -67,6 +69,8 @@ or these environment variables: * `SALESFORCE_CLIENT_ID` * `SALESFORCE_CLIENT_SECRET` +The endpoint (defaults to `https://login.salesforce.com`) and modules configurations are optional. The list of modules can be specified so that only particular Salesforce Objects are compiled instead of compiling entire Salesforce object. + HTTPoison request-specific options may also be configured: ```elixir