groupme

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 14 Imported by: 1

README

Version 1.0 Release Date: TBD

I would like to add common helper functions/features inspired by the package use in the community. So please, especially before Version 1.0 release, let me know what you would like to see added to the package, but bear in mind the main objective to be a simple wrapper for the API exposed by the GroupMe team.


GroupMe API Wrapper

GitHub tag (latest SemVer) PkgGoDev Go Test golangci-lint

Description

The design of this package is meant to be super simple. Wrap the exposed API endpoints documented by the GroupMe team. While you can achieve the core of this package with cURL, there are some small added features, coupled along with a modern language, that should simplify writing GroupMe bots and applications.

[FUTURE] In addition to the Go package, there is also a CLI application built using this package; all the features are available from the command line.

Why?

I enjoy programming, I use GroupMe with friends, and I wanted to write a fun add-on application for our group. I happened to start using Go around this time, so it was good practice.

Example

package main

import (
	"fmt"

	"github.com/densestvoid/groupme"
)

// This is not a real token. Please find yours by logging
// into the GroupMe development website: https://dev.groupme.com/
const authorizationToken = "0123456789ABCDEF"

// A short program that gets the first 5 groups the user
// is part of, and then the first 10 messages of the first
// group in that list
func main() {
	// Create a new client with your auth token
	client := groupme.NewClient(authorizationToken)

	// Get the groups your user is part of
	groups, err := client.IndexGroups(&groupme.GroupsQuery{
		Page:    0,
		PerPage: 5,
		Omit:    "memberships",
	})

	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(groups)

	// Get first 10 messages of the first group
	if len(groups) <= 0 {
		fmt.Println("No groups")
	}

	messages, err := client.IndexMessages(groups[0].ID, &groupme.IndexMessagesQuery{
		Limit: 10,
	})

	if err != nil {
		fmt.Println(err)
	}

	fmt.Println(messages)
}

Installation

Go Package

go get github.com/densestvoid/groupme

[FUTURE] CLI

Support

You can join the GroupMe support group (you will need to provide a reason for joining), or the Discord server.

Contribute

I find the hours I can spend developing personal projects decreasing every year, so I welcome any help I can get. Feel free to tackle any open issues, or if a feature request catches your eye, feel free to reach out to me and we can discuss adding it to the package. However, once version 1.0 is released, I don't foresee much work happening on this project unless the GroupMe API is updated.

Credits

All credits for the actual platform belong to the GroupMe team; I only used the exposed API they wrote.

License

GPL-3.0 License © DensestVoid

Documentation

Overview

Package groupme defines a client capable of executing API commands for the GroupMe chat service

Index

Constants

View Source
const (
	ChangeOwnerOk                changeOwnerStatusCode = "200"
	ChangeOwnerRequesterNewOwner changeOwnerStatusCode = "400"
	ChangeOwnerNotOwner          changeOwnerStatusCode = "403"
	ChangeOwnerBadGroupOrOwner   changeOwnerStatusCode = "404"
	ChangeOwnerBadRequest        changeOwnerStatusCode = "405"
)

Change owner Status Codes

View Source
const (
	PictureEncodingPNG  = "png"
	PictureEncodingJPEG = "jpeg"
)
View Source
const (
	SenderTypeUser   senderType = "user"
	SenderTypeBot    senderType = "bot"
	SenderTypeSystem senderType = "system"
)

SenderType constants

View Source
const (
	Mentions attachmentType = "mentions"
	Image    attachmentType = "image"
	Location attachmentType = "location"
	Emoji    attachmentType = "emoji"
)

AttachmentType constants

View Source
const (
	PeriodDay   = "day"
	PeriodWeek  = "week"
	PeriodMonth = "month"
)

Define acceptable period values

View Source
const GroupMeAPIBase = "https://api.groupme.com/v3"

GroupMeAPIBase - Endpoints are added on to this to get the full URI. Overridable for testing

View Source
const GroupMeImageBase = "https://image.groupme.com"

Variables

This section is empty.

Functions

func HTTPHandlerFunc added in v0.3.0

func HTTPHandlerFunc(callbacks ...HTTPMessageCallback) http.HandlerFunc

HTTPHandlerFunc creates an http.HandlerFunc that executes callback functions on each received message. Function should be registered on an http.Handler route for use in a callback URL server.

func HTTPStatusText added in v0.3.0

func HTTPStatusText(code int) string

StatusText returns a text for the HTTP status code (according to GroupMe). It returns the empty string if the code is unknown.

func ValidID added in v0.3.0

func ValidID(id string) bool

Valid checks if the ID string is alpha numeric

Types

type Attachment

type Attachment struct {
	Type        attachmentType `json:"type,omitempty"`
	Loci        [][]int        `json:"loci,omitempty"`
	UserIDs     []string       `json:"user_ids,omitempty"`
	URL         string         `json:"url,omitempty"`
	Name        string         `json:"name,omitempty"`
	Latitude    string         `json:"lat,omitempty"`
	Longitude   string         `json:"lng,omitempty"`
	Placeholder string         `json:"placeholder,omitempty"`
	Charmap     [][]int        `json:"charmap,omitempty"`
}

Attachment is a GroupMe message attachment, returned in JSON API responses

func (*Attachment) String

func (a *Attachment) String() string

type Block

type Block struct {
	UserID        string    `json:"user_id,omitempty"`
	BlockedUserID string    `json:"blocked_user_id,omitempty"`
	CreatedAT     Timestamp `json:"created_at,omitempty"`
}

Block is a GroupMe block between two users, direct messages are not allowed

func (Block) String

func (b Block) String() string

type Bot

type Bot struct {
	BotID          string `json:"bot_id,omitempty"`
	GroupID        string `json:"group_id,omitempty"`
	Name           string `json:"name,omitempty"`
	AvatarURL      string `json:"avatar_url,omitempty"`
	CallbackURL    string `json:"callback_url,omitempty"`
	DMNotification bool   `json:"dm_notification,omitempty"`
}

Bot is a GroupMe bot, it is connected to a specific group which it can send messages to

func (*Bot) String

func (b *Bot) String() string

type BotClient added in v0.3.0

type BotClient struct {
	// contains filtered or unexported fields
}

Client posts bot messages

func NewBotClient added in v0.3.0

func NewBotClient(botID string, options ...ClientOption) *BotClient

NewBotClient creates a new GroupMe API Client to post bot messages

func (*BotClient) Close added in v0.3.0

func (c *BotClient) Close() error

Close safely shuts down the Client

func (*BotClient) PostBotMessage added in v0.3.0

func (c *BotClient) PostBotMessage(ctx context.Context, text string, pictureURL *string) error

PostBotMessage - Post a message from a bot

type ChangeOwnerRequest

type ChangeOwnerRequest struct {
	// Required
	GroupID string `json:"group_id"`
	// Required. UserId of the new owner of the group
	// who must be an active member of the group
	OwnerID string `json:"owner_id"`
}

ChangeOwnerRequest defines the new owner of a group

func (ChangeOwnerRequest) String

func (r ChangeOwnerRequest) String() string

type ChangeOwnerResult

type ChangeOwnerResult struct {
	GroupID string `json:"group_id"`
	// UserId of the new owner of the group who is
	// an active member of the group
	OwnerID string                `json:"owner_id"`
	Status  changeOwnerStatusCode `json:"status"`
}

ChangeOwnerResult holds the status of the group owner change

func (ChangeOwnerResult) String

func (r ChangeOwnerResult) String() string

type Chat

type Chat struct {
	CreatedAt     Timestamp `json:"created_at,omitempty"`
	UpdatedAt     Timestamp `json:"updated_at,omitempty"`
	LastMessage   *Message  `json:"last_message,omitempty"`
	MessagesCount int       `json:"messages_count,omitempty"`
	OtherUser     User      `json:"other_user,omitempty"`
}

Chat is a GroupMe direct message conversation between two users, returned in JSON API responses

func (*Chat) String

func (c *Chat) String() string

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client communicates with the GroupMe API to perform actions on the basic types, i.e. Listing, Creating, Destroying

func NewClient

func NewClient(authToken string, options ...ClientOption) *Client

NewClient creates a new GroupMe API Client

func (*Client) AddMembers

func (c *Client) AddMembers(ctx context.Context, groupID string, members ...*Member) (string, error)

AddMembers -

Add members to a group.

Multiple members can be added in a single request, and results are fetchedwith a separate call (since memberships are processed asynchronously). The response includes a results_id that's used in the results request.

In order to correlate request params with resulting memberships, GUIDs can be added to the members parameters. These GUIDs will be reflected in the membership JSON objects.

Parameters:

groupID - required, string
See Member.
	Nickname - required
	One of the following identifiers must be used:
		UserID - string
		PhoneNumber - PhoneNumber(string)
		Email - string

func (*Client) AddMembersResults

func (c *Client) AddMembersResults(ctx context.Context, groupID string, resultID string) ([]*Member, error)

AddMembersResults - Get the membership results from an add call.

Successfully created memberships will be returned, including any GUIDs that were sent up in the add request. If GUIDs were absent, they are filled in automatically. Failed memberships and invites are omitted.

Keep in mind that results are temporary -- they will only be available for 1 hour after the add request.

Parameters:

groupID - required, string
resultID - required, string

func (*Client) BlockBetween

func (c *Client) BlockBetween(ctx context.Context, userID, otherUserID string) (bool, error)

BlockBetween - Asks if a block exists between you and another user id

func (*Client) ChangeGroupOwner

func (c *Client) ChangeGroupOwner(ctx context.Context, reqs ChangeOwnerRequest) (ChangeOwnerResult, error)

ChangeGroupOwner - Change owner of requested groups.

This action is only available to the group creator.

Response is a result object which contain status field, the result of change owner action for the request

Parameters: See ChangeOwnerRequest

func (*Client) Close

func (c *Client) Close() error

Close safely shuts down the Client

func (*Client) CreateBlock

func (c *Client) CreateBlock(ctx context.Context, userID, otherUserID string) (*Block, error)

CreateBlock - Creates a block between you and the contact

func (*Client) CreateBot

func (c *Client) CreateBot(ctx context.Context, bot *Bot) (*Bot, error)

CreateBot - Create a bot. See the Bots Tutorial (https://dev.groupme.com/tutorials/bots) for a full walkthrough.

func (*Client) CreateDirectMessage

func (c *Client) CreateDirectMessage(ctx context.Context, m *Message) (*Message, error)

CreateDirectMessage - Send a DM to another user

If you want to attach an image, you must first process it through our image service.

Attachments of type emoji rely on data from emoji PowerUps.

Clients use a placeholder character in the message text and specify a replacement charmap to substitute emoji characters

The character map is an array of arrays containing rune data ([[{pack_id,offset}],...]).

func (*Client) CreateGroup

func (c *Client) CreateGroup(ctx context.Context, gs GroupSettings) (*Group, error)

CreateGroup -

Create a new group

Parameters: See GroupSettings

func (*Client) CreateLike

func (c *Client) CreateLike(ctx context.Context, conversationID, messageID string) error

CreateLike - Like a message.

func (*Client) CreateMessage

func (c *Client) CreateMessage(ctx context.Context, groupID string, m *Message) (*Message, error)

CreateMessage - Send a message to a group

If you want to attach an image, you must first process it through our image service.

Attachments of type emoji rely on data from emoji PowerUps.

Clients use a placeholder character in the message text and specify a replacement charmap to substitute emoji characters

The character map is an array of arrays containing rune data ([[{pack_id,offset}],...]).

The placeholder should be a high-point/invisible UTF-8 character.

func (*Client) CreateSMSMode

func (c *Client) CreateSMSMode(ctx context.Context, duration int, registrationID *string) error

CreateSMSMode - Enables SMS mode for N hours, where N is at most 48. After N hours have elapsed, user will receive push notfications.

Parameters:

duration - required, integer
registration_id - string; The push notification ID/token
	that should be suppressed during SMS mode. If this is
	omitted, both SMS and push notifications will be
	delivered to the device.

func (*Client) DeleteSMSMode

func (c *Client) DeleteSMSMode(ctx context.Context) error

DeleteSMSMode -

Disables SMS mode

func (*Client) DestroyBot

func (c *Client) DestroyBot(ctx context.Context, botID string) error

DestroyBot - Remove a bot that you have created

func (*Client) DestroyGroup

func (c *Client) DestroyGroup(ctx context.Context, groupID string) error

DestroyGroup -

Disband a group

This action is only available to the group creator

Parameters:

groupID - required, ßstring

func (*Client) DestroyLike

func (c *Client) DestroyLike(ctx context.Context, conversationID, messageID string) error

DestroyLike - Unlike a message.

func (*Client) FormerGroups

func (c *Client) FormerGroups(ctx context.Context) ([]*Group, error)

FormerGroups -

List they groups you have left but can rejoin.

func (*Client) IndexBlock

func (c *Client) IndexBlock(ctx context.Context, userID string) ([]*Block, error)

IndexBlock - A list of contacts you have blocked. These people cannot DM you

func (*Client) IndexBots

func (c *Client) IndexBots(ctx context.Context) ([]*Bot, error)

IndexBots - list bots that you have created

func (*Client) IndexChats

func (c *Client) IndexChats(ctx context.Context, req *IndexChatsQuery) ([]*Chat, error)

IndexChats - Returns a paginated list of direct message chats, or conversations, sorted by updated_at descending.

func (*Client) IndexDirectMessages

func (c *Client) IndexDirectMessages(ctx context.Context, otherUserID string, req *IndexDirectMessagesQuery) (IndexDirectMessagesResponse, error)

IndexDirectMessages -

Fetch direct messages between two users.

DMs are returned in groups of 20, ordered by created_at descending.

If no messages are found (e.g. when filtering with since_id) we return code 304.

Note that for historical reasons, likes are returned as an array of user ids in the favorited_by key.

Parameters:

otherUserID - required, string; the other participant in the conversation.
See IndexDirectMessagesQuery

func (*Client) IndexGroups

func (c *Client) IndexGroups(ctx context.Context, req *GroupsQuery) ([]*Group, error)

IndexGroups -

List the authenticated user's active groups.

The response is paginated, with a default of 10 groups per page.

Please consider using of omit=memberships parameter. Not including member lists might significantly improve user experience of your app for users who are participating in huge groups.

Parameters: See GroupsQuery

func (*Client) IndexLeaderboard

func (c *Client) IndexLeaderboard(ctx context.Context, groupID string, p period) ([]*Message, error)

IndexLeaderboard - A list of the liked messages in the group for a given period of time. Messages are ranked in order of number of likes.

func (*Client) IndexMessages

func (c *Client) IndexMessages(ctx context.Context, groupID string, req *IndexMessagesQuery) (IndexMessagesResponse, error)

IndexMessages - Retrieves messages for a group. By default, messages are returned in groups of 20, ordered by created_at descending. This can be raised or lowered by passing a limit parameter, up to a maximum of 100 messages. Messages can be scanned by providing a message ID as either the before_id, since_id, or after_id parameter. If before_id is provided, then messages immediately preceding the given message will be returned, in descending order. This can be used to continually page back through a group's messages. The after_id parameter will return messages that immediately follow a given message, this time in ascending order (which makes it easy to pick off the last result for continued pagination). Finally, the since_id parameter also returns messages created after the given message, but it retrieves the most recent messages. For example, if more than twenty messages are created after the since_id message, using this parameter will omit the messages that immediately follow the given message. This is a bit counterintuitive, so take care. If no messages are found (e.g. when filtering with before_id) we return code 304. Note that for historical reasons, likes are returned as an array of user ids in the favorited_by key.

func (*Client) JoinGroup

func (c *Client) JoinGroup(ctx context.Context, groupID string, shareToken string) (*Group, error)

JoinGroup -

Join a shared group

Parameters:

groupID - required, string
shareToken - required, string

func (*Client) MyHitsLeaderboard

func (c *Client) MyHitsLeaderboard(ctx context.Context, groupID string) ([]*Message, error)

MyHitsLeaderboard -

A list of messages you have liked. Messages are returned in reverse chrono-order. Note that the payload includes a liked_at timestamp in ISO-8601 format.

Parameters:

groupID - required, string

func (*Client) MyLikesLeaderboard

func (c *Client) MyLikesLeaderboard(ctx context.Context, groupID string) ([]*Message, error)

MyLikesLeaderboard -

A list of messages you have liked. Messages are returned in reverse chrono-order. Note that the payload includes a liked_at timestamp in ISO-8601 format.

Parameters:

groupID - required, string

func (*Client) MyUser

func (c *Client) MyUser(ctx context.Context) (*User, error)

MyUser -

Loads a specific group.

Parameters:

groupID - required, string

func (*Client) RejoinGroup

func (c *Client) RejoinGroup(ctx context.Context, groupID string) (*Group, error)

RejoinGroup -

Rejoin a group. Only works if you previously removed yourself.

Parameters:

groupID - required, string

func (*Client) RemoveMember

func (c *Client) RemoveMember(ctx context.Context, groupID, membershipID string) error

RemoveMember -

Remove a member (or yourself) from a group.

Note: The creator of the group cannot be removed or exit.

Parameters:

groupID - required, string
membershipID - required, string. Not the same as userID

func (*Client) ShowGroup

func (c *Client) ShowGroup(ctx context.Context, groupID string) (*Group, error)

ShowGroup -

Loads a specific group.

Parameters:

groupID - required, string

func (*Client) Unblock

func (c *Client) Unblock(ctx context.Context, userID, otherUserID string) error

Unblock - Removes block between you and other user

func (*Client) UpdateGroup

func (c *Client) UpdateGroup(ctx context.Context, groupID string, gs GroupSettings) (*Group, error)

UpdateGroup -

Update a group after creation

Parameters:

groupID - required, string
See GroupSettings

func (*Client) UpdateMember

func (c *Client) UpdateMember(ctx context.Context, groupID string, nickname string) (*Member, error)

UpdateMember -

Update your nickname in a group. The nickname must be between 1 and 50 characters.

func (*Client) UpdateMyUser

func (c *Client) UpdateMyUser(ctx context.Context, us UserSettings) (*User, error)

UpdateMyUser -

Update attributes about your own account

Parameters: See UserSettings

func (*Client) UploadPicture added in v0.3.0

func (c *Client) UploadPicture(ctx context.Context, img image.Image, encoding PictureEncoding) (PictureURL, error)

UploadPicture posts an image to the GroupMe image service. Accepts either PNG or JPEG. Returns URLs to the uploaded image to be used in messages or avatars.

type ClientOption added in v0.3.0

type ClientOption func(client *client)

func WithHTTPClient added in v0.3.0

func WithHTTPClient(httpClient *http.Client) ClientOption

type Group

type Group struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
	// Type of group (private|public)
	Type          string        `json:"type,omitempty"`
	Description   string        `json:"description,omitempty"`
	ImageURL      string        `json:"image_url,omitempty"`
	CreatorUserID string        `json:"creator_user_id,omitempty"`
	CreatedAt     Timestamp     `json:"created_at,omitempty"`
	UpdatedAt     Timestamp     `json:"updated_at,omitempty"`
	Members       []*Member     `json:"members,omitempty"`
	ShareURL      string        `json:"share_url,omitempty"`
	Messages      GroupMessages `json:"messages,omitempty"`
}

Group is a GroupMe group, returned in JSON API responses

func (*Group) GetMemberByNickname

func (g *Group) GetMemberByNickname(nickname string) *Member

GetMemberByNickname gets the group member by their Nickname, nil if no member matches

func (*Group) GetMemberByUserID

func (g *Group) GetMemberByUserID(userID string) *Member

GetMemberByUserID gets the group member by their UserID, nil if no member matches

func (*Group) String

func (g *Group) String() string

type GroupMessages

type GroupMessages struct {
	Count                uint           `json:"count,omitempty"`
	LastMessageID        string         `json:"last_message_id,omitempty"`
	LastMessageCreatedAt Timestamp      `json:"last_message_created_at,omitempty"`
	Preview              MessagePreview `json:"preview,omitempty"`
}

GroupMessages is a Group field, only returned in Group JSON API responses

type GroupSettings

type GroupSettings struct {
	// Required. Primary name of the group. Maximum 140 characters
	Name string `json:"name"`
	// A subheading for the group. Maximum 255 characters
	Description string `json:"description"`
	// GroupMe Image Service URL
	ImageURL string `json:"image_url"`
	// Defaults false. If true, disables notifications for all members.
	// Documented for use only for UpdateGroup
	OfficeMode bool `json:"office_mode"`
	// Defaults false. If true, generates a share URL.
	// Anyone with the URL can join the group
	Share bool `json:"share"`
}

GroupSettings is the settings for a group, used by CreateGroup and UpdateGroup

func (GroupSettings) String

func (gss GroupSettings) String() string

type GroupsQuery

type GroupsQuery struct {
	// Fetch a particular page of results. Defaults to 1.
	Page int `json:"page"`
	// Define page size. Defaults to 10.
	PerPage int `json:"per_page"`
	// Comma separated list of data to omit from output.
	// Currently supported value is only "memberships".
	// If used then response will contain empty (null) members field.
	Omit string `json:"omit"`
}

GroupsQuery defines optional URL parameters for IndexGroups

func (GroupsQuery) String

func (q GroupsQuery) String() string

type HTTPMessageCallback added in v0.3.0

type HTTPMessageCallback func(Message)

HTTPMessageCallback is a function that acts on new messages sent from the GroupMe server to a callback URL.

type IndexChatsQuery

type IndexChatsQuery struct {
	// Page Number
	Page int `json:"page"`
	// Number of chats per page
	PerPage int `json:"per_page"`
}

IndexChatsQuery defines the optional URL parameters for IndexChats

type IndexDirectMessagesQuery

type IndexDirectMessagesQuery struct {
	// Returns 20 messages created before the given message ID
	BeforeID string `json:"before_id"`
	// Returns 20 messages created after the given message ID
	SinceID string `json:"since_id"`
}

IndexDirectMessagesQuery defines the optional URL parameters for IndexDirectMessages

func (IndexDirectMessagesQuery) String

func (q IndexDirectMessagesQuery) String() string

type IndexDirectMessagesResponse

type IndexDirectMessagesResponse struct {
	Count    int        `json:"count"`
	Messages []*Message `json:"direct_messages"`
}

IndexDirectMessagesResponse contains the count and set of messages returned by the IndexDirectMessages API request

func (IndexDirectMessagesResponse) String

type IndexMessagesQuery

type IndexMessagesQuery struct {
	// Returns messages created before the given message ID
	BeforeID string
	// Returns most recent messages created after the given message ID
	SinceID string
	// Returns messages created immediately after the given message ID
	AfterID string
	// Number of messages returned. Default is 20. Max is 100.
	Limit int
}

IndexMessagesQuery defines the optional URL parameters for IndexMessages

func (IndexMessagesQuery) String

func (q IndexMessagesQuery) String() string

type IndexMessagesResponse

type IndexMessagesResponse struct {
	Count    int        `json:"count"`
	Messages []*Message `json:"messages"`
}

IndexMessagesResponse contains the count and set of messages returned by the IndexMessages API request

func (IndexMessagesResponse) String

func (r IndexMessagesResponse) String() string

type Member

type Member struct {
	ID           string `json:"id,omitempty"`
	UserID       string `json:"user_id,omitempty"`
	Nickname     string `json:"nickname,omitempty"`
	Muted        bool   `json:"muted,omitempty"`
	ImageURL     string `json:"image_url,omitempty"`
	AutoKicked   bool   `json:"autokicked,omitempty"`
	AppInstalled bool   `json:"app_installed,omitempty"`
	GUID         string `json:"guid,omitempty"`
	PhoneNumber  string `json:"phone_number,omitempty"` // Only used when searching for the member to add to a group.
	Email        string `json:"email,omitempty"`        // Only used when searching for the member to add to a group.
}

Member is a GroupMe group member, returned in JSON API responses

func (*Member) String

func (m *Member) String() string

type Message

type Message struct {
	ID             string     `json:"id,omitempty"`
	SourceGUID     string     `json:"source_guid,omitempty"`
	CreatedAt      Timestamp  `json:"created_at,omitempty"`
	GroupID        string     `json:"group_id,omitempty"`
	UserID         string     `json:"user_id,omitempty"`
	BotID          string     `json:"bot_id,omitempty"`
	SenderID       string     `json:"sender_id,omitempty"`
	SenderType     senderType `json:"sender_type,omitempty"`
	System         bool       `json:"system,omitempty"`
	Name           string     `json:"name,omitempty"`
	RecipientID    string     `json:"recipient_id,omitempty"`
	ConversationID string     `json:"conversation_id,omitempty"`
	AvatarURL      string     `json:"avatar_url,omitempty"`
	// Maximum length of 1000 characters
	Text string `json:"text,omitempty"`
	// Must be an image service URL (i.groupme.com)
	ImageURL    string        `json:"image_url,omitempty"`
	FavoritedBy []string      `json:"favorited_by,omitempty"`
	Attachments []*Attachment `json:"attachments,omitempty"`
}

Message is a GroupMe group message, returned in JSON API responses

func (*Message) String

func (m *Message) String() string

type MessagePreview

type MessagePreview struct {
	Nickname    string        `json:"nickname,omitempty"`
	Text        string        `json:"text,omitempty"`
	ImageURL    string        `json:"image_url,omitempty"`
	Attachments []*Attachment `json:"attachments,omitempty"`
}

MessagePreview is a GroupMessages field, only returned in Group JSON API responses. Abbreviated form of Message type

type Meta

type Meta struct {
	Code   int      `json:"code,omitempty"`
	Errors []string `json:"errors,omitempty"`
}

Meta is the error type returned in the GroupMe response. Meant for clients that can't read HTTP status codes

func (Meta) Error

func (m Meta) Error() string

Error returns the code and the error list as a string. Satisfies the error interface

type PhoneNumber

type PhoneNumber string

PhoneNumber is the country code plus the number of the user

func (PhoneNumber) String

func (pn PhoneNumber) String() string

func (PhoneNumber) Valid

func (pn PhoneNumber) Valid() bool

Valid checks if the Phone Number string is numeric

type PictureEncoding added in v0.3.0

type PictureEncoding string

PictureEncoding specifies the encoding and Content-Type for the image upload.

type PictureURL added in v0.3.0

type PictureURL struct {
	Base    string
	Preview string
	Large   string
	Avatar  string
}

PictureURL contains URLS to an uploaded picture as well as the various thumbnails provided by GroupMe.

type Timestamp

type Timestamp uint64

Timestamp is the number of seconds since the UNIX epoch

func FromTime

func FromTime(t time.Time) Timestamp

FromTime returns the time.Time as a Timestamp

func (Timestamp) String

func (t Timestamp) String() string

String returns the Timestamp in the default time.Time string format

func (Timestamp) ToTime

func (t Timestamp) ToTime() time.Time

ToTime returns the Timestamp as a UTC Time

type User

type User struct {
	ID          string      `json:"id,omitempty"`
	PhoneNumber PhoneNumber `json:"phone_number,omitempty"`
	ImageURL    string      `json:"image_url,omitempty"`
	Name        string      `json:"name,omitempty"`
	CreatedAt   Timestamp   `json:"created_at,omitempty"`
	UpdatedAt   Timestamp   `json:"updated_at,omitempty"`
	AvatarURL   string      `json:"avatar_url,omitempty"`
	Email       string      `json:"email,omitempty"`
	SMS         bool        `json:"sms,omitempty"`
}

User is a GroupMe user, returned in JSON API responses

func (*User) String

func (u *User) String() string

type UserSettings

type UserSettings struct {
	// URL to valid JPG/PNG/GIF image. URL will be converted into
	// an image service link (https://i.groupme.com/....)
	AvatarURL string `json:"avatar_url"`
	// Name must be of the form FirstName LastName
	Name string `json:"name"`
	// Email address. Must be in name@domain.com form
	Email   string `json:"email"`
	ZipCode string `json:"zip_code"`
}

UserSettings are the settings for a GroupMe user

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL