// GetChats ask server for all existent chats
GetChats ask server for all existent chats
// GetChats ask server for all existent chats
func (b *Client) GetChats() ([]string, error) {
	getChatsURL := b.URL + constants.RouteApi + constants.RouteLoggedOnly + constants.RouteGetChats
	w, err := b.client.Get(getChatsURL)
	if err != nil {
		return nil, err
	}
	defer w.Body.Close()
	chatReports := []db.ChatReport{}
	if err := json.NewDecoder(w.Body).Decode(&chatReports); err != nil {
		return nil, err
	}
	res := make([]string, 0, len(chatReports))
	for _, cr := range chatReports {
		res = append(res, cr.ChatName)
	}
	log.Tracef("got %d chats", len(res))
	return res, nil
}
func ( b * Client ) GetChats ( ) ( [ ] string , error ) { getChatsURL := b . URL + constants . RouteApi + constants . RouteLoggedOnly + constants . RouteGetChats w , err := b . client . Get ( getChatsURL ) if err != nil { return nil , err } defer w . Body . Close ( ) chatReports := [ ] db . ChatReport { } if err := json . NewDecoder ( w . Body ) . Decode ( & chatReports ) ; err != nil { return nil , err } res := make ( [ ] string , 0 , len ( chatReports ) ) for _ , cr := range chatReports { res = append ( res , cr . ChatName ) } log . Tracef ( " " , len ( res ) ) return res , nil }
GetChats ask server for all existent chats
GetChats ask server for all existent chats