func GetAllContactTypes(rw http.ResponseWriter, req *http.Request, enc encoding.Encoder, dtx *apicontext.DataContext) string { types, err := contact.GetAllContactTypes(dtx) if err != nil { apierror.GenerateError("Trouble getting all contact types", err, rw, req) } return encoding.Must(enc.Encode(types)) }
func (i *VehicleInquiry) SendEmail(dtx *apicontext.DataContext) error { cts, err := contact.GetAllContactTypes(dtx) if err != nil { return err } var ct contact.ContactType for _, t := range cts { if t.Name == "Vehicle Inquiry" { ct = t break } } // Get Category // var cat Category // cat.CategoryID = i.Category // cat.GetCategory(dtx.APIKey, 1, 1, true, nil, nil, dtx) // Start to build email body body := fmt.Sprintf("Name: %s\n", i.Name) body = fmt.Sprintf("%sEmail: %s\n", body, i.Email) body = fmt.Sprintf("%sPhone: %s\n", body, i.Phone) // body = fmt.Sprintf("%sCategory: %s\n", body, cat.Title) // Decode vehicle var v Vehicle if err := json.Unmarshal([]byte(i.Vehicle), &v); err == nil { str := v.stringify() if str != "" { body = fmt.Sprintf("%sVehicle: %s\n", body, str) } } if i.Message != "" { body = fmt.Sprintf("%s\nMessage: %s\n", body, i.Message) } // Send Email return contact.SendEmail(ct, "Email from VehicleInquiry Request Form", body) //contact type id, subject, techSupport }