doorkeeper

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: MIT Imports: 7 Imported by: 1

README

go-doorkeeper

Doorkeeper API client for Go

Build Status Maintainability Test Coverage GoDoc

Example

package main

import (
	"github.com/sue445/go-doorkeeper"
	"os"
)

func main() {
	accessToken := os.Getenv("DOORKEEPER_ACCESS_TOKEN")
	if accessToken == "" {
		panic("DOORKEEPER_ACCESS_TOKEN is required")
	}

	client := doorkeeper.NewClient(accessToken)

	// List all featured events
	events, rateLimit, err := client.GetEvents(&doorkeeper.GetEventsParams{})
	// more options
	events, rateLimit, err := client.GetEvents(&doorkeeper.GetEventsParams{Query: "golang"})

	// List a community's events
	groupName := "trbmeetup"
	events, rateLimit, err := client.GetGroupEvents(groupName, &doorkeeper.GetEventsParams{})

	// Show a specific event
	eventID := 28319
	event, rateLimit, err := client.GetEvent(eventID)
	// or
	event, rateLimit, err := client.GetEvent(eventID, doorkeeper.WithLocale("en"))

	// Show a specific group
	groupName := "trbmeetup"
	group, rateLimit, err := client.GetGroup(groupName)
	// or
	group, rateLimit, err := client.GetGroup(groupName, doorkeeper.WithLocale("en"))
}

Reference

https://godoc.org/github.com/sue445/go-doorkeeper

Documentation

Index

Constants

View Source
const (
	// Version represents go-doorkeeper version
	Version = "v0.1.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

A Client manages communication with the Doorkeeper API

func NewClient

func NewClient(accessToken string) *Client

NewClient returns a new API Client instance

func (*Client) GetEvent

func (c *Client) GetEvent(eventID int, options ...OptionFunc) (*Event, *RateLimit, error)

GetEvent returns a specific event

func (*Client) GetEvents

func (c *Client) GetEvents(params *GetEventsParams) ([]*Event, *RateLimit, error)

GetEvents returns events

func (*Client) GetGroup

func (c *Client) GetGroup(groupName string, options ...OptionFunc) (*Group, *RateLimit, error)

GetGroup returns a specific group

func (*Client) GetGroupEvents

func (c *Client) GetGroupEvents(groupName string, params *GetEventsParams) ([]*Event, *RateLimit, error)

GetGroupEvents returns group events

type Event

type Event struct {
	Title        string
	ID           int
	StartsAt     time.Time
	EndsAt       time.Time
	VenueName    string
	Address      string
	Lat          *float64
	Long         *float64
	PublishedAt  time.Time
	UpdatedAt    time.Time
	Group        int
	Description  string
	PublicURL    string
	Participants int
	Waitlisted   int
	TicketLimit  int
}

A Event represents doorkeeper event

type GetEventsParams

type GetEventsParams struct {
	Page     int
	Locale   string
	Sort     Sort
	Since    *time.Time
	Until    *time.Time
	Query    string
	Callback string
}

GetEventsParams manages params of GetEvents

type Group

type Group struct {
	ID           int    `json:"id"`
	Name         string `json:"name"`
	CountryCode  string `json:"country_code"`
	Description  string `json:"description"`
	PublicURL    string `json:"public_url"`
	MembersCount int    `json:"members_count"`
}

A Group represents doorkeeper group

type OptionFunc

type OptionFunc func(map[string]string)

OptionFunc represents base optional param

func WithLocale

func WithLocale(locale string) OptionFunc

WithLocale pass specific locale

type RateLimit

type RateLimit struct {
	Name      string
	Period    int
	Limit     int
	Remaining int
	Until     time.Time
}

A RateLimit represents API Rate Limit

type Sort

type Sort int

Sort represents sort type of events API

const (
	// Nothing represents no sort
	Nothing Sort = iota

	// PublishedAt represents sort by published_at
	PublishedAt

	// StartsAt represents sort by starts_at
	StartsAt

	// UpdatedAt represents sort by updated_at
	UpdatedAt
)

func (Sort) String

func (s Sort) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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