Пример #1
0
func ClientFromConfig() (client.Client, error) {
	c := client.Client{
		Host:          viper.GetString("host"),
		AccessKeyName: viper.GetString("access_key_name"),
		AccessKey:     viper.GetString("access_key"),
		ShowRequests:  viper.GetBool("show_requests"),
		Mailbox:       viper.GetString("mailbox"),
	}
	if c.AccessKeyName == "" {
		c.AccessKeyName = viper.GetString("mailbox")
	}
	return c, nil
}
Пример #2
0
func _respond(call otto.FunctionCall) otto.Value {
	response, _ := call.Argument(0).ToString()
	client := client.Client{
		Host:          viper.GetString("host"),
		AccessKey:     viper.GetString("access_key"),
		AccessKeyName: viper.GetString("access_key_name"),
		ShowRequests:  viper.GetBool("show_requests"),
	}
	if client.AccessKeyName == "" {
		client.AccessKeyName = viper.GetString("mailbox")
	}
	messageId := getConstant(call.Otto, "SCRIPT_ID")
	err := client.Respond(messageId, response, false)
	if err != nil {
		jsThrow(call, err)
	}
	var v otto.Value
	v, _ = otto.ToValue(true)
	return v
}