-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rtm): implement current team/user/channel api
- Loading branch information
Showing
5 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package bearychat | ||
|
||
import "fmt" | ||
|
||
type RTMChannelService struct { | ||
rtm *RTMClient | ||
} | ||
|
||
func newRTMChannelService(rtm *RTMClient) error { | ||
rtm.Channel = &RTMChannelService{rtm} | ||
return nil | ||
} | ||
|
||
func (s *RTMChannelService) Info(channelId string) (*Channel, error) { | ||
channel := new(Channel) | ||
resource := fmt.Sprintf("v1/channel.info?channel_id=%s", channelId) | ||
_, err := s.rtm.Get(resource, channel) | ||
return channel, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package bearychat | ||
|
||
type RTMCurrentTeamService struct { | ||
rtm *RTMClient | ||
} | ||
|
||
func newRTMCurrentTeamService(rtm *RTMClient) error { | ||
rtm.CurrentTeam = &RTMCurrentTeamService{rtm} | ||
|
||
return nil | ||
} | ||
|
||
// Retrieves current team's information. | ||
func (s *RTMCurrentTeamService) Info() (*Team, error) { | ||
team := new(Team) | ||
_, err := s.rtm.Get("v1/current_team.info", team) | ||
return team, err | ||
} | ||
|
||
// Retrieves current team's members. | ||
func (s *RTMCurrentTeamService) Members() ([]*User, error) { | ||
members := []*User{} | ||
_, err := s.rtm.Get("v1/current_team.members?all=true", &members) | ||
return members, err | ||
} | ||
|
||
// Retrieves current team's channels. | ||
func (s *RTMCurrentTeamService) Channels() ([]*Channel, error) { | ||
channels := []*Channel{} | ||
_, err := s.rtm.Get("v1/current_team.channels", &channels) | ||
return channels, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package bearychat | ||
|
||
import "fmt" | ||
|
||
type RTMUserService struct { | ||
rtm *RTMClient | ||
} | ||
|
||
func newRTMUserService(rtm *RTMClient) error { | ||
rtm.User = &RTMUserService{rtm} | ||
return nil | ||
} | ||
|
||
func (s *RTMUserService) Info(userId string) (*User, error) { | ||
user := new(User) | ||
resource := fmt.Sprintf("v1/user.info?user_id=%s", userId) | ||
_, err := s.rtm.Get(resource, user) | ||
return user, err | ||
} |