doorkeeper

package module
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 8 Imported by: 1

README

go-doorkeeper

Doorkeeper API client for Go

Latest Version Build Status Maintainability Coverage Status GoDoc Go Report Card

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", Sort: doorkeeper.SortByPublishedAt()})

	// 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.10"
)

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     SortEnum
	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(url.Values)

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 SortEnum added in v0.1.1

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

SortEnum represents sort enum

func SortByPublishedAt added in v0.1.1

func SortByPublishedAt() SortEnum

SortByPublishedAt sort by published_at

func SortByStartsAt added in v0.1.1

func SortByStartsAt() SortEnum

SortByStartsAt sort by starts_at

func SortByUpdatedAt added in v0.1.1

func SortByUpdatedAt() SortEnum

SortByUpdatedAt sort by updated_at

func (SortEnum) GetValue added in v0.1.1

func (s SortEnum) GetValue() string

GetValue returns value for SortEnum option

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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