// Send post issues via jiraCommentJournal with information in the message.Composer
546086
func (j *jiraCommentJournal) Send(m message.Composer) {
	if j.Level().ShouldLog(m) {
		issue := j.issueID
		if c, ok := m.Raw().(*message.JIRAComment); ok {
			issue = c.IssueID
		}
		if err := j.opts.client.Authenticate(j.opts.Username, j.opts.Password, j.opts.UseBasicAuth); err != nil {
			j.errHandler(fmt.Errorf("jira authentication error: %v", err), message.NewFormattedMessage(m.Priority(), m.String()))
		}
		if err := j.opts.client.PostComment(issue, m.String()); err != nil {
			j.ErrorHandler(err, m)
		}
	}
}
259520
func SendIssueMentionMail(issue Issue, repo Repository, doer User, tos []string) {
	if len(tos) == 0 {
		return
	}
	Send(composeIssueMessage(issue, repo, doer, MAIL_ISSUE_MENTION, tos, "issue mention"))
}
732477
func Send(w http.ResponseWriter, r *http.Request, payload Sendable) *Error {

	validationErr := payload.Validate(r, true)
	if validationErr != nil {

		// use the prepared error as the new response, unless something went horribly
		// wrong
		err := validationErr.Validate(r, true)
		if err != nil {
			http.Error(w, DefaultErrorTitle, http.StatusInternalServerError)
			return err
		}

		payload = validationErr
	}

	return SendDocument(w, r, Build(payload))
}
704767
func (bot *BotAPI) Send(u User, c interface{}, notif string) (APIResponse, error) {
	var r Request

	n := RegularNotif
	if notif != "" {
		n = notif
	}

	switch c.(type) {
	case Request:
		return APIResponse{}, errors.New("Use MakeRequest to send Request!!")

	case Action:
		r = Request{
			Recipient: u,
			Action:    c.(Action),
			NotifType: n,
		}

	case Message:
		r = Request{
			Recipient: u,
			Message:   c.(Message),
			NotifType: n,
		}

	case GenericTemplate:
		r = Request{
			Recipient: u,
			NotifType: n,
			Message: Message{
				Attachment: &Attachment{
					Type:    "template",
					Payload: c.(GenericTemplate),
				},
			},
		}

	case ListTemplate:
		r = Request{
			Recipient: u,
			NotifType: n,
			Message: Message{
				Attachment: &Attachment{
					Type:    "template",
					Payload: c.(ListTemplate),
				},
			},
		}

	case ButtonTemplate:
		r = Request{
			Recipient: u,
			NotifType: n,
			Message: Message{
				Attachment: &Attachment{
					Type:    "template",
					Payload: c.(ButtonTemplate),
				},
			},
		}

	case ReceiptTemplate:
		r = Request{
			Recipient: u,
			NotifType: n,
			Message: Message{
				Attachment: &Attachment{
					Type:    "template",
					Payload: c.(ReceiptTemplate),
				},
			},
		}

	default:
		return APIResponse{}, errors.New("Type is not supported")
	}

	//if r == (Request{}) {
	//	return APIResponse{}, errors.New("Unknown Error")
	//}
	payl, _ := json.Marshal(r)
	if bot.Debug {
		log.Printf("[INFO] Payload: %s", string(payl))
	}
	return bot.MakeRequest(bytes.NewBuffer(payl))
}
1233690
func (sm *BaseMiddleware) PostWrite(msg interface{}, conn IOSession) (bool, error) {
	return true, nil
}
975512
func (b *Batch) Send(cb func()) {
	if b.Deflate {
		b.Writer.(*zlib.Writer).Flush()
	} else {
		b.Writer.(*bufio.Writer).Flush()
	}

	b.Message.PushPayload(b.Buf.Bytes())
	cb()
}
1074118
func (sc *seqClient) send(event *seqLog, apiKey string, client *http.Client) error {
	fullURL := sc.baseURL + endpoint

	serialized, _ := json.Marshal(event)

	request, err := http.NewRequest("POST", fullURL, bytes.NewBuffer(serialized))

	if len(apiKey) > 1 {
		request.Header.Set("X-Seq-ApiKey", apiKey)
		request.Header.Set("Content-Type", "application/json")
	}

	if err != nil {
		return err
	}

	response, err := client.Do(request)
	defer request.Body.Close()
	if err != nil {
		return err
	}
	defer response.Body.Close()

	if response.StatusCode != 201 {
		return errors.New(response.Status)
	}
	return nil
}
1124439
func (peer *Peer) send(message bytes.Buffer) (err error) {
	//Logln("Sending", message)
	Send(peer, message)
	peer.lastSent = time.Now().UnixNano()
	return nil // no error handling for now (sending is asynchronous)
}
217914
func (r SlashCommandResponse) Send(p *Payload) error {
	if p.ResponseUrl == "" {
		return fmt.Errorf("Empty ResponseUrl in Payload: %v", p)
	}
	return Message(r).sendToUrl(p.ResponseUrl)
}
548237
func (r *Report) Send() (err error) {
	var req *http.Request
	var resp *http.Response
	var payload []byte

	if payload, err = json.MarshalIndent(r, "", "  "); err != nil {
		return
	}

	if req, err = http.NewRequest("POST", "https://api.honeybadger.io/v1/notices", bytes.NewBuffer(payload)); err != nil {
		return
	}

	req.Header.Add("Content-Type", "application/json")
	req.Header.Add("Accept", "application/json")
	req.Header.Add("X-API-Key", ApiKey)

	if resp, err = Client.Do(req); err != nil {
		return
	}
	defer resp.Body.Close()

	if resp.StatusCode < 201 {
		err = errors.New(fmt.Sprintf("unable to send: error %d", resp.StatusCode))
	}
	return
}
1035711
func (target *MQTTTarget) Send(eventKey string) error {

	if !target.client.IsConnectionOpen() {
		return errNotConnected
	}

	eventData, eErr := target.store.Get(eventKey)
	if eErr != nil {
		// The last event key in a successful batch will be sent in the channel atmost once by the replayEvents()
		// Such events will not exist and wouldve been already been sent successfully.
		if os.IsNotExist(eErr) {
			return nil
		}
		return eErr
	}

	objectName, err := url.QueryUnescape(eventData.S3.Object.Key)
	if err != nil {
		return err
	}
	key := eventData.S3.Bucket.Name + "/" + objectName

	data, err := json.Marshal(event.Log{EventName: eventData.EventName, Key: key, Records: []event.Event{eventData}})
	if err != nil {
		return err
	}

	token := target.client.Publish(target.args.Topic, target.args.QoS, false, string(data))
	token.Wait()
	if token.Error() != nil {
		return token.Error()
	}

	// Delete the event from store.
	return target.store.Del(eventKey)
}
363509
func (u *User) Send(message string) {
	textMessage := TextMessage{
		Users:   []*User{u},
		Message: message,
	}
	u.client.Send(&textMessage)
}
761841
func Send(w http.ResponseWriter, contentType string, data interface{}, rCode int) {
	w.Header().Set(HeaderContentType, contentType)
	w.WriteHeader(rCode)
	_, err := fmt.Fprint(w, data)
	if err != nil {
		R500(w, ErrInternalServer)
	}
}
567787
func (c *Client) send(msgs []interface{}) error {
	if len(msgs) == 0 {
		return nil
	}

	batch := new(Batch)
	batch.Messages = msgs
	batch.MessageId = c.uid()
	batch.SentAt = timestamp(c.now())
	batch.Context = DefaultContext

	b, err := json.Marshal(batch)
	if err != nil {
		return fmt.Errorf("error marshalling msgs: %s", err)
	}

	for i := 0; i < 10; i++ {
		if err = c.upload(b); err == nil {
			return nil
		}
		Backo.Sleep(i)
	}

	return err
}
430050
func sendResponse(w http.ResponseWriter, response interface{}, status int) {
	w.Header().Set("Content-Type", "application/json; charset=utf-8")
	marshalledResponse, err := json.Marshal(response)
	if err != nil {
		w.WriteHeader(http.StatusInternalServerError)
		w.Write([]byte(fmt.Sprintf("Failed to marshal response: %v %v", response, err)))
		return
	}
	w.WriteHeader(status)
	w.Write(marshalledResponse)
}
1027492
func (c *Client) sendRequest(jReq *jsonRequest) {
	// Choose which marshal and send function to use depending on whether
	// the client running in HTTP POST mode or not.  When running in HTTP
	// POST mode, the command is issued via an HTTP client.  Otherwise,
	// the command is issued via the asynchronous websocket channels.
	if c.config.HTTPPostMode {
		c.sendPost(jReq)
		return
	}

	// Check whether the websocket connection has never been established,
	// in which case the handler goroutines are not running.
	select {
	case <-c.connEstablished:
	default:
		jReq.responseChan <- &response{err: ErrClientNotConnected}
		return
	}

	// Add the request to the internal tracking map so the response from the
	// remote server can be properly detected and routed to the response
	// channel.  Then send the marshalled request via the websocket
	// connection.
	if err := c.addRequest(jReq); err != nil {
		jReq.responseChan <- &response{err: err}
		return
	}
	log.Tracef("Sending command [%s] with id %d", jReq.method, jReq.id)
	c.sendMessage(jReq.marshalledJSON)
}
530097
func (mdcli2 *Mdcli2) Send(service string, request ...string) (err error) {
	//  Prefix request with protocol frames
	//  Frame 0: empty (REQ emulation)
	//  Frame 1: "MDPCxy" (six bytes, MDP/Client x.y)
	//  Frame 2: Service name (printable string)

	req := make([]string, 3, len(request)+3)
	req = append(req, request...)
	req[2] = service
	req[1] = MDPC_CLIENT
	req[0] = ""
	if mdcli2.verbose {
		log.Printf("I: send request to '%s' service: %q\n", service, req)
	}
	_, err = mdcli2.client.SendMessage(req)
	return
}