meetup

package module
v0.0.0-...-e7380fd Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2017 License: Apache-2.0 Imports: 8 Imported by: 0

README

meetup-client

GoDoc

Client library for the Meetup REST API

This package aims to provide robust and intuitive client functionality to interact with Meetup via their REST API. The overall goal is to bring an easily usable and therefore usefulness to the consuming developer so that your Go application may easily integrate with Meetup. If you have any suggestions on how this package could improve, please see Contributions.

Quick-start

Docs

$ go get github.com/Guitarbum722/meetup-client

Initialize a new Client with your API Key.

Make sure you have a Meetup API Key HERE

c := meetup.NewClient(&meetup.ClientOpts{
	APIKey: "111API222KEY333SAMPLE444",
})

Get a single Meetup member by ID

member, err := c.Member(123234345)

fmt.Printf("%s is interested in the following topics:\n", member.Name)
for _, v := range member.Topics {
    fmt.Println(v)
}

Get all members of a particular Meetup group by Group ID

members, err := c.Members(666666)

fmt.Println("Group members: ")
for _, v := range members.Members {
    fmt.Println(v)
}

Docs

Get groups

group, err := c.GroupByID(727272)

groups, err := c.GroupByURLName([]string{"Meetup-API-Testing"})

groups, err := c.GroupByOrganizer([]int{909090, 808080})
Events

The event functionality is perhaps the most robust part of the library, since that is the whole point of Meetup. Many of the Client methods require a function and a map to prepare the request. Here are a couple of examples:

Create your own eventOptions function:

func eventOptions(et map[string][]string, vals url.Values) {
	for k, v := range et {
		if len(v) < 1 {
			break
		}
		switch k {
		case meetup.CommentID:
			vals.Add(meetup.CommentID, strings.Join(v, ","))
		case meetup.MemberID:
			vals.Add(meetup.MemberID, strings.Join(v, ","))
		case meetup.GroupID:
			vals.Add(meetup.GroupID, strings.Join(v, ","))
		case meetup.EventID:
			vals.Add(meetup.EventID, strings.Join(v, ","))
		case meetup.Rating:
			vals.Add(meetup.Rating, strings.Join(v, ","))
		case meetup.GroupURLName:
			vals.Add(meetup.GroupURLName, strings.Join(v, ","))
		case meetup.CommentText:
			vals.Add(meetup.CommentText, strings.Join(v, ","))
		case meetup.EventName:
			vals.Add(meetup.EventName, strings.Join(v, ","))
		case meetup.Description:
			vals.Add(meetup.Description, strings.Join(v, ","))
		case meetup.EventTime:
			vals.Add(meetup.EventTime, strings.Join(v, ","))
		default:
			//
		}
	}

}

Query Comments on the desired events:

func main() {
	comments, err := c.EventComments(eventOptions, map[meetup.EventOptsType][]string{
		meetup.EventID:  {"9999", "2234523"},
		meetup.MemberID: {"7823"},
	})
}

Create an event (the authenticated user must have the appropriate permissions)

event, err := c.CreateEvent(EventOptions, map[string][]string{
	meetup.GroupID:      {"2048502"},                  // required
	meetup.GroupURLName: {"Meetup-API-Testing"},       // required
	meetup.EventName:    {"Test Meetup integration"},  // required
	meetup.Description:  {"This is an event test."},   // optional
})

Update an existing event

d := time.Date(2017, time.November, 10, 18, 0, 0, 0, time.UTC)
eventDate := strconv.FormatInt((d.UnixNano() / 1000000), 10)
event, err := c.UpdateEvent("9999", EventOptions, map[string][]string{
	meetup.EventTime:      {eventDate},                // milleseconds since epoch
})
Contributions

Contributions of any kind are welcome and likely considered. If you feel that a change or enhancement is necessary, please follow the Fork/Pull Request approach. Otherwise, opening an issue will suffice.

Documentation

Index

Constants

View Source
const (
	CommentID     = "comment_id"
	CommentText   = "comment"
	InReplyTo     = "in_reply_to"
	MemberID      = "member_id"
	GroupID       = "group_id"
	EventID       = "event_id"
	EventName     = "name"
	Rating        = "rating"
	GroupURLName  = "group_urlname"
	Description   = "description"
	PublishStatus = "publish_status"
	EventTime     = "time"
)

Commonly used query param or form field names. These can be used as the options passed to your eopts func and the keys in the map the configures the options.

View Source
const (
	EventCancelled = "cancelled"
	EventDraft     = "draft"
	EventPast      = "past"
	EventProposed  = "proposed"
	EventSuggested = "suggested"
	EventUpcoming  = "upcoming"
)

Status types to be used in Event queries

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents a meetup client

func (*Client) Categories

func (c *Client) Categories() (*models.Categories, error)

Categories returns available meetup categories

func (*Client) CommentOnEvent

func (c *Client) CommentOnEvent(prep func(map[string][]string, url.Values), o map[string][]string) (*models.Comment, error)

CommentOnEvent posts a comment to the specified event Required event options are EventID and CommentText Optionally, use InReplyTo to specify the comment ID in which to reply to

func (*Client) CreateEvent

func (c *Client) CreateEvent(prep func(map[string][]string, url.Values), o map[string][]string) (*models.Event, error)

CreateEvent posts a new event for the given group EventOpts required are GroupID, GroupURLName and EventName (name of the event) Optional Event Opts supported by this lib include Description, PublishStatus (organizer only) You can set more options with the passed prep func and map parameters to this method (see Meetup API docs for a full list)

func (*Client) DeleteEvent

func (c *Client) DeleteEvent(eventID string) error

DeleteEvent removes a previously posted event with the given eventID

func (*Client) EventByID

func (c *Client) EventByID(urlName, eventID string) (*models.Event, error)

EventByID returns a single event with the specified group's url name and event ID

func (*Client) EventCommentByID

func (c *Client) EventCommentByID(commentID int) (*models.Comment, error)

EventCommentByID returns a single Comment using the provided comment id.

func (*Client) EventComments

func (c *Client) EventComments(prep func(map[string][]string, url.Values), o map[string][]string) (*models.Comments, error)

EventComments returns comments based on the query criteria provided with the EventOpts

func (*Client) EventRatings

func (c *Client) EventRatings(prep func(map[string][]string, url.Values), o map[string][]string) (*models.Ratings, error)

EventRatings returns the ratings for the given eventID options o is required to have at least an EventID and an optional MemberID

func (*Client) EventsByGeo

func (c *Client) EventsByGeo(lat, lon, radius string) (*models.Events, error)

EventsByGeo returns event data based on latitude, longitude and radius respectively. Radius can be a value of 'smart', or in between 0.5 and 100 If an empty string is passed for radius, then 'smart' will be used as a default

func (*Client) EventsByGroup

func (c *Client) EventsByGroup(urlName string, status []string, desc bool) (*models.Events, error)

EventsByGroup returns event data for the specified group with its urlName. Use these contstants to input status: EventCancelled, EventDraft, EventPast, EventProposed, EventSuggested, EventUpcoming

func (*Client) EventsByGroupID

func (c *Client) EventsByGroupID(groupID int, status []string, desc bool) (*models.Events, error)

EventsByGroupID returns event data for the specified groupID. Use these contstants to input status: EventCancelled, EventDraft, EventPast, EventProposed, EventSuggested, EventUpcoming

func (*Client) GroupByID

func (c *Client) GroupByID(groupIDs []int) (*models.Groups, error)

GroupByID returns the meetup groups using the specified groupIDs The response contains an array of results, even if there is only one because the request can consist of comma separated values as the group_id parameter.

func (*Client) GroupByOrganizer

func (c *Client) GroupByOrganizer(organizerIDs []int) (*models.Groups, error)

GroupByOrganizer returns the data the specified meetup groups using organizerIDs The response contains an array of results, even if there is only one because the request can consist of comma separated values as the group_id parameter.

func (*Client) GroupByURLName

func (c *Client) GroupByURLName(urlNames []string) (*models.Groups, error)

GroupByURLName returns the group data using the specified urlNames The response contains an array of results, even if there is only one because the request can consist of comma separated values as the group_id parameter.

func (*Client) GroupByZip

func (c *Client) GroupByZip(zipCode int) (*models.Groups, error)

GroupByZip returns the group data for the specified zip code

func (*Client) LikeComment

func (c *Client) LikeComment(commentID int) error

LikeComment uses the specified commentID to 'like' it.

func (*Client) Member

func (c *Client) Member(memberID int) (*models.Member, error)

Member returns the meetup profile data for a single member

func (*Client) Members

func (c *Client) Members(groupID int) (*models.Members, error)

Members returns all of the members that belong to the specified meetup group

func (*Client) RateEvent

func (c *Client) RateEvent(prep func(map[string][]string, url.Values), o map[string][]string) (*models.Rating, error)

RateEvent posts the provided rating to the specified eventID Use EventID and Rating as options

func (*Client) RemoveEventComment

func (c *Client) RemoveEventComment(commentID int) error

RemoveEventComment deletes a previously posted comment with the provided commentID

func (*Client) UnlikeComment

func (c *Client) UnlikeComment(commentID int) error

UnlikeComment will remove a previously posted 'like' on the specified commentID

func (*Client) UpdateEvent

func (c *Client) UpdateEvent(eventID string, prep func(map[string][]string, url.Values), o map[string][]string) (*models.Event, error)

UpdateEvent modifies an existing event

type ClientOpts

type ClientOpts struct {
	APIKey     string
	HTTPClient *http.Client
}

ClientOpts contains options to be passed in when creating a new meetup client value

type Clienter

type Clienter interface {
	Members(int) (*models.Members, error)
	Member(int) (*models.Member, error)
	GroupByID([]int) (*models.Groups, error)
	GroupByURLName([]string) (*models.Groups, error)
	GroupByOrganizer([]int) (*models.Groups, error)
	GroupByZip(int) (*models.Groups, error)
	Categories() (*models.Categories, error)
	EventsByGeo(string, string, string) (*models.Events, error)
	EventsByGroup(string, []string, bool) (*models.Events, error)
	EventByID(string, string) (*models.Event, error)
	EventsByGroupID(int, []string, bool) (*models.Events, error)
	EventComments(func(map[string][]string, url.Values), map[string][]string) (*models.Comments, error)
	EventCommentByID(int) (*models.Comment, error)
	EventRatings(func(map[string][]string, url.Values), map[string][]string) (*models.Ratings, error)
	RateEvent(func(map[string][]string, url.Values), map[string][]string) (*models.Rating, error)
	CommentOnEvent(func(map[string][]string, url.Values), map[string][]string) (*models.Comment, error)
	LikeComment(int) error
	UnlikeComment(int) error
	RemoveEventComment(int) error
	CreateEvent(func(map[string][]string, url.Values), map[string][]string) (*models.Event, error)
	UpdateEvent(string, func(map[string][]string, url.Values), map[string][]string) (*models.Event, error)
	DeleteEvent(string) error
}

Clienter

func NewClient

func NewClient(opts *ClientOpts) Clienter

NewClient creates a new Meetup client with the given parameters

Directories

Path Synopsis
Code generated by mockery v1.0.0
Code generated by mockery v1.0.0

Jump to

Keyboard shortcuts

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