-
Notifications
You must be signed in to change notification settings - Fork 1
/
socials.go
37 lines (29 loc) · 1.02 KB
/
socials.go
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
package guildedgo
import "errors"
type SocialResponse struct {
SocialLink `json:"socialLink"`
}
type SocialLink struct {
Handle string `json:"handle,omitempty"`
ServiceID string `json:"serviceId,omitempty"`
Type string `json:"type"`
}
type SocialsService interface {
GetMemberSocialLinks(serverID string, userID string, socialType string) (*SocialLink, error)
}
type socialsEndpoint struct{}
func (e *socialsEndpoint) Default(serverID string, userID string, socialType string) string {
return guildedApi + "/servers/" + serverID + "/members/" + userID + "/social-links/" + socialType
}
type socialsService struct {
client *Client
endpoints *socialsEndpoint
}
func (s *socialsService) GetMemberSocialLinks(serverID string, userID string, socialType string) (*SocialLink, error) {
var social SocialResponse
err := s.client.GetRequestV2(s.endpoints.Default(serverID, userID, socialType), &social)
if err != nil {
return nil, errors.New("failed to get social links: " + err.Error())
}
return &social.SocialLink, nil
}