Added UserConnections function and structs (#514)

* Added UserConnections function and structs

* Rename Connection to UserConnection

* Embed Integrations inside GuildIntegration and remove GuildIntegrationAccount

* Replaced GuildIntegration with Integration
This commit is contained in:
Necroforger 2018-03-07 18:45:09 -05:00 committed by Chris Rhodes
parent ffa9956c9b
commit 1ff9565306
2 changed files with 47 additions and 22 deletions

View file

@ -361,6 +361,21 @@ func (s *Session) UserUpdateStatus(status Status) (st *Settings, err error) {
return
}
// UserConnections returns the user's connections
func (s *Session) UserConnections() (conn []*UserConnection, err error) {
response, err := s.RequestWithBucketID("GET", EndpointUserConnections("@me"), nil, EndpointUserConnections("@me"))
if err != nil {
return nil, err
}
err = unmarshal(response, &conn)
if err != nil {
return
}
return
}
// UserChannels returns an array of Channel structures for all private
// channels.
func (s *Session) UserChannels() (st []*Channel, err error) {
@ -1075,7 +1090,7 @@ func (s *Session) GuildPrune(guildID string, days uint32) (count uint32, err err
// GuildIntegrations returns an array of Integrations for a guild.
// guildID : The ID of a Guild.
func (s *Session) GuildIntegrations(guildID string) (st []*GuildIntegration, err error) {
func (s *Session) GuildIntegrations(guildID string) (st []*Integration, err error) {
body, err := s.RequestWithBucketID("GET", EndpointGuildIntegrations(guildID), nil, EndpointGuildIntegrations(guildID))
if err != nil {

View file

@ -112,6 +112,37 @@ type Session struct {
wsMutex sync.Mutex
}
// UserConnection is a Connection returned from the UserConnections endpoint
type UserConnection struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Revoked bool `json:"revoked"`
Integrations []*Integration `json:"integrations"`
}
// Integration stores integration information
type Integration struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Enabled bool `json:"enabled"`
Syncing bool `json:"syncing"`
RoleID string `json:"role_id"`
ExpireBehavior int `json:"expire_behavior"`
ExpireGracePeriod int `json:"expire_grace_period"`
User *User `json:"user"`
Account IntegrationAccount `json:"account"`
SyncedAt Timestamp `json:"synced_at"`
}
// IntegrationAccount is integration account information
// sent by the UserConnections endpoint
type IntegrationAccount struct {
ID string `json:"id"`
Name string `json:"name"`
}
// A VoiceRegion stores data for a specific voice region server.
type VoiceRegion struct {
ID string `json:"id"`
@ -475,27 +506,6 @@ type GuildBan struct {
User *User `json:"user"`
}
// A GuildIntegration stores data for a guild integration.
type GuildIntegration struct {
ID string `json:"id"`
Name string `json:"name"`
Type string `json:"type"`
Enabled bool `json:"enabled"`
Syncing bool `json:"syncing"`
RoleID string `json:"role_id"`
ExpireBehavior int `json:"expire_behavior"`
ExpireGracePeriod int `json:"expire_grace_period"`
User *User `json:"user"`
Account *GuildIntegrationAccount `json:"account"`
SyncedAt int `json:"synced_at"`
}
// A GuildIntegrationAccount stores data for a guild integration account.
type GuildIntegrationAccount struct {
ID string `json:"id"`
Name string `json:"name"`
}
// A GuildEmbed stores data for a guild embed.
type GuildEmbed struct {
Enabled bool `json:"enabled"`