本文整理汇总了Golang中github.com/skypies/complaints/complaintdb/types.Complaint.Activity方法的典型用法代码示例。如果您正苦于以下问题:Golang Complaint.Activity方法的具体用法?Golang Complaint.Activity怎么用?Golang Complaint.Activity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/skypies/complaints/complaintdb/types.Complaint
的用法示例。
在下文中一共展示了Complaint.Activity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: PostComplaint
func PostComplaint(client *http.Client, p types.ComplainerProfile, c types.Complaint) (string, error) {
first, last := p.SplitName()
addr := p.GetStructuredAddress()
if c.Activity == "" {
c.Activity = "Loud noise"
}
debug, submitkey, err := GetSubmitkey(client)
if err != nil {
return debug, err
}
debug += fmt.Sprintf("We got submitkey=%s\n", submitkey)
// {{{ Populate form
vals := url.Values{
"response": {"json"},
"contactmethod": {"App"},
"app_key": {"TUC8uDJMooVMvf7hew93nhUGcWgw"},
"caller_code": {p.CallerCode},
"name": {first},
"surname": {last},
"address1": {addr.Street},
"address2": {""},
"zipcode": {addr.Zip},
"city": {addr.City},
"state": {addr.State},
"email": {p.EmailAddress},
"airports": {"KSFO"}, // KOAK, KSJC, KSAN
"month": {date.InPdt(c.Timestamp).Format("1")},
"day": {date.InPdt(c.Timestamp).Format("2")},
"year": {date.InPdt(c.Timestamp).Format("2006")},
"hour": {date.InPdt(c.Timestamp).Format("15")},
"min": {date.InPdt(c.Timestamp).Format("4")},
"aircraftcategory": {"J"},
"eventtype": {"Loud noise"}, // perhaps map c.Activity to something ?
"comments": {c.Description},
"responserequired": {"N"},
"enquirytype": {"C"},
"submit": {"Submit complaint"},
"submitkey": {submitkey},
"nowebtrak": {"1"},
"defaulttime": {"0"},
"webtraklinkback": {""},
"title": {""},
"homephone": {""},
"workphone": {""},
"cellphone": {""},
}
if c.AircraftOverhead.FlightNumber != "" {
vals.Add("acid", c.AircraftOverhead.Callsign)
vals.Add("aacode", c.AircraftOverhead.Id2)
vals.Add("tailnumber", c.AircraftOverhead.Registration)
vals.Add("aircrafttype", c.AircraftOverhead.EquipType)
//vals.Add("adflag", "??") // Operation type (A, D or O for Arr, Dept or Overflight)
//vals.Add("beacon", "??") // SSR code (eg 210)
}
// }}}
debug += "Submitting these vals:-\n"
for k, v := range vals {
debug += fmt.Sprintf(" * %-20.20s: %v\n", k, v)
}
if resp, err := client.PostForm("https://"+bksvHost+bksvPath, vals); err != nil {
return debug, err
} else {
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
if resp.StatusCode >= 400 {
debug += fmt.Sprintf("ComplaintPOST: HTTP err '%s'\nBody:-\n%s\n--\n", resp.Status, body)
return debug, fmt.Errorf("ComplaintPOST: HTTP err %s", resp.Status)
}
var jsonMap map[string]interface{}
if err := json.Unmarshal([]byte(body), &jsonMap); err != nil {
debug += fmt.Sprintf("ComplaintPOST: JSON unmarshal '%v'\nBody:-\n%s\n--\n", err, body)
return debug, fmt.Errorf("ComplaintPOST: JSON unmarshal %v", err)
/* Fall back ?
if !regexp.MustCompile(`(?i:received your complaint)`).MatchString(string(body)) {
debug += fmt.Sprintf("BKSV body ...\n%s\n------\n", string(body))
return debug,fmt.Errorf("Returned response did not say 'received your complaint'")
} else {
debug += "Success !\n"+string(body)
}
*/
} else if v := jsonMap["result"]; v == nil {
//.........这里部分代码省略.........
示例2: PopulateForm
func PopulateForm(c types.Complaint, submitkey string) url.Values {
first, last := c.Profile.SplitName()
addr := c.Profile.GetStructuredAddress()
if c.Activity == "" {
c.Activity = "Loud noise"
}
vals := url.Values{
"response": {"json"},
"contactmethod": {"App"},
"apiKey": {"399734e01c8cd5c21205599689cc77f2a50467f28e6f5d58a69f2b097d71b839c20e0051175107e74130ae9a3bbaccbe51ec5742e6ca3e51ff40cc1a8f401009"},
"caller_code": {c.Profile.CallerCode},
"name": {first},
"surname": {last},
"address1": {addr.Street},
"address2": {""},
"zipcode": {addr.Zip},
"city": {addr.City},
"state": {addr.State},
"email": {c.Profile.EmailAddress},
"airports": {"KSFO"}, // KOAK, KSJC, KSAN
"month": {date.InPdt(c.Timestamp).Format("1")},
"day": {date.InPdt(c.Timestamp).Format("2")},
"year": {date.InPdt(c.Timestamp).Format("2006")},
"hour": {date.InPdt(c.Timestamp).Format("15")},
"min": {date.InPdt(c.Timestamp).Format("4")},
"aircraftcategory": {"J"},
"eventtype": {"Loud noise"}, // perhaps map c.Activity to something ?
"comments": {c.Description},
"responserequired": {"N"},
"enquirytype": {"C"},
"submit": {"Submit complaint"},
//"submitkey": {submitkey},
"nowebtrak": {"1"},
"defaulttime": {"0"},
"webtraklinkback": {""},
"title": {""},
"homephone": {""},
"workphone": {""},
"cellphone": {""},
"browser_name": {c.Browser.Name},
"browser_version": {c.Browser.Version},
"browser_vendor": {c.Browser.Vendor},
"browser_uuid": {c.Browser.UUID},
"browser_platform": {c.Browser.Platform},
}
if c.AircraftOverhead.FlightNumber != "" {
vals.Add("acid", c.AircraftOverhead.Callsign)
vals.Add("aacode", c.AircraftOverhead.Id2)
vals.Add("tailnumber", c.AircraftOverhead.Registration)
vals.Add("aircrafttype", c.AircraftOverhead.EquipType)
//vals.Add("adflag", "??") // Operation type (A, D or O for Arr, Dept or Overflight)
//vals.Add("beacon", "??") // Squawk SSR code (eg 2100)
}
return vals
}