connpass

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2021 License: MIT Imports: 11 Imported by: 15

README

connpass

pkg.go.dev

The connpass package provides API client of connpass API.

Examples

See _examples directory.

Documentation

Overview

The package connpass provides API client of connpass. You can see details of connpass API via https://connpass.com/about/api/.

Index

Constants

View Source
const (
	TypeParticipation = "participation"
	TypeAdvertisement = "advertisement"
)

Variables

This section is empty.

Functions

func SearchParam

func SearchParam(params ...Param) (url.Values, error)

SearchParam sets parameter to url.Values. If params have validation errors, they will be returned as the second result. If you want to get individual errors, you can use "go.uber.org/multierr".Errors.

Types

type APIError

type APIError struct {
	StatusCode int
}

APIError represents an error of connpass API.

func (*APIError) Error

func (err *APIError) Error() string

Error implements error.Error.

type Client

type Client struct {
	SearchService
	HTTPClient *http.Client
	BaseURL    string
	UserAgent  string
}

Client is a client of connpass API.

func NewClient

func NewClient() *Client

NewClient creates a new connpass client.

type Event

type Event struct {
	ID               int       `json:"event_id"`
	Title            string    `json:"title"`
	Catch            string    `json:"catch"`
	Description      string    `json:"description"`
	URL              string    `json:"event_url"`
	Hashtag          string    `json:"hash_tag"`
	StartedAt        time.Time `json:"started_at"`
	EndedAt          time.Time `json:"ended_at"`
	Limit            int       `json:"limit"`
	Type             Type      `json:"event_type"`
	Series           Series    `json:"series"`
	Address          string    `json:"address"`
	Place            string    `json:"place"`
	Lat              string    `json:"lat"`
	Lon              string    `json:"lon"`
	OwnerID          int       `json:"owner_id"`
	OwnerNickname    string    `json:"owner_nickname"`
	OwnerDisplayName string    `json:"owner_display_name"`
	Accepted         int       `json:"accepted"`
	Waiting          int       `json:"waiting"`
	UpdatedAt        time.Time `json:"updated_at"`
}

Event repressents a single event of connpass.

type OrderBy

type OrderBy int

OrderBy represents order of events.

const (
	OrderByUpdate OrderBy = 1
	OrderByDate   OrderBy = 2
	OrderByNewest OrderBy = 3
)

type Param

type Param func(vals url.Values) error

Param is a function which set a value to url.Values.

func Count

func Count(count int) Param

Count sets value to url.Values with key "count". count must be positive integer.

func EventID

func EventID(eventID int) Param

EventID sets value to url.Values with key "event_id". eventID must be positive integer.

func Keyword

func Keyword(keyword string) Param

Keyword sets value to url.Values with key "keyword". keyword must not be empty string.

func KeywordOr

func KeywordOr(keyword string) Param

KeywordOr sets value to url.Values with key "keyword_or". keyword must not be empty string.

func Nickname

func Nickname(nickname string) Param

Nickname sets value to url.Values with key "nickname". nickname must not be empty string.

func Order

func Order(by OrderBy) Param

Order sets value to url.Values with key "order". order must be OrderByUpdate, OrderByDate or OrderByNewest.

func OwnerNickname

func OwnerNickname(nickname string) Param

OwnerNickname sets value to url.Values with key "owner_nickname". nickname must not be empty string.

func SeriesID

func SeriesID(seriesID int) Param

SeriesID sets value to url.Values with key "series_id". seriesID must be positive integer.

func Start

func Start(start int) Param

Start sets value to url.Values with key "start". start must be positive integer.

func YearMonth

func YearMonth(year int, month time.Month) Param

YearMonth sets value to url.Values with key "ym". year must be between 0 and 9999 and month must be between time.January and time.December.

func YearMonthDay

func YearMonthDay(year int, month time.Month, day int) Param

YearMonth sets value to url.Values with key "ymd". year must be between 0 and 9999 and month must be between time.January and time.December. day must be valid day at the corresponded month.

type SearchResult

type SearchResult struct {
	Returned  int      `json:"results_returned"`
	Available int      `json:"results_available"`
	Start     int      `json:"results_start"`
	Events    []*Event `json:"events"`
}

SearchResult represents a result of Search.

type SearchService

type SearchService interface {
	Search(ctx context.Context, params url.Values) (*SearchResult, error)
}

SearchService provides the Search method which searches events of connpass.

type Series

type Series struct {
	ID    int    `json:"id"`
	Title string `json:"title"`
	URL   string `json:"url"`
}

Series repressents an organization or event series.

type Type

type Type string

Type repressents type of event.

Jump to

Keyboard shortcuts

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