// CreateMessages sends some messages (SMS/MMS)
// It statuses of created messages or error
512399
func (api *Client) CreateMessages(data ...*CreateMessageData) ([]*CreateMessageResult, error) {
	result, _, err := api.makeRequest(http.MethodPost, api.concatUserPath(messagesPath), &[]*CreateMessageResult{}, data)
	if err != nil {
		return nil, err
	}
	list := *(result.(*[]*CreateMessageResult))
	for _, r := range list {
		r.ID = getIDFromLocation(r.Location)
	}
	return list, nil
}
1027323
func (s *EntityRecognizerProperties) SetMessage(v string) *EntityRecognizerProperties {
	s.Message = &v
	return s
}
650607
func NewMessage(hdr *Header, msg []byte) *Message {
	var h Header
	if hdr != nil {
		h = *hdr
	}

	if h.Timestamp.IsZero() {
		h.Timestamp = time.Now().UTC()
	}

	if h.Version == 0 {
		h.Version = 1
	}

	if msg != nil {
		m := make([]byte, len(msg))
		copy(m, msg)
		msg = m
	}

	return &Message{Header: h, Msg: msg}
}
1051560
func (s *FailedCreateAssociation) SetMessage(v string) *FailedCreateAssociation {
	s.Message = &v
	return s
}
1368505
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {

	// Ignore all messages created by the bot itself
	// This isn't required in this specific example but it's a good practice.
	if m.Author.ID == s.State.User.ID {
		return
	}
	// If the message is "ping" reply with "Pong!"
	if m.Content == "ping" {
		s.ChannelMessageSend(m.ChannelID, "Pong!")
	}

	// If the message is "pong" reply with "Ping!"
	if m.Content == "pong" {
		s.ChannelMessageSend(m.ChannelID, "Ping!")
	}
}
1145951
func NewMessage(data interface{}) (*Message, error) {
	m := &Message{}
	if err := m.unmarshalInterface(data); err != nil {
		return nil, err
	}
	return m, nil
}
256305
func (engine *CryptoEngine) NewEncryptedMessage(msg message) (EncryptedMessage, error) {

	m := EncryptedMessage{}

	// derive nonce
	nonce, err := deriveNonce(engine.nonceKey, engine.salt, engine.context, engine.fetchAndIncrement())
	if err != nil {
		return m, err
	}

	m.nonce = nonce

	encryptedData := secretbox.Seal(nil, msg.toBytes(), &m.nonce, &engine.secretKey)

	// assign the encrypted data to the message
	m.data = encryptedData

	// calculate the overall size of the message
	m.length = uint64(len(m.data) + len(m.nonce) + 8)

	return m, nil

}
1027124
func (s *DescribeFlowOutput) SetMessages(v *Messages) *DescribeFlowOutput {
	s.Messages = v
	return s
}
678808
func NewMessage(seqNum uint32, items []FetchItem) *Message {
	msg := &Message{
		SeqNum:     seqNum,
		Items:      make(map[FetchItem]interface{}),
		Body:       make(map[*BodySectionName]Literal),
		itemsOrder: items,
	}

	for _, k := range items {
		msg.Items[k] = nil
	}

	return msg
}
654129
func (m *DummyMailbox) NewMessage() Message {
	return &DummyMessage{
		sequenceNumber: 0,
		uid:            0,
		header:         make(textproto.MIMEHeader),
		internalDate:   time.Now(),
		flags:          types.Flags(0),
		mailstore:      m.mailstore,
		mailboxID:      m.ID,
		body:           "",
	}
}
771096
func (c *conn) SendMessages(messages []Message) error {
	var buf []byte
	for _, m := range messages {
		b, err := m.MarshalBinary()
		if err != nil {
			return err
		}

		buf = append(buf, b...)
	}

	addr := &unix.SockaddrNetlink{
		Family: unix.AF_NETLINK,
	}

	return os.NewSyscallError("sendmsg", c.s.Sendmsg(buf, nil, addr, 0))
}
1024941
func (w *Writer) WriteMessage(m *Message) error {
	return w.Write(m.String())
}
687826
func makeCompoundMessage(msgs [][]byte) []byte {
	cMsg := CompoundMessage{}

	cMsg.Messages = make([]*CompoundMessage_SimpleMessage, 0, len(msgs))
	for _, m := range msgs {
		cMsg.Messages = append(cMsg.Messages, &CompoundMessage_SimpleMessage{
			Payload: m,
		})
	}

	buf, err := proto.Marshal(&cMsg)
	if err != nil {
		return nil
	}

	gMsg := GossipMessage{
		Type: MessageTypeCompound,
		Data: buf,
	}

	buf, err = proto.Marshal(&gMsg)
	if err != nil {
		return nil
	}

	return buf
}
715530
func (api *Client) CreateMessage(data *CreateMessageData) (string, error) {
	_, headers, err := api.makeRequest(http.MethodPost, api.concatUserPath(messagesPath), nil, data)
	if err != nil {
		return "", err
	}
	return getIDFromLocationHeader(headers), nil
}
109302
func Create(c *messagebird.Client, originator string, recipients []string, body string, msgParams *Params) (*Message, error) {
	requestData, err := requestDataForMessage(originator, recipients, body, msgParams)
	if err != nil {
		return nil, err
	}

	message := &Message{}
	if err := c.Request(message, http.MethodPost, path, requestData); err != nil {
		return nil, err
	}

	return message, nil
}
315804
func (s *MetricDataResult) SetMessages(v []*MessageData) *MetricDataResult {
	s.Messages = v
	return s
}
84722
func Create(c *messagebird.Client, originator string, recipients []string, msgParams *Params) (*Message, error) {
	params, err := paramsForMessage(msgParams)
	if err != nil {
		return nil, err
	}

	params.Set("originator", originator)
	params.Set("recipients", strings.Join(recipients, ","))

	mmsMessage := &Message{}
	if err := c.Request(mmsMessage, http.MethodPost, path, params); err != nil {
		return nil, err
	}

	return mmsMessage, nil
}