// Invite someone to the Room.
//
// HipChat API docs: https://www.hipchat.com/docs/apiv2/method/invite_user
553778
func (r *RoomService) Invite(room string, user string, reason string) (*http.Response, error) {
	reasonReq := &InviteRequest{Reason: reason}

	req, err := r.client.NewRequest("POST", fmt.Sprintf("room/%s/invite/%s", room, user), nil, reasonReq)
	if err != nil {
		return nil, err
	}

	return r.client.Do(req, nil)
}
132971
func (u *InviteeInfo) UnmarshalJSON(body []byte) error {
	type wrap struct {
		dropbox.Tagged
	}
	var w wrap
	var err error
	if err = json.Unmarshal(body, &w); err != nil {
		return err
	}
	u.Tag = w.Tag
	switch u.Tag {
	case "email":
		err = json.Unmarshal(body, &u.Email)

		if err != nil {
			return err
		}
	}
	return nil
}
256917
func (api *Client) InviteUsersToConversation(channelID string, users ...string) (*Channel, error) {
	return api.InviteUsersToConversationContext(context.Background(), channelID, users...)
}
1146159
func NewRoom() *Room {
	r := Room{
		members: make(map[*Connection]bool),
		stop:    make(chan bool),
		join:    make(chan *Connection),
		leave:   make(chan *Connection),
		send:    make(chan *message, roomSendChannelSize),
	}
	// Run the message loop
	go r.run()
	// Return pointer
	return &r
}
606856
func (c *Conversation) Like() error {
	insta := c.inst
	to, err := prepareRecipients(c)
	if err != nil {
		return err
	}

	thread, err := json.Marshal([]string{c.ID})
	if err != nil {
		return err
	}

	data := insta.prepareDataQuery(
		map[string]interface{}{
			"recipient_users": to,
			"client_context":  generateUUID(),
			"thread_ids":      b2s(thread),
			"action":          "send_item",
		},
	)
	_, err = insta.sendRequest(
		&reqOptions{
			Connection: "keep-alive",
			Endpoint:   urlInboxSendLike,
			Query:      data,
			IsPost:     true,
		},
	)
	return err
}
715590
func (r *RoomService) List(opt *RoomsListOptions) (*Rooms, *http.Response, error) {
	req, err := r.client.NewRequest("GET", "room", opt, nil)
	if err != nil {
		return nil, nil, err
	}

	rooms := new(Rooms)
	resp, err := r.client.Do(req, rooms)
	if err != nil {
		return nil, resp, err
	}
	return rooms, resp, nil
}
1109725
func NewRoom(roomID string) *Room {
	// Init the State map and return a pointer to the Room
	return &Room{
		ID:    roomID,
		State: make(map[string]map[string]*Event),
	}
}
107446
func (c *InvitesClient) Create(ctx context.Context, createInvite *CreateInvite) (*Invite, error) {
	p := "/invites"

	req, err := c.backend.NewRequest(http.MethodPost, p, nil, createInvite)
	if err != nil {
		return nil, err
	}

	var resp Invite
	_, err = c.backend.Do(ctx, req, &resp, func(code int) error {
		return &Error{}
	})
	if err != nil {
		return nil, err
	}

	return &resp, nil
}
957221
func (rm *RoomManager) Join(name string, conn *Connection) {
	rm.join <- &roomReq{
		name: name,
		conn: conn,
	}
}
9152
func (c *NodeCommand) Invite(client auth.ClientI) error {
	// parse --roles flag
	roles, err := teleport.ParseRoles(c.roles)
	if err != nil {
		return trace.Wrap(err)
	}
	token, err := client.GenerateToken(auth.GenerateTokenRequest{Roles: roles, TTL: c.ttl, Token: c.token})
	if err != nil {
		return trace.Wrap(err)
	}

	// Calculate the CA pin for this cluster. The CA pin is used by the client
	// to verify the identity of the Auth Server.
	caPin, err := calculateCAPin(client)
	if err != nil {
		return trace.Wrap(err)
	}

	authServers, err := client.GetAuthServers()
	if err != nil {
		return trace.Wrap(err)
	}
	if len(authServers) == 0 {
		return trace.Errorf("This cluster does not have any auth servers running.")
	}

	// output format swtich:
	if c.format == "text" {
		if roles.Include(teleport.RoleTrustedCluster) || roles.Include(teleport.LegacyClusterTokenType) {
			fmt.Printf(trustedClusterMessage, token, int(c.ttl.Minutes()))
		} else {
			fmt.Printf(nodeMessage,
				token,
				int(c.ttl.Minutes()),
				strings.ToLower(roles.String()),
				token,
				caPin,
				authServers[0].GetAddr(),
				int(c.ttl.Minutes()),
				authServers[0].GetAddr(),
			)
		}
	} else {
		// Always return a list, otherwise we'll break users tooling. See #1846 for
		// more details.
		tokens := []string{token}
		out, err := json.Marshal(tokens)
		if err != nil {
			return trace.Wrap(err, "failed to marshal token")
		}
		fmt.Printf(string(out))
	}
	return nil
}
25141
func (r *RoomService) Update(id string, roomReq *UpdateRoomRequest) (*http.Response, error) {
	req, err := r.client.NewRequest("PUT", fmt.Sprintf("room/%s", id), nil, roomReq)
	if err != nil {
		return nil, err
	}

	return r.client.Do(req, nil)
}
438104
func (s *Server) Rooms() map[string]int {
	rooms := make(map[string]int)

	s.roomsMu.RLock()
	defer s.roomsMu.RUnlock()
	for room, clients := range s.rooms {
		rooms[room] = len(clients)
	}

	return rooms
}
500955
func (service *IYOPhonenumberValidationService) SendOrganizationInviteSms(request *http.Request, invite *invitations.JoinOrganizationInvitation) (err error) {
	link := fmt.Sprintf(invitations.InviteURL, request.Host, url.QueryEscape(invite.Code))
	// todo: perhaps this should be shorter but that might be confusing for the end user
	message := fmt.Sprintf("You have been invited to the %s organization on It's You Online. Click the following link to accept it. %s", invite.Organization, link)
	go service.SMSService.Send(invite.PhoneNumber, message)
	return
}
323607
func (a *adapter) Send(res *hal.Response, strings ...string) error {
	for _, str := range strings {
		a.client.Say(res.Message.Room, a.name, str)
	}
	return nil
}
169111
func (r *RoomService) Get(id string) (*Room, *http.Response, error) {
	req, err := r.client.NewRequest("GET", fmt.Sprintf("room/%s", id), nil, nil)
	if err != nil {
		return nil, nil, err
	}

	room := new(Room)
	resp, err := r.client.Do(req, room)
	if err != nil {
		return nil, resp, err
	}
	return room, resp, nil
}
1374165
func (c *Client) PromoteChatMember(chatID string, userID int, p *Promotions) error {
	req := url.Values{}
	req.Set("chat_id", chatID)
	req.Set("user_id", fmt.Sprint(userID))
	req.Set("can_change_info", fmt.Sprint(p.CanChangeInfo))
	req.Set("can_post_messages", fmt.Sprint(p.CanPostMessages))
	req.Set("can_edit_messages", fmt.Sprint(p.CanEditMessages))
	req.Set("can_delete_messages", fmt.Sprint(p.CanDeleteMessages))
	req.Set("can_invite_users", fmt.Sprint(p.CanInviteUsers))
	req.Set("can_restrict_members", fmt.Sprint(p.CanRestrictMembers))
	req.Set("can_pin_messages", fmt.Sprint(p.CanPinMessages))
	req.Set("can_promote_member", fmt.Sprint(p.CanPromoteMembers))
	var promoted bool
	return c.doRequest("promoteChatMember", req, &promoted)
}
1353278
def invite(user, reason='')
      response = self.class.post(@api.invite_config[:url]+"/#{user}",
        :query => { :auth_token => @token },
        :body => {
          :reason => reason
        }.to_json,
        :headers => @api.headers)

      ErrorHandler.response_code_to_exception_for :room, room_id, response
      true
    end