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

Test voting endpoint just to make sure the civic API works in prod #2209

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config/runtime.exs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ config :dotcom, DotcomWeb.ViewHelpers,
google_tag_manager_auth: System.get_env("GOOGLE_TAG_MANAGER_AUTH"),
google_tag_manager_preview: System.get_env("GOOGLE_TAG_MANAGER_PREVIEW")

config :dotcom, google_api_key: System.get_env("GOOGLE_API_KEY")

config :recaptcha,
public_key: System.get_env("RECAPTCHA_PUBLIC_KEY"),
secret: System.get_env("RECAPTCHA_PRIVATE_KEY", "6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe")
Expand Down
23 changes: 23 additions & 0 deletions lib/dotcom_web/controllers/vote_test_controller.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
defmodule DotcomWeb.VoteTestController do
use DotcomWeb, :controller

def show(conn, _params) do
address = "6 Greenough Ave, Boston, MA 02130"

google_api_key = Application.get_env(:dotcom, :google_api_key)

response =
Req.get("https://www.googleapis.com/civicinfo/v2/voterinfo",
params: [
key: google_api_key,
electionId: "9000",
address: address
]
)

conn
|> assign(:address, address)
|> assign(:response, response)
|> render()
end
end
2 changes: 2 additions & 0 deletions lib/dotcom_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,8 @@ defmodule DotcomWeb.Router do
for static_page <- StaticPage.static_pages() do
get("/#{StaticPage.convert_path(static_page)}", StaticPageController, static_page)
end

get "/vote-test", VoteTestController, :show
end

scope "/", DotcomWeb do
Expand Down
5 changes: 5 additions & 0 deletions lib/dotcom_web/templates/vote_test/show.html.heex
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<h2>Address</h2>
<pre><%= inspect @address, pretty: true %></pre>

<h2>Response</h2>
<pre><%= inspect @response, pretty: true %></pre>
3 changes: 3 additions & 0 deletions lib/dotcom_web/views/vote_test_view.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
defmodule DotcomWeb.VoteTestView do
use DotcomWeb, :view
end
Loading