openapi

package
v0.0.0-...-d09d4a5 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package openapi implements BearyChat's OpenAPI methods.

For full api doc, please visit https://github.com/bearyinnovative/OpenAPI

Usage:

import "github.com/bearyinnovative/bearychat-go/openapi"

API methods are bound to a API client. To construct a new client:

client := openapi.NewClient(token)

API methods are grouped by "namespace":

team, _, err := client.Team.Info()

Index

Constants

This section is empty.

Variables

View Source
var (
	// Shorthand function for passing limit value as pointer.
	MessageQueryWithLimit = uintp
	// Shorthand function for passing forward value as pointer.
	MessageQueryWithForward = uintp
	// Shorthand function for passing backward value as pointer.
	MessageQueryWithBackward = uintp
)

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present.

func NewClientWithBaseURL

func NewClientWithBaseURL(u *url.URL) clientOpt

NewClientWithBaseURL binds BaseURL to client.

func NewClientWithFastClient

func NewClientWithFastClient(fastClient *fasthttp.Client) clientOpt

NewClientWithFastClient binds http client to client.

func NewClientWithHTTPClient

func NewClientWithHTTPClient(httpClient *http.Client) clientOpt

NewClientWithHTTPClient binds http client to client.

Types

type Channel

type Channel struct {
	ID            string       `json:"id,omitempty"`
	TeamID        string       `json:"team_id,omitempty"`
	VChannelID    string       `json:"vchannel_id,omitempty"`
	UserID        string       `json:"uid,omitempty"`
	Name          string       `json:"name,omitempty"`
	Type          VChannelType `json:"type,omitempty"`
	Private       bool         `json:"private,omitempty"`
	General       bool         `json:"general,omitempty"`
	Topic         string       `json:"topic,omitempty"`
	IsMember      bool         `json:"is_member,omitempty"`
	IsActive      bool         `json:"is_active,omitempty"`
	MemberUserIDs []string     `json:"member_uids,omitempty"`
	LatestTS      VChannelTS   `json:"latest_ts,omitempty"`
}

type ChannelArchiveOptions

type ChannelArchiveOptions struct {
	ChannelID string `json:"channel_id"`
}

type ChannelCreateOptions

type ChannelCreateOptions struct {
	Name    string  `json:"name"`
	Topic   *string `json:"topic,omitempty"`
	Private *bool   `json:"private,omitempty"`
}

type ChannelInfoOptions

type ChannelInfoOptions struct {
	ChannelID string
}

type ChannelInviteOptions

type ChannelInviteOptions struct {
	ChannelID    string `json:"channel_id"`
	InviteUserID string `json:"invite_uid"`
}

type ChannelJoinOptions

type ChannelJoinOptions struct {
	ChannelID string `json:"channel_id"`
}

type ChannelKickOptions

type ChannelKickOptions struct {
	ChannelID  string `json:"channel_id"`
	KickUserID string `json:"kick_uid"`
}

type ChannelLeaveOptions

type ChannelLeaveOptions struct {
	ChannelID string `json:"channel_id"`
}

type ChannelService

type ChannelService service

func (*ChannelService) Archive

Archive implements `POST /channel.archive`

func (*ChannelService) Create

Create implements `POST /channel.create`

func (*ChannelService) Info

Info implements `GET /channel.info`

func (*ChannelService) Invite

Invite implements `POST /channel.invite`

func (*ChannelService) Join

Join implements `POST /channel.join`

func (*ChannelService) Kick

Kick implements `POST /channel.kick`

func (*ChannelService) Kickout

Kickout implements `POST /channel.kickout`

func (*ChannelService) Leave

Leave implements `POST /channel.leave`

func (*ChannelService) List

func (c *ChannelService) List(ctx context.Context) ([]*Channel, *http.Response, error)

List implements `GET /channel.list`

func (*ChannelService) Unarchive

Unarchive implements `POST /channel.unarchive`

type ChannelUnarchiveOptions

type ChannelUnarchiveOptions struct {
	ChannelID string `json:"channel_id"`
}

type Client

type Client struct {

	// Base URL for API requests. Defaults to BearyChat's OpenAPI host.
	// BaseURL should always be specified with a trailing slash.
	BaseURL *url.URL

	// Access token for the client.
	Token string

	Meta           *MetaService
	Team           *TeamService
	User           *UserService
	Channel        *ChannelService
	SessionChannel *SessionChannelService
	Message        *MessageService
	P2P            *P2PService
	Emoji          *EmojiService
	Sticker        *StickerService
	RTM            *RTMService
	MessagePin     *MessagePinService
	// contains filtered or unexported fields
}

Client interacts with BearyChat's API.

func NewClient

func NewClient(token string, opts ...clientOpt) *Client

NewClient constructs a client with given access token. Other settings can set via clientOpt functions.

type Emoji

type Emoji struct {
	ID      string `json:"id,omitempty"`
	UserID  string `json:"uid,omitempty"`
	TeamID  string `json:"team_id,omitempty"`
	Name    string `json:"name,omitempty"`
	URL     string `json:"url,omitempty"`
	Created Time   `json:"created,omitempty"`
	Updated Time   `json:"updated,omitempty"`
}

type EmojiService

type EmojiService service

func (*EmojiService) List

func (e *EmojiService) List(ctx context.Context) ([]*Emoji, *http.Response, error)

List implements `GET /emoji.list`

type ErrorResponse

type ErrorResponse struct {
	// HTTP response that caused this error
	Response    *http.Response
	ErrorCode   int    `json:"code"`
	ErrorReason string `json:"error"`
}

ErrorResponse represents errors caused by an API request.

func (ErrorResponse) Error

func (r ErrorResponse) Error() string

type File

type File struct {
	Inactive    bool       `json:"inactive,omitempty"`
	Description string     `json:"description,omitempty"`
	Category    string     `json:"category,omitempty"`
	Deleted     bool       `json:"deleted,omitempty"`
	StarID      string     `json:"star_id,omitempty"`
	Key         MessageKey `json:"key,omitempty"`
	Updated     Time       `json:"updated,omitempty"`
	UID         string     `json:"uid,omitempty"`
	VCIDS       []string   `json:"vcids,omitempty"`
	Name        string     `json:"name,omitempty"`
	Type        string     `json:"type,omitempty"`
	Created     Time       `json:"created,omitempty"`
	Source      string     `json:"source,omitempty"`
	Mime        string     `json:"mime,omitempty"`
	ImageURL    string     `json:"image_url,omitempty"`
	PreviewURL  string     `json:"preview_url,omitempty"`
	Title       string     `json:"title,omitempty"`
	ChannelID   string     `json:"channel_id,omitempty"`
	Summary     string     `json:"summary,omitempty"`
	IsPublic    bool       `json:"is_public,omitempty"`
	ID          string     `json:"id,omitempty"`
	URL         string     `json:"url,omitempty"`
	TeamID      string     `json:"team_id,omitempty"`
}

type Message

type Message struct {
	Repost          Repost            `json:"repost,omitempty"`
	Key             MessageKey        `json:"key,omitempty"`
	Updated         Time              `json:"updated,omitempty"`
	UID             string            `json:"uid,omitempty"`
	Created         Time              `json:"created,omitempty"`
	VchannelID      string            `json:"vchannel_id,omitempty"`
	ReferKey        string            `json:"refer_key,omitempty"`
	RobotID         string            `json:"robot_id,omitempty"`
	Edited          bool              `json:"edited,omitempty"`
	CreatedTS       VChannelTS        `json:"created_ts,omitempty"`
	PinID           string            `json:"pin_id,omitempty"`
	StarID          string            `json:"star_id,omitempty"`
	ID              string            `json:"id,omitempty"`
	TeamID          string            `json:"team_id,omitempty"`
	TextI18n        map[string]string `json:"text_i18n,omitempty"`
	Reactions       []Reaction        `json:"reactions,omitempty"`
	Subtype         MessageSubtype    `json:"subtype,omitempty"`
	Text            string            `json:"text,omitempty"`
	DisableMarkdown bool              `json:"disable_markdown,omitempty"`
	File            File              `json:"file,omitempty"`
}

type MessageAttachment

type MessageAttachment struct {
	Title  string                   `json:"title,omitempty"`
	Url    string                   `json:"url,omitempty"`
	Text   string                   `json:"text,omitempty"`
	Color  string                   `json:"color,omitempty"`
	Images []MessageAttachmentImage `json:"images,omitempty"`
}

type MessageAttachmentImage

type MessageAttachmentImage struct {
	Url string `json:"url,omitempty"`
}

type MessageCreateOptions

type MessageCreateOptions struct {
	VChannelID  string              `json:"vchannel_id"`
	Text        string              `json:"text"`
	Markdown    bool                `json:"markdown"`
	Attachments []MessageAttachment `json:"attachments"`
}

type MessageDeleteOptions

type MessageDeleteOptions struct {
	VChannelID string     `json:"vchannel_id"`
	Key        MessageKey `json:"message_key"`
}

type MessageForwardOptions

type MessageForwardOptions struct {
	VChannelID   string     `json:"vchannel_id"`
	Key          MessageKey `json:"message_key"`
	ToVChannelID string     `json:"to_vchannel_id"`
}

type MessageInfoOptions

type MessageInfoOptions struct {
	VChannelID string
	Key        MessageKey
}

type MessageKey

type MessageKey string

type MessagePin

type MessagePin struct {
	ID         string     `json:"id,omitempty"`
	TeamID     string     `json:"team_id,omitempty"`
	UID        string     `json:"uid,omitempty"`
	VchannelID string     `json:"vchannel_id,omitempty"`
	MessageID  string     `json:"message_id,omitempty"`
	MessageKey MessageKey `json:"message_key,omitempty"`
	CreatedAt  Time       `json:"create_at,omitempty"`
	UpdatedAt  Time       `json:"update_at,omitempty"`
}

type MessagePinCreateOptions

type MessagePinCreateOptions struct {
	VChannelID string     `json:"vchannel_id"`
	MessageKey MessageKey `json:"message_key"`
}

type MessagePinDeleteOptions

type MessagePinDeleteOptions struct {
	VChannelID string `json:"vchannel_id"`
	PinID      string `json:"pin_id"`
}

type MessagePinListOptions

type MessagePinListOptions struct {
	VChannelID string `json:"vchannel_id"`
}

type MessagePinService

type MessagePinService service

func (*MessagePinService) Create

Create implements `POST /message_pin.create`

func (*MessagePinService) Delete

Delete implements `POST /message_pin.delete`

func (*MessagePinService) List

List implements `GET /message_pin.list`

type MessageQuery

type MessageQuery struct {
	Latest *MessageQueryByLatest `json:"latest,omitempty"`
	Since  *MessageQueryBySince  `json:"since,omitempty"`
	Window *MessageQueryByWindow `json:"window,omitempty"`
}

TODO(hbc): introduce a query builder or map literal

type MessageQueryByLatest

type MessageQueryByLatest struct {
	Limit int `json:"limit,omitempty"`
}

type MessageQueryBySince

type MessageQueryBySince struct {
	SinceKey MessageKey `json:"key,omitempty"`
	SinceTS  VChannelTS `json:"ts,omitempty"`
	Forward  int        `json:"forward,omitempty"`
	Backward int        `json:"backward,omitempty"`
}

type MessageQueryByWindow

type MessageQueryByWindow struct {
	FromKey  MessageKey `json:"from_key,omitempty"`
	ToKey    MessageKey `json:"to_key,omitempty"`
	FromTS   VChannelTS `json:"from_ts,omitempty"`
	ToTS     VChannelTS `json:"to_ts,omitempty"`
	Forward  int        `json:"forward,omitempty"`
	Backward int        `json:"backward,omitempty"`
}

type MessageQueryOptions

type MessageQueryOptions struct {
	VChannelID string        `json:"vchannel_id"`
	Query      *MessageQuery `json:"query"`
}

type MessageQueryResult

type MessageQueryResult struct {
	Messages []*Message `json:"messages"`
}

type MessageService

type MessageService service

func (*MessageService) Create

Create implements `POST /message.create`

func (*MessageService) CreateFast

func (m *MessageService) CreateFast(opt *MessageCreateOptions) (*Message, error)

func (*MessageService) Delete

Delete implements `POST /message.delete`

func (*MessageService) Forward

Forward implements `POST /message.forward`

func (*MessageService) Info

Info implements `GET /message.info`

func (*MessageService) Query

Query implements `POST /message.query`

func (*MessageService) UpdateText

UpdateText implements `POST /message.update_text`

type MessageSubtype

type MessageSubtype string
const (
	MessageSubtypeNormal MessageSubtype = "normal"
	MessageSubtypeInfo                  = "info"
)

type MessageUpdateTextOptions

type MessageUpdateTextOptions struct {
	VChannelID  string              `json:"vchannel_id"`
	Key         MessageKey          `json:"message_key"`
	Text        string              `json:"text"`
	Attachments []MessageAttachment `json:"attachments"` //TODO: shoud api support
}

type Meta

type Meta struct {
	Version *string `json:"version,omitempty"`
}

type MetaService

type MetaService service

func (*MetaService) Get

func (m *MetaService) Get(ctx context.Context) (*Meta, *http.Response, error)

Get implements `GET /meta`

type P2P

type P2P struct {
	ID            *string       `json:"id,omitempty"`
	TeamID        *string       `json:"team_id,omitempty"`
	VChannelID    *string       `json:"vchannel_id,omitempty"`
	Type          *VChannelType `json:"type,omitempty"`
	IsActive      *bool         `json:"is_active"`
	IsMember      *bool         `json:"is_member,omitempty"`
	MemberUserIDs []string      `json:"member_uids,omitempty"`
	LatestTS      *VChannelTS   `json:"latest_ts,omitempty"`
}

type P2PCreateOptions

type P2PCreateOptions struct {
	UserID string `json:"user_id"`
}

type P2PInfoOptions

type P2PInfoOptions struct {
	ChannelID string
}

type P2PService

type P2PService service

func (*P2PService) Create

func (p *P2PService) Create(ctx context.Context, opt *P2PCreateOptions) (*P2P, *http.Response, error)

Create implements `POST /p2p.create`

func (*P2PService) Info

func (p *P2PService) Info(ctx context.Context, opt *P2PInfoOptions) (*P2P, *http.Response, error)

Info implements `GET /p2p.info`

func (*P2PService) List

func (p *P2PService) List(ctx context.Context) ([]*P2P, *http.Response, error)

List implements `GET /p2p.list`

type RTMService

type RTMService service

func (*RTMService) Start

func (r *RTMService) Start(ctx context.Context) (*RTMStart, *http.Response, error)

Start implements `POST /rtm.start`

type RTMStart

type RTMStart struct {
	WebSocketHost *string `json:"ws_host,omitempty"`
	User          *User   `json:"user,omitempty"`
}

type Reaction

type Reaction struct {
	CreatedTS VChannelTS `json:"created_ts,omitempty"`
	Reaction  string     `json:"reaction,omitempty"`
	UIDs      []string   `json:"uids,omitempty"`
}

type Repost

type Repost struct {
	UID        string         `json:"uid,omitempty"`
	VchannelID string         `json:"vchannel_id,omitempty"`
	RobotID    string         `json:"robot_id,omitempty"`
	CreatedTS  VChannelTS     `json:"created_ts,omitempty"`
	MessageKey MessageKey     `json:"message_key,omitempty"`
	ID         string         `json:"id,omitempty"`
	TeamID     string         `json:"team_id,omitempty"`
	Subtype    MessageSubtype `json:"subtype,omitempty"`
	Text       string         `json:"text,omitempty"`
}

type ResponseNoContent

type ResponseNoContent struct{}

type ResponseOK

type ResponseOK struct {
	Code *int `json:"code,omitempty"`
}

type SessionChannel

type SessionChannel struct {
	ID            *string       `json:"id,omitempty"`
	TeamID        *string       `json:"team_id,omitempty"`
	VChannelID    *string       `json:"vchannel_id,omitempty"`
	Name          *string       `json:"name,omitempty"`
	Type          *VChannelType `json:"type,omitempty"`
	IsMember      *bool         `json:"is_member,omitempty"`
	IsActive      *bool         `json:"is_active,omitempty"`
	MemberUserIDs []string      `json:"member_uids,omitempty"`
	LatestTS      *VChannelTS   `json:"latest_ts,omitempty"`
}

type SessionChannelArchiveOptions

type SessionChannelArchiveOptions struct {
	ChannelID string `json:"session_channel_id"`
}

type SessionChannelConvertOptions

type SessionChannelConvertOptions struct {
	ChannelID string `json:"session_channel_id"`
	Name      string `json:"name"`
	Private   *bool  `json:"private,omitempty"`
}

type SessionChannelCreateOptions

type SessionChannelCreateOptions struct {
	Name          *string  `json:"name,omitempty"`
	MemberUserIDs []string `json:"member_uids"`
}

type SessionChannelInfoOptions

type SessionChannelInfoOptions struct {
	ChannelID string
}

type SessionChannelInviteOptions

type SessionChannelInviteOptions struct {
	ChannelID    string `json:"session_channel_id"`
	InviteUserID string `json:"invite_uid"`
}

type SessionChannelKickOptions

type SessionChannelKickOptions struct {
	ChannelID  string `json:"session_channel_id"`
	KickUserID string `json:"kick_uid"`
}

type SessionChannelLeaveOptions

type SessionChannelLeaveOptions struct {
	ChannelID string `json:"session_channel_id"`
}

type SessionChannelService

type SessionChannelService service

func (*SessionChannelService) Archive

Archive implements `POST /session_channel.archive`

func (*SessionChannelService) ConvertToChannel

ConvertToChannel implements `POST /session_channel.convert_to_channel`

func (*SessionChannelService) Create

Create implements `POST /session_channel.create`

func (*SessionChannelService) Info

Info implements `GET /session_channel.info`

func (*SessionChannelService) Invite

Invite implements `POST /session_channel.invite`

func (*SessionChannelService) Kick

Kick implements `POST /session_channel.kick`

func (*SessionChannelService) Leave

Leave implements `POST /session_channel.leave`

func (*SessionChannelService) List

List implements `GET /session_channel.list`

type Sticker

type Sticker struct {
	URL    *string `json:"url,omitempty"`
	Name   *string `json:"name,omitempty"`
	Width  *int    `json:"width,omitempty"`
	Height *int    `json:"height,omitempty"`
}

type StickerPack

type StickerPack struct {
	PackName *string    `json:"pack,omitempty"`
	Stickers []*Sticker `json:"stickers,omitempty"`
}

type StickerService

type StickerService service

func (*StickerService) List

List implements `GET /sticker.list`

type Team

type Team struct {
	ID          *string   `json:"id,omitempty"`
	Subdomain   *string   `json:"subdomain,omitempty"`
	Name        *string   `json:"name,omitempty"`
	EmailDomain *string   `json:"email_domain,omitempty"`
	LogoURL     *string   `json:"logo_url,omitempty"`
	Description *string   `json:"description,omitempty"`
	Plan        *TeamPlan `json:"plan,omitempty"`
	Created     *Time     `json:"created,omitempty"`
}

type TeamPlan

type TeamPlan string

type TeamService

type TeamService service

func (*TeamService) Info

func (t *TeamService) Info(ctx context.Context) (*Team, *http.Response, error)

Info implements `GET /team.info`

type Time

type Time struct {
	time.Time
}

Time with custom JSON format.

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (Time) UnmarshalJSON

func (t Time) UnmarshalJSON(b []byte) (err error)

type User

type User struct {
	ID       string      `json:"id,omitempty"`
	TeamID   string      `json:"team_id,omitempty"`
	Email    string      `json:"email,omitempty"`
	Name     string      `json:"name,omitempty"`
	FullName string      `json:"full_name,omitempty"`
	Type     UserType    `json:"type,omitempty"`
	Role     UserRole    `json:"role,omitempty"`
	Avatars  UserAvatar  `json:"avatars,omitempty"`
	Profile  UserProfile `json:"profile,omitempty"`
	Inactive bool        `json:"inactive,omitempty"`
	Created  Time        `json:"created,omitempty"`
}

type UserAvatar

type UserAvatar struct {
	Small  string `json:"small,omitempty"`
	Medium string `json:"medium,omitempty"`
	Large  string `json:"large,omitempty"`
}

type UserInfoOptions

type UserInfoOptions struct {
	UserID string
}

type UserProfile

type UserProfile struct {
	Bio      string `json:"bio,omitempty"`
	Position string `json:"position,omitempty"`
	Skype    string `json:"sykpe,omitempty"`
}

type UserRole

type UserRole string

type UserService

type UserService service

func (*UserService) Info

func (u *UserService) Info(ctx context.Context, opt *UserInfoOptions) (*User, *http.Response, error)

Info implements `GET /user.info`

func (*UserService) List

func (u *UserService) List(ctx context.Context) ([]*User, *http.Response, error)

List implements `GET /user.list`

func (*UserService) Me

func (u *UserService) Me(ctx context.Context) (*User, *http.Response, error)

Me implements `GET /user.me`

type UserType

type UserType string

type VChannelTS

type VChannelTS int64

VChannelTS represents unix timestamp type.

type VChannelType

type VChannelType string

VChannelType defines chat channel/inbox types.

Jump to

Keyboard shortcuts

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