READ ME


Ues Elastic Beanstalk CLI or set Env Vars from your .env file

The API uses environment variables for API keys (which have client name suffixes). Use a .env file mimicking the sample one in development (the aws access and secret keys are the ones belonging to ses.smtp iAm AWS user, they're also in LastPass).

To set new environment vars for forms.api thru the AWS CLI:

  1. (888) 850-5846
  2. Do eb init
  3. Pick region us-east-1
  4. Provice access credentials if needed (aws-access-id, and aws-secret-key), same ones we use for Travis CI
  5. Select form.api.dbxd
  6. Do eb setenv key=value

You can also set the variables from the AWS Console GUI, go to Elastic Beanstalk -> form-api-dbxd-env -> Configuration -> Software Configuration (gear icon) -> scroll down to Environment Properties

Setting environment API keys

To submit Sequent form:


    SECKEY_projectname
    SECKEY_108leonard
    

To submit Spark form:


    SPARK_ACCESS_TOKEN_projectname
    SPARK_ACCESS_TOKEN_108leonard
    

Send AWS SES Email

We are using AWS SES via Nodemailer to send emails via AWS-verified domains.

First Add Email Domain to SES

To add a new domain to send emails from, go into the AWS Console, go to SES -> Domains -> Verify new Domain. Then you must enter the records AWS wants you to enter, you can do this easily through Route 53 if your domain is on there. After the domain is verified, now you can use this API endpoint and send emails from any address ending with @yourverifieddomain.com. (With "yourverifieddomain.com" obviously being the domain you just verified).

Note, @dbox.com is verified, as a test you can send an email from anything @dbox.com. For example: web_admin@dbox.com or no_reply@dbox.com

After domain verification you can use the endpoint: /form.api.dbxd.com/send-ses-email

Or via POST request: /form.api.dbxd.com/post-ses-email

The parameters you must send are:


    from: '"Your Name" <you@youremail.com>'
    to: '"Their Name" <them@theiremail>'
    subject: 'Email subject in a string'
    htmlUrl: '/path/to/external/email_template.html'
    

Your html email template file can contain variables that will get filled in. Use the syntax {{variableName}} in your html email template code. For example:


          <div>
            <h1>Hello {{name}}!</h1>
          </div>
      

Then in the parameters you send to our api, add:

      variables: {
        name: 'Tony Stark'
      }
    
So the full parameter list becomes:

      from: '"Your Name" <you@youremail.com>'
      to: '"Their Name" <them@theiremail>'
      subject: 'Email subject in a string'
      htmlUrl: '/path/to/external/email_template.html',
      variables: {
        name: 'Tony Stark'
      }
    

Spark Submit Form

An API clients sometimes use is (714) 706-8477. It can be used to submit form entries and also to show listings.

How to use - Submit Spark Form

Here, we have Spark hooked up to post forms. The secret key to add to Elastic Beanstalk would be SPARK_ACCESS_TOKEN_projectname.

You can use either a GET request or a POST request. Endpoint:

/form.api.dbxd.com/post-spark-form/

The parameters are of type JSON.

       {
          projectname: 'projectname',
          contact: {
            first_name: 'Test',
            last_name: 'Test',
            email: 'test@email.com',
            phone: '1234567890',
            agent: 'True or False'
          }
        }
      
    

Other possible fields are rating_id (value gotten from Spark docs) and brokerage_name based on whether or not they selected true for agent. Another field that is usually a default field is a select field How did you hear about us? or something similar, follow Spark, project-specific, documentation for other fields and and the client for field values.

More information on the 7782181097 (login for 1 Wall Street Spark account is in LastPass, for other projects, ask the project directior).

Sequent Submit Form

This is the other API clients use to keep track of submissions and sometimes residences. (See our other 5815937802 to get project-specific list of residences via Sequent) To use this API with a new website, add the website's secret key to the environment variables via SECKEY_projectname.

How to use API - Submit Sequent Form

For GET requests: use the endpoint: /form.api.dbxd.com/submit-sequent-form.

For POST requests: use the endpoint: (718) 758-3761.

* (Unlike the Sequent directions you will receive) The first value in your json data should be projectname in all lowercase, no spaces, corresponding to the environment variables you set.

Construct a JavaScript object with the first key/value pair being "projectname" and the name of the lowercase, nospace project name you set in the env vars. The next key/value in the JavaScript object is "data" and its value is the JSON form data, following the Sequent submission field values and instructions pertaining to brokerage firm.

Form submit data example:

  {
        projectname: "thebelord",
        data: {
          address: "15 Park Row",
          brokerage_company: "Test Firm",
          city: "New York",
          client_type: "35491",
          country: "USA",
          debug: 1,
          email: "test@test.com",
          firstname: "Test",
          floorplan: "35495",
          hearfrom: "35505",
          homephone: "2123667277",
          lastname: "Test",
          price_range: "35642",
          realtor_name: "Test Test",
          state: "NY",
          zip: "10038"
        }
      }
    

In an HTTP request, send the above as a value of stringified JSON to the key "params". Your AJAX data should look like this:

{params: JSON.stringify(formData)}

-->Click here to go to Campaign Monitor/Email Marketing Manager DBXD API documentation.<--