Hack4Eugene / SpeedUpAmerica

Crowd-sourced internet speed tests using M-Lab data and user tests on a website, with charts, maps, and raw data downloads.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create POST /contact endpoint for contact form(s) (2SP)

ryanrolds opened this issue · comments

Is your feature request related to a problem? Please describe.
We need to add contact forms to the site for collecting inquiries/questions and issue reports. To do this we will need to add an endpoint that receives the details from the forms and creates a ZenDesk ticket.

Describe the solution you'd like
An endpoint at POST /contact that would consume name, email, type (dropdown: question/problem), subject, and a message from the body of the post. Using the credentials found in two environment variables (ZENDESK_USER and ZENDESK_TOKEN) create a ticket using the ZendDesk API. All fields are required and should return a 400 if not supplied. Any problems (outside of validation) whould return a 500 with a generic JSON response {"status":"error", "message": "<generic error>"} that can be shown to users.

An example curl request for making tickets in ZenDesk:

curl -X POST https://speedupamerica.zendesk.com/api/v2/tickets.json \
-u <ZENDESK_USER>/token:<ZENDESK_TOKEN> \
-H "Content-Type: application/json" \
-d '{"ticket": {"subject":"My printer is on fire!","comment":{"body":"The smoke is very colorful."}, "requester" : { "name" : "Test User", "email" : "testuser@example.com"}}}'

Expand the example include type and other details. See https://developer.zendesk.com/rest_api/docs/support/tickets for API details.

Prefix any tickets made by the test environment (RAILS_ENV=test) with TEST ENV: . so that we can easily differentiate test tickets from real tickets.

Talk to Ryan or Matt about getting a ZenDesk user account. Ryan can provide you a token.

Closing. Using ZenDesk Web Widget.