File size: 904 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
package mockslack
import (
"context"
"net/http"
)
// TeamInfoOpts contains parameters for the TeamInfo API call.
type TeamInfoOpts struct {
Team string
}
type Team struct {
ID string `json:"id"`
Name string `json:"name"`
}
func (st *API) TeamInfo(ctx context.Context, id string) (*Team, error) {
st.mx.Lock()
defer st.mx.Unlock()
if id != "" && id != st.teamID {
return nil, &response{Err: "team_not_found"}
}
return &Team{
ID: st.teamID,
Name: "Mock Slack Team",
}, nil
}
// ServeTeamInfo serves a request to the `team.info` API call.
//
// https://api.slack.com/methods/team.info
func (s *Server) ServeTeamInfo(w http.ResponseWriter, req *http.Request) {
t, err := s.API().TeamInfo(req.Context(), req.FormValue("team"))
if respondErr(w, err) {
return
}
var resp struct {
response
Team *Team `json:"team"`
}
resp.OK = true
resp.Team = t
respondWith(w, resp)
}
|