From 9aae26445f536c1a2e3fafd5f5f057c3fa2112bf Mon Sep 17 00:00:00 2001 From: Sebastian Winkler Date: Wed, 23 May 2018 16:27:14 +0200 Subject: [PATCH] adds InviteWithCounts --- restapi.go | 13 +++++++++++++ structs.go | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/restapi.go b/restapi.go index e5ef9f8..2855e79 100644 --- a/restapi.go +++ b/restapi.go @@ -1717,6 +1717,19 @@ func (s *Session) Invite(inviteID string) (st *Invite, err error) { return } +// InviteWithCounts returns an Invite structure of the given invite including approximate member counts +// inviteID : The invite code +func (s *Session) InviteWithCounts(inviteID string) (st *Invite, err error) { + + body, err := s.RequestWithBucketID("GET", EndpointInvite(inviteID)+"?with_counts=true", nil, EndpointInvite("")) + if err != nil { + return + } + + err = unmarshal(body, &st) + return +} + // InviteDelete deletes an existing invite // inviteID : the code of an invite func (s *Session) InviteDelete(inviteID string) (st *Invite, err error) { diff --git a/structs.go b/structs.go index bba5a01..1906e2d 100644 --- a/structs.go +++ b/structs.go @@ -177,6 +177,10 @@ type Invite struct { Revoked bool `json:"revoked"` Temporary bool `json:"temporary"` Unique bool `json:"unique"` + + // will only be filled when using InviteWithCounts + ApproximatePresenceCount int `json:"approximate_presence_count"` + ApproximateMemberCount int `json:"approximate_member_count"` } // ChannelType is the type of a Channel